home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- *** command.c (JJB TEMPLAR) ***
- *** Date modifications begun: 7/8/89. ***
- *** Last modified: 27/8/89. ***
- *************************************************************************/
- /*** User-level command processor. ***
- *************************************************************************/
-
- #include "less.h"
- #include <intuition/intuition.h>
- #include <proto/intuition.h>
-
- #include "win.h"
- #include "cmd.h"
-
- extern struct Window *Window;
- extern struct Requester req;
-
- extern int quit_at_eof;
- extern int hit_eof;
- extern int sc_height;
- extern int top_scroll;
- extern int l_start;
- extern char version[];
- extern char current_file[];
-
- int has_resized; /* Used by getc() to indicate if user resized */
-
- /*** Main command processor. ***
- *** Accept and execute commands until a quit command, then return. ***/
-
- void commands() /*====================================================*/
- {
- has_resized = 0;
- while (1) {
- if (has_resized) { /* In case user resizes during getc */
- has_resized = 0;
- resize();
- repaint();
- setbar(1);
- }
-
- if (quit_at_eof && (hit_eof > 1)) next_file(1);
-
- SetWindowTitles(Window,pr_string(),(char *)-1L); /* Prompt */
-
- switch (getcmd()) {
- case (C_FORW_PAGE): forward(sc_height-1, 1);
- setbar(1);
- break;
- case (C_BACK_PAGE): backward(sc_height-1, 1);
- setbar(1);
- break;
- case (C_FORW_LINE): forward(1, 0);
- setbar(0);
- break;
- case (C_BACK_LINE): backward(1, 0);
- setbar(0);
- break;
- case (C_TOP): jump_back(1);
- setbar(1);
- break;
- case (C_BOTTOM): jump_forw();
- setbar(1);
- break;
- case (C_HELP): help();
- repaint();
- break;
- case (C_ABOUT): about();
- repaint();
- break;
- case (C_FORW_FILE): next_file(1); break;
- case (C_BACK_FILE): prev_file(1); break;
- case (C_VERSION): error(version,0); break;
- case (C_QUIT): return; /* so infinite while() loop */
- case (C_REPAINT): repaint(); break;
- case (C_INFO): error(eq_message(),0); break;
- case (C_BOOM): doboom(); break;
- /* Don't fall through. It appears a NEWSIZE message is
- * still posted by Intuition. */
- case (C_RESIZE): resize();
- repaint();
- setbar(1);
- break;
- case (C_SRIGHT): l_start = MAXHORIZ; /* Fall thru */
- case (C_RIGHT): horiz(1);
- repaint();
- break;
- case (C_SLEFT): l_start = 0; /* Fall thru */
- case (C_LEFT): horiz(0);
- repaint();
- break;
- case (C_SCROLL): usebar(); break;
- case (C_HSCROLL): usehbar();
- repaint();
- break;
- case (C_SEARCH_F): search_forw(1); break;
- case (C_SEARCH_B): search_back(1); break;
- case (C_SEARCH_FNC):search_forw(0); break;
- case (C_SEARCH_BNC):search_back(0); break;
- case (C_SET_MARK): setmark(); break;
- case (C_GO_MARK): gomark(); break;
- case (C_PERCENT): jump_percent(); break;
- case (C_ICONIFY): doiconify(); break;
- case (C_PRINT): print(); break;
- case (C_MODE_ON): domode(1);
- repaint();
- break;
- case (C_MODE_OFF): domode(0);
- repaint();
- break;
- case (C_NEWCLI): newcli(); break;
- case (C_EDITOR): editor(); break;
- case (C_ADDFILE): add_file(); break;
- case (C_INNOCUOUS): r_bool("Not implemented");
- break;
- default: bell(); break;
- }
- }
- }
-