home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / most423.zip / cmd.c < prev    next >
C/C++ Source or Header  |  1994-01-28  |  4KB  |  149 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "sysdep.h"
  4. #include "search.h"
  5. #include "window.h"
  6. #include "file.h"
  7. #include "keym.h"
  8. #include "externs.h"
  9. #include "display.h"
  10.  
  11. /* returns zero if not quit */
  12.   
  13. int do_extended_key()
  14. {
  15.     char ch;
  16.     static int next = 1;
  17.     int quit = 0, n;
  18.     unsigned char *save;
  19.     
  20.     select_minibuffer();  putc(':',stdout); fflush(stdout);
  21.     ch = getkey();
  22.     putc(ch,stdout); fflush(stdout);
  23.     if (ch == 'n')
  24.       {
  25.           if (!NUM_FILES)
  26.             {
  27.                 message("File ring is empty.",1);
  28.             }
  29.           quit = next_file(&next);
  30.           if (next == -1) quit = 1;
  31.       }
  32.     else if ((ch == 'c') || (ch == 'C'))   /* toggle case sensitive search */
  33.       {
  34.           CASE_SENSITIVE = !CASE_SENSITIVE;
  35.           if (CASE_SENSITIVE)
  36.             message("Searches now respect case.",0);
  37.           else
  38.             message("Searches nolonger respect case.",0);
  39.       }
  40.     else if ((ch == 'D') && MOST_D_OPT) /* delete file */
  41.       {
  42.           /* notice the missing D. */
  43.      send_string_to_term("elete ");
  44.      send_string_to_term(BUF->file);
  45.      send_string_to_term("? [n]:");
  46.      
  47.           ch = getkey();
  48.           if (ch == 'y')
  49.             {
  50.                 if (!sys_delete_file(BUF->file))
  51.                   message("File could not be deleted.",1);
  52.                 else
  53.                   message("File deleted.",0);
  54.             }
  55.           else
  56.             message("File not deleted.",0);
  57.       }
  58.     else if (ch == 'o')
  59.       {
  60.           send_string_to_term("\rToggle option: b d t v w");
  61.           ch = getkey();
  62.           if ((ch == 'd') || (ch == 'w') || (ch == 'b') || (ch == 't') || (ch == 'v') || (ch == 's'))
  63.             {
  64.                 if (ch == 'b')
  65.                   {
  66.                       MOST_B_OPT = !MOST_B_OPT;
  67.                       NUM_LINES = count_lines(BEG,EOB);
  68.                   }
  69.                 else if (ch == 'd')
  70.                   {
  71.                       if (DIGIT_ARG == NULL)
  72.                         {
  73.                             message("Selective Display off.",0);
  74.                             n = 0;
  75.                         }
  76.                       else n = abs( *DIGIT_ARG );
  77.                       if (MOST_S_OPT != n)
  78.                         {
  79.                             MOST_S_OPT = n;
  80.                             NUM_LINES = count_lines(BEG,EOB);
  81.                         }
  82.                   }
  83.                 else if ((ch == 's') && !MOST_B_OPT)
  84.                   {
  85.                       SQUEEZE_LINES = !SQUEEZE_LINES;
  86.                       NUM_LINES = count_lines(BEG,EOB);
  87.                   }
  88.                 else if (ch == 'w')
  89.                   {
  90.                       MOST_W_OPT = !MOST_W_OPT;
  91.                       NUM_LINES = count_lines(BEG,EOB);
  92.                   }
  93.                 else if (ch == 'v') MOST_V_OPT = !MOST_V_OPT;
  94.                 else if (ch == 't') MOST_T_OPT = !MOST_T_OPT;
  95.  
  96.                 if (!NUM_LINES) NUM_LINES = 1;
  97.                 
  98.                 save_win_flags(WIN);
  99.                 save = C_POS;
  100.                 C_POS = BEG;
  101.                 C_LINE = 1;
  102.                 C_LINE = what_line(save);
  103.                 C_POS = save;
  104.                 WIN->beg_line = C_LINE;
  105.                 tt_erase_line();
  106.                 exit_minibuffer();
  107.                 redraw_window();
  108.                 update_status(0);
  109.                 return(quit);
  110.             }
  111.       }
  112.     else
  113.       {
  114.      beep();
  115.      tt_erase_line();
  116.       }
  117.     fflush(stdout);
  118.     
  119.     exit_minibuffer();
  120.     return(quit);
  121. }
  122.  
  123. /* returns zero if not quit */
  124.  
  125. int do_extended_cmd()
  126. {
  127.     char cmd[80];
  128.     int quit = 0;
  129.     cmd[0] = 0;
  130.     if (!read_from_minibuffer("Cmd",cmd)) return 0;
  131.     
  132.     if (!strcmp(cmd,"cd"))
  133.       {
  134.           cd();
  135.       }
  136.     else if ((!strncmp(cmd,"quit",strlen(cmd))) || 
  137.          (!strncmp(cmd,"exit",strlen(cmd))))
  138.       {
  139.           quit = -1;
  140.       }
  141.     else
  142.       {
  143.           strcat(cmd," not understood.");
  144.           message(cmd,1);
  145.       }
  146.     return(quit);
  147. }
  148.  
  149.