]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/curses.priv.h
ncurses 6.4 - patch 20230211
[ncurses.git] / ncurses / curses.priv.h
index a72555c158d7cd51f18a210b9d4485cf1746adf3..2d536d2d77cb16fb7c5bebcb73caece84d3af1de 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -35,7 +35,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.647 2021/10/23 16:13:16 tom Exp $
+ * $Id: curses.priv.h,v 1.656 2023/02/12 00:13:11 tom Exp $
  *
  *     curses.priv.h
  *
@@ -141,6 +141,10 @@ extern int errno;
 # 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>
 
@@ -206,6 +210,24 @@ extern int errno;
 #  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).
@@ -672,9 +694,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 #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
@@ -1506,6 +1533,13 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
                _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); \
@@ -1619,6 +1653,8 @@ typedef void VoidFunc(void);
 #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 *);
@@ -1693,6 +1729,8 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
 #define returnWin(code)                return code
 
 #define returnDB(code)         return code
+#define returnPtrDB(rc)                return rc
+#define returnVoidDB           return
 
 #endif /* TRACE/!TRACE */
 
@@ -2157,6 +2195,12 @@ extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
 
 #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)