From a6e4fdd3cdc7d71be239c8cae7bc2c2145619e60 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 7 Jul 2007 23:55:05 +0000 Subject: [PATCH] ncurses 5.6 - patch 20070707 + add continuous-move "M" to demo_panels to help test refresh changes. + improve fix for refresh of window on top of multi-column characters, taking into account some split characters on left/right window boundaries. --- NEWS | 8 ++++- dist.mk | 4 +-- ncurses/base/lib_refresh.c | 67 ++++++++++++++++++++++++++++---------- test/demo_panels.c | 62 ++++++++++++++++++++++++++--------- 4 files changed, 106 insertions(+), 35 deletions(-) diff --git a/NEWS b/NEWS index 4c925c76..4701dd03 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.1140 2007/06/30 23:37:37 tom Exp $ +-- $Id: NEWS,v 1.1141 2007/07/07 19:55:16 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,12 @@ 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. +20070707 + + add continuous-move "M" to demo_panels to help test refresh changes. + + improve fix for refresh of window on top of multi-column characters, + taking into account some split characters on left/right window + boundaries. + 20070630 + add "widec" row to _tracedump() output to help diagnose remaining problems with multi-column characters. diff --git a/dist.mk b/dist.mk index 39d65ea2..5b6913ae 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.599 2007/06/30 16:01:18 tom Exp $ +# $Id: dist.mk,v 1.600 2007/07/07 16:45:04 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 = 6 -NCURSES_PATCH = 20070630 +NCURSES_PATCH = 20070707 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c index a16dc8e6..bc4d21e8 100644 --- a/ncurses/base/lib_refresh.c +++ b/ncurses/base/lib_refresh.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_refresh.c,v 1.37 2007/06/30 23:35:43 tom Exp $") +MODULE_ID("$Id: lib_refresh.c,v 1.40 2007/07/07 22:08:38 tom Exp $") NCURSES_EXPORT(int) wrefresh(WINDOW *win) @@ -145,21 +145,56 @@ wnoutrefresh(WINDOW *win) register struct ldat *oline = &win->_line[src_row]; if (oline->firstchar != _NOCHANGE) { - int last = oline->lastchar; + int last_src = oline->lastchar; - if (last > limit_x) - last = limit_x; + if (last_src > limit_x) + last_src = limit_x; src_col = oline->firstchar; dst_col = src_col + begx; + if_WIDEC({ + register int j; + + /* + * Ensure that we will copy complete multi-column characters + * on the left-boundary. + */ + if (isWidecExt(oline->text[src_col])) { + j = 1 + dst_col - WidecExt(oline->text[src_col]); + if (j < 0) + j = 0; + if (dst_col > j) { + src_col -= (dst_col - j); + dst_col = j; + } + } + + /* + * Ensure that we will copy complete multi-column characters + * on the right-boundary. + */ + j = last_src; + if (WidecExt(oline->text[j])) { + ++j; + while (j <= limit_x) { + if (isWidecBase(oline->text[j])) { + break; + } else { + last_src = j; + } + ++j; + } + } + }); + if_WIDEC({ static cchar_t blank = BLANK; - int last_col = begx + ((last < win->_maxx) - ? last + int last_dst = begx + ((last_src < win->_maxx) + ? last_src : win->_maxx); int fix_left = dst_col; - int fix_right = last_col; + int fix_right = last_dst; register int j; /* @@ -178,7 +213,7 @@ wnoutrefresh(WINDOW *win) fix_left = 0; /* only if cell is corrupt */ } - j = last_col; + j = last_dst; if (WidecExt(nline->text[j]) != 0) { /* * On the right, any multi-column character is a problem, @@ -187,7 +222,7 @@ wnoutrefresh(WINDOW *win) * computation for 'fix_left' accounts for the left-side of * this character. Find the end of the character. */ - fix_right = ++j; + ++j; while (j <= newscr->_maxx && isWidecExt(nline->text[j])) { fix_right = j++; } @@ -197,20 +232,18 @@ wnoutrefresh(WINDOW *win) * The analysis is simpler if we do the clearing afterwards. * Do that now. */ - for (j = fix_left; j < dst_col; ++j) { - nline->text[j] = blank; - CHANGED_CELL(nline, j); - } - for (j = last_col + 1; j <= fix_right; ++j) { - nline->text[j] = blank; - CHANGED_CELL(nline, j); + if (fix_left < dst_col || fix_right > last_dst) { + for (j = fix_left; j <= fix_right; ++j) { + nline->text[j] = blank; + CHANGED_CELL(nline, j); + } } }); /* * Copy the changed text. */ - for (; src_col <= last; src_col++, dst_col++) { + for (; src_col <= last_src; src_col++, dst_col++) { if (!CharEq(oline->text[src_col], nline->text[dst_col])) { nline->text[dst_col] = oline->text[src_col]; CHANGED_CELL(nline, dst_col); diff --git a/test/demo_panels.c b/test/demo_panels.c index 8d5bac2b..8865f70d 100755 --- a/test/demo_panels.c +++ b/test/demo_panels.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_panels.c,v 1.22 2007/06/30 21:38:08 tom Exp $ + * $Id: demo_panels.c,v 1.26 2007/07/07 22:16:33 tom Exp $ * * Demonstrate a variety of functions from the panel library. */ @@ -37,6 +37,9 @@ #include +#define LAST_POS '@' +#define TEMP_POS '>' + typedef void (*InitPanel) (void); typedef void (*FillPanel) (PANEL *); @@ -113,6 +116,7 @@ get_position(NCURSES_CONST char *text, { int result = 0; int x1, y1; + char cmd; WINDOW *win; getyx(stdscr, y1, x1); @@ -121,9 +125,21 @@ get_position(NCURSES_CONST char *text, show_position(text, also, which, y1, x1); if (log_in != 0) { - (void) wgetch(stdscr); - if (fscanf(log_in, "@%d,%d\n", &y1, &x1) == 2) { - result = 1; + if (fscanf(log_in, "%c%d,%d\n", &cmd, &y1, &x1) == 3) { + switch (cmd) { + case LAST_POS: + result = 1; + (void) wgetch(stdscr); + break; + case TEMP_POS: + result = 0; + wrefresh(stdscr); + napms(100); + break; + default: + result = -1; + break; + } } else { result = -1; } @@ -170,11 +186,16 @@ get_position(NCURSES_CONST char *text, } wmove(stdscr, y1, x1); - if (result > 0) { + *ypos = y1; + *xpos = x1; + + if (result >= 0) { if (log_out) - fprintf(log_out, "@%d,%d\n", y1, x1); - *ypos = y1; - *xpos = x1; + fprintf(log_out, "%c%d,%d\n", + ((result > 0) + ? LAST_POS + : TEMP_POS), + y1, x1); } return result; } @@ -271,7 +292,7 @@ my_create_panel(PANEL ** pans, int which, FillPanel myFill) } static void -my_move_panel(PANEL ** pans, int which) +my_move_panel(PANEL ** pans, int which, bool continuous) { if (pans[which] != 0) { int code; @@ -284,7 +305,10 @@ my_move_panel(PANEL ** pans, int which) sprintf(also, " (start %d,%d)", y0, x0); wmove(stdscr, y0, x0); while ((code = get_position("Move panel", also, which, &x1, &y1)) == 0) { - ; + if (continuous) { + move_panel(pans[which], y1, x1); + pflush(); + } } if (code > 0) { move_panel(pans[which], y1, x1); @@ -450,7 +474,7 @@ show_panels(PANEL * px[MAX_PANELS + 1]) " c - create the panel", " d - delete the panel", " h - hide the panel", - " m - move the panel", + " m - move the panel (M for continuous move)", " r - resize the panel", " s - show the panel", " b - put the panel on the top of the stack" @@ -535,9 +559,13 @@ do_panel(PANEL * px[MAX_PANELS + 1], { int which = cmd[1] - '0'; + if (which < 1 || which > MAX_PANELS) { + beep(); + return; + } + if (log_in != 0) { pflush(); - (void) wgetch(stdscr); } saywhat(cmd); @@ -555,7 +583,10 @@ do_panel(PANEL * px[MAX_PANELS + 1], my_hide_panel(px[which]); break; case 'm': - my_move_panel(px, which); + my_move_panel(px, which, FALSE); + break; + case 'M': + my_move_panel(px, which, TRUE); break; case 'r': my_resize_panel(px, which, myFill); @@ -572,7 +603,7 @@ do_panel(PANEL * px[MAX_PANELS + 1], static bool ok_letter(int ch) { - return isalpha(UChar(ch)) && strchr("bcdhmrst", ch) != 0; + return isalpha(UChar(ch)) && strchr("bcdhmMrst", ch) != 0; } static bool @@ -601,14 +632,15 @@ get_command(PANEL * px[MAX_PANELS + 1], char *buffer, int limit) buffer[length = 0] = '\0'; if (log_in != 0) { - (void) wgetch(win); if (fgets(buffer, limit - 3, log_in) != 0) { length = strlen(buffer); while (length > 0 && isspace(buffer[length - 1])) buffer[--length] = '\0'; + waddstr(win, buffer); } else { close_input(); } + (void) wgetch(win); } else { c0 = 0; for (;;) { -- 2.45.0