diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2023-10-24 00:12:43 +0000 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2023-10-24 00:19:09 +0000 |
commit | b4e239624028cf574c9557486290c0e52f0966e4 (patch) | |
tree | 6f3798cf611b726c3af8649d058f9c90b190ede2 | |
parent | 26735ba8400464437273b79b24ac6481240e504b (diff) | |
download | lynx-snapshots-b4e239624028cf574c9557486290c0e52f0966e4.tar.gz |
snapshot of project "lynx", label v2-9-0dev_12j
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTParse.c | 4 | ||||
-rw-r--r-- | src/GridText.c | 33 | ||||
-rw-r--r-- | src/LYCurses.c | 7 | ||||
-rw-r--r-- | src/LYCurses.h | 30 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 5 | ||||
-rw-r--r-- | src/LYMain.c | 3 | ||||
-rw-r--r-- | src/LYMainLoop.c | 16 | ||||
-rw-r--r-- | src/LYStrings.c | 73 | ||||
-rw-r--r-- | src/LYUtils.c | 39 | ||||
-rw-r--r-- | src/LYUtils.h | 3 |
11 files changed, 116 insertions, 102 deletions
diff --git a/CHANGES b/CHANGES index a77fa4e3..89f0fae7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,10 @@ --- $LynxId: CHANGES,v 1.1142 2023/10/17 23:31:55 tom Exp $ +-- $LynxId: CHANGES,v 1.1144 2023/10/23 23:51:12 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2023-10-16 (2.9.0dev.13) +2023-10-23 (2.9.0dev.13) +* improve responsiveness with respect to SIGWINCH (report by Mark Zaharov) -TD * improve check for MAX_URI_SIZE -TD * improve check for UTF-8 character encoding in XML Text Declaration (report by Lennart Jablonka) -TD diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index 65d8f296..bf8ef164 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTParse.c,v 1.100 2023/10/17 23:38:48 tom Exp $ + * $LynxId: HTParse.c,v 1.101 2023/10/24 00:11:42 tom Exp $ * * Parse HyperText Document Address HTParse.c * ================================ @@ -798,7 +798,7 @@ char *HTParse(const char *aName, need = strlen(result); if (need > (size_t) max_uri_size) { CTRACE((tfp, "HTParse too-long address (have %ld vs limit %d)\n", - need, max_uri_size)); + (long) need, max_uri_size)); StrAllocCopy(return_value, ""); } else { StrAllocCopy(return_value, result); diff --git a/src/GridText.c b/src/GridText.c index 48696c30..3c7fa9da 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.342 2023/01/05 09:17:47 tom Exp $ + * $LynxId: GridText.c,v 1.344 2023/10/23 23:40:09 tom Exp $ * * Character grid hypertext object * =============================== @@ -512,10 +512,10 @@ struct _HText { BOOL historical_comments; BOOL minimal_comments; BOOL soft_dquotes; - short old_dtd; - short keypad_mode; - short disp_lines; /* Screen size */ - short disp_cols; /* Used for reports only */ + int old_dtd; + int keypad_mode; + int disp_lines; /* Screen size */ + int disp_cols; /* Used for reports only */ #endif }; @@ -1145,18 +1145,20 @@ HText *HText_new(HTParentAnchor *anchor) /* * Remember the parse settings. */ - self->clickable_images = clickable_images; - self->pseudo_inline_alts = pseudo_inline_alts; - self->verbose_img = verbose_img; - self->raw_mode = LYUseDefaultRawMode; + /* *INDENT-EQLS* */ + self->clickable_images = clickable_images; + self->pseudo_inline_alts = pseudo_inline_alts; + self->verbose_img = verbose_img; + self->raw_mode = LYUseDefaultRawMode; self->historical_comments = historical_comments; - self->minimal_comments = minimal_comments; - self->soft_dquotes = soft_dquotes; - self->old_dtd = (short) Old_DTD; - self->keypad_mode = (short) keypad_mode; - self->disp_lines = (short) LYlines; - self->disp_cols = (short) DISPLAY_COLS; + self->minimal_comments = minimal_comments; + self->soft_dquotes = soft_dquotes; + self->old_dtd = Old_DTD; + self->keypad_mode = keypad_mode; + self->disp_lines = LYlines; + self->disp_cols = DISPLAY_COLS; #endif + /* * If we are going to render the List Page, always merge in hidden * links to get the numbering consistent if form fields are numbered @@ -2065,6 +2067,7 @@ static void display_page(HText *text, return; } #ifdef DISP_PARTIAL + CheckScreenSize(); if (display_partial || recent_sizechange || text->stale) { /* Reset them, will be set near end if all is okay. - kw */ ResetPartialLinenos(text); diff --git a/src/LYCurses.c b/src/LYCurses.c index 8857d1cc..d97b9558 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.c,v 1.200 2023/01/02 23:52:18 tom Exp $ */ +/* $LynxId: LYCurses.c,v 1.201 2023/10/23 23:39:38 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -209,6 +209,7 @@ static void sl_suspend(int sig) r = SLtt_Screen_Rows; c = SLtt_Screen_Cols; size_change(0); + LYGetScreenSize(0); if ((r != SLtt_Screen_Rows) || (c != SLtt_Screen_Cols)) { recent_sizechange = TRUE; } @@ -940,6 +941,7 @@ static void delete_screen(SCREEN * screen) #endif #define LYDELSCR() { \ +CheckScreenSize(); \ if (recent_sizechange) { \ CTRACE((tfp, "Screen size: delscreen()\n")); \ delete_screen(LYscreen); \ @@ -1131,6 +1133,7 @@ void maxmizeWindowSize(void) CTRACE((tfp, "...actual maximum screen size: %dx%d\n", LYcols, LYlines)); LYStatusLine = -1; + LYGetScreenSize(0); recent_sizechange = TRUE; } @@ -1348,6 +1351,7 @@ void start_curses(void) savesize = recent_sizechange; size_change(0); + LYGetScreenSize(0); recent_sizechange = savesize; /* avoid extra redraw */ #if defined(__MVS__) { @@ -1384,6 +1388,7 @@ void start_curses(void) #if defined(SIGWINCH) && defined(NCURSES_VERSION) size_change(0); + LYGetScreenSize(0); recent_sizechange = FALSE; /* prevent mainloop drawing 1st doc twice */ #endif /* SIGWINCH */ CTRACE((tfp, "Screen size is now %d x %d\n", LYcols, LYlines)); diff --git a/src/LYCurses.h b/src/LYCurses.h index e8b52d69..f152ce2a 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.h,v 1.96 2018/03/11 22:19:36 tom Exp $ */ +/* $LynxId: LYCurses.h,v 1.98 2023/10/23 23:35:36 tom Exp $ */ #ifndef LYCURSES_H #define LYCURSES_H @@ -258,8 +258,8 @@ typedef char chtype; #else # if defined(VMS) && defined(__GNUC__) # include <LYGCurses.h> -# else -# include <curses.h> /* everything else */ +# else +# include <curses.h> /* everything else */ # endif /* VMS && __GNUC__ */ #endif /* HAVE_CONFIG_H */ @@ -431,6 +431,30 @@ extern "C" { extern int LYcols; /* replaces COLS */ /* + * Check if the SIGWINCH handler has caught a signal, before testing the + * recent_sizechange variable. + */ +#ifdef SIGWINCH +#if defined(KEY_RESIZE) && defined(HAVE_RESIZETERM) && defined(HAVE_WRESIZE) +#define USE_CURSES_RESIZE 1 +#endif + +#if defined(USE_CURSES_RESIZE) || defined(USE_SLANG) +#define CheckScreenSize() \ + do { \ + if (size_is_changed) { \ + size_is_changed = FALSE; \ + LYGetScreenSize(SIGWINCH); \ + } \ + } while (0) +#endif +#endif + +#ifndef CheckScreenSize +#define CheckScreenSize() /* nothing */ +#endif + +/* * The scrollbar, if used, occupies the rightmost column. */ #ifdef USE_SCROLLBAR diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 2802814e..37e30ba4 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYGlobalDefs.h,v 1.154 2022/04/02 00:12:18 Paul.G.Fox Exp $ + * $LynxId: LYGlobalDefs.h,v 1.155 2023/10/23 08:04:43 tom Exp $ * * global variable definitions */ @@ -252,8 +252,9 @@ extern "C" { extern BOOLEAN news_ok; extern BOOLEAN number_fields_on_left; extern BOOLEAN number_links_on_left; - extern BOOLEAN recent_sizechange; + extern BOOLEAN recent_sizechange; /* valid size_is_changed */ extern BOOLEAN rlogin_ok; + extern BOOLEAN size_is_changed; /* SIGWINCH was caught */ extern BOOLEAN syslog_requested_urls; extern BOOLEAN system_editor; /* True if locked-down editor */ extern BOOLEAN telnet_ok; diff --git a/src/LYMain.c b/src/LYMain.c index eef3ff76..f7b848e4 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.298 2022/04/01 07:50:45 tom Exp $ + * $LynxId: LYMain.c,v 1.299 2023/10/23 08:05:32 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -229,6 +229,7 @@ BOOLEAN minimal_comments = FALSE; BOOLEAN number_fields_on_left = TRUE; BOOLEAN number_links_on_left = TRUE; BOOLEAN recent_sizechange = FALSE; /* the window size changed recently? */ +BOOLEAN size_is_changed = FALSE; /* SIGWINCH is caught recently? */ BOOLEAN soft_dquotes = FALSE; BOOLEAN unique_urls = FALSE; BOOLEAN use_underscore = SUBSTITUTE_UNDERSCORES; diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 6b13814f..9584a9a5 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.250 2023/01/05 09:17:16 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.253 2023/10/23 23:36:31 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -6369,6 +6369,7 @@ int mainloop(void) * If the recent_sizechange variable is set to TRUE then the window * size changed recently. */ + CheckScreenSize(); if (recent_sizechange) { /* * First we need to make sure the display library - curses, slang, @@ -6385,21 +6386,15 @@ int mainloop(void) * are already filled based on the old size. So we notify the * ncurses library directly here. - kw */ -#if defined(NCURSES) && defined(HAVE_RESIZETERM) && defined(HAVE_WRESIZE) +#if defined(USE_CURSES_RESIZE) resizeterm(LYlines, LYcols); wresize(LYwin, LYlines, LYcols); -#else -#if 0 /* defined(PDCURSES) && defined(HAVE_XCURSES) */ - resize_term(LYlines, LYcols); - if (LYwin != 0) - LYwin = resize_window(LYwin, LYlines, LYcols); - refresh(); + wgetch(LYtopwindow()); /* eat the KEY_RESIZE */ #else stop_curses(); start_curses(); LYclear(); #endif -#endif refresh_screen = TRUE; /* to force a redraw */ if (HTMainText) /* to REALLY force it... - kw */ HText_setStale(HTMainText); @@ -7054,6 +7049,7 @@ int mainloop(void) c = DO_NOTHING; } #else + CheckScreenSize(); if (recent_sizechange) { if (c <= 0) c = DO_NOTHING; @@ -7098,7 +7094,7 @@ int mainloop(void) if (cmd != LYK_UP_LINK && cmd != LYK_DOWN_LINK) follow_col = -1; - CTRACE((tfp, "Handling key as %s\n", + CTRACE((tfp, "Handling key %d as %s\n", cmd, ((LYKeycodeToKcmd((LYKeymapCode) cmd) != 0) ? LYKeycodeToKcmd((LYKeymapCode) cmd)->name : "unknown"))); diff --git a/src/LYStrings.c b/src/LYStrings.c index 8199c2c8..2bbd56dd 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.280 2023/01/03 00:11:49 Jens.Schleusener Exp $ */ +/* $LynxId: LYStrings.c,v 1.282 2023/10/23 23:41:44 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -736,6 +736,7 @@ int LYmbcsstrlen(const char *str, } #undef GetChar +#undef USE_CURSES_RESIZE #ifdef USE_SLANG #if defined(VMS) @@ -752,11 +753,26 @@ int LYmbcsstrlen(const char *str, #define GetChar() (djgpp_idle_loop(), wgetch(LYtopwindow())) #elif defined(NCURSES_VERSION) && defined(__BEOS__) #define GetChar() myGetCharNodelay() -#elif defined(NCURSES) -#define GetChar() wgetch(LYtopwindow()) #endif #endif +#ifdef USE_CURSES_RESIZE +static int myGetCharResize(void) +{ + int c; + WINDOW *win = LYtopwindow(); + + do { + wtimeout(win, 20); + c = wgetch(win); + wtimeout(win, -1); + CheckScreenSize(); + } while (c <= 0); + return c; +} +#define GetChar() myGetCharResize() +#endif + #ifdef USE_CURSES_NODELAY /* PDCurses - until version 2.7 in 2005 - defined ERR as 0, unlike other * versions of curses. Generally both EOF and ERR are defined as -1's. @@ -776,6 +792,7 @@ static int myGetCharNodelay(void) if (c == -1) c = 0; + CheckScreenSize(); return c; } @@ -831,7 +848,7 @@ static int myGetChar(void) #if defined(USE_SLANG) && defined(USE_MOUSE) static int sl_parse_mouse_event(int *x, int *y, int *button) { - /* "ESC [ M" has already been processed. There more characters are + /* "ESC [ M" has already been processed. Three more characters are * expected: BUTTON X Y */ *button = (int) SLang_getkey(); @@ -1858,18 +1875,15 @@ static int LYgetch_for(int code) #else if (c == EOF && errno == EINTR) { -#if defined(HAVE_SIZECHANGE) || defined(USE_SLANG) - CTRACE((tfp, "Got EOF with EINTR, recent_sizechange so far is %d\n", + CTRACE((tfp, "Got EOF with EINTR, recent_sizechange is %d\n", recent_sizechange)); +#if defined(HAVE_SIZECHANGE) || defined(USE_SLANG) + CheckScreenSize(); if (!recent_sizechange) { /* not yet detected by ourselves */ size_change(0); CTRACE((tfp, "Now recent_sizechange is %d\n", recent_sizechange)); } -#else /* HAVE_SIZECHANGE || USE_SLANG */ - CTRACE((tfp, "Got EOF with EINTR, recent_sizechange is %d\n", - recent_sizechange)); -#endif /* HAVE_SIZECHANGE || USE_SLANG */ -#if !defined(UCX) || !defined(VAXC) /* errno not modifiable ? */ +#elif !defined(UCX) || !defined(VAXC) /* errno not modifiable ? */ set_errno(0); /* reset - kw */ #endif /* UCX && VAXC */ return (DO_NOTHING); @@ -1888,6 +1902,7 @@ static int LYgetch_for(int code) } #else /* not USE_SLANG: */ if (feof(stdin) || ferror(stdin) || c == EOF) { + CheckScreenSize(); if (recent_sizechange) return (LYCharINTERRUPT2); /* use ^G to cancel whatever called us. */ #ifdef IGNORE_CTRL_C @@ -2235,41 +2250,7 @@ static int LYgetch_for(int code) break; #endif /* KEY_BTAB */ #ifdef KEY_RESIZE - case KEY_RESIZE: /* size change detected by ncurses */ -#if defined(HAVE_SIZECHANGE) || defined(USE_SLANG) - /* Make call to detect new size, if that may be implemented. - * The call may set recent_sizechange (except for USE_SLANG), - * which will tell mainloop() to refresh. - kw - */ - CTRACE((tfp, "Got KEY_RESIZE, recent_sizechange so far is %d\n", - recent_sizechange)); - size_change(0); - CTRACE((tfp, "Now recent_sizechange is %d\n", recent_sizechange)); -#else /* HAVE_SIZECHANGE || USE_SLANG */ - CTRACE((tfp, "Got KEY_RESIZE, recent_sizechange is %d\n", - recent_sizechange)); -#endif /* HAVE_SIZECHANGE || USE_SLANG */ - if (!recent_sizechange) { -#if defined(NCURSES) - /* - * Work-around for scenario (Linux libc5) where we got a - * recent sizechange before reading KEY_RESIZE. If we do - * not reset the flag, we'll next get an EOF read, which - * causes Lynx to exit. - */ - recent_sizechange = TRUE; -#endif - /* - * May be just the delayed effect of mainloop()'s call to - * resizeterm(). Pretend we haven't read anything yet, don't - * return. - kw - */ - goto re_read; - } - /* - * Yep, we agree there was a change. Return now so that the caller - * can react to it. - kw - */ + case KEY_RESIZE: c = DO_NOTHING; break; #endif /* KEY_RESIZE */ diff --git a/src/LYUtils.c b/src/LYUtils.c index 414fb26b..c9c42489 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.301 2022/07/25 07:52:04 tom Exp $ + * $LynxId: LYUtils.c,v 1.306 2023/10/24 00:12:43 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -3087,7 +3087,7 @@ static BOOLEAN LYToggleSigDfl(int sig, # endif /* TERMIO_AND_TERMIOS */ #endif /* TERMIO_AND_CURSES */ -void size_change(int sig GCC_UNUSED) +void LYGetScreenSize(int sig GCC_UNUSED) { int old_lines = LYlines; int old_cols = LYcols; @@ -3099,22 +3099,13 @@ void size_change(int sig GCC_UNUSED) LYlines = SLtt_Screen_Rows; LYcols = SLtt_Screen_Cols; if (sig == 0) - /* - * Called from start_curses(). - */ + /* If called from start_curses(), no need to record size-changed */ return; #else /* Curses: */ #ifdef HAVE_SIZECHANGE -#ifdef TIOCGSIZE +#if defined(TIOCGSIZE) struct ttysize win; -#else -#ifdef TIOCGWINSZ - struct winsize win; -#endif /* TIOCGWINSZ */ -#endif /* TIOCGSIZE */ - -#ifdef TIOCGSIZE if (ioctl(0, TIOCGSIZE, &win) == 0) { if (win.ts_lines != 0) { LYlines = win.ts_lines; @@ -3123,8 +3114,9 @@ void size_change(int sig GCC_UNUSED) LYcols = win.ts_cols; } } -#else -#ifdef TIOCGWINSZ +#elif defined(TIOCGWINSZ) + struct winsize win; + if (ioctl(0, (long) TIOCGWINSZ, &win) == 0) { if (win.ws_row != 0) { LYlines = win.ws_row; @@ -3133,8 +3125,9 @@ void size_change(int sig GCC_UNUSED) LYcols = win.ws_col; } } -#endif /* TIOCGWINSZ */ -#endif /* TIOCGSIZE */ +#else +#error inconsistent settings for TIOCGSIZE/TIOCGWINSZ +#endif /* TIOCGSIZE/TIOCGWINSZ */ #endif /* HAVE_SIZECHANGE */ #ifdef __EMX__ @@ -3166,11 +3159,19 @@ void size_change(int sig GCC_UNUSED) Switch_Display_Charset(current_char_set, SWITCH_DISPLAY_CHARSET_RESIZE); #endif } +} + +/* + * curses/slang functions call this to start catching SIGWINCH when sig==0, + * and continue catching when sig!=0. + */ +void size_change(int sig GCC_UNUSED) +{ #ifdef SIGWINCH + if (sig) + size_is_changed = TRUE; LYExtSignal(SIGWINCH, size_change); #endif /* SIGWINCH */ - - return; } /* diff --git a/src/LYUtils.h b/src/LYUtils.h index d15a8169..7ad76db7 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -1,4 +1,4 @@ -/* $LynxId: LYUtils.h,v 1.100 2018/03/27 21:19:21 tom Exp $ */ +/* $LynxId: LYUtils.h,v 1.102 2023/10/23 08:04:01 tom Exp $ */ #ifndef LYUTILS_H #define LYUTILS_H @@ -197,6 +197,7 @@ extern "C" { extern void LYFixCursesOn(const char *reason); extern void LYFreeHilites(int first, int last); extern void LYFreeStringList(HTList *list); + extern void LYGetScreenSize(int sig); extern void LYLocalFileToURL(char **target, const char *source); extern void LYLocalhostAliases_free(void); extern void LYRenamedTemp(char *oldname, char *newname); |