include <term.h> for setupterm(), tputs() and tgoto()
[nvi.git] / cl / cl_funcs.c
blobfc697a71233c6f35a71ed49071c250888f5dde0c
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 <term.h>
27 #include <termios.h>
28 #include <unistd.h>
30 #include "../common/common.h"
31 #include "../vi/vi.h"
32 #include "cl.h"
34 static void cl_rdiv __P((SCR *));
36 static int
37 addstr4(SCR *sp, void *str, size_t len, int wide)
39 CL_PRIVATE *clp;
40 WINDOW *win;
41 size_t y, x;
42 int iv;
44 clp = CLP(sp);
45 win = CLSP(sp) ? CLSP(sp) : stdscr;
48 * If ex isn't in control, it's the last line of the screen and
49 * it's a split screen, use inverse video.
51 iv = 0;
52 getyx(win, y, x);
53 if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
54 y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
55 iv = 1;
56 (void)wstandout(win);
59 #ifdef USE_WIDECHAR
60 if (wide) {
61 if (waddnwstr(win, str, len) == ERR)
62 return (1);
63 } else
64 #endif
65 if (waddnstr(win, str, len) == ERR)
66 return (1);
68 if (iv)
69 (void)wstandend(win);
70 return (0);
74 * cl_waddstr --
75 * Add len bytes from the string at the cursor, advancing the cursor.
77 * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
79 int
80 cl_waddstr(SCR *sp, const CHAR_T *str, size_t len)
82 return addstr4(sp, (void *)str, len, 1);
86 * cl_addstr --
87 * Add len bytes from the string at the cursor, advancing the cursor.
89 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
91 int
92 cl_addstr(SCR *sp, const char *str, size_t len)
94 return addstr4(sp, (void *)str, len, 0);
98 * cl_attr --
99 * Toggle a screen attribute on/off.
101 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
104 cl_attr(SCR *sp, scr_attr_t attribute, int on)
106 CL_PRIVATE *clp;
107 WINDOW *win;
109 clp = CLP(sp);
110 win = CLSP(sp) ? CLSP(sp) : stdscr;
112 switch (attribute) {
113 case SA_ALTERNATE:
115 * !!!
116 * There's a major layering violation here. The problem is that the
117 * X11 xterm screen has what's known as an "alternate" screen. Some
118 * xterm termcap/terminfo entries include sequences to switch to/from
119 * that alternate screen as part of the ti/te (smcup/rmcup) strings.
120 * Vi runs in the alternate screen, so that you are returned to the
121 * same screen contents on exit from vi that you had when you entered
122 * vi. Further, when you run :shell, or :!date or similar ex commands,
123 * you also see the original screen contents. This wasn't deliberate
124 * on vi's part, it's just that it historically sent terminal init/end
125 * sequences at those times, and the addition of the alternate screen
126 * sequences to the strings changed the behavior of vi. The problem
127 * caused by this is that we don't want to switch back to the alternate
128 * screen while getting a new command from the user, when the user is
129 * continuing to enter ex commands, e.g.:
131 * :!date <<< switch to original screen
132 * [Hit return to continue] <<< prompt user to continue
133 * :command <<< get command from user
135 * Note that the :command input is a true vi input mode, e.g., input
136 * maps and abbreviations are being done. So, we need to be able to
137 * switch back into the vi screen mode, without flashing the screen.
139 * To make matters worse, the curses initscr() and endwin() calls will
140 * do this automatically -- so, this attribute isn't as controlled by
141 * the higher level screen as closely as one might like.
143 if (on) {
144 if (clp->ti_te != TI_SENT) {
145 clp->ti_te = TI_SENT;
146 if (clp->smcup == NULL)
147 (void)cl_getcap(sp, "smcup", &clp->smcup);
148 if (clp->smcup != NULL)
149 (void)tputs(clp->smcup, 1, cl_putchar);
151 } else
152 if (clp->ti_te != TE_SENT) {
153 clp->ti_te = TE_SENT;
154 if (clp->rmcup == NULL)
155 (void)cl_getcap(sp, "rmcup", &clp->rmcup);
156 if (clp->rmcup != NULL)
157 (void)tputs(clp->rmcup, 1, cl_putchar);
158 (void)fflush(stdout);
160 (void)fflush(stdout);
161 break;
162 case SA_INVERSE:
163 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
164 if (clp->smso == NULL)
165 return (1);
166 if (on)
167 (void)tputs(clp->smso, 1, cl_putchar);
168 else
169 (void)tputs(clp->rmso, 1, cl_putchar);
170 (void)fflush(stdout);
171 } else {
172 if (on)
173 (void)wstandout(win);
174 else
175 (void)wstandend(win);
177 break;
178 default:
179 abort();
181 return (0);
185 * cl_baud --
186 * Return the baud rate.
188 * PUBLIC: int cl_baud __P((SCR *, u_long *));
191 cl_baud(SCR *sp, u_long *ratep)
193 CL_PRIVATE *clp;
196 * XXX
197 * There's no portable way to get a "baud rate" -- cfgetospeed(3)
198 * returns the value associated with some #define, which we may
199 * never have heard of, or which may be a purely local speed. Vi
200 * only cares if it's SLOW (w300), slow (w1200) or fast (w9600).
201 * Try and detect the slow ones, and default to fast.
203 clp = CLP(sp);
204 switch (cfgetospeed(&clp->orig)) {
205 case B50:
206 case B75:
207 case B110:
208 case B134:
209 case B150:
210 case B200:
211 case B300:
212 case B600:
213 *ratep = 600;
214 break;
215 case B1200:
216 *ratep = 1200;
217 break;
218 default:
219 *ratep = 9600;
220 break;
222 return (0);
226 * cl_bell --
227 * Ring the bell/flash the screen.
229 * PUBLIC: int cl_bell __P((SCR *));
232 cl_bell(SCR *sp)
234 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
235 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
236 else {
238 * Vi has an edit option which determines if the terminal
239 * should be beeped or the screen flashed.
241 if (O_ISSET(sp, O_FLASH))
242 (void)flash();
243 else
244 (void)beep();
246 return (0);
250 * cl_clrtoeol --
251 * Clear from the current cursor to the end of the line.
253 * PUBLIC: int cl_clrtoeol __P((SCR *));
256 cl_clrtoeol(SCR *sp)
258 WINDOW *win;
259 size_t spcnt, y, x;
261 win = CLSP(sp) ? CLSP(sp) : stdscr;
263 #if 0
264 if (IS_VSPLIT(sp)) {
265 /* The cursor must be returned to its original position. */
266 getyx(win, y, x);
267 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
268 (void)waddch(win, ' ');
269 (void)wmove(win, y, x);
270 return (0);
271 } else
272 #endif
273 return (wclrtoeol(win) == ERR);
277 * cl_cursor --
278 * Return the current cursor position.
280 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
283 cl_cursor(SCR *sp, size_t *yp, size_t *xp)
285 WINDOW *win;
286 win = CLSP(sp) ? CLSP(sp) : stdscr;
288 * The curses screen support splits a single underlying curses screen
289 * into multiple screens to support split screen semantics. For this
290 * reason the returned value must be adjusted to be relative to the
291 * current screen, and not absolute. Screens that implement the split
292 * using physically distinct screens won't need this hack.
294 getyx(win, *yp, *xp);
296 *yp -= sp->roff;
297 *xp -= sp->coff;
299 return (0);
303 * cl_deleteln --
304 * Delete the current line, scrolling all lines below it.
306 * PUBLIC: int cl_deleteln __P((SCR *));
309 cl_deleteln(SCR *sp)
311 CHAR_T ch;
312 CL_PRIVATE *clp;
313 WINDOW *win;
314 size_t col, lno, spcnt, y, x;
316 clp = CLP(sp);
317 win = CLSP(sp) ? CLSP(sp) : stdscr;
320 * This clause is required because the curses screen uses reverse
321 * video to delimit split screens. If the screen does not do this,
322 * this code won't be necessary.
324 * If the bottom line was in reverse video, rewrite it in normal
325 * video before it's scrolled.
327 * Check for the existence of a chgat function; XSI requires it, but
328 * historic implementations of System V curses don't. If it's not
329 * a #define, we'll fall back to doing it by hand, which is slow but
330 * acceptable.
332 * By hand means walking through the line, retrieving and rewriting
333 * each character. Curses has no EOL marker, so track strings of
334 * spaces, and copy the trailing spaces only if there's a non-space
335 * character following.
337 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
338 getyx(win, y, x);
339 #ifdef mvchgat
340 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
341 #else
342 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
343 (void)wmove(win, lno, col);
344 ch = winch(win);
345 if (isblank(ch))
346 ++spcnt;
347 else {
348 (void)wmove(win, lno, col - spcnt);
349 for (; spcnt > 0; --spcnt)
350 (void)waddch(win, ' ');
351 (void)waddch(win, ch);
353 if (++col >= sp->cols)
354 break;
356 #endif
357 (void)wmove(win, y, x);
361 * The bottom line is expected to be blank after this operation,
362 * and other screens must support that semantic.
364 return (wdeleteln(win) == ERR);
368 * cl_discard --
369 * Discard a screen.
371 * PUBLIC: int cl_discard __P((SCR *, SCR **));
374 cl_discard(SCR *discardp, SCR **acquirep)
376 CL_PRIVATE *clp;
377 SCR* tsp;
379 if (discardp) {
380 clp = CLP(discardp);
381 F_SET(clp, CL_LAYOUT);
383 if (CLSP(discardp)) {
384 delwin(CLSP(discardp));
385 discardp->cl_private = NULL;
389 /* no screens got a piece; we're done */
390 if (!acquirep)
391 return 0;
393 for (; (tsp = *acquirep) != NULL; ++acquirep) {
394 clp = CLP(tsp);
395 F_SET(clp, CL_LAYOUT);
397 if (CLSP(tsp))
398 delwin(CLSP(tsp));
399 tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols,
400 tsp->roff, tsp->coff);
403 /* discardp is going away, acquirep is taking up its space. */
404 return (0);
408 * cl_ex_adjust --
409 * Adjust the screen for ex. This routine is purely for standalone
410 * ex programs. All special purpose, all special case.
412 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
415 cl_ex_adjust(SCR *sp, exadj_t action)
417 CL_PRIVATE *clp;
418 int cnt;
420 clp = CLP(sp);
421 switch (action) {
422 case EX_TERM_SCROLL:
423 /* Move the cursor up one line if that's possible. */
424 if (clp->cuu1 != NULL)
425 (void)tputs(clp->cuu1, 1, cl_putchar);
426 else if (clp->cup != NULL)
427 (void)tputs(tgoto(clp->cup,
428 0, LINES - 2), 1, cl_putchar);
429 else
430 return (0);
431 /* FALLTHROUGH */
432 case EX_TERM_CE:
433 /* Clear the line. */
434 if (clp->el != NULL) {
435 (void)putchar('\r');
436 (void)tputs(clp->el, 1, cl_putchar);
437 } else {
439 * Historically, ex didn't erase the line, so, if the
440 * displayed line was only a single glyph, and <eof>
441 * was more than one glyph, the output would not fully
442 * overwrite the user's input. To fix this, output
443 * the maxiumum character number of spaces. Note,
444 * this won't help if the user entered extra prompt
445 * or <blank> characters before the command character.
446 * We'd have to do a lot of work to make that work, and
447 * it's almost certainly not worth the effort.
449 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
450 (void)putchar('\b');
451 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
452 (void)putchar(' ');
453 (void)putchar('\r');
454 (void)fflush(stdout);
456 break;
457 default:
458 abort();
460 return (0);
464 * cl_insertln --
465 * Push down the current line, discarding the bottom line.
467 * PUBLIC: int cl_insertln __P((SCR *));
470 cl_insertln(SCR *sp)
472 WINDOW *win;
473 win = CLSP(sp) ? CLSP(sp) : stdscr;
475 * The current line is expected to be blank after this operation,
476 * and the screen must support that semantic.
478 return (winsertln(win) == ERR);
482 * cl_keyval --
483 * Return the value for a special key.
485 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
488 cl_keyval(SCR *sp, scr_keyval_t val, CHAR_T *chp, int *dnep)
490 CL_PRIVATE *clp;
493 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
494 * VWERASE is a 4BSD extension.
496 clp = CLP(sp);
497 switch (val) {
498 case KEY_VEOF:
499 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
500 break;
501 case KEY_VERASE:
502 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
503 break;
504 case KEY_VKILL:
505 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
506 break;
507 #ifdef VWERASE
508 case KEY_VWERASE:
509 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
510 break;
511 #endif
512 default:
513 *dnep = 1;
514 break;
516 return (0);
520 * cl_move --
521 * Move the cursor.
523 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
526 cl_move(SCR *sp, size_t lno, size_t cno)
528 WINDOW *win;
529 win = CLSP(sp) ? CLSP(sp) : stdscr;
530 /* See the comment in cl_cursor. */
531 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
532 msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)",
533 lno, sp->roff, cno, sp->coff);
534 return (1);
536 return (0);
540 * cl_refresh --
541 * Refresh the screen.
543 * PUBLIC: int cl_refresh __P((SCR *, int));
546 cl_refresh(SCR *sp, int repaint)
548 GS *gp;
549 CL_PRIVATE *clp;
550 WINDOW *win;
551 SCR *psp, *tsp;
552 size_t y, x;
554 gp = sp->gp;
555 clp = CLP(sp);
556 win = CLSP(sp) ? CLSP(sp) : stdscr;
559 * If we received a killer signal, we're done, there's no point
560 * in refreshing the screen.
562 if (clp->killersig)
563 return (0);
566 * If repaint is set, the editor is telling us that we don't know
567 * what's on the screen, so we have to repaint from scratch.
569 * If repaint set or the screen layout changed, we need to redraw
570 * any lines separating vertically split screens. If the horizontal
571 * offsets are the same, then the split was vertical, and need to
572 * draw a dividing line.
574 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
575 getyx(stdscr, y, x);
576 for (psp = sp;
577 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
578 for (tsp = psp->q.cqe_next;
579 tsp != (void *)&sp->wp->scrq;
580 tsp = tsp->q.cqe_next)
581 if (psp->roff == tsp->roff) {
582 if (psp->coff + psp->cols + 1 == tsp->coff)
583 cl_rdiv(psp);
584 else
585 if (tsp->coff + tsp->cols + 1 == psp->coff)
586 cl_rdiv(tsp);
588 (void)wmove(stdscr, y, x);
589 F_CLR(clp, CL_LAYOUT);
593 * In the curses library, doing wrefresh(curscr) is okay, but the
594 * screen flashes when we then apply the refresh() to bring it up
595 * to date. So, use clearok().
597 if (repaint)
598 clearok(curscr, 1);
600 * Only do an actual refresh, when this is the focus window,
601 * i.e. the one holding the cursor. This assumes that refresh
602 * is called for that window after refreshing the others.
603 * This prevents the cursor being drawn in the other windows.
605 return (wnoutrefresh(stdscr) == ERR ||
606 wnoutrefresh(win) == ERR ||
607 (sp == clp->focus && doupdate() == ERR));
611 * cl_rdiv --
612 * Draw a dividing line between two vertically split screens.
614 static void
615 cl_rdiv(SCR *sp)
617 size_t cnt;
619 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
620 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
621 waddch(stdscr, '|');
626 * cl_rename --
627 * Rename the file.
629 * PUBLIC: int cl_rename __P((SCR *, char *, int));
632 cl_rename(SCR *sp, char *name, int on)
634 CL_PRIVATE *clp;
635 FILE *pfp;
636 GS *gp;
637 char buf[256], *p;
639 gp = sp->gp;
640 clp = CLP(sp);
642 if (on) {
643 clp->focus = sp;
644 if (!F_ISSET(clp, CL_RENAME_OK))
645 return (0);
648 * XXX
649 * We can only rename windows for xterm.
651 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
652 return (0);
655 * XXX
656 * Try and figure out the current name of this window. There
657 * are two forms of the xwininfo output I've seen:
659 * Window id: 0x400000d "name"
660 * Window id: 0x140000d (name)
662 #define COMMAND \
663 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
665 if (clp->oname == NULL &&
666 (pfp = popen(COMMAND, "r")) != NULL) {
667 if (fgets(buf, sizeof(buf), pfp) != NULL &&
668 (p = strchr(buf, '\n')) != NULL) {
669 *p = '\0';
670 clp->oname = strdup(buf);
672 (void)fclose(pfp);
675 cl_setname(gp, name);
677 F_SET(clp, CL_RENAME);
678 } else
679 if (F_ISSET(clp, CL_RENAME)) {
680 cl_setname(gp, clp->oname);
682 F_CLR(clp, CL_RENAME);
684 return (0);
688 * cl_setname --
689 * Set a X11 icon/window name.
691 * PUBLIC: void cl_setname __P((GS *, char *));
693 void
694 cl_setname(GS *gp, char *name)
696 /* X11 xterm escape sequence to rename the icon/window. */
697 #define XTERM_RENAME "\033]0;%s\007"
699 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
700 (void)fflush(stdout);
704 * cl_split --
705 * Split a screen.
707 * PUBLIC: int cl_split __P((SCR *, SCR *));
710 cl_split(SCR *origp, SCR *newp)
712 CL_PRIVATE *clp;
714 clp = CLP(origp);
715 F_SET(clp, CL_LAYOUT);
717 if (CLSP(origp))
718 delwin(CLSP(origp));
720 origp->cl_private = subwin(stdscr, origp->rows, origp->cols,
721 origp->roff, origp->coff);
722 newp->cl_private = subwin(stdscr, newp->rows, newp->cols,
723 newp->roff, newp->coff);
725 /* origp is the original screen, giving up space to newp. */
726 return (0);
730 * cl_suspend --
731 * Suspend a screen.
733 * PUBLIC: int cl_suspend __P((SCR *, int *));
736 cl_suspend(SCR *sp, int *allowedp)
738 struct termios t;
739 CL_PRIVATE *clp;
740 WINDOW *win;
741 GS *gp;
742 size_t y, x;
743 int changed;
745 gp = sp->gp;
746 clp = CLP(sp);
747 win = CLSP(sp) ? CLSP(sp) : stdscr;
748 *allowedp = 1;
751 * The ex implementation of this function isn't needed by screens not
752 * supporting ex commands that require full terminal canonical mode
753 * (e.g. :suspend).
755 * The vi implementation of this function isn't needed by screens not
756 * supporting vi process suspension, i.e. any screen that isn't backed
757 * by a UNIX shell.
759 * Setting allowedp to 0 will cause the editor to reject the command.
761 if (F_ISSET(sp, SC_EX)) {
762 /* Save the terminal settings, and restore the original ones. */
763 if (F_ISSET(clp, CL_STDIN_TTY)) {
764 (void)tcgetattr(STDIN_FILENO, &t);
765 (void)tcsetattr(STDIN_FILENO,
766 TCSASOFT | TCSADRAIN, &clp->orig);
769 /* Stop the process group. */
770 (void)kill(0, SIGTSTP);
772 /* Time passes ... */
774 /* Restore terminal settings. */
775 if (F_ISSET(clp, CL_STDIN_TTY))
776 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
777 return (0);
781 * Move to the lower left-hand corner of the screen.
783 * XXX
784 * Not sure this is necessary in System V implementations, but it
785 * shouldn't hurt.
787 getyx(win, y, x);
788 (void)wmove(win, LINES - 1, 0);
789 (void)wrefresh(win);
792 * Temporarily end the screen. System V introduced a semantic where
793 * endwin() could be restarted. We use it because restarting curses
794 * from scratch often fails in System V. 4BSD curses didn't support
795 * restarting after endwin(), so we have to do what clean up we can
796 * without calling it.
798 /* Save the terminal settings. */
799 (void)tcgetattr(STDIN_FILENO, &t);
801 /* Restore the cursor keys to normal mode. */
802 (void)keypad(stdscr, FALSE);
804 /* Restore the window name. */
805 (void)cl_rename(sp, NULL, 0);
807 #ifdef HAVE_BSD_CURSES
808 (void)cl_attr(sp, SA_ALTERNATE, 0);
809 #else
810 (void)endwin();
811 #endif
813 * XXX
814 * Restore the original terminal settings. This is bad -- the
815 * reset can cause character loss from the tty queue. However,
816 * we can't call endwin() in BSD curses implementations, and too
817 * many System V curses implementations don't get it right.
819 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
821 /* Stop the process group. */
822 (void)kill(0, SIGTSTP);
824 /* Time passes ... */
827 * If we received a killer signal, we're done. Leave everything
828 * unchanged. In addition, the terminal has already been reset
829 * correctly, so leave it alone.
831 if (clp->killersig) {
832 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
833 return (0);
836 /* Restore terminal settings. */
837 wrefresh(win); /* Needed on SunOs/Solaris ? */
838 if (F_ISSET(clp, CL_STDIN_TTY))
839 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
841 #ifdef HAVE_BSD_CURSES
842 (void)cl_attr(sp, SA_ALTERNATE, 1);
843 #endif
845 /* Set the window name. */
846 (void)cl_rename(sp, sp->frp->name, 1);
848 /* Put the cursor keys into application mode. */
849 (void)keypad(stdscr, TRUE);
851 /* Refresh and repaint the screen. */
852 (void)wmove(win, y, x);
853 (void)cl_refresh(sp, 1);
855 /* If the screen changed size, set the SIGWINCH bit. */
856 if (cl_ssize(sp, 1, NULL, NULL, &changed))
857 return (1);
858 if (changed)
859 F_SET(CLP(sp), CL_SIGWINCH);
861 return (0);
865 * cl_usage --
866 * Print out the curses usage messages.
868 * PUBLIC: void cl_usage __P((void));
870 void
871 cl_usage(void)
873 #define USAGE "\
874 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
875 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
876 (void)fprintf(stderr, "%s", USAGE);
877 #undef USAGE
880 #ifdef DEBUG
882 * gdbrefresh --
883 * Stub routine so can flush out curses screen changes using gdb.
886 gdbrefresh(void)
888 refresh();
889 return (0); /* XXX Convince gdb to run it. */
891 #endif