Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 980 lines (858 sloc) 25.451 kb
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
1 /* event.c */
2 /* Copyright 1995 by Steve Kirkendall */
3
4
5 #include "elvis.h"
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
6 #ifdef FEATURE_RCSID
7 char id_event[] = "$Id: event.c,v 2.85 2003/10/17 17:41:23 steve Exp $";
8 #endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
9
10 #ifndef DEBUG_EVENT
11 # define WATCH(x)
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
12 # define USUAL_SUSPECTS ;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
13 #else
14 # define WATCH(x) x
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
15 # ifdef NDEBUG
16 # define USUAL_SUSPECTS ;
17 # else
18 # define USUAL_SUSPECTS {WINDOW w; for (w = windows; w; w = w->next){ \
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
19 if (!w->state) continue; \
20 assert(markbuffer(w->state->top) == markbuffer(w->state->cursor)); \
21 assert(markbuffer(w->state->bottom) == markbuffer(w->state->cursor)); \
22 assert(markoffset(w->state->top) <= markoffset(w->state->cursor)); \
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
23 assert(markoffset(w->state->bottom) == 0 \
24 || markoffset(w->state->bottom) >= markoffset(w->state->cursor)); \
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
25 } }
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
26 # endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
27 #endif
28
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
29 #if USE_PROTOTYPES
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
30 static void setcursor(WINDOW win, long offset, ELVBOOL clean);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
31 #endif
32
33 /* This counts the number of events that have been processed. In particular,
34 * if eventcounter==0 then we know we're still performing initialization.
35 */
36 long eventcounter;
37
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
38 /* Regenerate the CUSTOM_BUF if necessary */
39 void eventupdatecustom(later)
40 ELVBOOL later; /* update it before waiting for an event? (else now) */
41 {
42 #ifdef FEATURE_MKEXRC
43 static ELVBOOL mustupdate;
44 BUFFER custom; /* the CUSTOM_BUF buffer */
45 MARKBUF top, bottom;
46
47 /* if just supposed to update later, then remember that */
48 if (later)
49 {
50 mustupdate = ElvTrue;
51 return;
52 }
53
54 /* if no update is needed, then do nothing */
55 if (!mustupdate)
56 return;
57 mustupdate = ElvFalse;
58
59 /* find/create the CUSTOM_BUF buffer */
60 custom = bufalloc(toCHAR(CUSTOM_BUF), 0, ElvTrue);
61 if (o_bufchars(custom) != 0)
62 {
63 bufreplace(marktmp(top, custom, 0),
64 marktmp(bottom, custom, o_bufchars(custom)),
65 NULL, 0);
66 }
67
68 /* add stuff into it */
69 optsave(custom);
70 mapsave(custom);
71 digsave(custom);
72 colorsave(custom);
73 /* abbrsave(custom); */
74 # ifdef FEATURE_ALIAS
75 exaliassave(custom);
76 # endif
77 # ifdef FEATURE_SPELL
78 spellsave(custom);
79 # endif
80 # ifdef FEATURE_AUTOCMD
81 ausave(custom);
82 # endif
83 if (gui && gui->save && windefault)
84 {
85 (*gui->save)(custom, windefault->gw);
86 }
87 #endif
88 }
89
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
90 /* Some events move the cursor. E.g., clicking the mouse or moving the
91 * scrollbar's thumb. If the window is in input mode, then there may be
92 * some superfluous text between the cursor and the end of the edit region
93 * (usually marked with a '$') which needs to be deleted before the cursor
94 * can be moved.
95 *
96 * This function detects those situations, and performs the necessary steps.
97 * The eventXXX functions should always use this function to set the cursor
98 * position.
99 */
100 static void setcursor(win, offset, clean)
101 WINDOW win; /* window whose cursor should be moved */
102 long offset; /* new offset for the cursor */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
103 ELVBOOL clean; /* definitely delete superfluous text */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
104 {
105 /* if in input mode, and there are superfluous characters after the
106 * cursor (probably the end is marked with a '$' character) then we
107 * may need to delete those characters. Exception: If the new
108 * location is still in the same edit region, then we don't need to
109 * worry about it.
110 */
111 if ((win->state->flags & ELVIS_REGION) == ELVIS_REGION
112 && markoffset(win->state->bottom) != markoffset(win->state->cursor)
113 && (clean
114 || offset < markoffset(win->state->top)
115 || markoffset(win->state->bottom) <= offset))
116 {
117 /* tweak offset to compensate for the following bufreplace() */
118 if (offset > markoffset(win->state->bottom))
119 offset -= (markoffset(win->state->bottom) - markoffset(win->state->cursor));
120
121 /* delete the superfluous text */
122 bufreplace(win->state->cursor, win->state->bottom, NULL, 0L);
123 }
124
125 /* move the cursor, and maybe adjust the edit region too */
126 marksetoffset(win->state->cursor, offset);
127 if (offset < markoffset(win->state->top)
128 || markoffset(win->state->bottom) <= offset)
129 {
130 marksetoffset(win->state->top, offset);
131 marksetoffset(win->state->bottom, offset);
132 }
133 }
134
135 /* This function creates a WINDOW -- an internal data structure
136 * used to describe the characteristics of a window. The GUI
137 * calls this function when an elvis window suddenly pops into
138 * existence. (Note: Each GUI has a creategw() function to request
139 * that a new window be created.)
140 *
141 * The GUIWIN already exists, and the BUFFER named "name" must also
142 * exist. If anything goes wrong, this function issues an error message
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
143 * via msg(), and returns ElvFalse; the GUI should then destroy its window and
144 * forget about it. Returns ElvTrue for successful creations.
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
145 */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
146 ELVBOOL eventcreate(gw, guivals, name, rows, columns)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
147 GUIWIN *gw; /* GUI's handle for new window */
148 OPTVAL *guivals; /* values of GUI's window-dependent options */
149 char *name; /* name of the new window */
150 int rows; /* height of the new window */
151 int columns; /* width of the new window */
152 {
153 BUFFER buf;
154 WINDOW win;
155
156 WATCH(fprintf(stderr, "eventcreate(..., name=\"%s\", rows=%d, columns=%d)\n", name, rows, columns));
157 USUAL_SUSPECTS
158 eventcounter++;
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
159 if (windefault)
160 o_eventcounter(windefault) = eventcounter;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
161
162 /* find/create a buffer with the requested name */
163 buf = buffind(toCHAR(name));
164 if (!buf)
165 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
166 buf = bufload((CHAR *)0, name, ElvFalse);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
167 }
168
169 /* create a WINDOW */
170 win = winalloc(gw, guivals, buf, rows, columns);
171
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
172 #ifndef NDEBUG
173 if (gui->moveto) USUAL_SUSPECTS
174 #endif
175
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
176 return (ELVBOOL)(win != NULL);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
177 }
178
179 /* This function frees the WINDOW associated with gw, and frees it. */
180 void eventdestroy(gw)
181 GUIWIN *gw; /* GUI's handle for a window which has been deleted */
182 {
183 WINDOW win;
184 BUFFER msgq;
185
186 WATCH(fprintf(stderr, "eventdestroy(...)\n"));
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
187 #ifndef NDEBUG
188 if (gui->moveto) USUAL_SUSPECTS
189 #endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
190 eventcounter++;
191
192 /* find the window */
193 win = winofgw(gw);
194 assert(win);
195
196 /* free it */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
197 winfree(win, ElvFalse);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
198
199 /* if there are any messages pending, and we aren't about to exit,
200 * then flush the messages out to some other window.
201 */
202 msgq = buffind(toCHAR(MSGQUEUE_BUF));
203 if (msgq && o_bufchars(msgq) > 0L && winofbuf(NULL, NULL) != NULL)
204 {
205 win = winofbuf(NULL, NULL);
206 winoptions(win);
207 msgflush();
208 }
209 USUAL_SUSPECTS
210 }
211
212 /* Change the size of an existing window. This doesn't automatically redraw
213 * the window; later expose events or eventdraw() calls will take care of that.
214 */
215 void eventresize(gw, rows, columns)
216 GUIWIN *gw; /* GUI's handle for the window that was resized */
217 int rows; /* new height of the window */
218 int columns;/* new width of the window */
219 {
220 WINDOW win;
221
222 USUAL_SUSPECTS
223 WATCH(fprintf(stderr, "eventresize(..., rows=%d, columns=%d\n", rows, columns));
224 eventcounter++;
225
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
226 /* if too small, then ignore the change */
227 if (rows < 2 || columns < 30)
228 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
229 return; /* ElvFalse? */
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
230 }
231
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
232 /* find the window */
233 win = winofgw(gw);
234 assert(win);
235
236 /* resize it */
237 winresize(win, rows, columns);
238
239 USUAL_SUSPECTS
240 }
241
242 /* Replace the current buffer with some other buffer, for the WINDOW
243 * associated with "gw", and then maybe free the old version. If
244 * anything goes wrong, then issue an error message instead.
245 */
246 void eventreplace(gw, freeold, name)
247 GUIWIN *gw; /* GUI's handle for window to be switched */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
248 ELVBOOL freeold;/* if ElvTrue, destroy old buffer; else retain it */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
249 char *name; /* name of new buffer to use */
250 {
251 WINDOW win;
252 BUFFER buf;
253
254 WATCH(fprintf(stderr, "eventreplace(..., freeold=%s, name=\"%s\")\n", freeold?"True":"False", name));
255 USUAL_SUSPECTS
256 eventcounter++;
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
257 if (windefault)
258 o_eventcounter(windefault) = eventcounter;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
259
260 /* find/create a buffer with the requested name */
261 buf = buffind(toCHAR(name));
262 if (!buf)
263 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
264 buf = bufload((CHAR *)0, name, ElvFalse);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
265 }
266
267 /* find the window */
268 win = winofgw(gw);
269 assert(win);
270
271 /* replace its buffer */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
272 winchgbuf(win, buf, ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
273 USUAL_SUSPECTS
274 }
275
276 /* Redraw a portion of a window. */
277 void eventexpose(gw, top, left, bottom, right)
278 GUIWIN *gw; /* GUI's handle for window which has been exposed */
279 int top; /* top edge of exposed rectangle */
280 int left; /* left edge of exposed rectangle */
281 int bottom; /* bottom edge of exposed rectangle */
282 int right; /* right edge of exposed rectangle */
283 {
284 WINDOW win = winofgw(gw);
285
286 WATCH(fprintf(stderr, "eventexpose(..., top=%d, left=%d, bottom=%d, right=%d)\n", top, left, bottom, right));
287 USUAL_SUSPECTS
288 eventcounter++;
289
290 /* permit the bell to ring */
291 guibeep(NULL);
292
293 if (top < 0) top = 0;
294 if (left < 0) left = 0;
295 if (bottom >= o_lines(win)) bottom = o_lines(win) - 1;
296 if (right >= o_columns(win)) right = o_columns(win) - 1;
297 drawexpose(win, top, left, bottom, right);
298 USUAL_SUSPECTS
299 }
300
301 /* Makes sure that a window shows a current image of its buffer's
302 * text. The GUI should only call this function when will have to
303 * *wait* for the next event. It returns the cursor shape.
304 */
305 ELVCURSOR eventdraw(gw)
306 GUIWIN *gw; /* GUI's handle for window to be updated */
307 {
308 WINDOW win = winofgw(gw);
309
310 WATCH(fprintf(stderr, "eventdraw(...)\n"));
311 USUAL_SUSPECTS
312 assert(win && win->state);
313 eventcounter++;
314
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
315 /* update the CUSTOM_BUF now, if necessary */
316 eventupdatecustom(ElvFalse);
317
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
318 /* flush any messages */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
319 #ifdef FEATURE_MAKE
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
320 if (!makeflag)
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
321 #endif
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
322 msgflush();
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
323
324 /* permit the bell to ring */
325 guibeep(NULL);
326
327 /* call drawopenedit for open-mode windows, or drawimage for visual-mode */
328 if (win->state->flags & ELVIS_BOTTOM)
329 {
330 /* line-at-a-time */
331 drawopenedit(win);
332 }
333 else if (win->di->drawstate == DRAW_OPENOUTPUT)
334 {
335 /* push a "more" key state */
336 morepush(win, win->state->morekey);
337
338 /* display the message */
339 drawopenedit(win);
340 }
341 else
342 {
343 /* draw the screen */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
344 #ifdef FEATURE_SPELL
345 spellbegin();
346 #endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
347 drawimage(win);
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
348 #ifdef FEATURE_SPELL
349 spellend();
350 #endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
351 }
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
352
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
353 #ifdef FEATURE_MAKE
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
354 /* After user hits <Enter>, reset the makeflag */
355 if (makeflag && morehit)
356 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
357 makeflag = morehit = ElvFalse;
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
358 msgflush();
359 }
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
360 #else
361 msgflush();
362 #endif
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
363
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
364 USUAL_SUSPECTS
365 return (win->state ? (*win->state->shape)(win) : CURSOR_NONE);
366 }
367
368 /* Make the WINDOW and BUFFER associated with "gw" be the defaults. Returns
369 * the cursor shape. Since the the eventkeys() function does this itself,
370 * the only forseeable use of this function is to return the current cursor
371 * shape.
372 */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
373 ELVCURSOR eventfocus(gw, change)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
374 GUIWIN *gw; /* GUI's handle for window to become new default */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
375 ELVBOOL change; /* really change focus? else just use options */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
376 {
377 WINDOW win = winofgw(gw);
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
378 WINDOW other;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
379
380 WATCH(fprintf(stderr, "eventfocus(...)\n"));
381 USUAL_SUSPECTS
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
382 assert(!win || win->state);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
383 eventcounter++;
384
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
385 if (change && (!win || !o_hasfocus(win)))
386 {
387 #if 1
388 for (other = windows; other; other = other->next)
389 {
390 if (!o_hasfocus(other))
391 continue;
392 o_hasfocus(other) = ElvFalse;
393 if (guicolorsync(other) && gui && gui->draw)
394 {
395 if (other->state->pop)
396 drawexpose(other, 0, 0, (int)o_lines(other)-1, (int)o_columns(other)-1);
397 else
398 {
399 other->di->logic = DRAW_SCRATCH;
400 drawimage(other);
401 }
402 }
403 }
404 #endif
405 if (!win)
406 return CURSOR_NONE;
407 winoptions(win);
408 o_hasfocus(win) = ElvTrue;
409 #if 1
410 if (guicolorsync(win) && gui && gui->draw)
411 {
412 if (win->state->pop)
413 drawexpose(win, 0, 0, (int)o_lines(win)-1, (int)o_columns(win)-1);
414 else
415 {
416 win->di->logic = DRAW_SCRATCH;
417 drawimage(win);
418 }
419 }
420 #endif
421 }
422 else
423 winoptions(win);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
424 USUAL_SUSPECTS
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
425
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
426 return (*win->state->shape)(win);
427 }
428
429 /* Convert a screen point (where (0,0) is the upper-left character cell)
430 * to a buffer offset, and move the cursor there. Optionally start visible
431 * marking, depending on the value of "what".
432 *
433 * This function can also cancel visible marking, when "what" is CLICK_CANCEL.
434 * In this case, the "row" and "column" parameters are ignored and the cursor
435 * does not move.
436 */
437 long eventclick(gw, row, column, what)
438 GUIWIN *gw; /* GUI's handle for window that was clicked */
439 int row; /* row where clicked */
440 int column; /* column where clicked */
441 CLICK what; /* action that the click should perform */
442 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
443 #ifndef FEATURE_MISC
444 return 0;
445 #else
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
446 WINDOW win = winofgw(gw);
447 VIINFO vinfbuf;
448 MARKBUF tmp;
449 MARK newcurs;
450 long offset;
451
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
452 WATCH(fprintf(stderr, "eventclick(..., row=%d, column=%d, what=%d)\n", row, column, (int)what));
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
453 USUAL_SUSPECTS
454 eventcounter++;
455
456 /* reset the poll frequency counter */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
457 guipoll(ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
458 bufmsgtype = MSG_STATUS;
459
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
460 /* use the options for this window */
461 eventfocus(gw, ElvTrue);
462 if (windefault)
463 o_eventcounter(windefault) = eventcounter;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
464
465 /* if the window is showing "Hit <Enter> to continue" then any click
466 * is treated as an <Enter> keystoke.
467 */
468 if (!strcmp(win->state->modename, "More"))
469 {
470 (void)eventkeys(gw, toCHAR("\n"), 1);
471 return markoffset(win->cursor);
472 }
473
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
474 /* if not in visual mode, then most clicks mean nothing */
475 if (win->state->acton && what != CLICK_PASTE)
476 {
477 return -1L;
478 }
479
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
480 /* for some operations, the position doesn't matter */
481 switch (what)
482 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
483 #ifndef FEATURE_V
484 case CLICK_CANCEL:
485 case CLICK_SSLINE:
486 case CLICK_SSCHAR:
487 case CLICK_YANK:
488 return 0;
489 #else
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
490 case CLICK_CANCEL:
491 vinfbuf.command = ELVCTRL('[');
492 (void)v_visible(win, &vinfbuf);
493 USUAL_SUSPECTS
494 return 0;
495
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
496 case CLICK_SSLINE:
497 if (win->seltop == NULL)
498 {
499 vinfbuf.command = 'V';
500 (void)v_visible(win, &vinfbuf);
501 USUAL_SUSPECTS
502 }
503 return 0;
504
505 case CLICK_SSCHAR:
506 if (win->seltop == NULL)
507 {
508 vinfbuf.command = 'v';
509 (void)v_visible(win, &vinfbuf);
510 USUAL_SUSPECTS
511 }
512 return 0;
513
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
514 case CLICK_YANK:
515 /* if no text is marked, then fail */
516 if (!win->seltop)
517 {
518 USUAL_SUSPECTS
519 return -1;
520 }
521
522 /* Do the yank */
523 switch (win->seltype)
524 {
525 case 'c':
526 /* for character yanks, we need to tweak the "to" value
527 * so the last character is included.
528 */
529 tmp = *win->selbottom;
530 markaddoffset(&tmp, 1);
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
531 cutyank((_CHAR_)'>', win->seltop, &tmp, win->seltype, 'y');
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
532 break;
533
534 case 'l':
535 /* for line yanks, we want to avoid readjusting the
536 * endpoints, so we'll pass 'L' as the type.
537 */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
538 cutyank((_CHAR_)'>', win->seltop, win->selbottom, 'L', 'y');
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
539 break;
540
541 case 'r':
542 tmp = *win->selbottom;
543 markaddoffset(&tmp, 1);
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
544 cutyank((_CHAR_)'>', win->seltop, &tmp, win->seltype, 'y');
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
545 break;
546 }
547 USUAL_SUSPECTS
548 return 0;
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
549 #endif /* FEATURE_V */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
550
551 case CLICK_PASTE:
552 /* end any pending selection */
553 vinfbuf.command = ELVCTRL('[');
554 (void)v_visible(win, &vinfbuf);
555
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
556 /* delete any superfluous text after the cursor */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
557 setcursor(win, markoffset(win->state->cursor), ElvTrue);
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
558
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
559 /* set the buffer's "willdo" flag so this paste is undoable */
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
560 if (!win->state->pop)
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
561 bufwilldo(win->state->cursor, ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
562
563 /* paste the text */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
564 newcurs = cutput((_CHAR_)'^', win, win->state->cursor, ElvFalse, ElvTrue, ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
565 if (newcurs)
566 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
567 /* newcurs is normally at the last character, but we
568 * want to leave it *AFTER* the last character.
569 */
570 markaddoffset(newcurs, 1L);
571
572 /* if the edit buffer was empty before, then we may
573 * need to add a newline after this.
574 */
575 if (markoffset(newcurs) >= o_bufchars(markbuffer(win->state->cursor)))
576 {
577 marksetoffset(newcurs, o_bufchars(markbuffer(win->state->cursor)));
578 bufreplace(newcurs, newcurs, toCHAR("\n"), 1L);
579 markaddoffset(newcurs, 1L);
580 marksetoffset(newcurs, o_bufchars(markbuffer(win->state->cursor)) - 2L);
581 }
582
583 /* Now we can move the cursor there. Note that we
584 * don't call setcursor() to do this, because we don't
585 * want to clobber the edit region -- the user should
586 * be able to backspace over the pasted text.
587 */
588 marksetoffset(win->state->cursor, markoffset(newcurs));
589 if (win->state->bottom)
590 marksetoffset(win->state->bottom, markoffset(newcurs));
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
591 }
592 USUAL_SUSPECTS
593 return 0;
594
595 case CLICK_TAG:
596 /* simulate a <Control-]> keystroke */
597 vinfbuf.command = ELVCTRL(']');
598 tmp = *win->state->cursor;
599 (void)v_tag(win, &vinfbuf);
600 USUAL_SUSPECTS
601 return 0;
602
603 case CLICK_UNTAG:
604 /* simulate a <Control-T> keystroke */
605 vinfbuf.command = ELVCTRL('T');
606 tmp = *win->state->cursor;
607 (void)v_tag(win, &vinfbuf);
608 USUAL_SUSPECTS
609 return 0;
610
611 default:
612 /* handled below... */
613 ;
614 }
615
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
616 /* Bad positions are always -1. If the screen is in ex mode, all
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
617 * positions are bad.
618 */
619 if (win->di->drawstate == DRAW_OPENEDIT
620 || win->di->drawstate == DRAW_OPENOUTPUT
621 || row < 0 || row >= o_lines(win) - 1
622 || column < 0 || column >= o_columns(win))
623 {
624 USUAL_SUSPECTS
625 return -1;
626 }
627
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
628 #ifdef FEATURE_LISTCHARS
629 /* if sidescrolled, and click is on left margin, then scroll to reveal
630 * chars to left of screen.
631 */
632 if (!o_wrap(win) && win->di->skipped > 0 && column < dmnlistchars('<', 9L, 0L, NULL, NULL))
633 {
634 if (win->di->skipped > o_sidescroll(win))
635 win->di->skipped -= o_sidescroll(win);
636 else
637 win->di->skipped = 0;
638 win->di->logic = DRAW_CHANGED;
639 }
640 #endif
641 /* Else look it up. If the clicked-on character is bad (not part of
642 * the buffer) then look leftward in that line for a good character
643 * and use it instead.
644 */
645 do
646 {
647 offset = win->di->offsets[row * o_columns(win) + column];
648 } while (offset < 0 && ++column < o_columns(win));
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
649 if (offset < 0 || offset >= o_bufchars(markbuffer(win->state->cursor)))
650 {
651 USUAL_SUSPECTS
652 return -1;
653 }
654
655 /* move the cursor to the click-on cell */
656 win->wantcol = column;
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
657 if (o_number(win))
658 win->wantcol -= 8;
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
659 setcursor(win, offset, ElvFalse);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
660
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
661 #ifdef FEATURE_V
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
662 /* perform the requested operation */
663 switch (what)
664 {
665 case CLICK_MOVE:
666 /* If a selection is in progress, then adjust one end of the
667 * selection to match the cursor position.
668 */
669 if (win->seltop)
670 {
671 (void)v_visible(win, NULL);
672 }
673 break;
674
675 case CLICK_SELCHAR:
676 /* start character selection */
677 vinfbuf.command = ELVCTRL('[');
678 (void)v_visible(win, &vinfbuf);
679 vinfbuf.command = 'v';
680 (void)v_visible(win, &vinfbuf);
681 break;
682
683 case CLICK_SELLINE:
684 /* start line selection */
685 vinfbuf.command = ELVCTRL('[');
686 (void)v_visible(win, &vinfbuf);
687 vinfbuf.command = 'V';
688 (void)v_visible(win, &vinfbuf);
689 break;
690
691 case CLICK_SELRECT:
692 /* start rectangle selection */
693 vinfbuf.command = ELVCTRL('[');
694 (void)v_visible(win, &vinfbuf);
695 vinfbuf.command = ELVCTRL('V');
696 (void)v_visible(win, &vinfbuf);
697 break;
698
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
699 case CLICK_SSCHAR:
700 case CLICK_SSLINE:
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
701 case CLICK_CANCEL:
702 case CLICK_NONE:
703 case CLICK_YANK:
704 case CLICK_PASTE:
705 case CLICK_TAG:
706 case CLICK_UNTAG:
707 /*NOTREACHED*/
708 ;
709 }
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
710 #endif
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
711 USUAL_SUSPECTS
712 return offset;
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
713 #endif /* FEATURE_MISC */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
714 }
715
716 /* This function makes the window and buffer associated with "gw"
717 * be the current window and buffer, and then interprets keystrokes.
718 * Keystroke interpretation involves mapping, states, commands, and
719 * all that stuff.
720 */
721 MAPSTATE eventkeys(gw, key, nkeys)
722 GUIWIN *gw; /* GUI's handle for window that received keypress event */
723 CHAR *key; /* array of ASCII characters from key */
724 int nkeys; /* number of ASCII characters */
725 {
726 MAPSTATE mapstate;
727 WATCH(fprintf(stderr, "eventkeys(..., key={%d, ...}, nkeys=%d)\n", key[0], nkeys));
728 USUAL_SUSPECTS
729 eventcounter++;
730
731 /* reset the poll frequency counter */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
732 guipoll(ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
733 bufmsgtype = MSG_STATUS;
734
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
735 /* Use the options for this window */
736 eventfocus(gw, ElvTrue);
737 if (windefault)
738 o_eventcounter(windefault) = eventcounter;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
739
740 /* send the keys through the mapper */
741 mapstate = mapdo(key, nkeys);
742 USUAL_SUSPECTS
743 return mapstate;
744 }
745
746
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
747 /* This scrolls the screen, and returns ElvTrue if successful. The screen's
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
748 * image won't be adjusted to reflect this, though, until the next eventdraw().
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
749 * This function is intended mostly to be used for processing mouse clicks on
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
750 * the scrollbar. It may also be useful for mouse draw-through operations
751 * in which the mouse is dragged off the edge of the screen.
752 */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
753 ELVBOOL eventscroll(gw, scroll, count, denom)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
754 GUIWIN *gw; /* GUI's handle for window to be scrolled */
755 SCROLL scroll; /* type of scrolling to perform */
756 long count; /* amount to scroll */
757 long denom; /* scrollbar height, for moving the "thumb" */
758 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
759 #ifndef FEATURE_MISC
760 return ElvFalse;
761 #else
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
762 WINDOW win = winofgw(gw);
763 VIINFO cmd;
764 RESULT result;
765 long origoffset;
766 long newoffset;
767
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
768 WATCH(fprintf(stderr, "eventscroll(..., %d, %ld, %ld)\n", scroll, count, denom));
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
769 USUAL_SUSPECTS
770 assert(win != NULL && (count > 0 || (count == 0 && scroll == SCROLL_PERCENT)));
771 eventcounter++;
772
773 /* reset the poll frequency counter */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
774 guipoll(ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
775
776 /* if window is in open mode, this fails */
777 if (win->state->flags & ELVIS_BOTTOM)
778 {
779 msg(MSG_WARNING, "not while in open mode");
780 USUAL_SUSPECTS
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
781 return ElvFalse;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
782 }
783
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
784 /* Use the options for this window */
785 eventfocus(gw, ElvTrue);
786 if (windefault)
787 o_eventcounter(windefault) = eventcounter;
788
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
789 /* remember the cursor's original offset */
790 origoffset = markoffset(win->state->cursor);
791
792 /* build & execute a vi command */
793 cmd.count = count;
794 switch (scroll)
795 {
796 case SCROLL_BACKSCR:
797 cmd.command = ELVCTRL('B');
798 result = m_scroll(win, &cmd);
799 break;
800
801 case SCROLL_FWDSCR:
802 cmd.command = ELVCTRL('F');
803 result = m_scroll(win, &cmd);
804 break;
805
806 case SCROLL_FWDLN:
807 cmd.command = ELVCTRL('E');
808 result = m_scroll(win, &cmd);
809 break;
810
811 case SCROLL_BACKLN:
812 cmd.command = ELVCTRL('Y');
813 result = m_scroll(win, &cmd);
814 break;
815
816 case SCROLL_COLUMN:
817 cmd.command = ELVCTRL('|');
818 result = m_column(win, &cmd);
819 break;
820
821 case SCROLL_PERCENT:
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
822 if (o_buflines(markbuffer(win->cursor)) == 0L)
823 {
824 /* do nothing */
825 }
826 else if (count > 0 && o_buflines(markbuffer(win->cursor)) > 0L)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
827 {
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
828 if (win->md->move == dmnormal.move && denom != 0)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
829 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
830 /* Prescale so we don't overflow 32-bit math */
831 while (0x7fffffff / o_bufchars(markbuffer(win->cursor)) < count)
832 {
833 count >>= 1;
834 denom >>= 1;
835 }
836
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
837 cmd.command = 'G';
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
838 cmd.count = 1 + o_buflines(markbuffer(win->cursor)) * count / denom;
839 if (cmd.count > o_buflines(markbuffer(win->cursor)))
840 cmd.count = o_buflines(markbuffer(win->cursor));
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
841 result = m_absolute(win, &cmd);
842 }
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
843 else if (o_bufchars(markbuffer(win->cursor)) == denom)
844 {
845 /* Move the cursor by setting its offset */
846 marksetoffset(win->cursor, count);
847 result = RESULT_COMPLETE;
848 }
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
849 else
850 {
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
851 /* Prescale so we don't overflow 32-bit math */
852 while (0x7fffffff / o_bufchars(markbuffer(win->cursor)) < count)
853 {
854 count >>= 1;
855 denom >>= 1;
856 }
857
858 /* Move the cursor by setting its offset */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
859 if (o_bufchars(markbuffer(win->cursor)) != 0)
860 marksetoffset(win->cursor, (o_bufchars(markbuffer(win->cursor)) - 1) * count / denom);
861 result = RESULT_COMPLETE;
862 }
863 if (result == RESULT_COMPLETE)
864 {
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
865 /* Scroll the cursor's line to top of window */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
866 cmd.count = cmd.count2 = 0L;
867 cmd.command = 'z';
868 cmd.key2 = '+';
869 result = m_z(win, &cmd);
870 if (result == RESULT_COMPLETE)
871 {
872 cmd.count = win->wantcol + 1;
873 cmd.command = ELVCTRL('|');
874 result = m_column(win, &cmd);
875 }
876 }
877 }
878 else
879 {
880 cmd.command = ELVCTRL('G');
881 cmd.count = 1L;
882 result = m_absolute(win, &cmd);
883 }
884 break;
885
886 case SCROLL_LINE:
887 cmd.command = 'G';
888 result = m_absolute(win, &cmd);
889 break;
890 }
891
892 /* Now we need to get clever about moving the cursor, due to the
893 * possibility of superfluous text after the old cursor position
894 * if we happened to be in input mode. Force the cursor back to
895 * its old offset, and then use setcursor() to move it to its new
896 * offset in an input-mode-sensitive way.
897 */
898 newoffset = markoffset(win->state->cursor);
899 marksetoffset(win->state->cursor, origoffset);
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
900 setcursor(win, newoffset, ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
901
902 USUAL_SUSPECTS
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
903 return ElvTrue;
904 #endif /* FEATURE_MISC */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
905 }
906
907
908 /* This function is called by the GUI when the user wants to suspend elvis */
909 void eventsuspend()
910 {
911 BUFFER buf;
912 WINDOW win;
913 eventcounter++;
914
915 USUAL_SUSPECTS
916
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
917 /* if autowrite is ElvFalse, then do nothing */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
918 if (!o_autowrite)
919 return;
920
921 /* If there is superfluous text after any cursor, delete it */
922 for (win = winofbuf(NULL, NULL); win; win = winofbuf(win, NULL))
923 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
924 setcursor(win, markoffset(win->state->cursor), ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
925 }
926
927 /* save all user buffers */
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
928 for (buf = elvis_buffers; buf; buf = buf->next)
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
929 {
930 if (!o_internal(buf))
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
931 bufsave(buf, ElvFalse, ElvFalse);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
932 }
933
934 USUAL_SUSPECTS
935 }
936
937 /* This function is called to execute ex command lines. This may be a result
938 * of selecting a menu item, clicking a button, or something else. If the
939 * command comes from an unreliable source (outside the process) then it should
940 * be executed with the "safer" flag set, for security.
941 */
942 void eventex(gw, cmd, safer)
943 GUIWIN *gw; /* window where command should be run */
944 char *cmd; /* an ex command to execute */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
945 ELVBOOL safer; /* temporarily set security=safer? */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
946 {
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
947 CHAR origsecurity;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
948
8d1ac0c1 »
2011-12-10 Import Elvis 2.1 (written by Steve Kirkendall)
949 eventcounter++;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
950 USUAL_SUSPECTS
951
952 /* reset the poll frequency counter */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
953 guipoll(ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
954 bufmsgtype = MSG_STATUS;
955
956 /* temporarily set the "safer" option appropriately */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
957 origsecurity = o_security;
958 if (safer && o_security == 'n'/* normal */)
959 o_security = 's' /* safer */;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
960
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
961 /* Use this window's options while executing the command. Note that
962 * we don't necessarily assume this window has input focus.
963 */
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
964 winoptions(winofgw(gw));
965
966 /* If there is superfluous text after the cursor, delete it */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
967 setcursor(windefault, markoffset(windefault->state->cursor), ElvTrue);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
968
969 /* execute the command */
3a9bb556 »
2011-12-10 Import Elvis 2.1_3 (written by Steve Kirkendall)
970 exstring(windefault, toCHAR(cmd), "gui");
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
971
972 /* update the state as though a key had just been pressed */
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
973 (void)statekey((_CHAR_)-1);
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
974
9f1c6f0f »
2011-12-10 Import Elvis 2.2_0 (written by Steve Kirkendall)
975 /* restore the "security" option */
976 o_security = origsecurity;
cf92e3be »
2011-12-10 Import Elvis 2.0 (written by Steve Kirkendall)
977
978 USUAL_SUSPECTS
979 }
Something went wrong with that request. Please try again.