Fix how keywords are picked up.
[nvi.git] / cl / cl_funcs.c
blobadc109ad9d06ac7d8a4acaabb252deaf21f77617
1 /*-
2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 static const char sccsid[] = "$Id: cl_funcs.c,v 10.72 2002/03/02 23:18:33 skimo Exp $ (Berkeley) $Date: 2002/03/02 23:18:33 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
18 #include <sys/time.h>
20 #include <bitstring.h>
21 #include <ctype.h>
22 #include <signal.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <termios.h>
27 #include <unistd.h>
29 #include "../common/common.h"
30 #include "../vi/vi.h"
31 #include "cl.h"
33 static void cl_rdiv __P((SCR *));
35 static int
36 addstr4(SCR *sp, void *str, size_t len, int wide)
38 CL_PRIVATE *clp;
39 WINDOW *win;
40 size_t y, x;
41 int iv;
43 clp = CLP(sp);
44 win = CLSP(sp) ? CLSP(sp) : stdscr;
47 * If ex isn't in control, it's the last line of the screen and
48 * it's a split screen, use inverse video.
50 iv = 0;
51 getyx(win, y, x);
52 if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
53 y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
54 iv = 1;
55 (void)wstandout(win);
58 #ifdef USE_WIDECHAR
59 if (wide) {
60 if (waddnwstr(win, str, len) == ERR)
61 return (1);
62 } else
63 #endif
64 if (waddnstr(win, str, len) == ERR)
65 return (1);
67 if (iv)
68 (void)wstandend(win);
69 return (0);
73 * cl_waddstr --
74 * Add len bytes from the string at the cursor, advancing the cursor.
76 * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
78 int
79 cl_waddstr(SCR *sp, const CHAR_T *str, size_t len)
81 return addstr4(sp, (void *)str, len, 1);
85 * cl_addstr --
86 * Add len bytes from the string at the cursor, advancing the cursor.
88 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
90 int
91 cl_addstr(SCR *sp, const char *str, size_t len)
93 return addstr4(sp, (void *)str, len, 0);
97 * cl_attr --
98 * Toggle a screen attribute on/off.
100 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
103 cl_attr(SCR *sp, scr_attr_t attribute, int on)
105 CL_PRIVATE *clp;
106 WINDOW *win;
108 clp = CLP(sp);
109 win = CLSP(sp) ? CLSP(sp) : stdscr;
111 switch (attribute) {
112 case SA_ALTERNATE:
114 * !!!
115 * There's a major layering violation here. The problem is that the
116 * X11 xterm screen has what's known as an "alternate" screen. Some
117 * xterm termcap/terminfo entries include sequences to switch to/from
118 * that alternate screen as part of the ti/te (smcup/rmcup) strings.
119 * Vi runs in the alternate screen, so that you are returned to the
120 * same screen contents on exit from vi that you had when you entered
121 * vi. Further, when you run :shell, or :!date or similar ex commands,
122 * you also see the original screen contents. This wasn't deliberate
123 * on vi's part, it's just that it historically sent terminal init/end
124 * sequences at those times, and the addition of the alternate screen
125 * sequences to the strings changed the behavior of vi. The problem
126 * caused by this is that we don't want to switch back to the alternate
127 * screen while getting a new command from the user, when the user is
128 * continuing to enter ex commands, e.g.:
130 * :!date <<< switch to original screen
131 * [Hit return to continue] <<< prompt user to continue
132 * :command <<< get command from user
134 * Note that the :command input is a true vi input mode, e.g., input
135 * maps and abbreviations are being done. So, we need to be able to
136 * switch back into the vi screen mode, without flashing the screen.
138 * To make matters worse, the curses initscr() and endwin() calls will
139 * do this automatically -- so, this attribute isn't as controlled by
140 * the higher level screen as closely as one might like.
142 if (on) {
143 if (clp->ti_te != TI_SENT) {
144 clp->ti_te = TI_SENT;
145 if (clp->smcup == NULL)
146 (void)cl_getcap(sp, "smcup", &clp->smcup);
147 if (clp->smcup != NULL)
148 (void)tputs(clp->smcup, 1, cl_putchar);
150 } else
151 if (clp->ti_te != TE_SENT) {
152 clp->ti_te = TE_SENT;
153 if (clp->rmcup == NULL)
154 (void)cl_getcap(sp, "rmcup", &clp->rmcup);
155 if (clp->rmcup != NULL)
156 (void)tputs(clp->rmcup, 1, cl_putchar);
157 (void)fflush(stdout);
159 (void)fflush(stdout);
160 break;
161 case SA_INVERSE:
162 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
163 if (clp->smso == NULL)
164 return (1);
165 if (on)
166 (void)tputs(clp->smso, 1, cl_putchar);
167 else
168 (void)tputs(clp->rmso, 1, cl_putchar);
169 (void)fflush(stdout);
170 } else {
171 if (on)
172 (void)wstandout(win);
173 else
174 (void)wstandend(win);
176 break;
177 default:
178 abort();
180 return (0);
184 * cl_baud --
185 * Return the baud rate.
187 * PUBLIC: int cl_baud __P((SCR *, u_long *));
190 cl_baud(SCR *sp, u_long *ratep)
192 CL_PRIVATE *clp;
195 * XXX
196 * There's no portable way to get a "baud rate" -- cfgetospeed(3)
197 * returns the value associated with some #define, which we may
198 * never have heard of, or which may be a purely local speed. Vi
199 * only cares if it's SLOW (w300), slow (w1200) or fast (w9600).
200 * Try and detect the slow ones, and default to fast.
202 clp = CLP(sp);
203 switch (cfgetospeed(&clp->orig)) {
204 case B50:
205 case B75:
206 case B110:
207 case B134:
208 case B150:
209 case B200:
210 case B300:
211 case B600:
212 *ratep = 600;
213 break;
214 case B1200:
215 *ratep = 1200;
216 break;
217 default:
218 *ratep = 9600;
219 break;
221 return (0);
225 * cl_bell --
226 * Ring the bell/flash the screen.
228 * PUBLIC: int cl_bell __P((SCR *));
231 cl_bell(SCR *sp)
233 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
234 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
235 else {
237 * Vi has an edit option which determines if the terminal
238 * should be beeped or the screen flashed.
240 if (O_ISSET(sp, O_FLASH))
241 (void)flash();
242 else
243 (void)beep();
245 return (0);
249 * cl_clrtoeol --
250 * Clear from the current cursor to the end of the line.
252 * PUBLIC: int cl_clrtoeol __P((SCR *));
255 cl_clrtoeol(SCR *sp)
257 WINDOW *win;
258 size_t spcnt, y, x;
260 win = CLSP(sp) ? CLSP(sp) : stdscr;
262 #if 0
263 if (IS_VSPLIT(sp)) {
264 /* The cursor must be returned to its original position. */
265 getyx(win, y, x);
266 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
267 (void)waddch(win, ' ');
268 (void)wmove(win, y, x);
269 return (0);
270 } else
271 #endif
272 return (wclrtoeol(win) == ERR);
276 * cl_cursor --
277 * Return the current cursor position.
279 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
282 cl_cursor(SCR *sp, size_t *yp, size_t *xp)
284 WINDOW *win;
285 win = CLSP(sp) ? CLSP(sp) : stdscr;
287 * The curses screen support splits a single underlying curses screen
288 * into multiple screens to support split screen semantics. For this
289 * reason the returned value must be adjusted to be relative to the
290 * current screen, and not absolute. Screens that implement the split
291 * using physically distinct screens won't need this hack.
293 getyx(win, *yp, *xp);
295 *yp -= sp->roff;
296 *xp -= sp->coff;
298 return (0);
302 * cl_deleteln --
303 * Delete the current line, scrolling all lines below it.
305 * PUBLIC: int cl_deleteln __P((SCR *));
308 cl_deleteln(SCR *sp)
310 CHAR_T ch;
311 CL_PRIVATE *clp;
312 WINDOW *win;
313 size_t col, lno, spcnt, y, x;
315 clp = CLP(sp);
316 win = CLSP(sp) ? CLSP(sp) : stdscr;
319 * This clause is required because the curses screen uses reverse
320 * video to delimit split screens. If the screen does not do this,
321 * this code won't be necessary.
323 * If the bottom line was in reverse video, rewrite it in normal
324 * video before it's scrolled.
326 * Check for the existence of a chgat function; XSI requires it, but
327 * historic implementations of System V curses don't. If it's not
328 * a #define, we'll fall back to doing it by hand, which is slow but
329 * acceptable.
331 * By hand means walking through the line, retrieving and rewriting
332 * each character. Curses has no EOL marker, so track strings of
333 * spaces, and copy the trailing spaces only if there's a non-space
334 * character following.
336 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
337 getyx(win, y, x);
338 #ifdef mvchgat
339 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
340 #else
341 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
342 (void)wmove(win, lno, col);
343 ch = winch(win);
344 if (isblank(ch))
345 ++spcnt;
346 else {
347 (void)wmove(win, lno, col - spcnt);
348 for (; spcnt > 0; --spcnt)
349 (void)waddch(win, ' ');
350 (void)waddch(win, ch);
352 if (++col >= sp->cols)
353 break;
355 #endif
356 (void)wmove(win, y, x);
360 * The bottom line is expected to be blank after this operation,
361 * and other screens must support that semantic.
363 return (wdeleteln(win) == ERR);
367 * cl_discard --
368 * Discard a screen.
370 * PUBLIC: int cl_discard __P((SCR *, SCR **));
373 cl_discard(SCR *discardp, SCR **acquirep)
375 CL_PRIVATE *clp;
376 SCR* tsp;
378 if (discardp) {
379 clp = CLP(discardp);
380 F_SET(clp, CL_LAYOUT);
382 if (CLSP(discardp)) {
383 delwin(CLSP(discardp));
384 discardp->cl_private = NULL;
388 /* no screens got a piece; we're done */
389 if (!acquirep)
390 return 0;
392 for (; (tsp = *acquirep) != NULL; ++acquirep) {
393 clp = CLP(tsp);
394 F_SET(clp, CL_LAYOUT);
396 if (CLSP(tsp))
397 delwin(CLSP(tsp));
398 tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols,
399 tsp->roff, tsp->coff);
402 /* discardp is going away, acquirep is taking up its space. */
403 return (0);
407 * cl_ex_adjust --
408 * Adjust the screen for ex. This routine is purely for standalone
409 * ex programs. All special purpose, all special case.
411 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
414 cl_ex_adjust(SCR *sp, exadj_t action)
416 CL_PRIVATE *clp;
417 int cnt;
419 clp = CLP(sp);
420 switch (action) {
421 case EX_TERM_SCROLL:
422 /* Move the cursor up one line if that's possible. */
423 if (clp->cuu1 != NULL)
424 (void)tputs(clp->cuu1, 1, cl_putchar);
425 else if (clp->cup != NULL)
426 (void)tputs(tgoto(clp->cup,
427 0, LINES - 2), 1, cl_putchar);
428 else
429 return (0);
430 /* FALLTHROUGH */
431 case EX_TERM_CE:
432 /* Clear the line. */
433 if (clp->el != NULL) {
434 (void)putchar('\r');
435 (void)tputs(clp->el, 1, cl_putchar);
436 } else {
438 * Historically, ex didn't erase the line, so, if the
439 * displayed line was only a single glyph, and <eof>
440 * was more than one glyph, the output would not fully
441 * overwrite the user's input. To fix this, output
442 * the maxiumum character number of spaces. Note,
443 * this won't help if the user entered extra prompt
444 * or <blank> characters before the command character.
445 * We'd have to do a lot of work to make that work, and
446 * it's almost certainly not worth the effort.
448 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
449 (void)putchar('\b');
450 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
451 (void)putchar(' ');
452 (void)putchar('\r');
453 (void)fflush(stdout);
455 break;
456 default:
457 abort();
459 return (0);
463 * cl_insertln --
464 * Push down the current line, discarding the bottom line.
466 * PUBLIC: int cl_insertln __P((SCR *));
469 cl_insertln(SCR *sp)
471 WINDOW *win;
472 win = CLSP(sp) ? CLSP(sp) : stdscr;
474 * The current line is expected to be blank after this operation,
475 * and the screen must support that semantic.
477 return (winsertln(win) == ERR);
481 * cl_keyval --
482 * Return the value for a special key.
484 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
487 cl_keyval(SCR *sp, scr_keyval_t val, CHAR_T *chp, int *dnep)
489 CL_PRIVATE *clp;
492 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
493 * VWERASE is a 4BSD extension.
495 clp = CLP(sp);
496 switch (val) {
497 case KEY_VEOF:
498 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
499 break;
500 case KEY_VERASE:
501 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
502 break;
503 case KEY_VKILL:
504 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
505 break;
506 #ifdef VWERASE
507 case KEY_VWERASE:
508 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
509 break;
510 #endif
511 default:
512 *dnep = 1;
513 break;
515 return (0);
519 * cl_move --
520 * Move the cursor.
522 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
525 cl_move(SCR *sp, size_t lno, size_t cno)
527 WINDOW *win;
528 win = CLSP(sp) ? CLSP(sp) : stdscr;
529 /* See the comment in cl_cursor. */
530 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
531 msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)",
532 lno, sp->roff, cno, sp->coff);
533 return (1);
535 return (0);
539 * cl_refresh --
540 * Refresh the screen.
542 * PUBLIC: int cl_refresh __P((SCR *, int));
545 cl_refresh(SCR *sp, int repaint)
547 GS *gp;
548 CL_PRIVATE *clp;
549 WINDOW *win;
550 SCR *psp, *tsp;
551 size_t y, x;
553 gp = sp->gp;
554 clp = CLP(sp);
555 win = CLSP(sp) ? CLSP(sp) : stdscr;
558 * If we received a killer signal, we're done, there's no point
559 * in refreshing the screen.
561 if (clp->killersig)
562 return (0);
565 * If repaint is set, the editor is telling us that we don't know
566 * what's on the screen, so we have to repaint from scratch.
568 * If repaint set or the screen layout changed, we need to redraw
569 * any lines separating vertically split screens. If the horizontal
570 * offsets are the same, then the split was vertical, and need to
571 * draw a dividing line.
573 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
574 getyx(stdscr, y, x);
575 for (psp = sp;
576 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
577 for (tsp = psp->q.cqe_next;
578 tsp != (void *)&sp->wp->scrq;
579 tsp = tsp->q.cqe_next)
580 if (psp->roff == tsp->roff) {
581 if (psp->coff + psp->cols + 1 == tsp->coff)
582 cl_rdiv(psp);
583 else
584 if (tsp->coff + tsp->cols + 1 == psp->coff)
585 cl_rdiv(tsp);
587 (void)wmove(stdscr, y, x);
588 F_CLR(clp, CL_LAYOUT);
592 * In the curses library, doing wrefresh(curscr) is okay, but the
593 * screen flashes when we then apply the refresh() to bring it up
594 * to date. So, use clearok().
596 if (repaint)
597 clearok(curscr, 1);
599 * Only do an actual refresh, when this is the focus window,
600 * i.e. the one holding the cursor. This assumes that refresh
601 * is called for that window after refreshing the others.
602 * This prevents the cursor being drawn in the other windows.
604 return (wnoutrefresh(stdscr) == ERR ||
605 wnoutrefresh(win) == ERR ||
606 (sp == clp->focus && doupdate() == ERR));
610 * cl_rdiv --
611 * Draw a dividing line between two vertically split screens.
613 static void
614 cl_rdiv(SCR *sp)
616 size_t cnt;
618 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
619 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
620 waddch(stdscr, '|');
625 * cl_rename --
626 * Rename the file.
628 * PUBLIC: int cl_rename __P((SCR *, char *, int));
631 cl_rename(SCR *sp, char *name, int on)
633 CL_PRIVATE *clp;
634 FILE *pfp;
635 GS *gp;
636 char buf[256], *p;
638 gp = sp->gp;
639 clp = CLP(sp);
641 if (on) {
642 clp->focus = sp;
643 if (!F_ISSET(clp, CL_RENAME_OK))
644 return (0);
647 * XXX
648 * We can only rename windows for xterm.
650 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
651 return (0);
654 * XXX
655 * Try and figure out the current name of this window. There
656 * are two forms of the xwininfo output I've seen:
658 * Window id: 0x400000d "name"
659 * Window id: 0x140000d (name)
661 #define COMMAND \
662 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
664 if (clp->oname == NULL &&
665 (pfp = popen(COMMAND, "r")) != NULL) {
666 if (fgets(buf, sizeof(buf), pfp) != NULL &&
667 (p = strchr(buf, '\n')) != NULL) {
668 *p = '\0';
669 clp->oname = strdup(buf);
671 (void)fclose(pfp);
674 cl_setname(gp, name);
676 F_SET(clp, CL_RENAME);
677 } else
678 if (F_ISSET(clp, CL_RENAME)) {
679 cl_setname(gp, clp->oname);
681 F_CLR(clp, CL_RENAME);
683 return (0);
687 * cl_setname --
688 * Set a X11 icon/window name.
690 * PUBLIC: void cl_setname __P((GS *, char *));
692 void
693 cl_setname(GS *gp, char *name)
695 /* X11 xterm escape sequence to rename the icon/window. */
696 #define XTERM_RENAME "\033]0;%s\007"
698 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
699 (void)fflush(stdout);
703 * cl_split --
704 * Split a screen.
706 * PUBLIC: int cl_split __P((SCR *, SCR *));
709 cl_split(SCR *origp, SCR *newp)
711 CL_PRIVATE *clp;
713 clp = CLP(origp);
714 F_SET(clp, CL_LAYOUT);
716 if (CLSP(origp))
717 delwin(CLSP(origp));
719 origp->cl_private = subwin(stdscr, origp->rows, origp->cols,
720 origp->roff, origp->coff);
721 newp->cl_private = subwin(stdscr, newp->rows, newp->cols,
722 newp->roff, newp->coff);
724 /* origp is the original screen, giving up space to newp. */
725 return (0);
729 * cl_suspend --
730 * Suspend a screen.
732 * PUBLIC: int cl_suspend __P((SCR *, int *));
735 cl_suspend(SCR *sp, int *allowedp)
737 struct termios t;
738 CL_PRIVATE *clp;
739 WINDOW *win;
740 GS *gp;
741 size_t y, x;
742 int changed;
744 gp = sp->gp;
745 clp = CLP(sp);
746 win = CLSP(sp) ? CLSP(sp) : stdscr;
747 *allowedp = 1;
750 * The ex implementation of this function isn't needed by screens not
751 * supporting ex commands that require full terminal canonical mode
752 * (e.g. :suspend).
754 * The vi implementation of this function isn't needed by screens not
755 * supporting vi process suspension, i.e. any screen that isn't backed
756 * by a UNIX shell.
758 * Setting allowedp to 0 will cause the editor to reject the command.
760 if (F_ISSET(sp, SC_EX)) {
761 /* Save the terminal settings, and restore the original ones. */
762 if (F_ISSET(clp, CL_STDIN_TTY)) {
763 (void)tcgetattr(STDIN_FILENO, &t);
764 (void)tcsetattr(STDIN_FILENO,
765 TCSASOFT | TCSADRAIN, &clp->orig);
768 /* Stop the process group. */
769 (void)kill(0, SIGTSTP);
771 /* Time passes ... */
773 /* Restore terminal settings. */
774 if (F_ISSET(clp, CL_STDIN_TTY))
775 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
776 return (0);
780 * Move to the lower left-hand corner of the screen.
782 * XXX
783 * Not sure this is necessary in System V implementations, but it
784 * shouldn't hurt.
786 getyx(win, y, x);
787 (void)wmove(win, LINES - 1, 0);
788 (void)wrefresh(win);
791 * Temporarily end the screen. System V introduced a semantic where
792 * endwin() could be restarted. We use it because restarting curses
793 * from scratch often fails in System V. 4BSD curses didn't support
794 * restarting after endwin(), so we have to do what clean up we can
795 * without calling it.
797 /* Save the terminal settings. */
798 (void)tcgetattr(STDIN_FILENO, &t);
800 /* Restore the cursor keys to normal mode. */
801 (void)keypad(stdscr, FALSE);
803 /* Restore the window name. */
804 (void)cl_rename(sp, NULL, 0);
806 #ifdef HAVE_BSD_CURSES
807 (void)cl_attr(sp, SA_ALTERNATE, 0);
808 #else
809 (void)endwin();
810 #endif
812 * XXX
813 * Restore the original terminal settings. This is bad -- the
814 * reset can cause character loss from the tty queue. However,
815 * we can't call endwin() in BSD curses implementations, and too
816 * many System V curses implementations don't get it right.
818 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
820 /* Stop the process group. */
821 (void)kill(0, SIGTSTP);
823 /* Time passes ... */
826 * If we received a killer signal, we're done. Leave everything
827 * unchanged. In addition, the terminal has already been reset
828 * correctly, so leave it alone.
830 if (clp->killersig) {
831 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
832 return (0);
835 /* Restore terminal settings. */
836 wrefresh(win); /* Needed on SunOs/Solaris ? */
837 if (F_ISSET(clp, CL_STDIN_TTY))
838 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
840 #ifdef HAVE_BSD_CURSES
841 (void)cl_attr(sp, SA_ALTERNATE, 1);
842 #endif
844 /* Set the window name. */
845 (void)cl_rename(sp, sp->frp->name, 1);
847 /* Put the cursor keys into application mode. */
848 (void)keypad(stdscr, TRUE);
850 /* Refresh and repaint the screen. */
851 (void)wmove(win, y, x);
852 (void)cl_refresh(sp, 1);
854 /* If the screen changed size, set the SIGWINCH bit. */
855 if (cl_ssize(sp, 1, NULL, NULL, &changed))
856 return (1);
857 if (changed)
858 F_SET(CLP(sp), CL_SIGWINCH);
860 return (0);
864 * cl_usage --
865 * Print out the curses usage messages.
867 * PUBLIC: void cl_usage __P((void));
869 void
870 cl_usage(void)
872 #define USAGE "\
873 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
874 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
875 (void)fprintf(stderr, "%s", USAGE);
876 #undef USAGE
879 #ifdef DEBUG
881 * gdbrefresh --
882 * Stub routine so can flush out curses screen changes using gdb.
885 gdbrefresh(void)
887 refresh();
888 return (0); /* XXX Convince gdb to run it. */
890 #endif