include sys/select.h before ex/extern.h
[nvi.git] / cl / cl_funcs.c
blobb82f658d88a70a58b90f831c01a2a88f80ca974e
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 #ifdef HAVE_TERM_H
27 #include <term.h>
28 #endif
29 #include <termios.h>
30 #include <unistd.h>
32 #include "../common/common.h"
33 #include "../vi/vi.h"
34 #include "cl.h"
36 static void cl_rdiv __P((SCR *));
38 static int
39 addstr4(SCR *sp, void *str, size_t len, int wide)
41 CL_PRIVATE *clp;
42 WINDOW *win;
43 size_t y, x;
44 int iv;
46 clp = CLP(sp);
47 win = CLSP(sp) ? CLSP(sp) : stdscr;
50 * If ex isn't in control, it's the last line of the screen and
51 * it's a split screen, use inverse video.
53 iv = 0;
54 getyx(win, y, x);
55 if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
56 y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
57 iv = 1;
58 (void)wstandout(win);
61 #ifdef USE_WIDECHAR
62 if (wide) {
63 if (waddnwstr(win, str, len) == ERR)
64 return (1);
65 } else
66 #endif
67 if (waddnstr(win, str, len) == ERR)
68 return (1);
70 if (iv)
71 (void)wstandend(win);
72 return (0);
76 * cl_waddstr --
77 * Add len bytes from the string at the cursor, advancing the cursor.
79 * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
81 int
82 cl_waddstr(SCR *sp, const CHAR_T *str, size_t len)
84 return addstr4(sp, (void *)str, len, 1);
88 * cl_addstr --
89 * Add len bytes from the string at the cursor, advancing the cursor.
91 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
93 int
94 cl_addstr(SCR *sp, const char *str, size_t len)
96 return addstr4(sp, (void *)str, len, 0);
100 * cl_attr --
101 * Toggle a screen attribute on/off.
103 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
106 cl_attr(SCR *sp, scr_attr_t attribute, int on)
108 CL_PRIVATE *clp;
109 WINDOW *win;
111 clp = CLP(sp);
112 win = CLSP(sp) ? CLSP(sp) : stdscr;
114 switch (attribute) {
115 case SA_ALTERNATE:
117 * !!!
118 * There's a major layering violation here. The problem is that the
119 * X11 xterm screen has what's known as an "alternate" screen. Some
120 * xterm termcap/terminfo entries include sequences to switch to/from
121 * that alternate screen as part of the ti/te (smcup/rmcup) strings.
122 * Vi runs in the alternate screen, so that you are returned to the
123 * same screen contents on exit from vi that you had when you entered
124 * vi. Further, when you run :shell, or :!date or similar ex commands,
125 * you also see the original screen contents. This wasn't deliberate
126 * on vi's part, it's just that it historically sent terminal init/end
127 * sequences at those times, and the addition of the alternate screen
128 * sequences to the strings changed the behavior of vi. The problem
129 * caused by this is that we don't want to switch back to the alternate
130 * screen while getting a new command from the user, when the user is
131 * continuing to enter ex commands, e.g.:
133 * :!date <<< switch to original screen
134 * [Hit return to continue] <<< prompt user to continue
135 * :command <<< get command from user
137 * Note that the :command input is a true vi input mode, e.g., input
138 * maps and abbreviations are being done. So, we need to be able to
139 * switch back into the vi screen mode, without flashing the screen.
141 * To make matters worse, the curses initscr() and endwin() calls will
142 * do this automatically -- so, this attribute isn't as controlled by
143 * the higher level screen as closely as one might like.
145 if (on) {
146 if (clp->ti_te != TI_SENT) {
147 clp->ti_te = TI_SENT;
148 if (clp->smcup == NULL)
149 (void)cl_getcap(sp, "smcup", &clp->smcup);
150 if (clp->smcup != NULL)
151 (void)tputs(clp->smcup, 1, cl_putchar);
153 } else
154 if (clp->ti_te != TE_SENT) {
155 clp->ti_te = TE_SENT;
156 if (clp->rmcup == NULL)
157 (void)cl_getcap(sp, "rmcup", &clp->rmcup);
158 if (clp->rmcup != NULL)
159 (void)tputs(clp->rmcup, 1, cl_putchar);
160 (void)fflush(stdout);
162 (void)fflush(stdout);
163 break;
164 case SA_INVERSE:
165 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
166 if (clp->smso == NULL)
167 return (1);
168 if (on)
169 (void)tputs(clp->smso, 1, cl_putchar);
170 else
171 (void)tputs(clp->rmso, 1, cl_putchar);
172 (void)fflush(stdout);
173 } else {
174 if (on)
175 (void)wstandout(win);
176 else
177 (void)wstandend(win);
179 break;
180 default:
181 abort();
183 return (0);
187 * cl_baud --
188 * Return the baud rate.
190 * PUBLIC: int cl_baud __P((SCR *, u_long *));
193 cl_baud(SCR *sp, u_long *ratep)
195 CL_PRIVATE *clp;
198 * XXX
199 * There's no portable way to get a "baud rate" -- cfgetospeed(3)
200 * returns the value associated with some #define, which we may
201 * never have heard of, or which may be a purely local speed. Vi
202 * only cares if it's SLOW (w300), slow (w1200) or fast (w9600).
203 * Try and detect the slow ones, and default to fast.
205 clp = CLP(sp);
206 switch (cfgetospeed(&clp->orig)) {
207 case B50:
208 case B75:
209 case B110:
210 case B134:
211 case B150:
212 case B200:
213 case B300:
214 case B600:
215 *ratep = 600;
216 break;
217 case B1200:
218 *ratep = 1200;
219 break;
220 default:
221 *ratep = 9600;
222 break;
224 return (0);
228 * cl_bell --
229 * Ring the bell/flash the screen.
231 * PUBLIC: int cl_bell __P((SCR *));
234 cl_bell(SCR *sp)
236 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
237 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
238 else {
240 * Vi has an edit option which determines if the terminal
241 * should be beeped or the screen flashed.
243 if (O_ISSET(sp, O_FLASH))
244 (void)flash();
245 else
246 (void)beep();
248 return (0);
252 * cl_clrtoeol --
253 * Clear from the current cursor to the end of the line.
255 * PUBLIC: int cl_clrtoeol __P((SCR *));
258 cl_clrtoeol(SCR *sp)
260 WINDOW *win;
261 size_t spcnt, y, x;
263 win = CLSP(sp) ? CLSP(sp) : stdscr;
265 #if 0
266 if (IS_VSPLIT(sp)) {
267 /* The cursor must be returned to its original position. */
268 getyx(win, y, x);
269 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
270 (void)waddch(win, ' ');
271 (void)wmove(win, y, x);
272 return (0);
273 } else
274 #endif
275 return (wclrtoeol(win) == ERR);
279 * cl_cursor --
280 * Return the current cursor position.
282 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
285 cl_cursor(SCR *sp, size_t *yp, size_t *xp)
287 WINDOW *win;
288 win = CLSP(sp) ? CLSP(sp) : stdscr;
290 * The curses screen support splits a single underlying curses screen
291 * into multiple screens to support split screen semantics. For this
292 * reason the returned value must be adjusted to be relative to the
293 * current screen, and not absolute. Screens that implement the split
294 * using physically distinct screens won't need this hack.
296 getyx(win, *yp, *xp);
298 *yp -= sp->roff;
299 *xp -= sp->coff;
301 return (0);
305 * cl_deleteln --
306 * Delete the current line, scrolling all lines below it.
308 * PUBLIC: int cl_deleteln __P((SCR *));
311 cl_deleteln(SCR *sp)
313 CHAR_T ch;
314 CL_PRIVATE *clp;
315 WINDOW *win;
316 size_t col, lno, spcnt, y, x;
318 clp = CLP(sp);
319 win = CLSP(sp) ? CLSP(sp) : stdscr;
322 * This clause is required because the curses screen uses reverse
323 * video to delimit split screens. If the screen does not do this,
324 * this code won't be necessary.
326 * If the bottom line was in reverse video, rewrite it in normal
327 * video before it's scrolled.
329 * Check for the existence of a chgat function; XSI requires it, but
330 * historic implementations of System V curses don't. If it's not
331 * a #define, we'll fall back to doing it by hand, which is slow but
332 * acceptable.
334 * By hand means walking through the line, retrieving and rewriting
335 * each character. Curses has no EOL marker, so track strings of
336 * spaces, and copy the trailing spaces only if there's a non-space
337 * character following.
339 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
340 getyx(win, y, x);
341 #ifdef mvchgat
342 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
343 #else
344 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
345 (void)wmove(win, lno, col);
346 ch = winch(win);
347 if (isblank(ch))
348 ++spcnt;
349 else {
350 (void)wmove(win, lno, col - spcnt);
351 for (; spcnt > 0; --spcnt)
352 (void)waddch(win, ' ');
353 (void)waddch(win, ch);
355 if (++col >= sp->cols)
356 break;
358 #endif
359 (void)wmove(win, y, x);
363 * The bottom line is expected to be blank after this operation,
364 * and other screens must support that semantic.
366 return (wdeleteln(win) == ERR);
370 * cl_discard --
371 * Discard a screen.
373 * PUBLIC: int cl_discard __P((SCR *, SCR **));
376 cl_discard(SCR *discardp, SCR **acquirep)
378 CL_PRIVATE *clp;
379 SCR* tsp;
381 if (discardp) {
382 clp = CLP(discardp);
383 F_SET(clp, CL_LAYOUT);
385 if (CLSP(discardp)) {
386 delwin(CLSP(discardp));
387 discardp->cl_private = NULL;
391 /* no screens got a piece; we're done */
392 if (!acquirep)
393 return 0;
395 for (; (tsp = *acquirep) != NULL; ++acquirep) {
396 clp = CLP(tsp);
397 F_SET(clp, CL_LAYOUT);
399 if (CLSP(tsp))
400 delwin(CLSP(tsp));
401 tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols,
402 tsp->roff, tsp->coff);
405 /* discardp is going away, acquirep is taking up its space. */
406 return (0);
410 * cl_ex_adjust --
411 * Adjust the screen for ex. This routine is purely for standalone
412 * ex programs. All special purpose, all special case.
414 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
417 cl_ex_adjust(SCR *sp, exadj_t action)
419 CL_PRIVATE *clp;
420 int cnt;
422 clp = CLP(sp);
423 switch (action) {
424 case EX_TERM_SCROLL:
425 /* Move the cursor up one line if that's possible. */
426 if (clp->cuu1 != NULL)
427 (void)tputs(clp->cuu1, 1, cl_putchar);
428 else if (clp->cup != NULL)
429 (void)tputs(tgoto(clp->cup,
430 0, LINES - 2), 1, cl_putchar);
431 else
432 return (0);
433 /* FALLTHROUGH */
434 case EX_TERM_CE:
435 /* Clear the line. */
436 if (clp->el != NULL) {
437 (void)putchar('\r');
438 (void)tputs(clp->el, 1, cl_putchar);
439 } else {
441 * Historically, ex didn't erase the line, so, if the
442 * displayed line was only a single glyph, and <eof>
443 * was more than one glyph, the output would not fully
444 * overwrite the user's input. To fix this, output
445 * the maxiumum character number of spaces. Note,
446 * this won't help if the user entered extra prompt
447 * or <blank> characters before the command character.
448 * We'd have to do a lot of work to make that work, and
449 * it's almost certainly not worth the effort.
451 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
452 (void)putchar('\b');
453 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
454 (void)putchar(' ');
455 (void)putchar('\r');
456 (void)fflush(stdout);
458 break;
459 default:
460 abort();
462 return (0);
466 * cl_insertln --
467 * Push down the current line, discarding the bottom line.
469 * PUBLIC: int cl_insertln __P((SCR *));
472 cl_insertln(SCR *sp)
474 WINDOW *win;
475 win = CLSP(sp) ? CLSP(sp) : stdscr;
477 * The current line is expected to be blank after this operation,
478 * and the screen must support that semantic.
480 return (winsertln(win) == ERR);
484 * cl_keyval --
485 * Return the value for a special key.
487 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
490 cl_keyval(SCR *sp, scr_keyval_t val, CHAR_T *chp, int *dnep)
492 CL_PRIVATE *clp;
495 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
496 * VWERASE is a 4BSD extension.
498 clp = CLP(sp);
499 switch (val) {
500 case KEY_VEOF:
501 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
502 break;
503 case KEY_VERASE:
504 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
505 break;
506 case KEY_VKILL:
507 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
508 break;
509 #ifdef VWERASE
510 case KEY_VWERASE:
511 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
512 break;
513 #endif
514 default:
515 *dnep = 1;
516 break;
518 return (0);
522 * cl_move --
523 * Move the cursor.
525 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
528 cl_move(SCR *sp, size_t lno, size_t cno)
530 WINDOW *win;
531 win = CLSP(sp) ? CLSP(sp) : stdscr;
532 /* See the comment in cl_cursor. */
533 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
534 msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)",
535 lno, sp->roff, cno, sp->coff);
536 return (1);
538 return (0);
542 * cl_refresh --
543 * Refresh the screen.
545 * PUBLIC: int cl_refresh __P((SCR *, int));
548 cl_refresh(SCR *sp, int repaint)
550 GS *gp;
551 CL_PRIVATE *clp;
552 WINDOW *win;
553 SCR *psp, *tsp;
554 size_t y, x;
556 gp = sp->gp;
557 clp = CLP(sp);
558 win = CLSP(sp) ? CLSP(sp) : stdscr;
561 * If we received a killer signal, we're done, there's no point
562 * in refreshing the screen.
564 if (clp->killersig)
565 return (0);
568 * If repaint is set, the editor is telling us that we don't know
569 * what's on the screen, so we have to repaint from scratch.
571 * If repaint set or the screen layout changed, we need to redraw
572 * any lines separating vertically split screens. If the horizontal
573 * offsets are the same, then the split was vertical, and need to
574 * draw a dividing line.
576 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
577 getyx(stdscr, y, x);
578 for (psp = sp;
579 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
580 for (tsp = psp->q.cqe_next;
581 tsp != (void *)&sp->wp->scrq;
582 tsp = tsp->q.cqe_next)
583 if (psp->roff == tsp->roff) {
584 if (psp->coff + psp->cols + 1 == tsp->coff)
585 cl_rdiv(psp);
586 else
587 if (tsp->coff + tsp->cols + 1 == psp->coff)
588 cl_rdiv(tsp);
590 (void)wmove(stdscr, y, x);
591 F_CLR(clp, CL_LAYOUT);
595 * In the curses library, doing wrefresh(curscr) is okay, but the
596 * screen flashes when we then apply the refresh() to bring it up
597 * to date. So, use clearok().
599 if (repaint)
600 clearok(curscr, 1);
602 * Only do an actual refresh, when this is the focus window,
603 * i.e. the one holding the cursor. This assumes that refresh
604 * is called for that window after refreshing the others.
605 * This prevents the cursor being drawn in the other windows.
607 return (wnoutrefresh(stdscr) == ERR ||
608 wnoutrefresh(win) == ERR ||
609 (sp == clp->focus && doupdate() == ERR));
613 * cl_rdiv --
614 * Draw a dividing line between two vertically split screens.
616 static void
617 cl_rdiv(SCR *sp)
619 size_t cnt;
621 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
622 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
623 waddch(stdscr, '|');
628 * cl_rename --
629 * Rename the file.
631 * PUBLIC: int cl_rename __P((SCR *, char *, int));
634 cl_rename(SCR *sp, char *name, int on)
636 CL_PRIVATE *clp;
637 FILE *pfp;
638 GS *gp;
639 char buf[256], *p;
641 gp = sp->gp;
642 clp = CLP(sp);
644 if (on) {
645 clp->focus = sp;
646 if (!F_ISSET(clp, CL_RENAME_OK))
647 return (0);
650 * XXX
651 * We can only rename windows for xterm.
653 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
654 return (0);
657 * XXX
658 * Try and figure out the current name of this window. There
659 * are two forms of the xwininfo output I've seen:
661 * Window id: 0x400000d "name"
662 * Window id: 0x140000d (name)
664 #define COMMAND \
665 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
667 if (clp->oname == NULL &&
668 (pfp = popen(COMMAND, "r")) != NULL) {
669 if (fgets(buf, sizeof(buf), pfp) != NULL &&
670 (p = strchr(buf, '\n')) != NULL) {
671 *p = '\0';
672 clp->oname = strdup(buf);
674 (void)fclose(pfp);
677 cl_setname(gp, name);
679 F_SET(clp, CL_RENAME);
680 } else
681 if (F_ISSET(clp, CL_RENAME)) {
682 cl_setname(gp, clp->oname);
684 F_CLR(clp, CL_RENAME);
686 return (0);
690 * cl_setname --
691 * Set a X11 icon/window name.
693 * PUBLIC: void cl_setname __P((GS *, char *));
695 void
696 cl_setname(GS *gp, char *name)
698 /* X11 xterm escape sequence to rename the icon/window. */
699 #define XTERM_RENAME "\033]0;%s\007"
701 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
702 (void)fflush(stdout);
706 * cl_split --
707 * Split a screen.
709 * PUBLIC: int cl_split __P((SCR *, SCR *));
712 cl_split(SCR *origp, SCR *newp)
714 CL_PRIVATE *clp;
716 clp = CLP(origp);
717 F_SET(clp, CL_LAYOUT);
719 if (CLSP(origp))
720 delwin(CLSP(origp));
722 origp->cl_private = subwin(stdscr, origp->rows, origp->cols,
723 origp->roff, origp->coff);
724 newp->cl_private = subwin(stdscr, newp->rows, newp->cols,
725 newp->roff, newp->coff);
727 /* origp is the original screen, giving up space to newp. */
728 return (0);
732 * cl_suspend --
733 * Suspend a screen.
735 * PUBLIC: int cl_suspend __P((SCR *, int *));
738 cl_suspend(SCR *sp, int *allowedp)
740 struct termios t;
741 CL_PRIVATE *clp;
742 WINDOW *win;
743 GS *gp;
744 size_t y, x;
745 int changed;
747 gp = sp->gp;
748 clp = CLP(sp);
749 win = CLSP(sp) ? CLSP(sp) : stdscr;
750 *allowedp = 1;
753 * The ex implementation of this function isn't needed by screens not
754 * supporting ex commands that require full terminal canonical mode
755 * (e.g. :suspend).
757 * The vi implementation of this function isn't needed by screens not
758 * supporting vi process suspension, i.e. any screen that isn't backed
759 * by a UNIX shell.
761 * Setting allowedp to 0 will cause the editor to reject the command.
763 if (F_ISSET(sp, SC_EX)) {
764 /* Save the terminal settings, and restore the original ones. */
765 if (F_ISSET(clp, CL_STDIN_TTY)) {
766 (void)tcgetattr(STDIN_FILENO, &t);
767 (void)tcsetattr(STDIN_FILENO,
768 TCSASOFT | TCSADRAIN, &clp->orig);
771 /* Stop the process group. */
772 (void)kill(0, SIGTSTP);
774 /* Time passes ... */
776 /* Restore terminal settings. */
777 if (F_ISSET(clp, CL_STDIN_TTY))
778 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
779 return (0);
783 * Move to the lower left-hand corner of the screen.
785 * XXX
786 * Not sure this is necessary in System V implementations, but it
787 * shouldn't hurt.
789 getyx(win, y, x);
790 (void)wmove(win, LINES - 1, 0);
791 (void)wrefresh(win);
794 * Temporarily end the screen. System V introduced a semantic where
795 * endwin() could be restarted. We use it because restarting curses
796 * from scratch often fails in System V. 4BSD curses didn't support
797 * restarting after endwin(), so we have to do what clean up we can
798 * without calling it.
800 /* Save the terminal settings. */
801 (void)tcgetattr(STDIN_FILENO, &t);
803 /* Restore the cursor keys to normal mode. */
804 (void)keypad(stdscr, FALSE);
806 /* Restore the window name. */
807 (void)cl_rename(sp, NULL, 0);
809 #ifdef HAVE_BSD_CURSES
810 (void)cl_attr(sp, SA_ALTERNATE, 0);
811 #else
812 (void)endwin();
813 #endif
815 * XXX
816 * Restore the original terminal settings. This is bad -- the
817 * reset can cause character loss from the tty queue. However,
818 * we can't call endwin() in BSD curses implementations, and too
819 * many System V curses implementations don't get it right.
821 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
823 /* Stop the process group. */
824 (void)kill(0, SIGTSTP);
826 /* Time passes ... */
829 * If we received a killer signal, we're done. Leave everything
830 * unchanged. In addition, the terminal has already been reset
831 * correctly, so leave it alone.
833 if (clp->killersig) {
834 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
835 return (0);
838 /* Restore terminal settings. */
839 wrefresh(win); /* Needed on SunOs/Solaris ? */
840 if (F_ISSET(clp, CL_STDIN_TTY))
841 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
843 #ifdef HAVE_BSD_CURSES
844 (void)cl_attr(sp, SA_ALTERNATE, 1);
845 #endif
847 /* Set the window name. */
848 (void)cl_rename(sp, sp->frp->name, 1);
850 /* Put the cursor keys into application mode. */
851 (void)keypad(stdscr, TRUE);
853 /* Refresh and repaint the screen. */
854 (void)wmove(win, y, x);
855 (void)cl_refresh(sp, 1);
857 /* If the screen changed size, set the SIGWINCH bit. */
858 if (cl_ssize(sp, 1, NULL, NULL, &changed))
859 return (1);
860 if (changed)
861 F_SET(CLP(sp), CL_SIGWINCH);
863 return (0);
867 * cl_usage --
868 * Print out the curses usage messages.
870 * PUBLIC: void cl_usage __P((void));
872 void
873 cl_usage(void)
875 #define USAGE "\
876 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
877 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
878 (void)fprintf(stderr, "%s", USAGE);
879 #undef USAGE
882 #ifdef DEBUG
884 * gdbrefresh --
885 * Stub routine so can flush out curses screen changes using gdb.
888 gdbrefresh(void)
890 refresh();
891 return (0); /* XXX Convince gdb to run it. */
893 #endif