Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / cl / cl_funcs.c
blob66c899f3b1b05851828794a4b53fda8faf150c67
1 /* $NetBSD: cl_funcs.c,v 1.3 2009/11/15 18:23:08 dsl Exp $ */
3 /*-
4 * Copyright (c) 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #ifndef lint
15 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";
16 #endif /* not lint */
18 #include <sys/types.h>
19 #include <sys/queue.h>
20 #include <sys/time.h>
22 #include <bitstring.h>
23 #include <ctype.h>
24 #include <signal.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <termios.h>
29 #include <unistd.h>
31 #include "../common/common.h"
32 #include "../vi/vi.h"
33 #include "cl.h"
35 static void cl_rdiv __P((SCR *));
37 static int
38 addstr4(SCR *sp, const void *str, size_t len, int wide)
40 CL_PRIVATE *clp;
41 WINDOW *win;
42 size_t y, x;
43 int iv;
45 clp = CLP(sp);
46 win = CLSP(sp) ? CLSP(sp) : stdscr;
49 * If ex isn't in control, it's the last line of the screen and
50 * it's a split screen, use inverse video.
52 iv = 0;
53 getyx(win, y, x);
54 if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
55 y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
56 iv = 1;
57 (void)wstandout(win);
60 #ifdef USE_WIDECHAR
61 if (wide) {
62 if (waddnwstr(win, str, len) == ERR)
63 return (1);
64 } else
65 #endif
66 if (waddnstr(win, str, len) == ERR)
67 return (1);
69 if (iv)
70 (void)wstandend(win);
71 return (0);
75 * cl_waddstr --
76 * Add len bytes from the string at the cursor, advancing the cursor.
78 * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
80 int
81 cl_waddstr(SCR *sp, const CHAR_T *str, size_t len)
83 return addstr4(sp, (const void *)str, len, 1);
87 * cl_addstr --
88 * Add len bytes from the string at the cursor, advancing the cursor.
90 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
92 int
93 cl_addstr(SCR *sp, const char *str, size_t len)
95 return addstr4(sp, (const void *)str, len, 0);
99 * cl_attr --
100 * Toggle a screen attribute on/off.
102 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
105 cl_attr(SCR *sp, scr_attr_t attribute, int on)
107 CL_PRIVATE *clp;
108 WINDOW *win;
110 clp = CLP(sp);
111 win = CLSP(sp) ? CLSP(sp) : stdscr;
113 switch (attribute) {
114 case SA_ALTERNATE:
116 * !!!
117 * There's a major layering violation here. The problem is that the
118 * X11 xterm screen has what's known as an "alternate" screen. Some
119 * xterm termcap/terminfo entries include sequences to switch to/from
120 * that alternate screen as part of the ti/te (smcup/rmcup) strings.
121 * Vi runs in the alternate screen, so that you are returned to the
122 * same screen contents on exit from vi that you had when you entered
123 * vi. Further, when you run :shell, or :!date or similar ex commands,
124 * you also see the original screen contents. This wasn't deliberate
125 * on vi's part, it's just that it historically sent terminal init/end
126 * sequences at those times, and the addition of the alternate screen
127 * sequences to the strings changed the behavior of vi. The problem
128 * caused by this is that we don't want to switch back to the alternate
129 * screen while getting a new command from the user, when the user is
130 * continuing to enter ex commands, e.g.:
132 * :!date <<< switch to original screen
133 * [Hit return to continue] <<< prompt user to continue
134 * :command <<< get command from user
136 * Note that the :command input is a true vi input mode, e.g., input
137 * maps and abbreviations are being done. So, we need to be able to
138 * switch back into the vi screen mode, without flashing the screen.
140 * To make matters worse, the curses initscr() and endwin() calls will
141 * do this automatically -- so, this attribute isn't as controlled by
142 * the higher level screen as closely as one might like.
144 if (on) {
145 if (clp->ti_te != TI_SENT) {
146 clp->ti_te = TI_SENT;
147 if (clp->smcup == NULL)
148 (void)cl_getcap(sp, "smcup", &clp->smcup);
149 if (clp->smcup != NULL)
150 (void)tputs(clp->smcup, 1, cl_putchar);
152 } else
153 if (clp->ti_te != TE_SENT) {
154 clp->ti_te = TE_SENT;
155 if (clp->rmcup == NULL)
156 (void)cl_getcap(sp, "rmcup", &clp->rmcup);
157 if (clp->rmcup != NULL)
158 (void)tputs(clp->rmcup, 1, cl_putchar);
159 (void)fflush(stdout);
161 (void)fflush(stdout);
162 break;
163 case SA_INVERSE:
164 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
165 if (clp->smso == NULL)
166 return (1);
167 if (on)
168 (void)tputs(clp->smso, 1, cl_putchar);
169 else
170 (void)tputs(clp->rmso, 1, cl_putchar);
171 (void)fflush(stdout);
172 } else {
173 if (on)
174 (void)wstandout(win);
175 else
176 (void)wstandend(win);
178 break;
179 default:
180 abort();
182 return (0);
186 * cl_baud --
187 * Return the baud rate.
189 * PUBLIC: int cl_baud __P((SCR *, u_long *));
192 cl_baud(SCR *sp, u_long *ratep)
194 CL_PRIVATE *clp;
197 * XXX
198 * There's no portable way to get a "baud rate" -- cfgetospeed(3)
199 * returns the value associated with some #define, which we may
200 * never have heard of, or which may be a purely local speed. Vi
201 * only cares if it's SLOW (w300), slow (w1200) or fast (w9600).
202 * Try and detect the slow ones, and default to fast.
204 clp = CLP(sp);
205 switch (cfgetospeed(&clp->orig)) {
206 case B50:
207 case B75:
208 case B110:
209 case B134:
210 case B150:
211 case B200:
212 case B300:
213 case B600:
214 *ratep = 600;
215 break;
216 case B1200:
217 *ratep = 1200;
218 break;
219 default:
220 *ratep = 9600;
221 break;
223 return (0);
227 * cl_bell --
228 * Ring the bell/flash the screen.
230 * PUBLIC: int cl_bell __P((SCR *));
233 cl_bell(SCR *sp)
235 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
236 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
237 else {
239 * Vi has an edit option which determines if the terminal
240 * should be beeped or the screen flashed.
242 if (O_ISSET(sp, O_FLASH))
243 (void)flash();
244 else
245 (void)beep();
247 return (0);
251 * cl_clrtoeol --
252 * Clear from the current cursor to the end of the line.
254 * PUBLIC: int cl_clrtoeol __P((SCR *));
257 cl_clrtoeol(SCR *sp)
259 WINDOW *win;
260 #if 0
261 size_t spcnt, y, x;
262 #endif
264 win = CLSP(sp) ? CLSP(sp) : stdscr;
266 #if 0
267 if (IS_VSPLIT(sp)) {
268 /* The cursor must be returned to its original position. */
269 getyx(win, y, x);
270 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
271 (void)waddch(win, ' ');
272 (void)wmove(win, y, x);
273 return (0);
274 } else
275 #endif
276 return (wclrtoeol(win) == ERR);
280 * cl_cursor --
281 * Return the current cursor position.
283 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
286 cl_cursor(SCR *sp, size_t *yp, size_t *xp)
288 WINDOW *win;
289 win = CLSP(sp) ? CLSP(sp) : stdscr;
291 * The curses screen support splits a single underlying curses screen
292 * into multiple screens to support split screen semantics. For this
293 * reason the returned value must be adjusted to be relative to the
294 * current screen, and not absolute. Screens that implement the split
295 * using physically distinct screens won't need this hack.
297 getyx(win, *yp, *xp);
299 *yp -= sp->roff;
300 *xp -= sp->coff;
302 return (0);
306 * cl_deleteln --
307 * Delete the current line, scrolling all lines below it.
309 * PUBLIC: int cl_deleteln __P((SCR *));
312 cl_deleteln(SCR *sp)
314 CHAR_T ch;
315 CL_PRIVATE *clp;
316 WINDOW *win;
317 size_t col, lno, spcnt, y, x;
319 clp = CLP(sp);
320 win = CLSP(sp) ? CLSP(sp) : stdscr;
323 * This clause is required because the curses screen uses reverse
324 * video to delimit split screens. If the screen does not do this,
325 * this code won't be necessary.
327 * If the bottom line was in reverse video, rewrite it in normal
328 * video before it's scrolled.
330 * Check for the existence of a chgat function; XSI requires it, but
331 * historic implementations of System V curses don't. If it's not
332 * a #define, we'll fall back to doing it by hand, which is slow but
333 * acceptable.
335 * By hand means walking through the line, retrieving and rewriting
336 * each character. Curses has no EOL marker, so track strings of
337 * spaces, and copy the trailing spaces only if there's a non-space
338 * character following.
340 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
341 getyx(win, y, x);
342 #ifdef mvchgat
343 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
344 #else
345 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
346 (void)wmove(win, lno, col);
347 ch = winch(win);
348 if (isblank(ch))
349 ++spcnt;
350 else {
351 (void)wmove(win, lno, col - spcnt);
352 for (; spcnt > 0; --spcnt)
353 (void)waddch(win, ' ');
354 (void)waddch(win, ch);
356 if (++col >= sp->cols)
357 break;
359 #endif
360 (void)wmove(win, y, x);
364 * The bottom line is expected to be blank after this operation,
365 * and other screens must support that semantic.
367 return (wdeleteln(win) == ERR);
371 * cl_discard --
372 * Discard a screen.
374 * PUBLIC: int cl_discard __P((SCR *, SCR **));
377 cl_discard(SCR *discardp, SCR **acquirep)
379 CL_PRIVATE *clp;
380 SCR* tsp;
382 if (discardp) {
383 clp = CLP(discardp);
384 F_SET(clp, CL_LAYOUT);
386 if (CLSP(discardp)) {
387 delwin(CLSP(discardp));
388 discardp->cl_private = NULL;
392 /* no screens got a piece; we're done */
393 if (!acquirep)
394 return 0;
396 for (; (tsp = *acquirep) != NULL; ++acquirep) {
397 clp = CLP(tsp);
398 F_SET(clp, CL_LAYOUT);
400 if (CLSP(tsp))
401 delwin(CLSP(tsp));
402 tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols,
403 tsp->roff, tsp->coff);
406 /* discardp is going away, acquirep is taking up its space. */
407 return (0);
411 * cl_ex_adjust --
412 * Adjust the screen for ex. This routine is purely for standalone
413 * ex programs. All special purpose, all special case.
415 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
418 cl_ex_adjust(SCR *sp, exadj_t action)
420 CL_PRIVATE *clp;
421 int cnt;
423 clp = CLP(sp);
424 switch (action) {
425 case EX_TERM_SCROLL:
426 /* Move the cursor up one line if that's possible. */
427 if (clp->cuu1 != NULL)
428 (void)tputs(clp->cuu1, 1, cl_putchar);
429 else if (clp->cup != NULL)
430 (void)tputs(tgoto(clp->cup,
431 0, LINES - 2), 1, cl_putchar);
432 else
433 return (0);
434 /* FALLTHROUGH */
435 case EX_TERM_CE:
436 /* Clear the line. */
437 if (clp->el != NULL) {
438 (void)putchar('\r');
439 (void)tputs(clp->el, 1, cl_putchar);
440 } else {
442 * Historically, ex didn't erase the line, so, if the
443 * displayed line was only a single glyph, and <eof>
444 * was more than one glyph, the output would not fully
445 * overwrite the user's input. To fix this, output
446 * the maxiumum character number of spaces. Note,
447 * this won't help if the user entered extra prompt
448 * or <blank> characters before the command character.
449 * We'd have to do a lot of work to make that work, and
450 * it's almost certainly not worth the effort.
452 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
453 (void)putchar('\b');
454 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
455 (void)putchar(' ');
456 (void)putchar('\r');
457 (void)fflush(stdout);
459 break;
460 default:
461 abort();
463 return (0);
467 * cl_insertln --
468 * Push down the current line, discarding the bottom line.
470 * PUBLIC: int cl_insertln __P((SCR *));
473 cl_insertln(SCR *sp)
475 WINDOW *win;
476 win = CLSP(sp) ? CLSP(sp) : stdscr;
478 * The current line is expected to be blank after this operation,
479 * and the screen must support that semantic.
481 return (winsertln(win) == ERR);
485 * cl_keyval --
486 * Return the value for a special key.
488 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
491 cl_keyval(SCR *sp, scr_keyval_t val, CHAR_T *chp, int *dnep)
493 CL_PRIVATE *clp;
496 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
497 * VWERASE is a 4BSD extension.
499 clp = CLP(sp);
500 switch (val) {
501 case KEY_VEOF:
502 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
503 break;
504 case KEY_VERASE:
505 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
506 break;
507 case KEY_VKILL:
508 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
509 break;
510 #ifdef VWERASE
511 case KEY_VWERASE:
512 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
513 break;
514 #endif
515 default:
516 *dnep = 1;
517 break;
519 return (0);
523 * cl_move --
524 * Move the cursor.
526 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
529 cl_move(SCR *sp, size_t lno, size_t cno)
531 WINDOW *win;
532 win = CLSP(sp) ? CLSP(sp) : stdscr;
533 /* See the comment in cl_cursor. */
534 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
535 msgq(sp, M_ERR, "Error: move: l(%zu + %zu) c(%zu + %zu)",
536 lno, sp->roff, cno, sp->coff);
537 return (1);
539 return (0);
543 * cl_refresh --
544 * Refresh the screen.
546 * PUBLIC: int cl_refresh __P((SCR *, int));
549 cl_refresh(SCR *sp, int repaint)
551 GS *gp;
552 CL_PRIVATE *clp;
553 WINDOW *win;
554 SCR *psp, *tsp;
555 size_t y, x;
557 gp = sp->gp;
558 clp = CLP(sp);
559 win = CLSP(sp) ? CLSP(sp) : stdscr;
562 * If we received a killer signal, we're done, there's no point
563 * in refreshing the screen.
565 if (clp->killersig)
566 return (0);
569 * If repaint is set, the editor is telling us that we don't know
570 * what's on the screen, so we have to repaint from scratch.
572 * If repaint set or the screen layout changed, we need to redraw
573 * any lines separating vertically split screens. If the horizontal
574 * offsets are the same, then the split was vertical, and need to
575 * draw a dividing line.
577 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
578 getyx(stdscr, y, x);
579 for (psp = sp;
580 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
581 for (tsp = psp->q.cqe_next;
582 tsp != (void *)&sp->wp->scrq;
583 tsp = tsp->q.cqe_next)
584 if (psp->roff == tsp->roff) {
585 if (psp->coff + psp->cols + 1 == tsp->coff)
586 cl_rdiv(psp);
587 else
588 if (tsp->coff + tsp->cols + 1 == psp->coff)
589 cl_rdiv(tsp);
591 (void)wmove(stdscr, y, x);
592 F_CLR(clp, CL_LAYOUT);
596 * In the curses library, doing wrefresh(curscr) is okay, but the
597 * screen flashes when we then apply the refresh() to bring it up
598 * to date. So, use clearok().
600 if (repaint)
601 clearok(curscr, 1);
603 * Only do an actual refresh, when this is the focus window,
604 * i.e. the one holding the cursor. This assumes that refresh
605 * is called for that window after refreshing the others.
606 * This prevents the cursor being drawn in the other windows.
608 return (wnoutrefresh(stdscr) == ERR ||
609 wnoutrefresh(win) == ERR ||
610 (sp == clp->focus && doupdate() == ERR));
614 * cl_rdiv --
615 * Draw a dividing line between two vertically split screens.
617 static void
618 cl_rdiv(SCR *sp)
620 size_t cnt;
622 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
623 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
624 waddch(stdscr, '|');
629 * cl_rename --
630 * Rename the file.
632 * PUBLIC: int cl_rename __P((SCR *, char *, int));
635 cl_rename(SCR *sp, char *name, int on)
637 CL_PRIVATE *clp;
638 FILE *pfp;
639 GS *gp;
640 char buf[256], *p;
642 gp = sp->gp;
643 clp = CLP(sp);
645 if (on) {
646 clp->focus = sp;
647 if (!F_ISSET(clp, CL_RENAME_OK))
648 return (0);
651 * XXX
652 * We can only rename windows for xterm.
654 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
655 return (0);
658 * XXX
659 * Try and figure out the current name of this window. There
660 * are two forms of the xwininfo output I've seen:
662 * Window id: 0x400000d "name"
663 * Window id: 0x140000d (name)
665 #define COMMAND \
666 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
668 if (clp->oname == NULL &&
669 (pfp = popen(COMMAND, "r")) != NULL) {
670 if (fgets(buf, sizeof(buf), pfp) != NULL &&
671 (p = strchr(buf, '\n')) != NULL) {
672 *p = '\0';
673 clp->oname = strdup(buf);
675 (void)fclose(pfp);
678 cl_setname(gp, name);
680 F_SET(clp, CL_RENAME);
681 } else
682 if (F_ISSET(clp, CL_RENAME)) {
683 cl_setname(gp, clp->oname);
685 F_CLR(clp, CL_RENAME);
687 return (0);
691 * cl_setname --
692 * Set a X11 icon/window name.
694 * PUBLIC: void cl_setname __P((GS *, char *));
696 void
697 cl_setname(GS *gp, char *name)
699 /* X11 xterm escape sequence to rename the icon/window. */
700 #define XTERM_RENAME "\033]0;%s\007"
702 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
703 (void)fflush(stdout);
707 * cl_split --
708 * Split a screen.
710 * PUBLIC: int cl_split __P((SCR *, SCR *));
713 cl_split(SCR *origp, SCR *newp)
715 CL_PRIVATE *clp;
717 clp = CLP(origp);
718 F_SET(clp, CL_LAYOUT);
720 if (CLSP(origp))
721 delwin(CLSP(origp));
723 origp->cl_private = subwin(stdscr, origp->rows, origp->cols,
724 origp->roff, origp->coff);
725 newp->cl_private = subwin(stdscr, newp->rows, newp->cols,
726 newp->roff, newp->coff);
728 /* origp is the original screen, giving up space to newp. */
729 return (0);
733 * cl_suspend --
734 * Suspend a screen.
736 * PUBLIC: int cl_suspend __P((SCR *, int *));
739 cl_suspend(SCR *sp, int *allowedp)
741 struct termios t;
742 CL_PRIVATE *clp;
743 WINDOW *win;
744 GS *gp;
745 size_t y, x;
746 int changed;
748 gp = sp->gp;
749 clp = CLP(sp);
750 win = CLSP(sp) ? CLSP(sp) : stdscr;
751 *allowedp = 1;
754 * The ex implementation of this function isn't needed by screens not
755 * supporting ex commands that require full terminal canonical mode
756 * (e.g. :suspend).
758 * The vi implementation of this function isn't needed by screens not
759 * supporting vi process suspension, i.e. any screen that isn't backed
760 * by a UNIX shell.
762 * Setting allowedp to 0 will cause the editor to reject the command.
764 if (F_ISSET(sp, SC_EX)) {
765 /* Save the terminal settings, and restore the original ones. */
766 if (F_ISSET(clp, CL_STDIN_TTY)) {
767 (void)tcgetattr(STDIN_FILENO, &t);
768 (void)tcsetattr(STDIN_FILENO,
769 TCSASOFT | TCSADRAIN, &clp->orig);
772 /* Stop the process group. */
773 (void)kill(0, SIGTSTP);
775 /* Time passes ... */
777 /* Restore terminal settings. */
778 if (F_ISSET(clp, CL_STDIN_TTY))
779 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
780 return (0);
784 * Move to the lower left-hand corner of the screen.
786 * XXX
787 * Not sure this is necessary in System V implementations, but it
788 * shouldn't hurt.
790 getyx(win, y, x);
791 (void)wmove(win, LINES - 1, 0);
792 (void)wrefresh(win);
795 * Temporarily end the screen. System V introduced a semantic where
796 * endwin() could be restarted. We use it because restarting curses
797 * from scratch often fails in System V. 4BSD curses didn't support
798 * restarting after endwin(), so we have to do what clean up we can
799 * without calling it.
801 /* Save the terminal settings. */
802 (void)tcgetattr(STDIN_FILENO, &t);
804 /* Restore the cursor keys to normal mode. */
805 (void)keypad(stdscr, FALSE);
807 /* Restore the window name. */
808 (void)cl_rename(sp, NULL, 0);
810 #ifdef HAVE_BSD_CURSES
811 (void)cl_attr(sp, SA_ALTERNATE, 0);
812 #else
813 (void)endwin();
814 #endif
816 * XXX
817 * Restore the original terminal settings. This is bad -- the
818 * reset can cause character loss from the tty queue. However,
819 * we can't call endwin() in BSD curses implementations, and too
820 * many System V curses implementations don't get it right.
822 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
824 /* Stop the process group. */
825 (void)kill(0, SIGTSTP);
827 /* Time passes ... */
830 * If we received a killer signal, we're done. Leave everything
831 * unchanged. In addition, the terminal has already been reset
832 * correctly, so leave it alone.
834 if (clp->killersig) {
835 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
836 return (0);
839 /* Restore terminal settings. */
840 wrefresh(win); /* Needed on SunOs/Solaris ? */
841 if (F_ISSET(clp, CL_STDIN_TTY))
842 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
844 #ifdef HAVE_BSD_CURSES
845 (void)cl_attr(sp, SA_ALTERNATE, 1);
846 #endif
848 /* Set the window name. */
849 (void)cl_rename(sp, sp->frp->name, 1);
851 /* Put the cursor keys into application mode. */
852 (void)keypad(stdscr, TRUE);
854 /* Refresh and repaint the screen. */
855 (void)wmove(win, y, x);
856 (void)cl_refresh(sp, 1);
858 /* If the screen changed size, set the SIGWINCH bit. */
859 if (cl_ssize(sp, 1, NULL, NULL, &changed))
860 return (1);
861 if (changed)
862 F_SET(CLP(sp), CL_SIGWINCH);
864 return (0);
868 * cl_usage --
869 * Print out the curses usage messages.
871 * PUBLIC: void cl_usage __P((void));
873 void
874 cl_usage(void)
876 #define USAGE "\
877 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
878 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
879 (void)fprintf(stderr, "%s", USAGE);
880 #undef USAGE
883 #ifdef DEBUG
885 * gdbrefresh --
886 * Stub routine so can flush out curses screen changes using gdb.
889 gdbrefresh(void)
891 refresh();
892 return (0); /* XXX Convince gdb to run it. */
894 #endif