]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/lib_tracebits.c
ncurses 6.4 - patch 20240414
[ncurses.git] / ncurses / trace / lib_tracebits.c
index 6f7c8ca26af3001dc06940e83c941a8952385502..4bc50f3b0857020eb0b7a8cef548b53423f7040c 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2015 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracebits.c,v 1.25 2015/04/04 13:45:27 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.31 2020/11/14 23:38:11 tom Exp $")
 
 #if HAVE_SYS_TERMIO_H
 #include <sys/termio.h>                /* needed for ISC */
@@ -71,9 +72,15 @@ MODULE_ID("$Id: lib_tracebits.c,v 1.25 2015/04/04 13:45:27 tom Exp $")
 
 #ifdef TRACE
 
+#if defined(EXP_WIN32_DRIVER)
+#define BITNAMELEN 36
+#else
+#define BITNAMELEN 8
+#endif
+
 typedef struct {
     unsigned int val;
-    const char name[8];
+    const char name[BITNAMELEN];
 } BITNAMES;
 
 #define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size)
@@ -85,7 +92,7 @@ lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned int v
 
     _nc_STRCAT(buf, label, TRACE_BUF_SIZE(0));
     _nc_STRCAT(buf, ": {", TRACE_BUF_SIZE(0));
-    for (sp = table; sp->name; sp++)
+    for (sp = table; sp->name[0]; sp++)
        if (sp->val != 0
            && (val & sp->val) == sp->val) {
            _nc_STRCAT(buf, sp->name, TRACE_BUF_SIZE(0));
@@ -97,7 +104,7 @@ lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned int v
 }
 
 NCURSES_EXPORT(char *)
-_nc_trace_ttymode(TTY * tty)
+_nc_trace_ttymode(const TTY * tty)
 /* describe the state of the terminal control bits exactly */
 {
     char *buf;
@@ -130,7 +137,7 @@ _nc_trace_ttymode(TTY * tty)
        DATA(ONOCR),
        DATA(ONLRET),
        DATAX()
-#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET)
+#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET|OFLAGS_TABS)
     }, cflags[] =
     {
        DATA(CLOCAL),
@@ -211,6 +218,36 @@ _nc_trace_ttymode(TTY * tty)
        if (tty->c_lflag & ALLLOCAL)
            lookup_bits(buf, lflags, "lflags", tty->c_lflag);
     }
+#elif defined(EXP_WIN32_DRIVER)
+#define DATA(name)        { name, { #name } }
+    static const BITNAMES dwFlagsOut[] =
+    {
+       DATA(ENABLE_PROCESSED_OUTPUT),
+       DATA(ENABLE_WRAP_AT_EOL_OUTPUT),
+       DATA(ENABLE_VIRTUAL_TERMINAL_PROCESSING),
+       DATA(DISABLE_NEWLINE_AUTO_RETURN),
+       DATA(ENABLE_LVB_GRID_WORLDWIDE)
+    };
+    static const BITNAMES dwFlagsIn[] =
+    {
+       DATA(ENABLE_PROCESSED_INPUT),
+       DATA(ENABLE_LINE_INPUT),
+       DATA(ENABLE_ECHO_INPUT),
+       DATA(ENABLE_MOUSE_INPUT),
+       DATA(ENABLE_INSERT_MODE),
+       DATA(ENABLE_QUICK_EDIT_MODE),
+       DATA(ENABLE_EXTENDED_FLAGS),
+       DATA(ENABLE_AUTO_POSITION),
+       DATA(ENABLE_VIRTUAL_TERMINAL_INPUT)
+    };
+
+    buf = _nc_trace_buf(0,
+                       8 + sizeof(dwFlagsOut) +
+                       8 + sizeof(dwFlagsIn));
+    if (buf != 0) {
+       lookup_bits(buf, dwFlagsIn, "dwIn", tty->dwFlagIn);
+       lookup_bits(buf, dwFlagsOut, "dwOut", tty->dwFlagOut);
+    }
 #else
     /* reference: ttcompat(4M) on SunOS 4.1 */
 #ifndef EVENP