split off ipc vi
[nvi.git] / ipc / ip.h
blob0ee0674149d3f7e4d0488c0c3418af059b1a9c9b
1 /*-
2 * Copyright (c) 1996
3 * Keith Bostic. All rights reserved.
5 * See the LICENSE file for redistribution information.
7 * $Id: ip.h,v 8.21 2000/06/24 18:54:50 skimo Exp $ (Berkeley) $Date: 2000/06/24 18:54:50 $
8 */
10 extern int vi_ifd; /* Input file descriptor. */
11 extern int vi_ofd; /* Output file descriptor. */
13 typedef struct _ip_private {
14 int i_fd; /* Input file descriptor. */
15 int o_fd; /* Output file descriptor. */
17 int argc;
18 char **argv;
20 size_t row; /* Current row. */
21 size_t col; /* Current column. */
23 db_recno_t sb_total; /* scrollbar: total lines in file. */
24 db_recno_t sb_top; /* scrollbar: top line on screen. */
25 size_t sb_num; /* scrollbar: number of lines on screen. */
27 size_t iblen; /* Input buffer length. */
28 size_t iskip; /* Returned input buffer. */
29 char ibuf[256]; /* Input buffer. */
31 #define IP_SCR_VI_INIT 0x0001 /* Vi screen initialized. */
32 u_int32_t flags;
33 } IP_PRIVATE;
35 #define IPP(sp) ((IP_PRIVATE *)((sp)->gp->ip_private))
36 #define GIPP(gp) ((IP_PRIVATE *)((gp)->ip_private))
38 /* The screen line relative to a specific window. */
39 #define RLNO(sp, lno) (sp)->roff + (lno)
40 #define RCNO(sp, cno) (sp)->coff + (cno)
42 #define IPO_CODE_LEN 1 /* Length of a code value. */
43 #define IPO_INT_LEN 4 /* Length of an integer. */
45 /* A structure that can hold the information for any frame. */
46 typedef struct _ip_buf {
47 int code; /* Event code. */
48 const char *str1; /* String #1. */
49 u_int32_t len1; /* String #1 length. */
50 const char *str2; /* String #1. */
51 u_int32_t len2; /* String #1 length. */
52 u_int32_t val1; /* Value #1. */
53 u_int32_t val2; /* Value #2. */
54 u_int32_t val3; /* Value #3. */
55 } IP_BUF;
58 * Screen/editor IP_CODE's.
60 * The program structure depends on the event loop being able to return
61 * IPO_EOF/IPO_ERR multiple times -- eventually enough things will end
62 * due to the events that vi will reach the command level for the screen,
63 * at which point the exit flags will be set and vi will exit.
65 * IP events sent from the screen to vi.
67 #define CODE_OOB 0 /* Illegal code. */
68 #define VI_C_BOL 1 /* Cursor to start of line. */
69 #define VI_C_BOTTOM 2 /* Cursor to bottom. */
70 #define VI_C_DEL 3 /* Cursor delete. */
71 #define VI_C_DOWN 4 /* Cursor down N lines: IPO_INT. */
72 #define VI_C_EOL 5 /* Cursor to end of line. */
73 #define VI_C_INSERT 6 /* Cursor: enter insert mode. */
74 #define VI_C_LEFT 7 /* Cursor left. */
75 #define VI_C_PGDOWN 8 /* Cursor down N pages: IPO_INT. */
76 #define VI_C_PGUP 9 /* Cursor up N lines: IPO_INT. */
77 #define VI_C_RIGHT 10 /* Cursor right. */
78 #define VI_C_SEARCH 11 /* Cursor: search: IPO_INT, IPO_STR. */
79 #define VI_C_SETTOP 12 /* Cursor: set screen top line: IPO_INT. */
80 #define VI_C_TOP 13 /* Cursor to top. */
81 #define VI_C_UP 14 /* Cursor up N lines: IPO_INT. */
82 #define VI_EDIT 15 /* Edit a file: IPO_STR. */
83 #define VI_EDITOPT 16 /* Edit option: 2 * IPO_STR, IPO_INT. */
84 #define VI_EDITSPLIT 17 /* Split to a file: IPO_STR. */
85 #define VI_EOF 18 /* End of input (NOT ^D). */
86 #define VI_ERR 19 /* Input error. */
87 #define VI_INTERRUPT 20 /* Interrupt. */
88 #define VI_MOUSE_MOVE 21 /* Mouse click move: IPO_INT, IPO_INT. */
89 #define VI_QUIT 22 /* Quit. */
90 #define VI_RESIZE 23 /* Screen resize: IPO_INT, IPO_INT. */
91 #define VI_SEL_END 24 /* Select end: IPO_INT, IPO_INT. */
92 #define VI_SEL_START 25 /* Select start: IPO_INT, IPO_INT. */
93 #define VI_SIGHUP 26 /* SIGHUP. */
94 #define VI_SIGTERM 27 /* SIGTERM. */
95 #define VI_STRING 28 /* Input string: IPO_STR. */
96 #define VI_TAG 29 /* Tag. */
97 #define VI_TAGAS 30 /* Tag to a string: IPO_STR. */
98 #define VI_TAGSPLIT 31 /* Split to a tag. */
99 #define VI_UNDO 32 /* Undo. */
100 #define VI_WQ 33 /* Write and quit. */
101 #define VI_WRITE 34 /* Write. */
102 #define VI_WRITEAS 35 /* Write as another file: IPO_STR. */
104 #define VI_SEARCH_EXT 0x001 /* VI_C_SEARCH: ignore case. */
105 #define VI_SEARCH_IC 0x002 /* VI_C_SEARCH: ignore case. */
106 #define VI_SEARCH_ICL 0x004 /* VI_C_SEARCH: ignore case if lower-case. */
107 #define VI_SEARCH_INCR 0x008 /* VI_C_SEARCH: incremental search. */
108 #define VI_SEARCH_LIT 0x010 /* VI_C_SEARCH: literal string. */
109 #define VI_SEARCH_REV 0x020 /* VI_C_SEARCH: reverse direction. */
110 #define VI_SEARCH_WR 0x040 /* VI_C_SEARCH: wrap at sof/eof. */
113 * IP events sent from vi to the screen.
115 #define SI_ADDSTR 1 /* Add a string: IPO_STR. */
116 #define SI_ATTRIBUTE 2 /* Set screen attribute: 2 * IPO_INT. */
117 #define SI_BELL 3 /* Beep/bell/flash the terminal. */
118 #define SI_BUSY_OFF 4 /* Display a busy message: IPO_STR. */
119 #define SI_BUSY_ON 5 /* Display a busy message: IPO_STR. */
120 #define SI_CLRTOEOL 6 /* Clear to the end of the line. */
121 #define SI_DELETELN 7 /* Delete a line. */
122 #define SI_DISCARD 8 /* Discard the screen. */
123 #define SI_EDITOPT 9 /* Edit option: 2 * IPO_STR, IPO_INT. */
124 #define SI_INSERTLN 10 /* Insert a line. */
125 #define SI_MOVE 11 /* Move the cursor: 2 * IPO_INT. */
126 #define SI_QUIT 12 /* Quit. */
127 #define SI_REDRAW 13 /* Redraw the screen. */
128 #define SI_REFRESH 14 /* Refresh the screen. */
129 #define SI_RENAME 15 /* Rename the screen: IPO_STR. */
130 #define SI_REPLY 16 /* Reply: IPO_INT (0/1), IPO_STR. */
131 #define SI_REWRITE 17 /* Rewrite a line: IPO_INT. */
132 #define SI_SCROLLBAR 18 /* Reset the scrollbar: 3 * IPO_INT. */
133 #define SI_SELECT 19 /* Select area: IPO_STR. */
134 #define SI_SPLIT 20 /* Split the screen. */
135 #define SI_EVENT_MAX 20
137 #include "extern.h"