lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LYNX-DEV Window resize patch


From: Alex Lyons A32/373-Winfrith Tel2368 FAX2508
Subject: LYNX-DEV Window resize patch
Date: Fri, 20 Jun 97 17:33:30 BST

 I'm running lynx on SunOS 4.1.3 in Sunview (remember it anyone?), using
 Sun's SysV curses, and I've been getting irritated by not being able to
 resize my shelltool (read xterm) window to anything larger than the
 initial size it has when lynx starts up.  I note that this problem has
 been reported before, but nothing seems to have been done about it.
 
 The problem appears to be that the one-off call to curses initscr seems
 to allocate space based on the current window size, which then can't be
 increased, although the window can get smaller.  So, what I've done is
 fool curses into allocating space for a very large window size by
 setting the environment variables LINES and COLUMNS to suitably large
 values, then starting curses, then setting the actual LYlines and
 LYcols by directly calling the size_change routine (as is done for
 slang).  It seems to work.
 
 Note that I've put the mods in LYCurses.c inside an #ifndef NO_SIZECHANGE
 block.  THIS IS ALMOST CERTAINLY WRONG, but I'm not sure what defines,
 if any, would be appropriate - perhaps someone out there could advise?
 
 I've also fixed what appears to be a buglet in the setting of LYlines
 in this routine: there's no need to subtract 1 from the value got from
 the ioctl call, as the zero-based line addressing is taken into account
 when LYStatusLine is set to LYlines-1, and similarly for
 display_lines.
 
 Finally, I've put a couple of lines in LyMainloop.c to force a reload
 (not of any proxy cache) whenever the window size actually changes: the
 flag recent_sizechange is only set if this has happened - SIGWINCHes
 are also generated if the window running lynx is covered or uncovered,
 etc, but size not changed.
 
 It's a pity lynx doesn't cache the source before rendering, as this
 would speed up a number of operations by not requiring a refetch:
 toggling source/rendered display, toggling inline image links,
 downloading/saving the currently displayed document, etc, and now
 window resizes.  Perhaps that's a topic to go on someone's wish list?
 
 Anyway, here follow the mods, in diff -c form.
 
 Alex Lyons


*** LYCurses.c  Fri Jun 20 12:56:26 1997
--- LYCurses.c.org      Sat May 31 10:46:06 1997
***************
*** 370,391 ****
      static char term_putenv[120];
      char buffer[120];
  
- #ifndef NO_SIZECHANGE
- /*
-  * AJL - Hack to fix bug in sysV curses, that screen can't be resized to
-  * greater than the size used by initscr, which can only be called once.
-  * So set environment variables LINES and COLUMNS to some suitably large size
-  * to force initscr to allocate enough space.  Later we get the real window
-  * size for setting LYlines and LYcols.
-  * I don't know whether ncurses suffers from the same problem.
-  */
-     static char *lines_putenv = "LINES=120";
-     static char *cols_putenv = "COLUMNS=240";
- 
-     (void) putenv(lines_putenv);
-     (void) putenv(cols_putenv);
- #endif
- 
     /*
      *  If the display was not set by a command line option then
      *  see if it is available from the environment .
--- 370,375 ----
***************
*** 431,445 ****
      }
  #endif /* !NO_TTYTYPE */
  
- #ifndef NO_SIZECHANGE
- /*
-  * AJL - Use SIGWINCH handler to set the true window size
-  */
-     size_change(0);
- #else
      LYlines = LINES;
      LYcols = COLS;
- #endif
  
      return(1);
  }
