remove spurious cursor movements on split screens
[nvi.git] / cl / cl_funcs.c
blob4072814cf7730fdb8756b282eae601821d516919
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.65 2001/04/24 21:47:44 skimo Exp $ (Berkeley) $Date: 2001/04/24 21:47: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 *));
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 wchar_t *dstr;
61 size_t dlen;
62 INT2DISP(sp, str, len, dstr, dlen);
63 if (waddnwstr(win, (wchar_t*) 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(sp, str, len)
83 SCR *sp;
84 const CHAR_T *str;
85 size_t len;
87 addstr4(sp, (void *)str, len, 1);
91 * cl_addstr --
92 * Add len bytes from the string at the cursor, advancing the cursor.
94 * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
96 int
97 cl_addstr(sp, str, len)
98 SCR *sp;
99 const char *str;
100 size_t len;
102 addstr4(sp, (void *)str, len, 0);
106 * cl_attr --
107 * Toggle a screen attribute on/off.
109 * PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
112 cl_attr(sp, attribute, on)
113 SCR *sp;
114 scr_attr_t attribute;
115 int on;
117 CL_PRIVATE *clp;
118 WINDOW *win;
120 clp = CLP(sp);
121 win = CLSP(sp) ? CLSP(sp) : stdscr;
123 switch (attribute) {
124 case SA_ALTERNATE:
126 * !!!
127 * There's a major layering violation here. The problem is that the
128 * X11 xterm screen has what's known as an "alternate" screen. Some
129 * xterm termcap/terminfo entries include sequences to switch to/from
130 * that alternate screen as part of the ti/te (smcup/rmcup) strings.
131 * Vi runs in the alternate screen, so that you are returned to the
132 * same screen contents on exit from vi that you had when you entered
133 * vi. Further, when you run :shell, or :!date or similar ex commands,
134 * you also see the original screen contents. This wasn't deliberate
135 * on vi's part, it's just that it historically sent terminal init/end
136 * sequences at those times, and the addition of the alternate screen
137 * sequences to the strings changed the behavior of vi. The problem
138 * caused by this is that we don't want to switch back to the alternate
139 * screen while getting a new command from the user, when the user is
140 * continuing to enter ex commands, e.g.:
142 * :!date <<< switch to original screen
143 * [Hit return to continue] <<< prompt user to continue
144 * :command <<< get command from user
146 * Note that the :command input is a true vi input mode, e.g., input
147 * maps and abbreviations are being done. So, we need to be able to
148 * switch back into the vi screen mode, without flashing the screen.
150 * To make matters worse, the curses initscr() and endwin() calls will
151 * do this automatically -- so, this attribute isn't as controlled by
152 * the higher level screen as closely as one might like.
154 if (on) {
155 if (clp->ti_te != TI_SENT) {
156 clp->ti_te = TI_SENT;
157 if (clp->smcup == NULL)
158 (void)cl_getcap(sp, "smcup", &clp->smcup);
159 if (clp->smcup != NULL)
160 (void)tputs(clp->smcup, 1, cl_putchar);
162 } else
163 if (clp->ti_te != TE_SENT) {
164 clp->ti_te = TE_SENT;
165 if (clp->rmcup == NULL)
166 (void)cl_getcap(sp, "rmcup", &clp->rmcup);
167 if (clp->rmcup != NULL)
168 (void)tputs(clp->rmcup, 1, cl_putchar);
169 (void)fflush(stdout);
171 (void)fflush(stdout);
172 break;
173 case SA_INVERSE:
174 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
175 if (clp->smso == NULL)
176 return (1);
177 if (on)
178 (void)tputs(clp->smso, 1, cl_putchar);
179 else
180 (void)tputs(clp->rmso, 1, cl_putchar);
181 (void)fflush(stdout);
182 } else {
183 if (on)
184 (void)wstandout(win);
185 else
186 (void)wstandend(win);
188 break;
189 default:
190 abort();
192 return (0);
196 * cl_baud --
197 * Return the baud rate.
199 * PUBLIC: int cl_baud __P((SCR *, u_long *));
202 cl_baud(sp, ratep)
203 SCR *sp;
204 u_long *ratep;
206 CL_PRIVATE *clp;
209 * XXX
210 * There's no portable way to get a "baud rate" -- cfgetospeed(3)
211 * returns the value associated with some #define, which we may
212 * never have heard of, or which may be a purely local speed. Vi
213 * only cares if it's SLOW (w300), slow (w1200) or fast (w9600).
214 * Try and detect the slow ones, and default to fast.
216 clp = CLP(sp);
217 switch (cfgetospeed(&clp->orig)) {
218 case B50:
219 case B75:
220 case B110:
221 case B134:
222 case B150:
223 case B200:
224 case B300:
225 case B600:
226 *ratep = 600;
227 break;
228 case B1200:
229 *ratep = 1200;
230 break;
231 default:
232 *ratep = 9600;
233 break;
235 return (0);
239 * cl_bell --
240 * Ring the bell/flash the screen.
242 * PUBLIC: int cl_bell __P((SCR *));
245 cl_bell(sp)
246 SCR *sp;
248 if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
249 (void)write(STDOUT_FILENO, "\07", 1); /* \a */
250 else {
252 * Vi has an edit option which determines if the terminal
253 * should be beeped or the screen flashed.
255 if (O_ISSET(sp, O_FLASH))
256 (void)flash();
257 else
258 (void)beep();
260 return (0);
264 * cl_clrtoeol --
265 * Clear from the current cursor to the end of the line.
267 * PUBLIC: int cl_clrtoeol __P((SCR *));
270 cl_clrtoeol(sp)
271 SCR *sp;
273 WINDOW *win;
274 size_t spcnt, y, x;
276 win = CLSP(sp) ? CLSP(sp) : stdscr;
278 #if 0
279 if (IS_VSPLIT(sp)) {
280 /* The cursor must be returned to its original position. */
281 getyx(win, y, x);
282 for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
283 (void)waddch(win, ' ');
284 (void)wmove(win, y, x);
285 return (0);
286 } else
287 #endif
288 return (wclrtoeol(win) == ERR);
292 * cl_cursor --
293 * Return the current cursor position.
295 * PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
298 cl_cursor(sp, yp, xp)
299 SCR *sp;
300 size_t *yp, *xp;
302 WINDOW *win;
303 win = CLSP(sp) ? CLSP(sp) : stdscr;
305 * The curses screen support splits a single underlying curses screen
306 * into multiple screens to support split screen semantics. For this
307 * reason the returned value must be adjusted to be relative to the
308 * current screen, and not absolute. Screens that implement the split
309 * using physically distinct screens won't need this hack.
311 getyx(win, *yp, *xp);
313 *yp -= sp->roff;
314 *xp -= sp->coff;
316 return (0);
320 * cl_deleteln --
321 * Delete the current line, scrolling all lines below it.
323 * PUBLIC: int cl_deleteln __P((SCR *));
326 cl_deleteln(sp)
327 SCR *sp;
329 CHAR_T ch;
330 CL_PRIVATE *clp;
331 WINDOW *win;
332 size_t col, lno, spcnt, y, x;
334 clp = CLP(sp);
335 win = CLSP(sp) ? CLSP(sp) : stdscr;
338 * This clause is required because the curses screen uses reverse
339 * video to delimit split screens. If the screen does not do this,
340 * this code won't be necessary.
342 * If the bottom line was in reverse video, rewrite it in normal
343 * video before it's scrolled.
345 * Check for the existence of a chgat function; XSI requires it, but
346 * historic implementations of System V curses don't. If it's not
347 * a #define, we'll fall back to doing it by hand, which is slow but
348 * acceptable.
350 * By hand means walking through the line, retrieving and rewriting
351 * each character. Curses has no EOL marker, so track strings of
352 * spaces, and copy the trailing spaces only if there's a non-space
353 * character following.
355 if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
356 getyx(win, y, x);
357 #ifdef mvchgat
358 mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
359 #else
360 for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
361 (void)wmove(win, lno, col);
362 ch = winch(win);
363 if (isblank(ch))
364 ++spcnt;
365 else {
366 (void)wmove(win, lno, col - spcnt);
367 for (; spcnt > 0; --spcnt)
368 (void)waddch(win, ' ');
369 (void)waddch(win, ch);
371 if (++col >= sp->cols)
372 break;
374 #endif
375 (void)wmove(win, y, x);
379 * The bottom line is expected to be blank after this operation,
380 * and other screens must support that semantic.
382 return (wdeleteln(win) == ERR);
386 * cl_discard --
387 * Discard a screen.
389 * PUBLIC: int cl_discard __P((SCR *, SCR **));
392 cl_discard(discardp, acquirep)
393 SCR *discardp, **acquirep;
395 CL_PRIVATE *clp;
396 SCR* tsp;
398 if (discardp) {
399 clp = CLP(discardp);
400 F_SET(clp, CL_LAYOUT);
402 if (CLSP(discardp)) {
403 delwin(CLSP(discardp));
404 CLSP(discardp) = NULL;
408 /* no screens got a piece; we're done */
409 if (!acquirep)
410 return 0;
412 for (; (tsp = *acquirep) != NULL; ++acquirep) {
413 clp = CLP(tsp);
414 F_SET(clp, CL_LAYOUT);
416 if (CLSP(tsp))
417 delwin(CLSP(tsp));
418 CLSP(tsp) = subwin(stdscr, tsp->rows, tsp->cols,
419 tsp->roff, tsp->coff);
422 /* discardp is going away, acquirep is taking up its space. */
423 return (0);
427 * cl_ex_adjust --
428 * Adjust the screen for ex. This routine is purely for standalone
429 * ex programs. All special purpose, all special case.
431 * PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
434 cl_ex_adjust(sp, action)
435 SCR *sp;
436 exadj_t action;
438 CL_PRIVATE *clp;
439 int cnt;
441 clp = CLP(sp);
442 switch (action) {
443 case EX_TERM_SCROLL:
444 /* Move the cursor up one line if that's possible. */
445 if (clp->cuu1 != NULL)
446 (void)tputs(clp->cuu1, 1, cl_putchar);
447 else if (clp->cup != NULL)
448 (void)tputs(tgoto(clp->cup,
449 0, LINES - 2), 1, cl_putchar);
450 else
451 return (0);
452 /* FALLTHROUGH */
453 case EX_TERM_CE:
454 /* Clear the line. */
455 if (clp->el != NULL) {
456 (void)putchar('\r');
457 (void)tputs(clp->el, 1, cl_putchar);
458 } else {
460 * Historically, ex didn't erase the line, so, if the
461 * displayed line was only a single glyph, and <eof>
462 * was more than one glyph, the output would not fully
463 * overwrite the user's input. To fix this, output
464 * the maxiumum character number of spaces. Note,
465 * this won't help if the user entered extra prompt
466 * or <blank> characters before the command character.
467 * We'd have to do a lot of work to make that work, and
468 * it's almost certainly not worth the effort.
470 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
471 (void)putchar('\b');
472 for (cnt = 0; cnt < MAX_CHARACTER_COLUMNS; ++cnt)
473 (void)putchar(' ');
474 (void)putchar('\r');
475 (void)fflush(stdout);
477 break;
478 default:
479 abort();
481 return (0);
485 * cl_insertln --
486 * Push down the current line, discarding the bottom line.
488 * PUBLIC: int cl_insertln __P((SCR *));
491 cl_insertln(sp)
492 SCR *sp;
494 WINDOW *win;
495 win = CLSP(sp) ? CLSP(sp) : stdscr;
497 * The current line is expected to be blank after this operation,
498 * and the screen must support that semantic.
500 return (winsertln(win) == ERR);
504 * cl_keyval --
505 * Return the value for a special key.
507 * PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
510 cl_keyval(sp, val, chp, dnep)
511 SCR *sp;
512 scr_keyval_t val;
513 CHAR_T *chp;
514 int *dnep;
516 CL_PRIVATE *clp;
519 * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
520 * VWERASE is a 4BSD extension.
522 clp = CLP(sp);
523 switch (val) {
524 case KEY_VEOF:
525 *dnep = (*chp = clp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
526 break;
527 case KEY_VERASE:
528 *dnep = (*chp = clp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
529 break;
530 case KEY_VKILL:
531 *dnep = (*chp = clp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
532 break;
533 #ifdef VWERASE
534 case KEY_VWERASE:
535 *dnep = (*chp = clp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
536 break;
537 #endif
538 default:
539 *dnep = 1;
540 break;
542 return (0);
546 * cl_move --
547 * Move the cursor.
549 * PUBLIC: int cl_move __P((SCR *, size_t, size_t));
552 cl_move(sp, lno, cno)
553 SCR *sp;
554 size_t lno, cno;
556 WINDOW *win;
557 win = CLSP(sp) ? CLSP(sp) : stdscr;
558 /* See the comment in cl_cursor. */
559 if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
560 msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)",
561 lno, sp->roff, cno, sp->coff);
562 return (1);
564 return (0);
568 * cl_refresh --
569 * Refresh the screen.
571 * PUBLIC: int cl_refresh __P((SCR *, int));
574 cl_refresh(sp, repaint)
575 SCR *sp;
576 int repaint;
578 GS *gp;
579 CL_PRIVATE *clp;
580 WINDOW *win;
581 SCR *psp, *tsp;
582 size_t y, x;
584 gp = sp->gp;
585 clp = CLP(sp);
586 win = CLSP(sp) ? CLSP(sp) : stdscr;
589 * If we received a killer signal, we're done, there's no point
590 * in refreshing the screen.
592 if (clp->killersig)
593 return (0);
596 * If repaint is set, the editor is telling us that we don't know
597 * what's on the screen, so we have to repaint from scratch.
599 * If repaint set or the screen layout changed, we need to redraw
600 * any lines separating vertically split screens. If the horizontal
601 * offsets are the same, then the split was vertical, and need to
602 * draw a dividing line.
604 if (repaint || F_ISSET(clp, CL_LAYOUT)) {
605 getyx(stdscr, y, x);
606 for (psp = sp;
607 psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
608 for (tsp = psp->q.cqe_next;
609 tsp != (void *)&sp->wp->scrq;
610 tsp = tsp->q.cqe_next)
611 if (psp->roff == tsp->roff) {
612 if (psp->coff + psp->cols + 1 == tsp->coff)
613 cl_rdiv(psp);
614 else
615 if (tsp->coff + tsp->cols + 1 == psp->coff)
616 cl_rdiv(tsp);
618 (void)wmove(stdscr, y, x);
619 F_CLR(clp, CL_LAYOUT);
623 * In the curses library, doing wrefresh(curscr) is okay, but the
624 * screen flashes when we then apply the refresh() to bring it up
625 * to date. So, use clearok().
627 if (repaint)
628 clearok(curscr, 1);
629 return (wnoutrefresh(stdscr) == ERR ||
630 wnoutrefresh(win) == ERR || doupdate() == ERR);
634 * cl_rdiv --
635 * Draw a dividing line between two vertically split screens.
637 static void
638 cl_rdiv(sp)
639 SCR *sp;
641 size_t cnt;
643 for (cnt = 0; cnt < sp->rows - 1; ++cnt) {
644 wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff);
645 waddch(stdscr, '|');
650 * cl_rename --
651 * Rename the file.
653 * PUBLIC: int cl_rename __P((SCR *, char *, int));
656 cl_rename(sp, name, on)
657 SCR *sp;
658 char *name;
659 int on;
661 CL_PRIVATE *clp;
662 FILE *pfp;
663 GS *gp;
664 char buf[256], *p;
666 gp = sp->gp;
667 clp = CLP(sp);
669 if (on) {
670 if (!F_ISSET(clp, CL_RENAME_OK))
671 return (0);
674 * XXX
675 * We can only rename windows for xterm.
677 if (strncmp(OG_STR(gp, GO_TERM), "xterm", sizeof("xterm") - 1))
678 return (0);
681 * XXX
682 * Try and figure out the current name of this window. There
683 * are two forms of the xwininfo output I've seen:
685 * Window id: 0x400000d "name"
686 * Window id: 0x140000d (name)
688 #define COMMAND \
689 "expr \"`xwininfo -id $WINDOWID | grep id:`\" : '.* [\"(]\\(.*\\)[\")]'"
691 if (clp->oname == NULL &&
692 (pfp = popen(COMMAND, "r")) != NULL) {
693 if (fgets(buf, sizeof(buf), pfp) != NULL &&
694 (p = strchr(buf, '\n')) != NULL) {
695 *p = '\0';
696 clp->oname = strdup(buf);
698 (void)fclose(pfp);
701 cl_setname(gp, name);
703 F_SET(clp, CL_RENAME);
704 } else
705 if (F_ISSET(clp, CL_RENAME)) {
706 cl_setname(gp, clp->oname);
708 F_CLR(clp, CL_RENAME);
710 return (0);
714 * cl_setname --
715 * Set a X11 icon/window name.
717 * PUBLIC: void cl_setname __P((GS *, char *));
719 void
720 cl_setname(gp, name)
721 GS *gp;
722 char *name;
724 /* X11 xterm escape sequence to rename the icon/window. */
725 #define XTERM_RENAME "\033]0;%s\007"
727 (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
728 (void)fflush(stdout);
732 * cl_split --
733 * Split a screen.
735 * PUBLIC: int cl_split __P((SCR *, SCR *));
738 cl_split(origp, newp)
739 SCR *origp, *newp;
741 CL_PRIVATE *clp;
743 clp = CLP(origp);
744 F_SET(clp, CL_LAYOUT);
746 if (CLSP(origp))
747 delwin(CLSP(origp));
749 CLSP(origp) = subwin(stdscr, origp->rows, origp->cols,
750 origp->roff, origp->coff);
751 CLSP(newp) = subwin(stdscr, newp->rows, newp->cols,
752 newp->roff, newp->coff);
754 /* origp is the original screen, giving up space to newp. */
755 return (0);
759 * cl_suspend --
760 * Suspend a screen.
762 * PUBLIC: int cl_suspend __P((SCR *, int *));
765 cl_suspend(sp, allowedp)
766 SCR *sp;
767 int *allowedp;
769 struct termios t;
770 CL_PRIVATE *clp;
771 WINDOW *win;
772 GS *gp;
773 size_t y, x;
774 int changed;
776 gp = sp->gp;
777 clp = CLP(sp);
778 win = CLSP(sp) ? CLSP(sp) : stdscr;
779 *allowedp = 1;
782 * The ex implementation of this function isn't needed by screens not
783 * supporting ex commands that require full terminal canonical mode
784 * (e.g. :suspend).
786 * The vi implementation of this function isn't needed by screens not
787 * supporting vi process suspension, i.e. any screen that isn't backed
788 * by a UNIX shell.
790 * Setting allowedp to 0 will cause the editor to reject the command.
792 if (F_ISSET(sp, SC_EX)) {
793 /* Save the terminal settings, and restore the original ones. */
794 if (F_ISSET(clp, CL_STDIN_TTY)) {
795 (void)tcgetattr(STDIN_FILENO, &t);
796 (void)tcsetattr(STDIN_FILENO,
797 TCSASOFT | TCSADRAIN, &clp->orig);
800 /* Stop the process group. */
801 (void)kill(0, SIGTSTP);
803 /* Time passes ... */
805 /* Restore terminal settings. */
806 if (F_ISSET(clp, CL_STDIN_TTY))
807 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
808 return (0);
812 * Move to the lower left-hand corner of the screen.
814 * XXX
815 * Not sure this is necessary in System V implementations, but it
816 * shouldn't hurt.
818 getyx(win, y, x);
819 (void)wmove(win, LINES - 1, 0);
820 (void)wrefresh(win);
823 * Temporarily end the screen. System V introduced a semantic where
824 * endwin() could be restarted. We use it because restarting curses
825 * from scratch often fails in System V. 4BSD curses didn't support
826 * restarting after endwin(), so we have to do what clean up we can
827 * without calling it.
829 /* Save the terminal settings. */
830 (void)tcgetattr(STDIN_FILENO, &t);
832 /* Restore the cursor keys to normal mode. */
833 (void)keypad(stdscr, FALSE);
835 /* Restore the window name. */
836 (void)cl_rename(sp, NULL, 0);
838 #ifdef HAVE_BSD_CURSES
839 (void)cl_attr(sp, SA_ALTERNATE, 0);
840 #else
841 (void)endwin();
842 #endif
844 * XXX
845 * Restore the original terminal settings. This is bad -- the
846 * reset can cause character loss from the tty queue. However,
847 * we can't call endwin() in BSD curses implementations, and too
848 * many System V curses implementations don't get it right.
850 (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig);
852 /* Stop the process group. */
853 (void)kill(0, SIGTSTP);
855 /* Time passes ... */
858 * If we received a killer signal, we're done. Leave everything
859 * unchanged. In addition, the terminal has already been reset
860 * correctly, so leave it alone.
862 if (clp->killersig) {
863 F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT);
864 return (0);
867 /* Restore terminal settings. */
868 wrefresh(win); /* Needed on SunOs/Solaris ? */
869 if (F_ISSET(clp, CL_STDIN_TTY))
870 (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
872 #ifdef HAVE_BSD_CURSES
873 (void)cl_attr(sp, SA_ALTERNATE, 1);
874 #endif
876 /* Set the window name. */
877 (void)cl_rename(sp, sp->frp->name, 1);
879 /* Put the cursor keys into application mode. */
880 (void)keypad(stdscr, TRUE);
882 /* Refresh and repaint the screen. */
883 (void)wmove(win, y, x);
884 (void)cl_refresh(sp, 1);
886 /* If the screen changed size, set the SIGWINCH bit. */
887 if (cl_ssize(sp, 1, NULL, NULL, &changed))
888 return (1);
889 if (changed)
890 F_SET(CLP(sp), CL_SIGWINCH);
892 return (0);
896 * cl_usage --
897 * Print out the curses usage messages.
899 * PUBLIC: void cl_usage __P((void));
901 void
902 cl_usage()
904 #define USAGE "\
905 usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
906 usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
907 (void)fprintf(stderr, "%s", USAGE);
908 #undef USAGE
911 #ifdef DEBUG
913 * gdbrefresh --
914 * Stub routine so can flush out curses screen changes using gdb.
917 gdbrefresh()
919 refresh();
920 return (0); /* XXX Convince gdb to run it. */
922 #endif