home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.5.004 < prev    next >
Encoding:
Internet Message Format  |  1999-09-24  |  6.7 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 5.5.004
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.5.004
  8. Problem:    On Unix it's not possible to interrupt ":sleep 100".
  9. Solution:   Switch terminal to cooked mode while asleep, to allow a SIGINT to
  10.         wake us up.  But switch off echo, added TMODE_SLEEP.
  11. Files:        src/term.h, src/os_unix.c
  12.  
  13.  
  14. *** ../vim-5.5.3/src/term.h    Wed Sep 22 10:06:19 1999
  15. --- src/term.h    Fri Sep 24 22:46:26 1999
  16. ***************
  17. *** 147,151 ****
  18.   #define T_CRV    (term_str(KS_CRV))    /* request version string */
  19.   #define T_OP    (term_str(KS_OP))    /* original color pair */
  20.   
  21. ! #define TMODE_COOK  0        /* terminal mode for external cmds and Ex mode */
  22. ! #define TMODE_RAW   1        /* terminal mode for Normal and Insert mode */
  23. --- 147,152 ----
  24.   #define T_CRV    (term_str(KS_CRV))    /* request version string */
  25.   #define T_OP    (term_str(KS_OP))    /* original color pair */
  26.   
  27. ! #define TMODE_COOK  0    /* terminal mode for external cmds and Ex mode */
  28. ! #define TMODE_SLEEP 1    /* terminal mode for sleeping (cooked but no echo) */
  29. ! #define TMODE_RAW   2    /* terminal mode for Normal and Insert mode */
  30. *** ../vim-5.5.3/src/os_unix.c    Wed Sep 22 21:12:18 1999
  31. --- src/os_unix.c    Sat Sep 25 20:26:59 1999
  32. ***************
  33. *** 182,187 ****
  34. --- 182,189 ----
  35.   #endif
  36.   static int    deadly_signal = 0;        /* The signal we caught */
  37.   
  38. + static int curr_tmode = TMODE_COOK;    /* contains current terminal mode */
  39.   #ifdef SYS_SIGLIST_DECLARED
  40.   /*
  41.    * I have seen
  42. ***************
  43. *** 419,437 ****
  44.       long    msec;
  45.       int        ignoreinput;
  46.   {
  47.       if (ignoreinput)
  48.       {
  49.       /*
  50.        * Everybody sleeps in a different way...
  51.        * Prefer nanosleep(), some versions of usleep() can only sleep up to
  52.        * one second.
  53.        */
  54.   #ifdef HAVE_NANOSLEEP
  55. !     struct timespec ts;
  56.   
  57. !     ts.tv_sec = msec / 1000;
  58. !     ts.tv_nsec = (msec % 1000) * 1000000;
  59. !     (void)nanosleep(&ts, NULL);
  60.   #else
  61.   # ifdef HAVE_USLEEP
  62.       while (msec >= 1000)
  63. --- 421,448 ----
  64.       long    msec;
  65.       int        ignoreinput;
  66.   {
  67. +     int        old_tmode;
  68.       if (ignoreinput)
  69.       {
  70. +     /* Go to cooked mode without echo, to allow SIGINT interrupting us
  71. +      * here */
  72. +     old_tmode = curr_tmode;
  73. +     settmode(TMODE_SLEEP);
  74.       /*
  75.        * Everybody sleeps in a different way...
  76.        * Prefer nanosleep(), some versions of usleep() can only sleep up to
  77.        * one second.
  78.        */
  79.   #ifdef HAVE_NANOSLEEP
  80. !     {
  81. !         struct timespec ts;
  82.   
  83. !         ts.tv_sec = msec / 1000;
  84. !         ts.tv_nsec = (msec % 1000) * 1000000;
  85. !         (void)nanosleep(&ts, NULL);
  86. !     }
  87.   #else
  88.   # ifdef HAVE_USLEEP
  89.       while (msec >= 1000)
  90. ***************
  91. *** 447,465 ****
  92.   #   ifdef __EMX__
  93.       _sleep2(msec);
  94.   #   else
  95. !     struct timeval tv;
  96.   
  97. !     tv.tv_sec = msec / 1000;
  98. !     tv.tv_usec = (msec % 1000) * 1000;
  99. !     /*
  100. !      * NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get a
  101. !      * patch from Sun to fix this.  Reported by Gunnar Pedersen.
  102. !      */
  103. !     select(0, NULL, NULL, NULL, &tv);
  104.   #   endif /* __EMX__ */
  105.   #  endif /* HAVE_SELECT */
  106.   # endif /* HAVE_NANOSLEEP */
  107.   #endif /* HAVE_USLEEP */
  108.       }
  109.       else
  110.       WaitForChar(msec);
  111. --- 458,480 ----
  112.   #   ifdef __EMX__
  113.       _sleep2(msec);
  114.   #   else
  115. !     {
  116. !         struct timeval tv;
  117.   
  118. !         tv.tv_sec = msec / 1000;
  119. !         tv.tv_usec = (msec % 1000) * 1000;
  120. !         /*
  121. !          * NOTE: Solaris 2.6 has a bug that makes select() hang here.  Get
  122. !          * a patch from Sun to fix this.  Reported by Gunnar Pedersen.
  123. !          */
  124. !         select(0, NULL, NULL, NULL, &tv);
  125. !     }
  126.   #   endif /* __EMX__ */
  127.   #  endif /* HAVE_SELECT */
  128.   # endif /* HAVE_NANOSLEEP */
  129.   #endif /* HAVE_USLEEP */
  130. +     settmode(old_tmode);
  131.       }
  132.       else
  133.       WaitForChar(msec);
  134. ***************
  135. *** 1699,1706 ****
  136.       }
  137.   }
  138.   
  139. - static int curr_tmode = TMODE_COOK;    /* contains current terminal mode */
  140.       void
  141.   mch_settmode(tmode)
  142.       int        tmode;
  143. --- 1714,1719 ----
  144. ***************
  145. *** 1720,1737 ****
  146.          struct termio tnew;
  147.   # endif
  148.   
  149. !     if (tmode == TMODE_RAW)
  150.       {
  151. !     if (first)
  152. !     {
  153. !         first = FALSE;
  154.   # if defined(HAVE_TERMIOS_H)
  155. !         tcgetattr(read_cmd_fd, &told);
  156.   # else
  157. !         ioctl(read_cmd_fd, TCGETA, &told);
  158.   # endif
  159. !     }
  160. !     tnew = told;
  161.       /*
  162.        * ~ICRNL enables typing ^V^M
  163.        */
  164. --- 1733,1751 ----
  165.          struct termio tnew;
  166.   # endif
  167.   
  168. !     if (first)
  169.       {
  170. !     first = FALSE;
  171.   # if defined(HAVE_TERMIOS_H)
  172. !     tcgetattr(read_cmd_fd, &told);
  173.   # else
  174. !     ioctl(read_cmd_fd, TCGETA, &told);
  175.   # endif
  176. !     }
  177. !     tnew = told;
  178. !     if (tmode == TMODE_RAW)
  179. !     {
  180.       /*
  181.        * ~ICRNL enables typing ^V^M
  182.        */
  183. ***************
  184. *** 1747,1767 ****
  185.   # endif
  186.       tnew.c_cc[VMIN] = 1;        /* return after 1 char */
  187.       tnew.c_cc[VTIME] = 0;        /* don't wait */
  188. - # if defined(HAVE_TERMIOS_H)
  189. -     tcsetattr(read_cmd_fd, TCSANOW, &tnew);
  190. - # else
  191. -     ioctl(read_cmd_fd, TCSETA, &tnew);
  192. - # endif
  193.       }
  194. !     else
  195. !     {
  196.   # if defined(HAVE_TERMIOS_H)
  197. !     tcsetattr(read_cmd_fd, TCSANOW, &told);
  198.   # else
  199. !     ioctl(read_cmd_fd, TCSETA, &told);
  200.   # endif
  201. !     }
  202.   #else
  203.       /*
  204.        * for "old" tty systems
  205.        */
  206. --- 1761,1778 ----
  207.   # endif
  208.       tnew.c_cc[VMIN] = 1;        /* return after 1 char */
  209.       tnew.c_cc[VTIME] = 0;        /* don't wait */
  210.       }
  211. !     else if (tmode == TMODE_SLEEP)
  212. !     tnew.c_lflag &= ~(ECHO);
  213.   # if defined(HAVE_TERMIOS_H)
  214. !     tcsetattr(read_cmd_fd, TCSANOW, &tnew);
  215.   # else
  216. !     ioctl(read_cmd_fd, TCSETA, &tnew);
  217.   # endif
  218.   #else
  219.       /*
  220.        * for "old" tty systems
  221.        */
  222. ***************
  223. *** 1771,1790 ****
  224.       static struct sgttyb ttybold;
  225.          struct sgttyb ttybnew;
  226.   
  227.       if (tmode == TMODE_RAW)
  228.       {
  229. -     if (first)
  230. -     {
  231. -         first = FALSE;
  232. -         ioctl(read_cmd_fd, TIOCGETP, &ttybold);
  233. -     }
  234. -     ttybnew = ttybold;
  235.       ttybnew.sg_flags &= ~(CRMOD | ECHO);
  236.       ttybnew.sg_flags |= RAW;
  237. -     ioctl(read_cmd_fd, TIOCSETN, &ttybnew);
  238.       }
  239. !     else
  240. !     ioctl(read_cmd_fd, TIOCSETN, &ttybold);
  241.   #endif
  242.       curr_tmode = tmode;
  243.   }
  244. --- 1782,1802 ----
  245.       static struct sgttyb ttybold;
  246.          struct sgttyb ttybnew;
  247.   
  248. +     if (first)
  249. +     {
  250. +     first = FALSE;
  251. +     ioctl(read_cmd_fd, TIOCGETP, &ttybold);
  252. +     }
  253. +     ttybnew = ttybold;
  254.       if (tmode == TMODE_RAW)
  255.       {
  256.       ttybnew.sg_flags &= ~(CRMOD | ECHO);
  257.       ttybnew.sg_flags |= RAW;
  258.       }
  259. !     else if (tmode == TMODE_SLEEP)
  260. !     ttybnew.sg_flags &= ~(ECHO);
  261. !     ioctl(read_cmd_fd, TIOCSETN, &ttybnew);
  262.   #endif
  263.       curr_tmode = tmode;
  264.   }
  265. *** ../vim-5.5.3/src/version.c    Thu Sep 23 10:12:21 1999
  266. --- src/version.c    Sat Sep 25 20:32:06 1999
  267. ***************
  268. *** 420,420 ****
  269. --- 420,421 ----
  270.   {   /* Add new patch number below this line */
  271. +     4,
  272.  
  273. --
  274. hundred-and-one symptoms of being an internet addict:
  275. 172. You join listservers just for the extra e-mail.
  276.  
  277. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
  278.   \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /
  279.