the script used to extract a release
[nvi.git] / cl / cl_funcs.c
blob5c3e526899a6f6bd32977ac6249c744a107e8c91
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.62 2000/07/23 11:14:44 skimo Exp $ (Berkeley) $Date: 2000/07/23 11:14:44 $";
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 *));
36 * cl_addstr --
37 * Add len bytes from the string at the cursor, advancing the cursor.
39 * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
41 int
42 cl_waddstr(sp, str, len)
43 SCR *sp;
44 const CHAR_T *str;
45 size_t len;
47 CONST char *np;
48 size_t nlen;
50 INT2DISP(sp, str, len, np, nlen);
51 cl_addstr(sp, np, nlen);
55 * cl_addstr --
56 * Add len bytes from the string at the cursor, advancing the cursor.
58 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
60 int
61 cl_addstr(sp, str, len)
62 SCR *sp;
63 const char *str;
64 size_t len;
66 CL_PRIVATE *clp;
67 WINDOW *win;
68 size_t y, x;
69 int iv;
71 clp = CLP(sp);
72 win = CLSP(sp) ? CLSP(sp) : stdscr;
75 * If ex isn't in control, it's the last line of the screen and
76 * it's a split screen, use inverse video.
78 iv = 0;
79 getyx(win, y, x);
80 if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
81 y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
82 iv = 1;
83 (void)wstandout(win);
86 if (waddnstr(win, str, len) == ERR)
87 return (1);
89 if (iv)
90 (void)wstandend(win);
91 return (0);
95 * cl_attr --
96 * Toggle a screen attribute on/off.
98 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
101 cl_attr(sp, attribute, on)
102 SCR *sp;
103 scr_attr_t attribute;
104 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(sp, ratep)
192 SCR *sp;
193 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(sp)
235 SCR *sp;
237 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
238 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
239 else {
241 * Vi has an edit option which determines if the terminal
242 * should be beeped or the screen flashed.
244 if (O_ISSET(sp, O_FLASH))
245 (void)flash();
246 else
247 (void)beep();
249 return (0);
253 * cl_clrtoeol --
254 * Clear from the current cursor to the end of the line.
256 * PUBLIC: int cl_clrtoeol __P((SCR *));
259 cl_clrtoeol(sp)
260 SCR *sp;
262 WINDOW *win;
263 size_t spcnt, y, x;
265 win = CLSP(sp) ? CLSP(sp) : stdscr;
267 #if 0
268 if (IS_VSPLIT(sp)) {
269 /* The cursor must be returned to its original position. */
270 getyx(win, y, x);
271 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
272 (void)waddch(win, ' ');
273 (void)wmove(win, y, x);
274 return (0);
275 } else
276 #endif
277 return (wclrtoeol(win) == ERR);
281 * cl_cursor --
282 * Return the current cursor position.
284 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
287 cl_cursor(sp, yp, xp)
288 SCR *sp;
289 size_t *yp, *xp;
291 WINDOW *win;
292 win = CLSP(sp) ? CLSP(sp) : stdscr;
294 * The curses screen support splits a single underlying curses screen
295 * into multiple screens to support split screen semantics. For this
296 * reason the returned value must be adjusted to be relative to the
297 * current screen, and not absolute. Screens that implement the split
298 * using physically distinct screens won't need this hack.
300 getyx(win, *yp, *xp);
302 *yp -= sp->roff;
303 *xp -= sp->coff;
305 return (0);
309 * cl_deleteln --
310 * Delete the current line, scrolling all lines below it.
312 * PUBLIC: int cl_deleteln __P((SCR *));
315 cl_deleteln(sp)
316 SCR *sp;
318 CHAR_T ch;
319 CL_PRIVATE *clp;
320 WINDOW *win;
321 size_t col, lno, spcnt, y, x;
323 clp = CLP(sp);
324 win = CLSP(sp) ? CLSP(sp) : stdscr;
327 * This clause is required because the curses screen uses reverse
328 * video to delimit split screens. If the screen does not do this,
329 * this code won't be necessary.
331 * If the bottom line was in reverse video, rewrite it in normal
332 * video before it's scrolled.
334 * Check for the existence of a chgat function; XSI requires it, but
335 * historic implementations of System V curses don't. If it's not
336 * a #define, we'll fall back to doing it by hand, which is slow but
337 * acceptable.
339 * By hand means walking through the line, retrieving and rewriting
340 * each character. Curses has no EOL marker, so track strings of
341 * spaces, and copy the trailing spaces only if there's a non-space
342 * character following.
344 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
345 getyx(win, y, x);
346 #ifdef mvchgat
347 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
348 #else
349 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
350 (void)wmove(win, lno, col);
351 ch = winch(win);
352 if (isblank(ch))
353 ++spcnt;
354 else {
355 (void)wmove(win, lno, col - spcnt);
356 for (; spcnt > 0; --spcnt)
357 (void)waddch(win, ' ');
358 (void)waddch(win, ch);
360 if (++col >= sp->cols)
361 break;
363 #endif
364 (void)wmove(win, y, x);
368 * The bottom line is expected to be blank after this operation,
369 * and other screens must support that semantic.
371 return (wdeleteln(win) == ERR);
375 * cl_discard --
376 * Discard a screen.
378 * PUBLIC: int cl_discard __P((SCR *, SCR **));
381 cl_discard(discardp, acquirep)
382 SCR *discardp, **acquirep;
384 CL_PRIVATE *clp;
385 SCR* tsp;
387 if (discardp) {
388 clp = CLP(discardp);
389 F_SET(clp, CL_LAYOUT);
391 if (CLSP(discardp)) {
392 delwin(CLSP(discardp));
393 CLSP(discardp) = NULL;
397 /* no screens got a piece; we're done */
398 if (!acquirep)
399 return 0;
401 for (; (tsp = *acquirep) != NULL; ++acquirep) {
402 clp = CLP(tsp);
403 F_SET(clp, CL_LAYOUT);
405 if (CLSP(tsp))
406 delwin(CLSP(tsp));
407 CLSP(tsp) = subwin(stdscr, tsp->rows, tsp->cols,
408 tsp->roff, tsp->coff);
411 /* discardp is going away, acquirep is taking up its space. */
412 return (0);
416 * cl_ex_adjust --
417 * Adjust the screen for ex. This routine is purely for standalone
418 * ex programs. All special purpose, all special case.
420 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
423 cl_ex_adjust(sp, action)
424 SCR *sp;
425 exadj_t action;
427 CL_PRIVATE *clp;
428 int cnt;
430 clp = CLP(sp);
431 switch (action) {
432 case EX_TERM_SCROLL:
433 /* Move the cursor up one line if that's possible. */
434 if (clp->cuu1 != NULL)
435 (void)tputs(clp->cuu1, 1, cl_putchar);
436 else if (clp->cup != NULL)
437 (void)tputs(tgoto(clp->cup,
438 0, LINES - 2), 1, cl_putchar);
439 else
440 return (0);
441 /* FALLTHROUGH */
442 case EX_TERM_CE:
443 /* Clear the line. */
444 if (clp->el != NULL) {
445 (void)putchar('\r');
446 (void)tputs(clp->el, 1, cl_putchar);
447 } else {
449 * Historically, ex didn't erase the line, so, if the
450 * displayed line was only a single glyph, and <eof>
451 * was more than one glyph, the output would not fully
452 * overwrite the user's input. To fix this, output
453 * the maxiumum character number of spaces. Note,
454 * this won't help if the user entered extra prompt
455 * or <blank> characters before the command character.
456 * We'd have to do a lot of work to make that work, and
457 * it's almost certainly not worth the effort.
459 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
460 (void)putchar('\b');
461 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
462 (void)putchar(' ');
463 (void)putchar('\r');
464 (void)fflush(stdout);
466 break;
467 default:
468 abort();
470 return (0);
474 * cl_insertln --
475 * Push down the current line, discarding the bottom line.
477 * PUBLIC: int cl_insertln __P((SCR *));
480 cl_insertln(sp)
481 SCR *sp;
483 WINDOW *win;
484 win = CLSP(sp) ? CLSP(sp) : stdscr;
486 * The current line is expected to be blank after this operation,
487 * and the screen must support that semantic.
489 return (winsertln(win) == ERR);
493 * cl_keyval --
494 * Return the value for a special key.
496 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
499 cl_keyval(sp, val, chp, dnep)
500 SCR *sp;
501 scr_keyval_t val;
502 CHAR_T *chp;
503 int *dnep;
505 CL_PRIVATE *clp;
508 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
509 * VWERASE is a 4BSD extension.
511 clp = CLP(sp);
512 switch (val) {
513 case KEY_VEOF:
514 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
515 break;
516 case KEY_VERASE:
517 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
518 break;
519 case KEY_VKILL:
520 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
521 break;
522 #ifdef VWERASE
523 case KEY_VWERASE:
524 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
525 break;
526 #endif
527 default:
528 *dnep = 1;
529 break;
531 return (0);
535 * cl_move --
536 * Move the cursor.
538 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
541 cl_move(sp, lno, cno)
542 SCR *sp;
543 size_t lno, cno;
545 WINDOW *win;
546 win = CLSP(sp) ? CLSP(sp) : stdscr;
547 /* See the comment in cl_cursor. */
548 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
549 msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)",
550 lno, sp->roff, cno, sp->coff);
551 return (1);
553 return (0);
557 * cl_refresh --
558 * Refresh the screen.
560 * PUBLIC: int cl_refresh __P((SCR *, int));
563 cl_refresh(sp, repaint)
564 SCR *sp;
565 int repaint;
567 GS *gp;
568 CL_PRIVATE *clp;
569 WINDOW *win;
570 SCR *psp, *tsp;
571 size_t y, x;
573 gp = sp->gp;
574 clp = CLP(sp);
575 win = CLSP(sp) ? CLSP(sp) : stdscr;
578 * If we received a killer signal, we're done, there's no point
579 * in refreshing the screen.
581 if (clp->killersig)
582 return (0);
585 * If repaint is set, the editor is telling us that we don't know
586 * what's on the screen, so we have to repaint from scratch.
588 * If repaint set or the screen layout changed, we need to redraw
589 * any lines separating vertically split screens. If the horizontal
590 * offsets are the same, then the split was vertical, and need to
591 * draw a dividing line.
593 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
594 getyx(win, y, x);
595 for (psp = sp;
596 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
597 for (tsp = psp->q.cqe_next;
598 tsp != (void *)&sp->wp->scrq;
599 tsp = tsp->q.cqe_next)
600 if (psp->roff == tsp->roff) {
601 if (psp->coff + psp->cols + 1 == tsp->coff)
602 cl_rdiv(psp);
603 else
604 if (tsp->coff + tsp->cols + 1 == psp->coff)
605 cl_rdiv(tsp);
607 (void)wmove(win, y, x);
608 F_CLR(clp, CL_LAYOUT);
612 * In the curses library, doing wrefresh(curscr) is okay, but the
613 * screen flashes when we then apply the refresh() to bring it up
614 * to date. So, use clearok().
616 if (repaint)
617 clearok(curscr, 1);
618 return (wrefresh(stdscr) == ERR || wrefresh(win) == ERR);
622 * cl_rdiv --
623 * Draw a dividing line between two vertically split screens.
625 static void
626 cl_rdiv(sp)
627 SCR *sp;
629 WINDOW *win;
630 size_t cnt;
632 win = CLSP(sp) ? CLSP(sp) : stdscr;
634 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
635 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
636 waddch(stdscr, '|');
641 * cl_rename --
642 * Rename the file.
644 * PUBLIC: int cl_rename __P((SCR *, char *, int));
647 cl_rename(sp, name, on)
648 SCR *sp;
649 char *name;
650 int on;
652 CL_PRIVATE *clp;
653 FILE *pfp;
654 GS *gp;
655 char buf[256], *p;
657 gp = sp->gp;
658 clp = CLP(sp);
660 if (on) {
661 if (!F_ISSET(clp, CL_RENAME_OK))
662 return (0);
665 * XXX
666 * We can only rename windows for xterm.
668 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
669 return (0);
672 * XXX
673 * Try and figure out the current name of this window. There
674 * are two forms of the xwininfo output I've seen:
676 * Window id: 0x400000d "name"
677 * Window id: 0x140000d (name)
679 #define COMMAND \
680 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
682 if (clp->oname == NULL &&
683 (pfp = popen(COMMAND, "r")) != NULL) {
684 if (fgets(buf, sizeof(buf), pfp) != NULL &&
685 (p = strchr(buf, '\n')) != NULL) {
686 *p = '\0';
687 clp->oname = strdup(buf);
689 (void)fclose(pfp);
692 cl_setname(gp, name);
694 F_SET(clp, CL_RENAME);
695 } else
696 if (F_ISSET(clp, CL_RENAME)) {
697 cl_setname(gp, clp->oname);
699 F_CLR(clp, CL_RENAME);
701 return (0);
705 * cl_setname --
706 * Set a X11 icon/window name.
708 * PUBLIC: void cl_setname __P((GS *, char *));
710 void
711 cl_setname(gp, name)
712 GS *gp;
713 char *name;
715 /* X11 xterm escape sequence to rename the icon/window. */
716 #define XTERM_RENAME "\033]0;%s\007"
718 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
719 (void)fflush(stdout);
723 * cl_split --
724 * Split a screen.
726 * PUBLIC: int cl_split __P((SCR *, SCR *));
729 cl_split(origp, newp)
730 SCR *origp, *newp;
732 CL_PRIVATE *clp;
734 clp = CLP(origp);
735 F_SET(clp, CL_LAYOUT);
737 if (CLSP(origp))
738 delwin(CLSP(origp));
740 CLSP(origp) = subwin(stdscr, origp->rows, origp->cols,
741 origp->roff, origp->coff);
742 CLSP(newp) = subwin(stdscr, newp->rows, newp->cols,
743 newp->roff, newp->coff);
745 /* origp is the original screen, giving up space to newp. */
746 return (0);
750 * cl_suspend --
751 * Suspend a screen.
753 * PUBLIC: int cl_suspend __P((SCR *, int *));
756 cl_suspend(sp, allowedp)
757 SCR *sp;
758 int *allowedp;
760 struct termios t;
761 CL_PRIVATE *clp;
762 WINDOW *win;
763 GS *gp;
764 size_t y, x;
765 int changed;
767 gp = sp->gp;
768 clp = CLP(sp);
769 win = CLSP(sp) ? CLSP(sp) : stdscr;
770 *allowedp = 1;
773 * The ex implementation of this function isn't needed by screens not
774 * supporting ex commands that require full terminal canonical mode
775 * (e.g. :suspend).
777 * The vi implementation of this function isn't needed by screens not
778 * supporting vi process suspension, i.e. any screen that isn't backed
779 * by a UNIX shell.
781 * Setting allowedp to 0 will cause the editor to reject the command.
783 if (F_ISSET(sp, SC_EX)) {
784 /* Save the terminal settings, and restore the original ones. */
785 if (F_ISSET(clp, CL_STDIN_TTY)) {
786 (void)tcgetattr(STDIN_FILENO, &t);
787 (void)tcsetattr(STDIN_FILENO,
788 TCSASOFT | TCSADRAIN, &clp->orig);
791 /* Stop the process group. */
792 (void)kill(0, SIGTSTP);
794 /* Time passes ... */
796 /* Restore terminal settings. */
797 if (F_ISSET(clp, CL_STDIN_TTY))
798 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
799 return (0);
803 * Move to the lower left-hand corner of the screen.
805 * XXX
806 * Not sure this is necessary in System V implementations, but it
807 * shouldn't hurt.
809 getyx(win, y, x);
810 (void)wmove(win, LINES - 1, 0);
811 (void)wrefresh(win);
814 * Temporarily end the screen. System V introduced a semantic where
815 * endwin() could be restarted. We use it because restarting curses
816 * from scratch often fails in System V. 4BSD curses didn't support
817 * restarting after endwin(), so we have to do what clean up we can
818 * without calling it.
820 /* Save the terminal settings. */
821 (void)tcgetattr(STDIN_FILENO, &t);
823 /* Restore the cursor keys to normal mode. */
824 (void)keypad(stdscr, FALSE);
826 /* Restore the window name. */
827 (void)cl_rename(sp, NULL, 0);
829 #ifdef HAVE_BSD_CURSES
830 (void)cl_attr(sp, SA_ALTERNATE, 0);
831 #else
832 (void)endwin();
833 #endif
835 * XXX
836 * Restore the original terminal settings. This is bad -- the
837 * reset can cause character loss from the tty queue. However,
838 * we can't call endwin() in BSD curses implementations, and too
839 * many System V curses implementations don't get it right.
841 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
843 /* Stop the process group. */
844 (void)kill(0, SIGTSTP);
846 /* Time passes ... */
849 * If we received a killer signal, we're done. Leave everything
850 * unchanged. In addition, the terminal has already been reset
851 * correctly, so leave it alone.
853 if (clp->killersig) {
854 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
855 return (0);
858 /* Restore terminal settings. */
859 wrefresh(win); /* Needed on SunOs/Solaris ? */
860 if (F_ISSET(clp, CL_STDIN_TTY))
861 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
863 #ifdef HAVE_BSD_CURSES
864 (void)cl_attr(sp, SA_ALTERNATE, 1);
865 #endif
867 /* Set the window name. */
868 (void)cl_rename(sp, sp->frp->name, 1);
870 /* Put the cursor keys into application mode. */
871 (void)keypad(stdscr, TRUE);
873 /* Refresh and repaint the screen. */
874 (void)wmove(win, y, x);
875 (void)cl_refresh(sp, 1);
877 /* If the screen changed size, set the SIGWINCH bit. */
878 if (cl_ssize(sp, 1, NULL, NULL, &changed))
879 return (1);
880 if (changed)
881 F_SET(CLP(sp), CL_SIGWINCH);
883 return (0);
887 * cl_usage --
888 * Print out the curses usage messages.
890 * PUBLIC: void cl_usage __P((void));
892 void
893 cl_usage()
895 #define USAGE "\
896 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
897 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
898 (void)fprintf(stderr, "%s", USAGE);
899 #undef USAGE
902 #ifdef DEBUG
904 * gdbrefresh --
905 * Stub routine so can flush out curses screen changes using gdb.
908 gdbrefresh()
910 refresh();
911 return (0); /* XXX Convince gdb to run it. */
913 #endif