ncurses 5.9 - patch 20150228
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 1 Mar 2015 02:12:21 +0000 (02:12 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 1 Mar 2015 02:12:21 +0000 (02:12 +0000)
+ modify win_driver.c to eliminate the constructor, to make it more
  usable in an application which may/may not need the console window
  (report by Grady Martin).

NEWS
VERSION
dist.mk
ncurses/win32con/win_driver.c
package/debian-mingw/changelog
package/debian-mingw64/changelog
package/debian/changelog
package/mingw-ncurses.nsi
package/mingw-ncurses.spec
package/ncurses.spec

diff --git a/NEWS b/NEWS
index eb72f2ab4db8e24c2bd1648151b1047a97f36b3d..3da15ad595427d7028f19d8d4644e0628e43a634 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2353 2015/02/21 21:17:50 tom Exp $
+-- $Id: NEWS,v 1.2355 2015/02/28 21:51:14 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,11 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20150228
+       + modify win_driver.c to eliminate the constructor, to make it more
+         usable in an application which may/may not need the console window
+         (report by Grady Martin).
+
 20150221
        + capture define's related to -D_XOPEN_SOURCE from the configure check
          and add those to the *-config and *.pc files, to simplify use for
diff --git a/VERSION b/VERSION
index 620c0cb40a7a810024985b0352fa072108a23a8f..3dc2f7bad29d97b357b004d6c246432e4c52aa2f 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5:0:9  5.9     20150221
+5:0:9  5.9     20150228
diff --git a/dist.mk b/dist.mk
index efc27853a40e71ab0c8fadbd11017bdc456f1ebd..d5c6057cf9a1365399fa424d2e6cea9601628c17 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1035 2015/02/21 16:19:10 tom Exp $
+# $Id: dist.mk,v 1.1036 2015/02/28 17:36:40 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 9
-NCURSES_PATCH = 20150221
+NCURSES_PATCH = 20150228
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 7478aceaa146904d19cb99c6be11530b5a910e6b..78ccfeda1b8289f472ccbf72084121a6919d3e8e 100644 (file)
@@ -54,7 +54,7 @@
 
 #define CUR my_term.type.
 
-MODULE_ID("$Id: win_driver.c,v 1.54 2015/01/10 23:13:24 tom Exp $")
+MODULE_ID("$Id: win_driver.c,v 1.55 2015/02/28 21:30:23 tom Exp $")
 
 #ifndef __GNUC__
 #  error We need GCC to compile for MinGW
@@ -66,7 +66,8 @@ MODULE_ID("$Id: win_driver.c,v 1.54 2015/01/10 23:13:24 tom Exp $")
 
 #define array_length(a) (sizeof(a)/sizeof(a[0]))
 
-#define okConsoleHandle(TCB) (TCB != 0 && CON.hdl != INVALID_HANDLE_VALUE)
+static bool InitConsole(void);
+static bool okConsoleHandle(TERMINAL_CONTROL_BLOCK *);
 
 #define AssertTCB() assert(TCB != 0 && (TCB->magic == WINMAGIC))
 #define SetSP()     assert(TCB->csp != 0); sp = TCB->csp; (void) sp
@@ -480,11 +481,9 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
     int y, nonempty, n, x0, x1, Width, Height;
     SCREEN *sp;
 
-    AssertTCB();
-    SetSP();
-
     T((T_CALLED("win32con::wcon_doupdate(%p)"), TCB));
     if (okConsoleHandle(TCB)) {
+       SetSP();
 
        Width = screen_columns(sp);
        Height = screen_lines(sp);
@@ -665,7 +664,7 @@ wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
                 int beepFlag)
 {
     SCREEN *sp;
-    int res = OK;
+    int res = ERR;
 
     int high = (CON.SBI.srWindow.Bottom - CON.SBI.srWindow.Top + 1);
     int wide = (CON.SBI.srWindow.Right - CON.SBI.srWindow.Left + 1);
@@ -678,40 +677,40 @@ wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
     SMALL_RECT this_region;
     COORD bufferCoord;
 
-    AssertTCB();
-
-    SetSP();
-
-    this_region.Top = CON.SBI.srWindow.Top;
-    this_region.Left = CON.SBI.srWindow.Left;
-    this_region.Bottom = CON.SBI.srWindow.Bottom;
-    this_region.Right = CON.SBI.srWindow.Right;
-
-    this_size.X = (SHORT) wide;
-    this_size.Y = (SHORT) high;
+    if (okConsoleHandle(TCB)) {
+       SetSP();
+       this_region.Top = CON.SBI.srWindow.Top;
+       this_region.Left = CON.SBI.srWindow.Left;
+       this_region.Bottom = CON.SBI.srWindow.Bottom;
+       this_region.Right = CON.SBI.srWindow.Right;
+
+       this_size.X = (SHORT) wide;
+       this_size.Y = (SHORT) high;
+
+       bufferCoord.X = this_region.Left;
+       bufferCoord.Y = this_region.Top;
+
+       if (!beepFlag &&
+           read_screen(CON.hdl,
+                       this_screen,
+                       this_size,
+                       bufferCoord,
+                       &this_region)) {
 
-    bufferCoord.X = this_region.Left;
-    bufferCoord.Y = this_region.Top;
+           memcpy(that_screen, this_screen, sizeof(that_screen));
 
-    if (!beepFlag &&
-       read_screen(CON.hdl,
-                   this_screen,
-                   this_size,
-                   bufferCoord,
-                   &this_region)) {
+           for (i = 0; i < max_cells; i++) {
+               that_screen[i].Attributes = RevAttr(that_screen[i].Attributes);
+           }
 
-       memcpy(that_screen, this_screen, sizeof(that_screen));
+           write_screen(CON.hdl, that_screen, this_size, bufferCoord, &this_region);
+           Sleep(200);
+           write_screen(CON.hdl, this_screen, this_size, bufferCoord, &this_region);
 
-       for (i = 0; i < max_cells; i++) {
-           that_screen[i].Attributes = RevAttr(that_screen[i].Attributes);
+       } else {
+           MessageBeep(MB_ICONWARNING);        /* MB_OK might be better */
        }
-
-       write_screen(CON.hdl, that_screen, this_size, bufferCoord, &this_region);
-       Sleep(200);
-       write_screen(CON.hdl, this_screen, this_size, bufferCoord, &this_region);
-
-    } else {
-       MessageBeep(MB_ICONWARNING);    /* MB_OK might be better */
+       res = OK;
     }
     return res;
 }
@@ -783,8 +782,6 @@ wcon_setcolor(TERMINAL_CONTROL_BLOCK * TCB,
              int color,
              int (*outc) (SCREEN *, int) GCC_UNUSED)
 {
-    AssertTCB();
-
     if (okConsoleHandle(TCB)) {
        WORD a = MapColor(fore, color);
        a |= (WORD) ((CON.SBI.wAttributes) & (fore ? 0xfff8 : 0xff8f));
@@ -798,7 +795,6 @@ wcon_rescol(TERMINAL_CONTROL_BLOCK * TCB)
 {
     bool res = FALSE;
 
-    AssertTCB();
     if (okConsoleHandle(TCB)) {
        WORD a = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN;
        SetConsoleTextAttribute(CON.hdl, a);
@@ -825,8 +821,6 @@ wcon_size(TERMINAL_CONTROL_BLOCK * TCB, int *Lines, int *Cols)
 {
     int result = ERR;
 
-    AssertTCB();
-
     T((T_CALLED("win32con::wcon_size(%p)"), TCB));
 
     if (okConsoleHandle(TCB) &&
@@ -861,65 +855,65 @@ wcon_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)
     DWORD dwFlag = 0;
     tcflag_t iflag;
     tcflag_t lflag;
+    int result = ERR;
 
-    AssertTCB();
-
-    if (TCB == 0 || buf == NULL)
-       return ERR;
+    if (buf != NULL && okConsoleHandle(TCB)) {
 
-    if (setFlag) {
-       iflag = buf->c_iflag;
-       lflag = buf->c_lflag;
+       if (setFlag) {
+           iflag = buf->c_iflag;
+           lflag = buf->c_lflag;
 
-       GetConsoleMode(CON.inp, &dwFlag);
+           GetConsoleMode(CON.inp, &dwFlag);
 
-       if (lflag & ICANON)
-           dwFlag |= ENABLE_LINE_INPUT;
-       else
-           dwFlag &= (DWORD) (~ENABLE_LINE_INPUT);
+           if (lflag & ICANON)
+               dwFlag |= ENABLE_LINE_INPUT;
+           else
+               dwFlag &= (DWORD) (~ENABLE_LINE_INPUT);
 
-       if (lflag & ECHO)
-           dwFlag |= ENABLE_ECHO_INPUT;
-       else
-           dwFlag &= (DWORD) (~ENABLE_ECHO_INPUT);
+           if (lflag & ECHO)
+               dwFlag |= ENABLE_ECHO_INPUT;
+           else
+               dwFlag &= (DWORD) (~ENABLE_ECHO_INPUT);
 
-       if (iflag & BRKINT)
-           dwFlag |= ENABLE_PROCESSED_INPUT;
-       else
-           dwFlag &= (DWORD) (~ENABLE_PROCESSED_INPUT);
+           if (iflag & BRKINT)
+               dwFlag |= ENABLE_PROCESSED_INPUT;
+           else
+               dwFlag &= (DWORD) (~ENABLE_PROCESSED_INPUT);
 
-       dwFlag |= ENABLE_MOUSE_INPUT;
+           dwFlag |= ENABLE_MOUSE_INPUT;
 
-       buf->c_iflag = iflag;
-       buf->c_lflag = lflag;
-       SetConsoleMode(CON.inp, dwFlag);
-       TCB->term.Nttyb = *buf;
-    } else {
-       iflag = TCB->term.Nttyb.c_iflag;
-       lflag = TCB->term.Nttyb.c_lflag;
-       GetConsoleMode(CON.inp, &dwFlag);
+           buf->c_iflag = iflag;
+           buf->c_lflag = lflag;
+           SetConsoleMode(CON.inp, dwFlag);
+           TCB->term.Nttyb = *buf;
+       } else {
+           iflag = TCB->term.Nttyb.c_iflag;
+           lflag = TCB->term.Nttyb.c_lflag;
+           GetConsoleMode(CON.inp, &dwFlag);
 
-       if (dwFlag & ENABLE_LINE_INPUT)
-           lflag |= ICANON;
-       else
-           lflag &= (tcflag_t) (~ICANON);
+           if (dwFlag & ENABLE_LINE_INPUT)
+               lflag |= ICANON;
+           else
+               lflag &= (tcflag_t) (~ICANON);
 
-       if (dwFlag & ENABLE_ECHO_INPUT)
-           lflag |= ECHO;
-       else
-           lflag &= (tcflag_t) (~ECHO);
+           if (dwFlag & ENABLE_ECHO_INPUT)
+               lflag |= ECHO;
+           else
+               lflag &= (tcflag_t) (~ECHO);
 
-       if (dwFlag & ENABLE_PROCESSED_INPUT)
-           iflag |= BRKINT;
-       else
-           iflag &= (tcflag_t) (~BRKINT);
+           if (dwFlag & ENABLE_PROCESSED_INPUT)
+               iflag |= BRKINT;
+           else
+               iflag &= (tcflag_t) (~BRKINT);
 
-       TCB->term.Nttyb.c_iflag = iflag;
-       TCB->term.Nttyb.c_lflag = lflag;
+           TCB->term.Nttyb.c_iflag = iflag;
+           TCB->term.Nttyb.c_lflag = lflag;
 
-       *buf = TCB->term.Nttyb;
+           *buf = TCB->term.Nttyb;
+       }
+       result = OK;
     }
-    return OK;
+    return result;
 }
 
 #define MIN_WIDE 80
@@ -1007,56 +1001,59 @@ wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
     TERMINAL *_term = (TERMINAL *) TCB;
     int code = ERR;
 
-    AssertTCB();
-    sp = TCB->csp;
-
-    T((T_CALLED("win32con::wcon_mode(%p, prog=%d, def=%d)"), TCB, progFlag, defFlag));
-    CON.progMode = progFlag;
-    CON.lastOut = progFlag ? CON.hdl : CON.out;
-    SetConsoleActiveScreenBuffer(CON.lastOut);
-
-    if (progFlag) /* prog mode */  {
-       if (defFlag) {
-           if ((wcon_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
-               _term->Nttyb.c_oflag &= (tcflag_t) (~OFLAGS_TABS);
-               code = OK;
+    if (okConsoleHandle(TCB)) {
+       sp = TCB->csp;
+
+       T((T_CALLED("win32con::wcon_mode(%p, prog=%d, def=%d)"),
+          TCB, progFlag, defFlag));
+
+       CON.progMode = progFlag;
+       CON.lastOut = progFlag ? CON.hdl : CON.out;
+       SetConsoleActiveScreenBuffer(CON.lastOut);
+
+       if (progFlag) /* prog mode */  {
+           if (defFlag) {
+               if ((wcon_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
+                   _term->Nttyb.c_oflag &= (tcflag_t) (~OFLAGS_TABS);
+                   code = OK;
+               }
+           } else {
+               /* reset_prog_mode */
+               if (wcon_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) {
+                   if (sp) {
+                       if (sp->_keypad_on)
+                           _nc_keypad(sp, TRUE);
+                   }
+                   if (!CON.buffered) {
+                       set_scrollback(FALSE, &CON.SBI);
+                   }
+                   code = OK;
+               }
            }
-       } else {
-           /* reset_prog_mode */
-           if (wcon_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) {
+           T(("... buffered:%d, clear:%d", CON.buffered, CurScreen(sp)->_clear));
+       } else {                /* shell mode */
+           if (defFlag) {
+               /* def_shell_mode */
+               if (wcon_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) {
+                   code = OK;
+               }
+           } else {
+               /* reset_shell_mode */
                if (sp) {
-                   if (sp->_keypad_on)
-                       _nc_keypad(sp, TRUE);
+                   _nc_keypad(sp, FALSE);
+                   NCURSES_SP_NAME(_nc_flush) (sp);
                }
+               code = wcon_sgmode(TCB, TRUE, &(_term->Ottyb));
                if (!CON.buffered) {
-                   set_scrollback(FALSE, &CON.SBI);
+                   set_scrollback(TRUE, &CON.save_SBI);
+                   if (!restore_original_screen())
+                       code = ERR;
                }
-               code = OK;
-           }
-       }
-       T(("... buffered:%d, clear:%d", CON.buffered, CurScreen(sp)->_clear));
-    } else {                   /* shell mode */
-       if (defFlag) {
-           /* def_shell_mode */
-           if (wcon_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) {
-               code = OK;
+               SetConsoleCursorInfo(CON.hdl, &CON.save_CI);
            }
-       } else {
-           /* reset_shell_mode */
-           if (sp) {
-               _nc_keypad(sp, FALSE);
-               NCURSES_SP_NAME(_nc_flush) (sp);
-           }
-           code = wcon_sgmode(TCB, TRUE, &(_term->Ottyb));
-           if (!CON.buffered) {
-               set_scrollback(TRUE, &CON.save_SBI);
-               if (!restore_original_screen())
-                   code = ERR;
-           }
-           SetConsoleCursorInfo(CON.hdl, &CON.save_CI);
        }
-    }
 
+    }
     returnCode(code);
 }
 
@@ -1234,7 +1231,7 @@ wcon_init(TERMINAL_CONTROL_BLOCK * TCB)
     AssertTCB();
 
     if (TCB) {
-       if (CON.hdl == INVALID_HANDLE_VALUE) {
+       if (!InitConsole()) {
            returnVoid;
        }
 
@@ -1266,12 +1263,13 @@ wcon_initpair(TERMINAL_CONTROL_BLOCK * TCB,
 {
     SCREEN *sp;
 
-    AssertTCB();
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    if ((pair > 0) && (pair < NUMPAIRS) && (f >= 0) && (f < 8)
-       && (b >= 0) && (b < 8)) {
-       CON.pairs[pair] = MapColor(true, f) | MapColor(false, b);
+       if ((pair > 0) && (pair < NUMPAIRS) && (f >= 0) && (f < 8)
+           && (b >= 0) && (b < 8)) {
+           CON.pairs[pair] = MapColor(true, f) | MapColor(false, b);
+       }
     }
 }
 
@@ -1307,10 +1305,11 @@ wcon_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
 {
     SCREEN *sp;
 
-    AssertTCB();
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    sp->_mouse_type = M_TERM_DRIVER;
+       sp->_mouse_type = M_TERM_DRIVER;
+    }
 }
 
 static int
@@ -1319,17 +1318,18 @@ wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay)
     int rc = 0;
     SCREEN *sp;
 
-    AssertTCB();
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
-       rc = TW_MOUSE;
-    } else {
-       rc = TCBOf(sp)->drv->td_twait(TCBOf(sp),
-                                     TWAIT_MASK,
-                                     delay,
-                                     (int *) 0
-                                     EVENTLIST_2nd(evl));
+       if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
+           rc = TW_MOUSE;
+       } else {
+           rc = TCBOf(sp)->drv->td_twait(TCBOf(sp),
+                                         TWAIT_MASK,
+                                         delay,
+                                         (int *) 0
+                                         EVENTLIST_2nd(evl));
+       }
     }
 
     return rc;
@@ -1426,13 +1426,14 @@ wcon_initacs(TERMINAL_CONTROL_BLOCK * TCB,
     unsigned n;
 
     SCREEN *sp;
-    AssertTCB();
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    for (n = 0; n < SIZEOF(table); ++n) {
-       real_map[table[n].acs_code] = (chtype) table[n].use_code | A_ALTCHARSET;
-       if (sp != 0)
-           sp->_screen_acs_map[table[n].acs_code] = TRUE;
+       for (n = 0; n < SIZEOF(table); ++n) {
+           real_map[table[n].acs_code] = (chtype) table[n].use_code | A_ALTCHARSET;
+           if (sp != 0)
+               sp->_screen_acs_map[table[n].acs_code] = TRUE;
+       }
     }
 }
 
@@ -1622,16 +1623,17 @@ wcon_twait(TERMINAL_CONTROL_BLOCK * TCB,
           EVENTLIST_2nd(_nc_eventlist * evl))
 {
     SCREEN *sp;
-    int code;
+    int code = 0;
 
-    AssertTCB();
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    code = console_twait(sp,
-                        CON.inp,
-                        mode,
-                        milliseconds,
-                        timeleft EVENTLIST_2nd(_nc_eventlist * evl));
+       code = console_twait(sp,
+                            CON.inp,
+                            mode,
+                            milliseconds,
+                            timeleft EVENTLIST_2nd(_nc_eventlist * evl));
+    }
     return code;
 }
 
@@ -1682,14 +1684,16 @@ static int
 wcon_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
 {
     SCREEN *sp;
-    int n;
+    int n = -1;
+
+    T((T_CALLED("win32con::wcon_read(%p)"), TCB));
 
-    AssertTCB();
     assert(buf);
-    SetSP();
+    if (okConsoleHandle(TCB)) {
+       SetSP();
 
-    T((T_CALLED("win32con::wcon_read(%p)"), TCB));
-    n = _nc_mingw_console_read(sp, CON.inp, buf);
+       n = _nc_mingw_console_read(sp, CON.inp, buf);
+    }
     returnCode(n);
 }
 
@@ -1705,19 +1709,22 @@ static int
 wcon_cursorSet(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int mode)
 {
     int res = -1;
-    CONSOLE_CURSOR_INFO this_CI = CON.save_CI;
+
     T((T_CALLED("win32con:wcon_cursorSet(%d)"), mode));
-    switch (mode) {
-    case 0:
-       this_CI.bVisible = FALSE;
-       break;
-    case 1:
-       break;
-    case 2:
-       this_CI.dwSize = 100;
-       break;
+    if (okConsoleHandle(TCB)) {
+       CONSOLE_CURSOR_INFO this_CI = CON.save_CI;
+       switch (mode) {
+       case 0:
+           this_CI.bVisible = FALSE;
+           break;
+       case 1:
+           break;
+       case 2:
+           this_CI.dwSize = 100;
+           break;
+       }
+       SetConsoleCursorInfo(CON.hdl, &this_CI);
     }
-    SetConsoleCursorInfo(CON.hdl, &this_CI);
     returnCode(res);
 }
 
@@ -1750,12 +1757,14 @@ wcon_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag GCC_UNUSED)
     SCREEN *sp;
     int code = ERR;
 
-    AssertTCB();
-    SetSP();
-
     T((T_CALLED("win32con::wcon_kpad(%p, %d)"), TCB, flag));
-    if (sp) {
-       code = OK;
+
+    if (okConsoleHandle(TCB)) {
+       SetSP();
+
+       if (sp) {
+           code = OK;
+       }
     }
     returnCode(code);
 }
@@ -1774,22 +1783,23 @@ wcon_keyok(TERMINAL_CONTROL_BLOCK * TCB,
 
     T((T_CALLED("win32con::wcon_keyok(%p, %d, %d)"), TCB, keycode, flag));
 
-    AssertTCB();
-    SetSP();
-
-    if (sp) {
-       res = bsearch(&key,
-                     CON.rmap,
-                     (size_t) (N_INI + FKEYS),
-                     sizeof(keylist[0]),
-                     rkeycompare);
-       if (res) {
-           key = *((LONG *) res);
-           vKey = HIWORD(key);
-           nKey = (LOWORD(key)) & 0x7fff;
-           if (!flag)
-               nKey |= 0x8000;
-           *(LONG *) res = GenMap(vKey, nKey);
+    if (okConsoleHandle(TCB)) {
+       SetSP();
+
+       if (sp) {
+           res = bsearch(&key,
+                         CON.rmap,
+                         (size_t) (N_INI + FKEYS),
+                         sizeof(keylist[0]),
+                         rkeycompare);
+           if (res) {
+               key = *((LONG *) res);
+               vKey = HIWORD(key);
+               nKey = (LOWORD(key)) & 0x7fff;
+               if (!flag)
+                   nKey |= 0x8000;
+               *(LONG *) res = GenMap(vKey, nKey);
+           }
        }
     }
     returnCode(code);
@@ -2081,7 +2091,7 @@ _nc_mingw_console_read(
                          HANDLE fd,
                          int *buf)
 {
-    int n = 1;
+    int rc = -1;
     INPUT_RECORD inp_rec;
     BOOL b;
     DWORD nRead;
@@ -2096,6 +2106,9 @@ _nc_mingw_console_read(
 
     while ((b = ReadConsoleInput(fd, &inp_rec, 1, &nRead))) {
        if (b && nRead > 0) {
+           if (rc < 0)
+               rc = 0;
+           rc += nRead;
            if (inp_rec.EventType == KEY_EVENT) {
                if (!inp_rec.Event.KeyEvent.bKeyDown)
                    continue;
@@ -2133,13 +2146,13 @@ _nc_mingw_console_read(
            continue;
        }
     }
-    returnCode(n);
+    returnCode(rc);
 }
 
-static
-__attribute__((constructor))
-     void _enter_console(void)
+static bool
+InitConsole(void)
 {
+    /* initalize once, or not at all */
     if (!console_initialized) {
        int i;
        DWORD num_buttons;
@@ -2226,4 +2239,26 @@ __attribute__((constructor))
 
        console_initialized = TRUE;
     }
+    return (CON.hdl != INVALID_HANDLE_VALUE);
+}
+
+static bool
+okConsoleHandle(TERMINAL_CONTROL_BLOCK * TCB)
+{
+    return ((TCB != 0) &&
+           (TCB->magic == WINMAGIC) &&
+           InitConsole());
 }
+
+/*
+ * While a constructor would ensure that this module is initialized, that will
+ * interfere with applications that may combine this with GUI interfaces.
+ */
+#if 0
+static
+__attribute__((constructor))
+     void _enter_console(void)
+{
+    (void) InitConsole();
+}
+#endif
index 6ac7b9d7289e96a5fe2c5a003903066fcb6e1657..6ad235368f601d713c26b903854cd0a50766e6ae 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9+20150221) unstable; urgency=low
+ncurses6 (5.9+20150228) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 21 Feb 2015 11:19:10 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 28 Feb 2015 12:36:40 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
index 6ac7b9d7289e96a5fe2c5a003903066fcb6e1657..6ad235368f601d713c26b903854cd0a50766e6ae 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9+20150221) unstable; urgency=low
+ncurses6 (5.9+20150228) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 21 Feb 2015 11:19:10 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 28 Feb 2015 12:36:40 -0500
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
index 208749c13b76833a70d4653074cd0594d6e5cc8a..66fbe85b9de8899cb6c2a4ab9adf2f1fb5fc0d82 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9+20150221) unstable; urgency=low
+ncurses6 (5.9+20150228) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 21 Feb 2015 11:19:10 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 28 Feb 2015 12:36:40 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index 319b95bc140712f9312c452bb1eb20ffb57437a9..e50f92dd7851623039517fd46322e97035fed639 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.88 2015/02/21 16:19:10 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.89 2015/02/28 17:36:40 tom Exp $\r
 \r
 ; TODO add examples\r
 ; TODO bump ABI to 6\r
@@ -10,7 +10,7 @@
 !define VERSION_MAJOR "5"\r
 !define VERSION_MINOR "9"\r
 !define VERSION_YYYY  "2015"\r
-!define VERSION_MMDD  "0221"\r
+!define VERSION_MMDD  "0228"\r
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
 \r
 !define MY_ABI   "5"\r
index 3ff08a6d140857b19dffb15254de6b97a8de232b..758b41ea3f4a25c6fa360c185ee5c08196e5748f 100644 (file)
@@ -3,7 +3,7 @@
 Summary: shared libraries for terminal handling
 Name: mingw32-ncurses6
 Version: 5.9
-Release: 20150221
+Release: 20150228
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
index fb3d411848216b176bb3c1ef384b2f1053d529db..91b6bd24f93e0e5e7b8547b78418c355fd7b4906 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 5.9
-Release: 20150221
+Release: 20150228
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz