From 1bab6fd2bd6c65560d26b46b0a245bd7d46f2add Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Mon, 30 Jun 2014 00:28:28 +0000 Subject: [PATCH] ncurses 5.9 - patch 20140629 + correct check in win_driver.c for saving screen contents, e.g., when NCURSES_CONSOLE2 is set (cf: 20140503). + reorganize b/B menu items in ncurses.c, putting the test-strings into subwindows. This is needed for a planned change to use Unicode fullwidth characters in the test-screens. + correct update to form status for _NEWTOP, broken by fixes for compiler warnings (patch by Leon Winter, cf: 20120616). --- NEWS | 11 ++- dist.mk | 4 +- form/frm_driver.c | 4 +- ncurses/win32con/win_driver.c | 4 +- package/debian-mingw/changelog | 4 +- package/debian-mingw64/changelog | 4 +- package/debian/changelog | 4 +- package/mingw-ncurses.nsi | 4 +- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- test/dots_curses.c | 6 +- test/ncurses.c | 150 ++++++++++++++++++++----------- 12 files changed, 128 insertions(+), 71 deletions(-) diff --git a/NEWS b/NEWS index 25b4a1c5..2d53cee2 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.2229 2014/06/21 21:51:45 tom Exp $ +-- $Id: NEWS,v 1.2234 2014/06/29 23:43:38 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,15 @@ 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. +20140629 + + correct check in win_driver.c for saving screen contents, e.g., when + NCURSES_CONSOLE2 is set (cf: 20140503). + + reorganize b/B menu items in ncurses.c, putting the test-strings into + subwindows. This is needed for a planned change to use Unicode + fullwidth characters in the test-screens. + + correct update to form status for _NEWTOP, broken by fixes for + compiler warnings (patch by Leon Winter, cf: 20120616). + 20140621 + change shared-library suffix for AIX 5 and 6 to ".so", avoiding conflict with the static library (report by Ben Lentz). diff --git a/dist.mk b/dist.mk index e2ded37d..f0986dea 100644 --- 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.992 2014/06/21 14:35:14 tom Exp $ +# $Id: dist.mk,v 1.994 2014/06/28 21:47:46 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 = 20140621 +NCURSES_PATCH = 20140629 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/form/frm_driver.c b/form/frm_driver.c index 3b770571..85d6a62f 100644 --- a/form/frm_driver.c +++ b/form/frm_driver.c @@ -32,7 +32,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_driver.c,v 1.111 2014/03/08 22:08:20 Xin.Li Exp $") +MODULE_ID("$Id: frm_driver.c,v 1.112 2014/06/28 16:28:22 Leon.Winter Exp $") /*---------------------------------------------------------------------------- This is the core module of the form library. It contains the majority @@ -1998,7 +1998,7 @@ Vertical_Scrolling(int (*const fct) (FORM *), FORM *form) { res = fct(form); if (res == E_OK) - SetStatus(form, _NEWTOP); + SetStatus(form->current, _NEWTOP); } return (res); } diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c index 44347646..0cb27e81 100644 --- a/ncurses/win32con/win_driver.c +++ b/ncurses/win32con/win_driver.c @@ -45,7 +45,7 @@ #define CUR my_term.type. -MODULE_ID("$Id: win_driver.c,v 1.38 2014/05/10 21:50:00 tom Exp $") +MODULE_ID("$Id: win_driver.c,v 1.39 2014/06/29 22:48:17 tom Exp $") #ifndef __GNUC__ # error We need GCC to compile for MinGW @@ -1909,7 +1909,7 @@ __attribute__((constructor)) if (CON.hdl != INVALID_HANDLE_VALUE) { CON.buffered = buffered; get_SBI(); - if (buffered) { + if (!buffered) { save_original_screen(); } } diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index bbefb0cd..a4ae93bc 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20140621) unstable; urgency=low +ncurses6 (5.9-20140629) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 21 Jun 2014 10:35:14 -0400 + -- Thomas E. Dickey Sat, 28 Jun 2014 17:47:47 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index bbefb0cd..a4ae93bc 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20140621) unstable; urgency=low +ncurses6 (5.9-20140629) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 21 Jun 2014 10:35:14 -0400 + -- Thomas E. Dickey Sat, 28 Jun 2014 17:47:47 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 233c827e..473831fb 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9-20140621) unstable; urgency=low +ncurses6 (5.9-20140629) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sat, 21 Jun 2014 10:35:14 -0400 + -- Thomas E. Dickey Sat, 28 Jun 2014 17:47:47 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 982ef476..04a60bcb 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.47 2014/06/21 14:35:14 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.49 2014/06/28 21:47:47 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "5" !define VERSION_MINOR "9" !define VERSION_YYYY "2014" -!define VERSION_MMDD "0621" +!define VERSION_MMDD "0629" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index db673dfc..8d272fda 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 5.9 -Release: 20140621 +Release: 20140629 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index c089851f..ef3dc2fb 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 5.9 -Release: 20140621 +Release: 20140629 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/test/dots_curses.c b/test/dots_curses.c index ef300ee4..dc767116 100644 --- a/test/dots_curses.c +++ b/test/dots_curses.c @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: dots_curses.c,v 1.1 2014/06/21 16:07:50 tom Exp $ + * $Id: dots_curses.c,v 1.2 2014/06/28 20:33:24 tom Exp $ * * A simple demo of the curses interface used for comparison with termcap. */ @@ -106,7 +106,7 @@ main(int argc GCC_UNUSED, for (bg = 0; bg < COLORS; bg++) { int pair = mypair(fg, bg); if (pair > 0) - init_pair(pair, fg, bg); + init_pair((short) pair, (short) fg, (short) bg); } } } @@ -142,7 +142,7 @@ main(int argc GCC_UNUSED, napms(1); } } - addch(p); + addch((chtype) p); refresh(); ++total_chars; } diff --git a/test/ncurses.c b/test/ncurses.c index 28d3de75..bf874677 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.401 2014/06/21 18:37:29 tom Exp $ +$Id: ncurses.c,v 1.408 2014/06/28 21:45:40 tom Exp $ ***************************************************************************/ @@ -303,7 +303,7 @@ wGetstring(WINDOW *win, char *buffer, int limit) #if USE_WIDEC_SUPPORT static wchar_t -fullwidth_of(int ch) +fullwidth_digit(int ch) { return (ch + 0xff10 - '0'); } @@ -313,7 +313,7 @@ make_fullwidth_text(wchar_t *target, const char *source) { int ch; while ((ch = *source++) != 0) { - *target++ = fullwidth_of(ch); + *target++ = fullwidth_digit(ch); } *target = 0; } @@ -334,7 +334,7 @@ make_fullwidth_digit(cchar_t *target, int digit) { wchar_t source[2]; - source[0] = fullwidth_of(digit + '0'); + source[0] = fullwidth_digit(digit + '0'); source[1] = 0; setcchar(target, source, A_NORMAL, 0, 0); } @@ -1252,8 +1252,13 @@ my_termattrs(void) #define termattrs() my_termattrs() #endif -#define MAX_ATTRSTRING 31 -#define LEN_ATTRSTRING 26 +#define ATTRSTRING_1ST 32 /* ' ' */ +#define ATTRSTRING_END 126 /* '~' */ + +#define COL_ATTRSTRING 25 +#define MARGIN_4_ATTRS (COL_ATTRSTRING + 8) +#define LEN_ATTRSTRING (COLS - MARGIN_4_ATTRS) +#define MAX_ATTRSTRING (ATTRSTRING_END + 1 - ATTRSTRING_1ST) static char attr_test_string[MAX_ATTRSTRING + 1]; @@ -1352,12 +1357,14 @@ cycle_color_attr(int ch, NCURSES_COLOR_T *fg, NCURSES_COLOR_T *bg, NCURSES_COLOR static void adjust_attr_string(int adjust) { - int first = ((int) UChar(attr_test_string[0])) + adjust; - int last = first + LEN_ATTRSTRING; + char save = attr_test_string[0]; + int first = ((int) UChar(save)) + adjust; + int j, k; - if (first >= ' ' && last <= '~') { /* 32..126 */ - int j, k; - for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) { + if (first >= ATTRSTRING_1ST) { + for (j = 0, k = first; j < MAX_ATTRSTRING; ++j, ++k) { + if (k > ATTRSTRING_END) + break; attr_test_string[j] = (char) k; if (((k + 1 - first) % 5) == 0) { if (++j >= MAX_ATTRSTRING) @@ -1365,23 +1372,40 @@ adjust_attr_string(int adjust) attr_test_string[j] = ' '; } } - while (j < MAX_ATTRSTRING) - attr_test_string[j++] = ' '; - attr_test_string[j] = '\0'; - } else { - beep(); + if ((LEN_ATTRSTRING - j) > 5) { + attr_test_string[0] = save; + adjust_attr_string(adjust - 1); + } else { + while (j < MAX_ATTRSTRING) + attr_test_string[j++] = ' '; + attr_test_string[j] = '\0'; + } } } +/* + * Prefer the right-end of the string for starting, since that maps to the + * VT100 line-drawing. + */ +static int +default_attr_string(void) +{ + int result = (ATTRSTRING_END - LEN_ATTRSTRING); + result += (LEN_ATTRSTRING / 5); + if (result < ATTRSTRING_1ST) + result = ATTRSTRING_1ST; + return result; +} + static void init_attr_string(void) { - attr_test_string[0] = 'a'; + attr_test_string[0] = (char) default_attr_string(); adjust_attr_string(0); } static int -show_attr(int row, int skip, bool arrow, chtype attr, const char *name) +show_attr(WINDOW *win, int row, int skip, bool arrow, chtype attr, const char *name) { int ncv = get_ncv(); chtype test = attr & (chtype) (~A_ALTCHARSET); @@ -1389,7 +1413,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name) if (arrow) MvPrintw(row, 5, "-->"); MvPrintw(row, 8, "%s mode:", name); - MvPrintw(row, 24, "|"); + MvPrintw(row, COL_ATTRSTRING - 1, "|"); if (skip) printw("%*s", skip, " "); /* @@ -1397,22 +1421,23 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name) * character at a time (to pass its rendition directly), and use the * string operation for the other attributes. */ + wmove(win, 0, 0); if (attr & A_ALTCHARSET) { const char *s; chtype ch; for (s = attr_test_string; *s != '\0'; ++s) { ch = UChar(*s); - addch(ch | attr); + (void) waddch(win, ch | attr); } } else { - (void) attrset(attr); - addstr(attr_test_string); - attroff(attr); + (void) wattrset(win, attr); + (void) waddstr(win, attr_test_string); + (void) wattroff(win, attr); } if (skip) printw("%*s", skip, " "); - printw("|"); + MvPrintw(row, COL_ATTRSTRING + LEN_ATTRSTRING, "|"); if (test != A_NORMAL) { if (!(termattrs() & test)) { printw(" (N/A)"); @@ -1570,10 +1595,18 @@ attr_test(void) NCURSES_COLOR_T tx = -1; int ac = 0; unsigned j, k; + WINDOW *my_wins[SIZEOF(attrs_to_test)]; ATTR_TBL my_list[SIZEOF(attrs_to_test)]; unsigned my_size = init_attr_list(my_list, termattrs()); if (my_size > 1) { + for (j = 0; j < my_size; ++j) { + my_wins[j] = subwin(stdscr, + 1, LEN_ATTRSTRING, + 2 + (int) (2 * j), COL_ATTRSTRING); + scrollok(my_wins[j], FALSE); + } + if (skip < 0) skip = 0; @@ -1614,7 +1647,7 @@ attr_test(void) for (j = 0; j < my_size; ++j) { bool arrow = (j == k); - row = show_attr(row, n, arrow, + row = show_attr(my_wins[j], row, n, arrow, extras | my_list[j].attr | my_list[k].attr, @@ -1645,12 +1678,14 @@ static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1]; static void wide_adjust_attr_string(int adjust) { - int first = ((int) UChar(wide_attr_test_string[0])) + adjust; - int last = first + LEN_ATTRSTRING; + char save = (char) wide_attr_test_string[0]; + int first = ((int) UChar(save)) + adjust; + int j, k; - if (first >= ' ' && last <= '~') { /* 32..126 */ - int j, k; - for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) { + if (first >= ATTRSTRING_1ST) { + for (j = 0, k = first; j < MAX_ATTRSTRING; ++j, ++k) { + if (k > ATTRSTRING_END) + break; wide_attr_test_string[j] = k; if (((k + 1 - first) % 5) == 0) { if (++j >= MAX_ATTRSTRING) @@ -1658,18 +1693,21 @@ wide_adjust_attr_string(int adjust) wide_attr_test_string[j] = ' '; } } - while (j < MAX_ATTRSTRING) - wide_attr_test_string[j++] = ' '; - wide_attr_test_string[j] = '\0'; - } else { - beep(); + if ((LEN_ATTRSTRING - j) > 5) { + wide_attr_test_string[0] = save; + wide_adjust_attr_string(adjust - 1); + } else { + while (j < MAX_ATTRSTRING) + wide_attr_test_string[j++] = ' '; + wide_attr_test_string[j] = '\0'; + } } } static void wide_init_attr_string(void) { - wide_attr_test_string[0] = 'a'; + wide_attr_test_string[0] = default_attr_string(); wide_adjust_attr_string(0); } @@ -1705,7 +1743,8 @@ get_wide_background(void) } static int -wide_show_attr(int row, +wide_show_attr(WINDOW *win, + int row, int skip, bool arrow, chtype attr, @@ -1718,7 +1757,7 @@ wide_show_attr(int row, if (arrow) MvPrintw(row, 5, "-->"); MvPrintw(row, 8, "%s mode:", name); - MvPrintw(row, 24, "|"); + MvPrintw(row, COL_ATTRSTRING - 1, "|"); if (skip) printw("%*s", skip, " "); @@ -1727,6 +1766,7 @@ wide_show_attr(int row, * character at a time (to pass its rendition directly), and use the * string operation for the other attributes. */ + wmove(win, 0, 0); if (attr & WA_ALTCHARSET) { const wchar_t *s; cchar_t ch; @@ -1736,20 +1776,20 @@ wide_show_attr(int row, fill[0] = *s; fill[1] = L'\0'; setcchar(&ch, fill, attr, pair, 0); - add_wch(&ch); + (void) wadd_wch(win, &ch); } } else { attr_t old_attr = 0; NCURSES_PAIRS_T old_pair = 0; - (void) (attr_get) (&old_attr, &old_pair, 0); - (void) attr_set(attr, pair, 0); - addwstr(wide_attr_test_string); - (void) attr_set(old_attr, old_pair, 0); + (void) (wattr_get) (win, &old_attr, &old_pair, 0); + (void) wattr_set(win, attr, pair, 0); + (void) waddwstr(win, wide_attr_test_string); + (void) wattr_set(win, old_attr, old_pair, 0); } if (skip) printw("%*s", skip, " "); - printw("|"); + MvPrintw(row, COL_ATTRSTRING + LEN_ATTRSTRING, "|"); if (test != A_NORMAL) { if (!(term_attrs() & test)) { printw(" (N/A)"); @@ -1862,9 +1902,17 @@ wide_attr_test(void) int ac = 0; unsigned j, k; ATTR_TBL my_list[SIZEOF(attrs_to_test)]; + WINDOW *my_wins[SIZEOF(attrs_to_test)]; unsigned my_size = init_attr_list(my_list, term_attrs()); if (my_size > 1) { + for (j = 0; j < my_size; ++j) { + my_wins[j] = subwin(stdscr, + 1, LEN_ATTRSTRING, + 2 + (int) (2 * j), COL_ATTRSTRING); + scrollok(my_wins[j], FALSE); + } + if (skip < 0) skip = 0; @@ -1900,7 +1948,7 @@ wide_attr_test(void) MvAddStr(0, 20, "Character attribute test display"); for (j = 0; j < my_size; ++j) { - row = wide_show_attr(row, n, j == k, + row = wide_show_attr(my_wins[j], row, n, (j == k), ((attr_t) ac | my_list[j].attr | my_list[k].attr), @@ -4752,13 +4800,13 @@ pflush(void) fill_panel(win) --------------------------------------------------------------------------*/ static void -init_panel(void) +init_panel(WINDOW *win) { register int y, x; for (y = 0; y < LINES - 1; y++) { for (x = 0; x < COLS; x++) - wprintw(stdscr, "%d", (y + x) % 10); + wprintw(win, "%d", (y + x) % 10); } } @@ -4784,7 +4832,7 @@ fill_panel(PANEL * pan) #if USE_WIDEC_SUPPORT static void -init_wide_panel(void) +init_wide_panel(WINDOW *win) { int digit; cchar_t temp[10]; @@ -4796,7 +4844,7 @@ init_wide_panel(void) int y, x; getyx(stdscr, y, x); digit = (y + x / 2) % 10; - } while (add_wch(&temp[digit]) != ERR); + } while (wadd_wch(win, &temp[digit]) != ERR); } static void @@ -4850,7 +4898,7 @@ canned_panel(PANEL * px[MAX_PANELS + 1], NCURSES_CONST char *cmd) } static void -demo_panels(void (*InitPanel) (void), void (*FillPanel) (PANEL *)) +demo_panels(void (*InitPanel) (WINDOW *), void (*FillPanel) (PANEL *)) { int count; int itmp; @@ -4859,7 +4907,7 @@ demo_panels(void (*InitPanel) (void), void (*FillPanel) (PANEL *)) scrollok(stdscr, FALSE); /* we don't want stdscr to scroll! */ refresh(); - InitPanel(); + InitPanel(stdscr); for (count = 0; count < 5; count++) { px[1] = mkpanel(COLOR_RED, LINES / 2 - 2, -- 2.44.0