/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2022,2023 Thomas E. Dickey *
* Copyright 1998-2017,2018 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
****************************************************************************/
/*
- * $Id: curses.priv.h,v 1.647 2021/10/23 16:13:16 tom Exp $
+ * $Id: curses.priv.h,v 1.663 2023/04/22 15:11:52 tom Exp $
*
* curses.priv.h
*
# endif
#endif
+#ifndef PRIxPTR
+# define PRIxPTR "lx"
+#endif
+
/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
#include <signal.h>
# define NCURSES_PATHSEP ';'
#endif
+/*
+ * When the standard handles have been redirected (such as inside a text editor
+ * or the less utility), keystrokes must be read from the console rather than
+ * the redirected handle. The standard output handle suffers from a similar
+ * problem. Both handles are not closed once opened. The console shall be
+ * considered reachable throughout the process.
+ */
+#if defined(_NC_WINDOWS)
+#define GetDirectHandle(fileName, shareMode) \
+ CreateFile(TEXT(fileName), \
+ GENERIC_READ | GENERIC_WRITE, \
+ shareMode, \
+ 0, \
+ OPEN_EXISTING, \
+ 0, \
+ 0)
+#endif
+
/*
* Not all platforms have memmove; some have an equivalent bcopy. (Some may
* have neither).
#define _nc_lock_global(name) /* nothing */
#define _nc_try_global(name) 0
#define _nc_unlock_global(name) /* nothing */
-
#endif /* USE_PTHREADS */
+#if USE_PTHREADS_EINTR
+extern NCURSES_EXPORT(void) _nc_set_read_thread(bool);
+#else
+#define _nc_set_read_thread(enable) /* nothing */
+#endif
+
/*
* When using sp-funcs, locks are targeted to SCREEN-level granularity.
* So the locking is done in the non-sp-func (which calls the sp-func) rather
#endif
-#if HAVE_GETTIMEOFDAY
+#if HAVE_CLOCK_GETTIME
+# define PRECISE_GETTIME 1
+# define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
+# define TimeType struct timespec
+# define TimeScale 1000000000L /* 1e9 */
+# define sub_secs tv_nsec
+#elif HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
+# define GetClockTime(t) gettimeofday(t, 0)
# define TimeType struct timeval
+# define TimeScale 1000000L /* 1e6 */
+# define sub_secs tv_usec
#else
# define PRECISE_GETTIME 0
# define TimeType time_t
_nc_err_abort(MSG_NO_MEMORY); \
} while (0)
+#define TYPE_CALLOC(type, size, name) \
+ do { \
+ name = typeCalloc(type, size); \
+ if (name == 0) \
+ _nc_err_abort(MSG_NO_MEMORY); \
+ } while (0)
+
#define TYPE_REALLOC(type, size, name) \
do { \
name = typeRealloc(type, size, name); \
#define returnMMask(code) TRACE_RETURN_SP(code,mmask_t)
#define returnPtr(code) TRACE_RETURN1(code,ptr)
#define returnSP(code) TRACE_RETURN1(code,sp)
-#define returnVoid T((T_RETURN(""))); return
+#define returnVoid { T((T_RETURN(""))); return; }
#define returnVoidPtr(code) TRACE_RETURN1(code,void_ptr)
#define returnWin(code) TRACE_RETURN1(code,win)
#define returnDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0)
+#define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0)
+#define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0)
extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int);
extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
#define returnWin(code) return code
#define returnDB(code) return code
+#define returnPtrDB(rc) return rc
+#define returnVoidDB return
#endif /* TRACE/!TRACE */
/* lib_acs.c */
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
-extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
+extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int);
/* lib_addch.c */
#if USE_WIDEC_SUPPORT
extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *);
extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int);
extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const);
extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC);
extern NCURSES_EXPORT(void) _nc_flush (void);
extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
+extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int);
#define _nc_fallback2(tp) _nc_fallback(tp)
#endif
+NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *);
+
#if NCURSES_EXT_NUMBERS
extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *);
extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *);
#endif /* _NC_WINDOWS && !_NC_MSC */
+#if defined(_NC_WINDOWS) || defined(_NC_MINGW)
+/* see wcwidth.c */
+NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
+#define wcwidth(ucs) _nc_wcwidth(ucs)
+#endif
+
#if HAVE_MBTOWC && HAVE_MBLEN
#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
#define count_mbytes(buffer,length,state) mblen(buffer,length)