limited capability to view long lines with vi

This commit is contained in:
Gunnar Ritter 2005-08-05 23:15:03 +00:00
parent b5ea77e25f
commit 5e1eca3ce2
12 changed files with 98 additions and 56 deletions

View File

@ -2,7 +2,9 @@ Release ...
* The screen buffers for visual mode are now dynamically allocated, so * The screen buffers for visual mode are now dynamically allocated, so
vi usually does not return to ex mode with "screen too large" when the vi usually does not return to ex mode with "screen too large" when the
terminal is resized on a large monitor anymore. terminal is resized on a large monitor anymore.
* ex (not vi) can now edit files with lines of arbitrary length. * ex can now edit files with lines of arbitrary length. vi currently only
shows the beginning of a line that does not fit onto the screen in its
entirety.
* Viewing executables and compressed files is no longer inhibited. * Viewing executables and compressed files is no longer inhibited.
Release 3/25/05 Release 3/25/05

6
ex.h
View File

@ -72,7 +72,7 @@
* *
* from ex.h 7.7.1.1 (Berkeley) 8/12/86 * from ex.h 7.7.1.1 (Berkeley) 8/12/86
* *
* Sccsid @(#)ex.h 1.55 (gritter) 8/4/05 * Sccsid @(#)ex.h 1.56 (gritter) 8/6/05
*/ */
/* /*
@ -456,7 +456,7 @@ var int exitoneof; /* exit command loop on EOF */
#define lastchar() lastc #define lastchar() lastc
#define outchar(c) (*Outchar)(c) #define outchar(c) (*Outchar)(c)
#define pastwh() (ignore(skipwh())) #define pastwh() (ignore(skipwh()))
#define pline(no) (*Pline)(no) #define pline(no, max) (*Pline)(no, max)
#define reset() LONGJMP(resetlab,1) #define reset() LONGJMP(resetlab,1)
#define resexit(a) copy(resetlab, a, sizeof (JMP_BUF)) #define resexit(a) copy(resetlab, a, sizeof (JMP_BUF))
#define setexit() SETJMP(resetlab) #define setexit() SETJMP(resetlab)
@ -526,7 +526,7 @@ var line *undadot; /* If we saved all lines, dot reverts here */
#define UNDPUT 4 #define UNDPUT 4
extern int (*Outchar)(int); extern int (*Outchar)(int);
extern void (*Pline)(int); extern void (*Pline)(int, int);
extern int (*Putchar)(int); extern int (*Putchar)(int);
#define NOSTR (char *) 0 #define NOSTR (char *) 0

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_cmdsub.c 1.31 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_cmdsub.c 1.32 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -984,7 +984,7 @@ plines(line *adr1, register line *adr2, bool movedot)
pofix(); pofix();
for (addr = adr1; addr <= adr2; addr++) { for (addr = adr1; addr <= adr2; addr++) {
getline(*addr); getline(*addr);
pline(lineno(addr)); pline(lineno(addr), -1);
if (inopen) { if (inopen) {
putchar('\n' | QUOTE); putchar('\n' | QUOTE);
} }

View File

@ -71,7 +71,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* Sccsid @(#)ex_proto.h 1.31 (gritter) 8/4/05 * Sccsid @(#)ex_proto.h 1.32 (gritter) 8/6/05
*/ */
/* /*
@ -192,12 +192,12 @@ extern int widthok(int c);
extern int GETWC(char *); extern int GETWC(char *);
/* ex_put.c */ /* ex_put.c */
extern int (*setlist(int))(int); extern int (*setlist(int))(int);
extern void (*setnumb(int))(int); extern void (*setnumb(int))(int, int);
extern int listchar(int); extern int listchar(int);
extern int normchar(register int); extern int normchar(register int);
extern void slobber(int); extern void slobber(int);
extern void numbline(int); extern void numbline(int, int);
extern void normline(int); extern void normline(int, int);
extern int putchar(int); extern int putchar(int);
extern int termchar(int); extern int termchar(int);
extern void flush2(void); extern void flush2(void);
@ -510,6 +510,7 @@ extern void vswitch(int);
extern int wskipleft(char *, char *); extern int wskipleft(char *, char *);
extern int wskipright(char *, char *); extern int wskipright(char *, char *);
extern int wsamechar(char *, int); extern int wsamechar(char *, int);
extern int xwcwidth(wint_t);
#endif /* MB */ #endif /* MB */
/* ex_vput.c */ /* ex_vput.c */
extern void vclear(void); extern void vclear(void);

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/05"; static char sccsid[] = "@(#)ex_put.c 1.33 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -101,7 +101,7 @@ static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/05";
*/ */
int (*Outchar)(int) = termchar; int (*Outchar)(int) = termchar;
int (*Putchar)(int) = normchar; int (*Putchar)(int) = normchar;
void (*Pline)(int) = normline; void (*Pline)(int, int) = normline;
int (* int (*
setlist(int t))(int) setlist(int t))(int)
@ -115,9 +115,9 @@ setlist(int t))(int)
} }
void (* void (*
setnumb(int t))(int) setnumb(int t))(int, int)
{ {
register void (*P)(int); register void (*P)(int, int);
numberf = t; numberf = t;
P = Pline; P = Pline;
@ -273,13 +273,13 @@ slobber(int c)
* Print a line with a number. * Print a line with a number.
*/ */
void void
numbline(int i) numbline(int i, int max)
{ {
if (shudclob) if (shudclob)
slobber(' '); slobber(' ');
printf("%6d ", i); max -= printf("%6d ", i);
normline(0); normline(0, max);
} }
/* /*
@ -287,22 +287,47 @@ numbline(int i)
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
void void
normline(int unused) normline(int unused, int max)
{ {
extern short vcntcol, lastsc;
short ovc = -1;
register char *cp; register char *cp;
int (*OO)(int);
int c, n; int c, n;
if (max > 0)
vcntcol = 0;
if (shudclob) if (shudclob)
slobber(linebuf[0]); slobber(linebuf[0]);
/* pdp-11 doprnt is not reentrant so can't use "printf" here /* pdp-11 doprnt is not reentrant so can't use "printf" here
in case we are tracing */ in case we are tracing */
cp = linebuf; cp = linebuf;
vcolbp = cp; vcolbp = cp;
while (*cp) { while (*cp && max) {
vcolbp = cp; vcolbp = cp;
nextc(c, cp, n); nextc(c, cp, n);
cp += n; cp += n;
putchar(c); if (max > 0) {
if (Outchar != qcount) {
OO = Outchar;
Outchar = qcount;
putchar(c);
Outchar = OO;
} else
putchar(c);
if ((vcntcol-1) % WCOLS == 0 && lastsc > 1)
vcntcol++;
if (vcntcol >= max) {
putchar('@');
vcntcol = ovc + 1;
lastsc = 1;
break;
}
ovc = vcntcol;
if (Outchar != qcount)
putchar(c);
} else
putchar(c);
} }
if (!inopen) { if (!inopen) {
putchar('\n' | QUOTE); putchar('\n' | QUOTE);

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_re.c 1.59 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_re.c 1.60 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -606,7 +606,7 @@ confirmed(line *a)
if (cflag == 0) if (cflag == 0)
return (1); return (1);
pofix(); pofix();
pline(lineno(a)); pline(lineno(a), -1);
if (inopen) if (inopen)
putchar('\n' | QUOTE); putchar('\n' | QUOTE);
c = column(loc1 - 1); c = column(loc1 - 1);

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_subr.c 1.39 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_subr.c 1.40 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -84,7 +84,7 @@ static char sccsid[] = "@(#)ex_subr.c 1.39 (gritter) 8/4/05";
#include "ex_tty.h" #include "ex_tty.h"
#include "ex_vis.h" #include "ex_vis.h"
static short lastsc; short lastsc;
/* /*
* Random routines, in alphabetical order. * Random routines, in alphabetical order.
@ -631,7 +631,7 @@ plural(long i)
: catgets(catd, 1, 179, "s")); : catgets(catd, 1, 179, "s"));
} }
static short vcntcol; short vcntcol;
int int
qcolumn(register char *lim, register char *gp) qcolumn(register char *lim, register char *gp)
@ -651,7 +651,7 @@ qcolumn(register char *lim, register char *gp)
n = skipright(linebuf, lim); n = skipright(linebuf, lim);
x = lim[n], lim[n] = 0; x = lim[n], lim[n] = 0;
} }
pline(0); pline(0, inopen ? WLINES*WCOLS : -1);
if (lim != NULL) if (lim != NULL)
lim[n] = x; lim[n] = x;
if (gp) if (gp)

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vadj.c 1.14 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_vadj.c 1.15 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -192,7 +192,7 @@ vreopen(int p, int lineno, int l)
* necessary to determine which way to go. * necessary to determine which way to go.
*/ */
vigoto(p, 0); vigoto(p, 0);
pline(lineno); pline(lineno, WCOLS*WLINES);
/* /*
* When we are typing part of a line for hardcopy open, don't * When we are typing part of a line for hardcopy open, don't

View File

@ -70,12 +70,12 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* Sccsid @(#)ex_version.c 1.141 (gritter) 8/4/05 * Sccsid @(#)ex_version.c 1.142 (gritter) 8/6/05
*/ */
#include "ex.h" #include "ex.h"
static char *versionstring = "@(#)Version 4.0 (gritter) 8/4/05"; static char *versionstring = "@(#)Version 4.0 (gritter) 8/6/05";
void void
printver(void) printver(void)
@ -91,22 +91,22 @@ printver(void)
/* SLIST */ /* SLIST */
/* /*
ex.c:static char sccsid[] = "@(#)ex.c 1.37 (gritter) 8/4/05"; ex.c:static char sccsid[] = "@(#)ex.c 1.37 (gritter) 8/4/05";
ex.h: * Sccsid @(#)ex.h 1.55 (gritter) 8/4/05 ex.h: * Sccsid @(#)ex.h 1.56 (gritter) 8/6/05
ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05"; ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05";
ex_argv.h: * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05 ex_argv.h: * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05
ex_cmds.c:static char sccsid[] = "@(#)ex_cmds.c 1.22 (gritter) 2/18/05"; ex_cmds.c:static char sccsid[] = "@(#)ex_cmds.c 1.22 (gritter) 2/18/05";
ex_cmds2.c:static char sccsid[] = "@(#)ex_cmds2.c 1.18 (gritter) 2/17/05"; ex_cmds2.c:static char sccsid[] = "@(#)ex_cmds2.c 1.18 (gritter) 2/17/05";
ex_cmdsub.c:static char sccsid[] = "@(#)ex_cmdsub.c 1.31 (gritter) 8/4/05"; ex_cmdsub.c:static char sccsid[] = "@(#)ex_cmdsub.c 1.32 (gritter) 8/6/05";
ex_data.c:static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04"; ex_data.c:static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04";
ex_extern.c:static char sccsid[] = "@(#)ex_extern.c 1.6 (gritter) 11/23/04"; ex_extern.c:static char sccsid[] = "@(#)ex_extern.c 1.6 (gritter) 11/23/04";
ex_get.c:static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05"; ex_get.c:static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05";
ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.42 (gritter) 8/4/05"; ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.42 (gritter) 8/4/05";
ex_proto.h: * Sccsid @(#)ex_proto.h 1.31 (gritter) 8/4/05 ex_proto.h: * Sccsid @(#)ex_proto.h 1.32 (gritter) 8/6/05
ex_put.c:static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/05"; ex_put.c:static char sccsid[] = "@(#)ex_put.c 1.33 (gritter) 8/6/05";
ex_re.c:static char sccsid[] = "@(#)ex_re.c 1.59 (gritter) 8/4/05"; ex_re.c:static char sccsid[] = "@(#)ex_re.c 1.60 (gritter) 8/6/05";
ex_re.h: * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05 ex_re.h: * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05
ex_set.c:static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04"; ex_set.c:static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04";
ex_subr.c:static char sccsid[] = "@(#)ex_subr.c 1.39 (gritter) 8/4/05"; ex_subr.c:static char sccsid[] = "@(#)ex_subr.c 1.40 (gritter) 8/6/05";
ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05"; ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05";
ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.26 (gritter) 8/4/05"; ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.26 (gritter) 8/4/05";
ex_temp.h: * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05 ex_temp.h: * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05
@ -115,15 +115,15 @@ ex_tty.h: * Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05
ex_tune.h: * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05 ex_tune.h: * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05
ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.17 (gritter) 8/4/05"; ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.17 (gritter) 8/4/05";
ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.19 (gritter) 8/4/05"; ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.19 (gritter) 8/4/05";
ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.14 (gritter) 8/4/05"; ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.15 (gritter) 8/6/05";
ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/05"; ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.30 (gritter) 8/6/05";
ex_vis.h: * Sccsid @(#)ex_vis.h 1.21 (gritter) 8/4/05 ex_vis.h: * Sccsid @(#)ex_vis.h 1.21 (gritter) 8/4/05
ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.31 (gritter) 8/4/05"; ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.32 (gritter) 8/6/05";
ex_voper.c:static char sccsid[] = "@(#)ex_voper.c 1.27 (gritter) 2/15/05"; ex_voper.c:static char sccsid[] = "@(#)ex_voper.c 1.27 (gritter) 2/15/05";
ex_vops.c:static char sccsid[] = "@(#)ex_vops.c 1.28 (gritter) 8/4/05"; ex_vops.c:static char sccsid[] = "@(#)ex_vops.c 1.28 (gritter) 8/4/05";
ex_vops2.c:static char sccsid[] = "@(#)ex_vops2.c 1.35 (gritter) 8/4/05"; ex_vops2.c:static char sccsid[] = "@(#)ex_vops2.c 1.35 (gritter) 8/4/05";
ex_vops3.c:static char sccsid[] = "@(#)ex_vops3.c 1.21 (gritter) 8/4/05"; ex_vops3.c:static char sccsid[] = "@(#)ex_vops3.c 1.21 (gritter) 8/4/05";
ex_vput.c:static char sccsid[] = "@(#)ex_vput.c 1.50 (gritter) 8/4/05"; ex_vput.c:static char sccsid[] = "@(#)ex_vput.c 1.51 (gritter) 8/6/05";
ex_vwind.c:static char sccsid[] = "@(#)ex_vwind.c 1.9 (gritter) 11/23/04"; ex_vwind.c:static char sccsid[] = "@(#)ex_vwind.c 1.9 (gritter) 11/23/04";
expreserve.c:static char sccsid[] UNUSED = "@(#)expreserve.c 1.23 (gritter) 11/27/04"; expreserve.c:static char sccsid[] UNUSED = "@(#)expreserve.c 1.23 (gritter) 11/27/04";
exrecover.c:static char sccsid[] UNUSED = "@(#)exrecover.c 1.22 (gritter) 8/4/05"; exrecover.c:static char sccsid[] UNUSED = "@(#)exrecover.c 1.22 (gritter) 8/4/05";

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/05"; static char sccsid[] = "@(#)ex_vget.c 1.30 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -406,7 +406,7 @@ int
readecho(int c) readecho(int c)
{ {
register char *sc = cursor; register char *sc = cursor;
register void (*OP)(int); register void (*OP)(int, int);
bool waste; bool waste;
register int OPeek; register int OPeek;

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vmain.c 1.31 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_vmain.c 1.32 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -100,11 +100,11 @@ vmain(void)
cell esave[TUBECOLS]; cell esave[TUBECOLS];
char *oglobp; char *oglobp;
short d; short d;
line *addr; line *addr, *odot;
int ind, nlput; int ind, nlput;
int shouldpo = 0; int shouldpo = 0;
int onumber = 0, olist = 0; int onumber = 0, olist = 0;
void (*OPline)(int) = NULL; void (*OPline)(int, int) = NULL;
int (*OPutchar)(int) = NULL; int (*OPutchar)(int) = NULL;
CLOBBGRD(c); CLOBBGRD(c);
@ -514,13 +514,22 @@ reread:
*/ */
case CTRL('b'): case CTRL('b'):
vsave(); vsave();
odot = dot;
if (one + vcline != dot && vcnt > 2) { if (one + vcline != dot && vcnt > 2) {
addr = dot - vcline + 2 - (cnt-1)*basWLINES; addr = dot - vcline + 2 - (cnt-1)*basWLINES;
forbid (addr <= zero); forbid (addr <= zero);
dot = (line*)addr;
vcnt = vcline = 0; vcnt = vcline = 0;
} do {
vzop(0, 0, '^'); dot = addr;
vzop(0, 0, '^');
/*
* When a single line fills the
* entire screen, ^B can become
* a no-op without the loop.
*/
} while (dot == odot && --addr > zero);
} else
vzop(0, 0, '^');
continue; continue;
/* /*

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vput.c 1.50 (gritter) 8/4/05"; static char sccsid[] = "@(#)ex_vput.c 1.51 (gritter) 8/6/05";
#endif #endif
#endif #endif
@ -1454,14 +1454,19 @@ def:
} }
} }
#ifdef MB #ifdef MB
if (mb_cur_max > 1 && (d = colsc(c&TRIM&~MULTICOL)) > 1) { if (mb_cur_max > 1) {
if ((hold & HOLDPUPD) == 0) if ((d = colsc(c&TRIM&~MULTICOL)) > 1) {
*tp |= MULTICOL;
while (--d) {
if ((hold & HOLDPUPD) == 0) if ((hold & HOLDPUPD) == 0)
*++tp = MULTICOL; *tp |= MULTICOL;
destcol++; while (--d) {
outcol++; if ((hold & HOLDPUPD) == 0)
*++tp = MULTICOL;
destcol++;
outcol++;
}
} else if (d == 0) {
destcol--;
outcol--;
} }
} }
#endif /* MB */ #endif /* MB */