home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / acorn / tech / 1151 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  4.8 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!acorn!steve
  2. From: steve@acorn.co.uk (Steve "daffy" Hunt)
  3. Newsgroups: comp.sys.acorn.tech
  4. Subject: Re: MicroEmacs 3.11c/RISCiX
  5. Message-ID: <20903@acorn.co.uk>
  6. Date: 4 Jan 93 16:34:08 GMT
  7. References: <1hlfkeINNbu1@swan.doc.ic.ac.uk>
  8. Organization: Acorn Computers Limited, Cambridge, UK
  9. Lines: 180
  10. X-Newsreader: TIN [version 1.1 PL8]
  11.  
  12. M Y Ben Gershon (mybg@doc.ic.ac.uk) wrote:
  13. : Manybe someone at Aocrn who knows about RISCiX can help?
  14.  
  15.  
  16. Basically it's very easy; intercept SIGWINCH.  The patch below
  17. is what I did to incorporate it into 3.9; I'm sure it could
  18. be adapted to work on more recent versions.
  19.  
  20. Our source tree contains the following log entry:-
  21.  
  22. 1.3:  bsd.2
  23. 88/09/23 13:40:25;  author: steve
  24. Made BSD version follow changes in window size.  Dependent on the
  25. flag FOLLOW_WINDOW_SIZE in estruct.h.  Modules affected: estruct.h,
  26. tcap.c
  27.  
  28. -- Steve
  29.  
  30. ---------------- CUT HERE ----------------
  31. *** old/estruct.h    Mon Jan  4 16:28:14 1993
  32. --- estruct.h    Fri Sep 23 14:40:25 1988
  33. ***************
  34. *** 112,117 ****
  35. --- 112,126 ----
  36.   #define ASCII    1    /* always using ASCII char sequences for now    */
  37.   #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  38.   
  39. + #define FOLLOW_WINDOW_SIZE 1    /* BSD only; if the kernel's idea of    */
  40. +                 /* window size is sensible, use it    */
  41. +                 /* rather than the size gleaned from    */
  42. +                 /* TERMCAP.  Also, follow any SIGWINCH    */
  43. +                 /* signals that come along.        */
  44. + #define WINDOW_MAX_ROWS 100    /* if FOLLOW_WINDOW_SIZE, then restrict    */
  45. + #define WINDOW_MAX_COLS 200    /* window to being this size */
  46.   /*    System dependant library redefinitions, structures and includes    */
  47.   
  48.   #if    TURBO
  49. *** old/tcap.c    Mon Jan  4 16:28:25 1993
  50. --- tcap.c    Mon Jan  4 16:29:31 1993
  51. ***************
  52. *** 10,15 ****
  53. --- 10,20 ----
  54.   
  55.   #if TERMCAP
  56.   
  57. + #if BSD && FOLLOW_WINDOW_SIZE
  58. + #include <sys/ioctl.h>
  59. + #include <signal.h>
  60. + #endif
  61.   #define    MARGIN    8
  62.   #define    SCRSIZ    64
  63.   #define    NPAUSE    10            /* # times thru update to pause */
  64. ***************
  65. *** 69,74 ****
  66. --- 74,106 ----
  67.   #endif
  68.   };
  69.   
  70. + #if (BSD) && (FOLLOW_WINDOW_SIZE)
  71. + /*
  72. +  * Signal handler for any SIGWINCH signals that might appear.
  73. +  */
  74. + window_changed () {
  75. +     int mycols, myrows;
  76. +     struct winsize wininfo;
  77. +     signal (SIGWINCH, SIG_IGN);
  78. +     if (ioctl (1, TIOCGWINSZ, &wininfo) == 0) {
  79. +     /* ioctl successful */
  80. +     myrows = wininfo.ws_row;
  81. +     mycols = wininfo.ws_col;
  82. +     if (myrows > 0 && mycols > 0) {
  83. +         if (myrows - 1 > term.t_mrow) myrows = term.t_mrow;
  84. +         if (mycols > term.t_mcol) mycols = term.t_mcol;
  85. +         newsize (TRUE, myrows);
  86. +         newwidth (TRUE, mycols);
  87. +     }
  88. +     }
  89. +     update (TRUE);
  90. +     signal (SIGWINCH, window_changed);
  91. + }
  92. + #endif
  93.   tcapopen()
  94.   
  95.   {
  96. ***************
  97. *** 91,108 ****
  98.                   exit(1);
  99.           }
  100.   
  101. !        if ((term.t_nrow=(short)tgetnum("li")-1) == -1){
  102. !                puts("termcap entry incomplete (lines)");
  103. !                exit(1);
  104. !        }
  105.       term.t_mrow =  term.t_nrow;
  106.   
  107. !        if ((term.t_ncol=(short)tgetnum("co")) == -1){
  108. !                puts("Termcap entry incomplete (columns)");
  109. !                exit(1);
  110. !        }
  111.       term.t_mcol = term.t_ncol;
  112.   
  113.           p = tcapbuf;
  114.           t = tgetstr("pc", &p);
  115.           if(t)
  116. --- 123,187 ----
  117.                   exit(1);
  118.           }
  119.   
  120. ! #if BSD && FOLLOW_WINDOW_SIZE
  121. !     term.t_mrow = WINDOW_MAX_ROWS;    /* max size that the screen can attain */
  122. !     term.t_mcol = WINDOW_MAX_COLS;
  123. ! /* Prefer the screen dimensions as the kernel believes */
  124. ! /* If this has silly entries (0) then use termcap-specified sizes */
  125. !     {    struct winsize wininfo;
  126. !         int window_size_sensible = FALSE;
  127. !         if (ioctl (1, TIOCGWINSZ, &wininfo) == 0)
  128. !         {
  129. !             if (wininfo.ws_row > 0 && wininfo.ws_col > 0)
  130. !             {
  131. !                 term.t_nrow = wininfo.ws_row - 1;
  132. !                 term.t_ncol = wininfo.ws_col - 1;
  133. !                 window_size_sensible = TRUE;
  134. !             }
  135. !         }
  136. !         if (!window_size_sensible)
  137. !         {
  138. !             /* Try for termcap's window size */
  139. !             if ((term.t_nrow=(short)tgetnum("li")-1) == -1)
  140. !             {
  141. !                 puts("termcap entry incomplete (lines)");
  142. !                 exit(1);
  143. !             }
  144. !         
  145. !             if ((term.t_ncol=(short)tgetnum("co")) == -1)
  146. !             {
  147. !                 puts("Termcap entry incomplete (columns)");
  148. !                 exit(1);
  149. !             }
  150. !         }
  151. !     }
  152. !     if (term.t_nrow > term.t_mrow) term.t_nrow = term.t_mrow;
  153. !     if (term.t_ncol > term.t_mcol) term.t_ncol = term.t_mcol;
  154. !     signal (SIGWINCH, window_changed);
  155. ! #else
  156. !     if ((term.t_nrow=(short)tgetnum("li")-1) == -1){
  157. !         puts("termcap entry incomplete (lines)");
  158. !         exit(1);
  159. !     }
  160.       term.t_mrow =  term.t_nrow;
  161.   
  162. !     if ((term.t_ncol=(short)tgetnum("co")) == -1){
  163. !         puts("Termcap entry incomplete (columns)");
  164. !         exit(1);
  165. !     }
  166.       term.t_mcol = term.t_ncol;
  167.   
  168. + #endif
  169. +         
  170.           p = tcapbuf;
  171.           t = tgetstr("pc", &p);
  172.           if(t)
  173. ---------------- CUT HERE ----------------
  174. -- 
  175.                 Steve Hunt    steve@acorn.co.uk
  176.