home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / eel / nextbuf.zip / NEXTBUF.E < prev    next >
Text File  |  1990-10-24  |  3KB  |  110 lines

  1. /*
  2.  EPSHeader
  3.  
  4.    File: nextbuf.e
  5.    Author: J. Kercheval
  6.    Created: Sat, 10/21/1990  23:46:28
  7. */
  8. /*
  9.  EPSRevision History
  10.  
  11.    J. Kercheval  Sat, 10/22/1990  20:51:59  prevent switch to kill and tmp buffers
  12.    J. Kercheval  Sat, 10/22/1990  21:29:45  add next_previous_buffer()
  13. */
  14.  
  15. /*
  16.  
  17.     This file implements two routines to add a quick single key switch from
  18.     buffer to buffer.  next_buffer() here assigned to ALT-N (in keeping
  19.     with the standard convention) and next_previous_buffer() assigned to 
  20.     ALT-P.
  21.         
  22.     These two routines will not switch to one of the '-' prefixed buffers
  23.     (ie. the kill buffers) and switches in a circular fashion.
  24.  
  25.         
  26.         John Kercheval
  27.         127 NW Bowdoin Pl #105
  28.         Seattle, WA  98107-4960
  29.         October 24, 1990
  30.             
  31. */
  32.  
  33. #include "eel.h"
  34.  
  35. #define TRUE 1;
  36. #define FALSE 0;
  37.  
  38. /*
  39. * next_buffer() will make current window display the next buffer in the
  40. * buffer list 10-22-90 JBK
  41. */
  42. command next_buffer() on reg_tab[ALT('n')]
  43. {
  44.     char *cur_buf,*tmp_str[2];
  45.     
  46.     cur_buf = buffer_list(1);
  47.     while (strcmp(bufname,cur_buf)) {
  48.         cur_buf = buffer_list(0);
  49.     }
  50.     do {
  51.         cur_buf = buffer_list(0);
  52.         if (!cur_buf) cur_buf = buffer_list(1);
  53.         strncpy(tmp_str,cur_buf,1);
  54.     }
  55.     while (!strcmp(tmp_str,"-"));
  56.     to_buffer(cur_buf);
  57. }
  58.     
  59. /*
  60. * next_previous_buffer() will make current window display the previous
  61. * buffer in the buffer list 10-22-90 JBK
  62. */
  63. command next_previous_buffer() on reg_tab[ALT('p')]
  64. {
  65.     char *cur_buf,*last_buf[256],*tmp_str[2];
  66.     int done;
  67.     
  68.     /*
  69.     * obtain first last_buf
  70.     */
  71.     cur_buf = buffer_list(1);
  72.     strcpy(last_buf,cur_buf);
  73.     done = FALSE;
  74.     do {
  75.         cur_buf = buffer_list(0);
  76.         if (!cur_buf) {
  77.             cur_buf = buffer_list(1);
  78.         }
  79.         strncpy(tmp_str,last_buf,1);
  80.         if (strcmp(tmp_str,"-")) {
  81.             done = TRUE;
  82.         }
  83.         else {
  84.             strcpy(last_buf,cur_buf);
  85.         }
  86.     }
  87.     while (!done);
  88.     
  89.     /* 
  90.     * find current buffer and maintain last_buf
  91.     */
  92.     done = FALSE;
  93.     do {
  94.         if (!strcmp(bufname,cur_buf)) {
  95.             done = TRUE;
  96.         }
  97.         else {
  98.             strncpy(tmp_str,cur_buf,1);
  99.             if (strcmp(tmp_str,"-")) 
  100.                 strcpy(last_buf,cur_buf);
  101.             cur_buf = buffer_list(0);
  102.             if (!cur_buf) 
  103.                 cur_buf = buffer_list(1);
  104.         }
  105.     }
  106.     while (!done);
  107.     to_buffer(last_buf);
  108.     
  109. }
  110.