--- 415,422 ----
*** LYUtils.c   Fri Jun 20 15:51:18 1997
--- LYUtils.c.org       Wed Jun  4 19:01:34 1997
***************
*** 1486,1494 ****
  PUBLIC void size_change ARGS1(
        int,            sig)
  {
-     int old_lines = LYlines;
-     int old_cols = LYcols;
- 
  #ifdef USE_SLANG
      SLtt_get_screen_size();
      LYlines = SLtt_Screen_Rows;
--- 1486,1491 ----
***************
*** 1511,1517 ****
  #ifdef TIOCGSIZE
      if (ioctl(0, TIOCGSIZE, &win) == 0) {
          if (win.ts_lines != 0) {
!           LYlines = win.ts_lines;
        }
        if (win.ts_cols != 0) {
            LYcols = win.ts_cols;
--- 1508,1514 ----
  #ifdef TIOCGSIZE
      if (ioctl________(0, TIOCGSIZE, &win) == 0) {
          if (win.ts_lines != 0) {
!           LYlines = win.ts_lines - 1;
        }
        if (win.ts_cols != 0) {
            LYcols = win.ts_cols;
***************
*** 1521,1527 ****
  #ifdef TIOCGWINSZ
      if (ioctl(0, TIOCGWINSZ, &win) == 0) {
          if (win.ws_row != 0) {
!           LYlines = win.ws_row;
        }
        if (win.ws_col != 0) {
            LYcols = win.ws_col;
--- 1518,1524 ----
  #ifdef TIOCGWINSZ
      if (ioctl(0, TIOCGWINSZ, &win) == 0) {
          if (win.ws_row != 0) {
!           LYlines = win.ws_row - 1;
        }
        if (win.ws_col != 0) {
            LYcols = win.ws_col;
***************
*** 1537,1549 ****
          LYcols = 80;
  #endif /* USE_SLANG */
  
! /* check if the screen size has actually changed -AJL */
!     if (LYlines!=old_lines || LYcols!=old_cols)
!       recent_sizechange = TRUE; 
!     if (TRACE)        fprintf(stderr,
!       "Window size changed from (%d,%d) to (%d,%d)\n",
!       old_lines,old_cols,LYlines,LYcols);
! 
  #ifdef SIGWINCH
      (void)signal (SIGWINCH, size_change);
  #endif /* SIGWINCH */
--- 1534,1540 ----
          LYcols = 80;
  #endif /* USE_SLANG */
  
!     recent_sizechange = TRUE; 
  #ifdef SIGWINCH
      (void)signal (SIGWINCH, size_change);
  #endif /* SIGWINCH */
*** LYMainLoop.c        Fri Jun 20 16:52:05 1997
--- LYMainLoop.c.org    Wed Jun  4 19:01:02 1997
***************
*** 800,820 ****
         *  then the window size changed recently. 
         */
        if (recent_sizechange) {
!           if (TRACE) fprintf(stderr,
!               "Restarting display for window size change\n");
!           stop_curses();
!           start_curses(); 
!           clear();
!           refresh_screen = TRUE; /* to force a redraw */
!           recent_sizechange = FALSE;
!           if (user_mode == NOVICE_MODE) {
!               display_lines = LYlines-4;
!           } else {
!               display_lines = LYlines-2;
!           }
!           /* Force document to be reloaded -AJL */
!           cmd = LYK_RELOAD;
!           goto new_cmd;
        }
  
          if (www_search_result != -1) {
--- 800,815 ----
         *  then the window size changed recently. 
         */
        if (recent_sizechange) {
!               stop_curses();
!               start_curses(); 
!               clear();
!               refresh_screen = TRUE; /* to force a redraw */
!               recent_sizechange = FALSE;
!               if (user_mode == NOVICE_MODE) {
!                   display_lines = LYlines-4;
!               } else {
!                   display_lines = LYlines-2;
!               }
        }
  
          if (www_search_result != -1) {
***************
*** 1612,1621 ****
             */
            if (real_cmd == LYK_RELOAD)
                reloading = TRUE;
- 
-           if (TRACE) fprintf(stderr,
-               "Document will be reloaded, cache=%d\n",reloading);
- 
            break;
  
        case LYK_HISTORICAL:  
--- 1605,1610 ----
;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]