3 * Keith Bostic. All rights reserved.
5 * See the LICENSE file for redistribution information.
11 static const char sccsid
[] = "$Id: v_event.c,v 8.13 1996/12/17 19:49:19 bostic Exp $ (Berkeley) $Date: 1996/12/17 19:49:19 $";
14 #include <sys/types.h>
15 #include <sys/queue.h>
18 #include <bitstring.h>
27 #include "../common/common.h"
43 * We want to scroll the screen, without changing the cursor position.
44 * So, we fill the screen map and then flush it to the screen. Then,
45 * set the VIP_S_REFRESH flag so the main vi loop doesn't update the
46 * screen. When the next real command happens, the refresh code will
47 * notice that the screen map is way wrong and fix it.
50 * There may be a serious performance problem here -- we're doing no
51 * optimization whatsoever, which means that we're copying the entire
52 * screen out to the X11 screen code on each change.
54 if (vs_sm_fill(sp
, vp
->ev
.e_lno
, P_TOP
))
56 for (smp
= HMAP
; smp
<= TMAP
; ++smp
) {
58 if (vs_line(sp
, smp
, NULL
, NULL
))
62 F_SET(VIP(sp
), VIP_S_REFRESH
);
64 return (sp
->gp
->scr_refresh(sp
, 0));
78 ex_cinit(sp
, &cmd
, C_EDIT
, 0, OOBLNO
, OOBLNO
, 0);
79 argv_exp0(sp
, &cmd
, vp
->ev
.e_csp
, vp
->ev
.e_len
);
80 return (v_exec_ex(sp
, vp
, &cmd
));
85 * Set an option value.
93 return (api_opts_set(sp
,
94 vp
->ev
.e_str1
, vp
->ev
.e_str2
, vp
->ev
.e_val1
, vp
->ev
.e_val1
));
99 * Edit in a split screen.
108 ex_cinit(sp
, &cmd
, C_EDIT
, 0, OOBLNO
, OOBLNO
, 0);
109 F_SET(&cmd
, E_NEWSCREEN
);
110 argv_exp0(sp
, &cmd
, vp
->ev
.e_csp
, vp
->ev
.e_len
);
111 return (v_exec_ex(sp
, vp
, &cmd
));
128 ex_cinit(sp
, &cmd
, C_TAG
, 0, OOBLNO
, OOBLNO
, 0);
129 argv_exp0(sp
, &cmd
, VIP(sp
)->keyw
, strlen(VIP(sp
)->keyw
));
130 return (v_exec_ex(sp
, vp
, &cmd
));
135 * Tag on the supplied string.
144 ex_cinit(sp
, &cmd
, C_TAG
, 0, OOBLNO
, OOBLNO
, 0);
145 argv_exp0(sp
, &cmd
, vp
->ev
.e_csp
, vp
->ev
.e_len
);
146 return (v_exec_ex(sp
, vp
, &cmd
));
151 * Tag in a split screen.
163 ex_cinit(sp
, &cmd
, C_TAG
, 0, OOBLNO
, OOBLNO
, 0);
164 F_SET(&cmd
, E_NEWSCREEN
);
165 argv_exp0(sp
, &cmd
, VIP(sp
)->keyw
, strlen(VIP(sp
)->keyw
));
166 return (v_exec_ex(sp
, vp
, &cmd
));
180 ex_cinit(sp
, &cmd
, C_QUIT
, 0, OOBLNO
, OOBLNO
, 0);
181 return (v_exec_ex(sp
, vp
, &cmd
));
186 * Repaint selected lines from the screen.
188 * PUBLIC: int v_erepaint __P((SCR *, EVENT *));
197 for (; evp
->e_flno
<= evp
->e_tlno
; ++evp
->e_flno
) {
198 smp
= HMAP
+ evp
->e_flno
- 1;
200 if (vs_line(sp
, smp
, NULL
, NULL
))
208 * Write and quit command.
217 ex_cinit(sp
, &cmd
, C_WQ
, 0, OOBLNO
, OOBLNO
, 0);
220 if (db_last(sp
, &cmd
.addr2
.lno
))
222 return (v_exec_ex(sp
, vp
, &cmd
));
236 ex_cinit(sp
, &cmd
, C_WRITE
, 0, OOBLNO
, OOBLNO
, 0);
239 if (db_last(sp
, &cmd
.addr2
.lno
))
241 return (v_exec_ex(sp
, vp
, &cmd
));
255 ex_cinit(sp
, &cmd
, C_WRITE
, 0, OOBLNO
, OOBLNO
, 0);
256 argv_exp0(sp
, &cmd
, vp
->ev
.e_csp
, vp
->ev
.e_len
);
259 if (db_last(sp
, &cmd
.addr2
.lno
))
261 return (v_exec_ex(sp
, vp
, &cmd
));
266 * Find the event associated with a fucntion.
273 /* This array maps events to vi command functions. */
274 static VIKEYS
const vievents
[] = {
275 #define V_C_SETTOP 0 /* VI_C_SETTOP */
277 #define V_EEDIT 1 /* VI_EDIT */
279 #define V_EEDITOPT 2 /* VI_EDITOPT */
281 #define V_EEDITSPLIT 3 /* VI_EDITSPLIT */
283 #define V_EMARK 4 /* VI_MOUSE_MOVE */
284 {v_emark
, V_ABS_L
|V_MOVE
},
285 #define V_EQUIT 5 /* VI_QUIT */
287 #define V_ESEARCH 6 /* VI_SEARCH */
288 {v_esearch
, V_ABS_L
|V_MOVE
},
289 #define V_ETAG 7 /* VI_TAG */
291 #define V_ETAGAS 8 /* VI_TAGAS */
293 #define V_ETAGSPLIT 9 /* VI_TAGSPLIT */
295 #define V_EWQ 10 /* VI_WQ */
297 #define V_EWRITE 11 /* VI_WRITE */
299 #define V_EWRITEAS 12 /* VI_WRITEAS */
303 switch (vp
->ev
.e_ipcom
) {
305 vp
->kp
= &vikeys
['0'];
308 vp
->kp
= &vikeys
['G'];
311 vp
->kp
= &vikeys
['x'];
315 vp
->count
= vp
->ev
.e_lno
;
316 vp
->kp
= &vikeys
['\012'];
319 vp
->kp
= &vikeys
['$'];
322 vp
->kp
= &vikeys
['i'];
325 vp
->kp
= &vikeys
['\010'];
329 vp
->count
= vp
->ev
.e_lno
;
330 vp
->kp
= &vikeys
['\006'];
334 vp
->count
= vp
->ev
.e_lno
;
335 vp
->kp
= &vikeys
['\002'];
338 vp
->kp
= &vikeys
['\040'];
341 vp
->kp
= &vievents
[V_ESEARCH
];
344 vp
->kp
= &vievents
[V_C_SETTOP
];
349 vp
->kp
= &vikeys
['G'];
353 vp
->count
= vp
->ev
.e_lno
;
354 vp
->kp
= &vikeys
['\020'];
357 vp
->kp
= &vievents
[V_EEDIT
];
360 vp
->kp
= &vievents
[V_EEDITOPT
];
363 vp
->kp
= &vievents
[V_EEDITSPLIT
];
366 vp
->kp
= &vievents
[V_EMARK
];
369 vp
->kp
= &vievents
[V_EQUIT
];
372 vp
->kp
= &vievents
[V_ETAG
];
375 vp
->kp
= &vievents
[V_ETAGAS
];
378 vp
->kp
= &vievents
[V_ETAGSPLIT
];
381 vp
->kp
= &vikeys
['u'];
384 vp
->kp
= &vievents
[V_EWQ
];
387 vp
->kp
= &vievents
[V_EWRITE
];
390 vp
->kp
= &vievents
[V_EWRITEAS
];