Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 68 lines (57 sloc) 2.962 kB
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
1 /* state2.h */
2 /* Copyright 1995 by Steve Kirkendall */
3
4
5
6 typedef enum
7 {
8 CURSOR_NONE, /* no visible cursor (may be handy inside gui module) */
9 CURSOR_INSERT, /* next character will be inserted */
10 CURSOR_REPLACE, /* next character will replace a existing text */
11 CURSOR_COMMAND, /* next character will be part of a visual command */
12 CURSOR_QUOTE /* next character should be quoted; will replace '^' */
13 } ELVCURSOR;
14
15 struct state_s
16 {
17 struct state_s *pop; /* next state on stack */
18 struct state_s *acton; /* state that enter() acts on */
19 RESULT (*enter) P_((WINDOW win)); /* perform line processing */
20 RESULT (*perform) P_((WINDOW win)); /* execute command */
21 RESULT (*parse) P_((_CHAR_ key, void *info)); /* parse a keystroke */
22 ELVCURSOR (*shape) P_((WINDOW win)); /* decide on cursor shape */
23 MARK cursor; /* the cursor & buffer to use */
24 MARK top, bottom; /* extent being edited */
25 void *info; /* extra info, for parser */
26 ELVISSTATE flags; /* flags of current state */
27 char *modename; /* mode name, for "showmode" */
28 CHAR morekey; /* special key for [More] */
29 CHAR prompt; /* prompt char, or '\0' */
30 MAPFLAGS mapflags; /* keystroke mapping state */
31 long wantcol; /* stratum's desired column */
32 };
33
34 #define ELVIS_USERMAP 0x0001 /* in the middle of a user's map */
35 #define ELVIS_KEYMAP 0x0002 /* in the middle of a function key map */
36 #define ELVIS_BOTTOM 0x0010 /* open mode; use bottom row only */
37 #define ELVIS_REGION 0x0020 /* editing a region; clean up if cursor moves */
38 #define ELVIS_POP 0x0100 /* pop after completing current keystroke */
39 #define ELVIS_ONCE 0x0200 /* pop after completing next keystroke */
40 #define ELVIS_1LINE 0x0400 /* pop after completing current line */
41 #define ELVIS_ALERT 0x0800 /* pop to this state if alerted */
42 #define ELVIS_FREE 0x1000 /* free(info) when freeing state */
43 #define ELVIS_MORE 0x2000 /* call perform() after popping */
44
45 BEGIN_EXTERNC
46 extern void statepush P_((WINDOW win, ELVISSTATE flags));
47 extern void statestratum P_((WINDOW win, CHAR *bufname, _CHAR_ prompt, RESULT (*enter)(WINDOW win)));
48 extern void statepop P_((WINDOW win));
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
49 extern RESULT statekey P_((_CHAR_ key));
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
50 END_EXTERNC
51
52 /* This macro returns the buffer that keystrokes act on. */
53 #define statecmdbuf(win) (markbuffer((win)->state->cursor))
54
55 /* This macro returns the cursor that ex commands and search commands should
56 * act on. This is generally the stratum under the keystroke's stratum.
57 */
58 #define statedatacursor(win) ((win)->state->acton->cursor)
59
60 /* These macros return the top & bottom of the range affected by a command. */
61 #define statedatatop(win) ((win)->state->acton->top)
62 #define statedatabottom(win) ((win)->state->acton->bottom)
63
64 /* This macro returns the buffer that ex commands and search commands should
65 * act on. This is generally the stratum under the keystroke's stratum.
66 */
67 #define statedatabuf(win) (markbuffer(statedatacursor(win)))
Something went wrong with that request. Please try again.