home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 287.lha / TY_v1.3 / src / command.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-07  |  4.8 KB  |  121 lines

  1. /*************************************************************************
  2.  ***                        command.c                    (JJB TEMPLAR) ***
  3.  *** Date modifications begun: 7/8/89.                                 ***
  4.  *** Last modified: 27/8/89.                                           ***
  5.  *************************************************************************/
  6. /*** User-level command processor.                                     ***
  7.  *************************************************************************/
  8.  
  9. #include "less.h"
  10. #include <intuition/intuition.h>
  11. #include <proto/intuition.h>
  12.  
  13. #include "win.h"
  14. #include "cmd.h"
  15.  
  16. extern struct Window    *Window;
  17. extern struct Requester req;
  18.  
  19. extern int  quit_at_eof;
  20. extern int  hit_eof;
  21. extern int  sc_height;
  22. extern int  top_scroll;
  23. extern int  l_start;
  24. extern char version[];
  25. extern char current_file[];
  26.  
  27. int     has_resized;    /* Used by getc() to indicate if user resized */
  28.  
  29. /*** Main command processor.                                           ***
  30.  *** Accept and execute commands until a quit command, then return.    ***/
  31.  
  32. void    commands() /*====================================================*/
  33. {
  34.     has_resized = 0;
  35.     while (1) {
  36.         if (has_resized) {      /* In case user resizes during getc */
  37.             has_resized = 0;
  38.             resize();
  39.             repaint();
  40.             setbar(1);
  41.         }
  42.  
  43.         if (quit_at_eof && (hit_eof > 1)) next_file(1);
  44.  
  45.         SetWindowTitles(Window,pr_string(),(char *)-1L);    /* Prompt */
  46.  
  47.         switch (getcmd()) {
  48.             case (C_FORW_PAGE): forward(sc_height-1, 1);
  49.                                 setbar(1);
  50.                                 break;
  51.             case (C_BACK_PAGE): backward(sc_height-1, 1);
  52.                                 setbar(1);
  53.                                 break;
  54.             case (C_FORW_LINE): forward(1, 0);
  55.                                 setbar(0);
  56.                                 break;
  57.             case (C_BACK_LINE): backward(1, 0);
  58.                                 setbar(0);
  59.                                 break;
  60.             case (C_TOP):   jump_back(1);
  61.                             setbar(1);
  62.                             break;
  63.             case (C_BOTTOM):    jump_forw();
  64.                                 setbar(1);
  65.                                 break;
  66.             case (C_HELP):  help();
  67.                             repaint();
  68.                             break;
  69.             case (C_ABOUT): about();
  70.                             repaint();
  71.                             break;
  72.             case (C_FORW_FILE): next_file(1);               break;
  73.             case (C_BACK_FILE): prev_file(1);               break;
  74.             case (C_VERSION):   error(version,0);           break;
  75.             case (C_QUIT):  return;     /* so infinite while() loop */
  76.             case (C_REPAINT):   repaint();                  break;
  77.             case (C_INFO):      error(eq_message(),0);      break;
  78.             case (C_BOOM):      doboom();                   break;
  79.                 /* Don't fall through. It appears a NEWSIZE message is 
  80.                  * still posted by Intuition. */
  81.             case (C_RESIZE):    resize();
  82.                                 repaint();
  83.                                 setbar(1);
  84.                                 break;
  85.             case (C_SRIGHT): l_start = MAXHORIZ;        /* Fall thru */
  86.             case (C_RIGHT): horiz(1);
  87.                             repaint();
  88.                             break;
  89.             case (C_SLEFT): l_start = 0;                /* Fall thru */
  90.             case (C_LEFT):  horiz(0);
  91.                             repaint();
  92.                             break;
  93.             case (C_SCROLL):    usebar();       break;
  94.             case (C_HSCROLL):   usehbar();
  95.                                 repaint();
  96.                                 break;
  97.             case (C_SEARCH_F):  search_forw(1); break;
  98.             case (C_SEARCH_B):  search_back(1); break;
  99.             case (C_SEARCH_FNC):search_forw(0); break;
  100.             case (C_SEARCH_BNC):search_back(0); break;
  101.             case (C_SET_MARK):  setmark();      break;
  102.             case (C_GO_MARK):   gomark();       break;
  103.             case (C_PERCENT):   jump_percent(); break;
  104.             case (C_ICONIFY):   doiconify();    break;
  105.             case (C_PRINT):     print();        break;
  106.             case (C_MODE_ON):   domode(1);
  107.                                 repaint();
  108.                                 break;
  109.             case (C_MODE_OFF):  domode(0);
  110.                                 repaint();
  111.                                 break;
  112.             case (C_NEWCLI):    newcli();       break;
  113.             case (C_EDITOR):    editor();       break;
  114.             case (C_ADDFILE):   add_file();     break;
  115.             case (C_INNOCUOUS): r_bool("Not implemented");
  116.                                 break;
  117.             default:            bell();                     break;
  118.         }
  119.     }
  120. }
  121.