2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: ex_visual.c,v 8.7 1993/11/29 20:01:54 bostic Exp $ (Berkeley) $Date: 1993/11/29 20:01:54 $";
12 #include <sys/types.h>
21 * ex_visual -- :[line] vi[sual] [^-.+] [window_size] [flags]
23 * Switch to visual mode.
26 ex_visual(sp
, ep
, cmdp
)
35 /* If open option off, disallow visual command. */
36 if (!O_ISSET(sp
, O_OPEN
)) {
38 "The visual command requires that the open option be set.");
42 /* If a line specified, move to that line. */
44 sp
->lno
= cmdp
->addr1
.lno
;
47 * Push a command based on the line position flags. If no
48 * flag specified, the line goes at the top of the screen.
50 switch (F_ISSET(cmdp
, E_F_CARAT
| E_F_DASH
| E_F_DOT
| E_F_PLUS
)) {
66 if (F_ISSET(cmdp
, E_COUNT
))
67 len
= snprintf(buf
, sizeof(buf
),
68 "%luz%c%lu", sp
->lno
, pos
, cmdp
->count
);
70 len
= snprintf(buf
, sizeof(buf
), "%luz%c", sp
->lno
, pos
);
71 (void)term_push(sp
, buf
, len
, 0, CH_NOMAP
| CH_QUOTED
);
75 * Historically, if no line address was specified, the [p#l] flags
76 * caused the cursor to be moved to the last line of the file, which
77 * was then positioned as described above. This seems useless, so
78 * I haven't implemented it.
80 switch (F_ISSET(cmdp
, E_F_HASH
| E_F_LIST
| E_F_PRINT
)) {
93 F_SET(sp
, sp
->saved_vi_mode
);