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
vi usually does not return to ex mode with "screen too large" when the
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.
Release 3/25/05

6
ex.h
View File

@ -72,7 +72,7 @@
*
* 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 outchar(c) (*Outchar)(c)
#define pastwh() (ignore(skipwh()))
#define pline(no) (*Pline)(no)
#define pline(no, max) (*Pline)(no, max)
#define reset() LONGJMP(resetlab,1)
#define resexit(a) copy(resetlab, a, sizeof (JMP_BUF))
#define setexit() SETJMP(resetlab)
@ -526,7 +526,7 @@ var line *undadot; /* If we saved all lines, dot reverts here */
#define UNDPUT 4
extern int (*Outchar)(int);
extern void (*Pline)(int);
extern void (*Pline)(int, int);
extern int (*Putchar)(int);
#define NOSTR (char *) 0

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -984,7 +984,7 @@ plines(line *adr1, register line *adr2, bool movedot)
pofix();
for (addr = adr1; addr <= adr2; addr++) {
getline(*addr);
pline(lineno(addr));
pline(lineno(addr), -1);
if (inopen) {
putchar('\n' | QUOTE);
}

View File

@ -71,7 +71,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* 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 *);
/* ex_put.c */
extern int (*setlist(int))(int);
extern void (*setnumb(int))(int);
extern void (*setnumb(int))(int, int);
extern int listchar(int);
extern int normchar(register int);
extern void slobber(int);
extern void numbline(int);
extern void normline(int);
extern void numbline(int, int);
extern void normline(int, int);
extern int putchar(int);
extern int termchar(int);
extern void flush2(void);
@ -510,6 +510,7 @@ extern void vswitch(int);
extern int wskipleft(char *, char *);
extern int wskipright(char *, char *);
extern int wsamechar(char *, int);
extern int xwcwidth(wint_t);
#endif /* MB */
/* ex_vput.c */
extern void vclear(void);

View File

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

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -606,7 +606,7 @@ confirmed(line *a)
if (cflag == 0)
return (1);
pofix();
pline(lineno(a));
pline(lineno(a), -1);
if (inopen)
putchar('\n' | QUOTE);
c = column(loc1 - 1);

View File

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

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -192,7 +192,7 @@ vreopen(int p, int lineno, int l)
* necessary to determine which way to go.
*/
vigoto(p, 0);
pline(lineno);
pline(lineno, WCOLS*WLINES);
/*
* 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,
* 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"
static char *versionstring = "@(#)Version 4.0 (gritter) 8/4/05";
static char *versionstring = "@(#)Version 4.0 (gritter) 8/6/05";
void
printver(void)
@ -91,22 +91,22 @@ printver(void)
/* SLIST */
/*
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_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_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_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_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_put.c:static char sccsid[] = "@(#)ex_put.c 1.32 (gritter) 2/17/05";
ex_re.c:static char sccsid[] = "@(#)ex_re.c 1.59 (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.33 (gritter) 8/6/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_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_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
@ -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_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_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.14 (gritter) 8/4/05";
ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/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.30 (gritter) 8/6/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_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_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";
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";

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -406,7 +406,7 @@ int
readecho(int c)
{
register char *sc = cursor;
register void (*OP)(int);
register void (*OP)(int, int);
bool waste;
register int OPeek;

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -100,11 +100,11 @@ vmain(void)
cell esave[TUBECOLS];
char *oglobp;
short d;
line *addr;
line *addr, *odot;
int ind, nlput;
int shouldpo = 0;
int onumber = 0, olist = 0;
void (*OPline)(int) = NULL;
void (*OPline)(int, int) = NULL;
int (*OPutchar)(int) = NULL;
CLOBBGRD(c);
@ -514,13 +514,22 @@ reread:
*/
case CTRL('b'):
vsave();
odot = dot;
if (one + vcline != dot && vcnt > 2) {
addr = dot - vcline + 2 - (cnt-1)*basWLINES;
forbid (addr <= zero);
dot = (line*)addr;
vcnt = vcline = 0;
}
vzop(0, 0, '^');
do {
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;
/*

View File

@ -73,7 +73,7 @@
#ifndef lint
#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
@ -1454,14 +1454,19 @@ def:
}
}
#ifdef MB
if (mb_cur_max > 1 && (d = colsc(c&TRIM&~MULTICOL)) > 1) {
if ((hold & HOLDPUPD) == 0)
*tp |= MULTICOL;
while (--d) {
if (mb_cur_max > 1) {
if ((d = colsc(c&TRIM&~MULTICOL)) > 1) {
if ((hold & HOLDPUPD) == 0)
*++tp = MULTICOL;
destcol++;
outcol++;
*tp |= MULTICOL;
while (--d) {
if ((hold & HOLDPUPD) == 0)
*++tp = MULTICOL;
destcol++;
outcol++;
}
} else if (d == 0) {
destcol--;
outcol--;
}
}
#endif /* MB */