* Made multicolumn characters work in lines longer than the screen width in

visual mode (Bugreport by Matthew Fischer).
This commit is contained in:
Gunnar Ritter 2005-02-15 16:31:11 +00:00
parent 625b7e45f5
commit d1a3bb3efa
9 changed files with 82 additions and 32 deletions

View File

@ -6,6 +6,8 @@ Release ...
was continued after vi had been stopped by ^Z, with the cursor positioned was continued after vi had been stopped by ^Z, with the cursor positioned
in a line longer than the terminal width as the last line of the current in a line longer than the terminal width as the last line of the current
screen. screen.
* Made multicolumn characters work in lines longer than the screen width in
visual mode (Bugreport by Matthew Fischer).
* Made it work for Big5 locales (Patches by Matthew Fischer). * Made it work for Big5 locales (Patches by Matthew Fischer).
* Fixed a problem with the 'r' command in EUC-JP and Big5 locales (Bugreport * Fixed a problem with the 'r' command in EUC-JP and Big5 locales (Bugreport
by Matthew Fischer). by Matthew Fischer).
@ -13,6 +15,11 @@ Release ...
locales now works with terminals that have the 'ic' but no 'im' termcap locales now works with terminals that have the 'ic' but no 'im' termcap
capability (Bugreport by Matthew Fischer). capability (Bugreport by Matthew Fischer).
* The argument to the -w option is correctly recognized now. * The argument to the -w option is correctly recognized now.
* If the SHELL environment variable is set to the empty string, it is now
ignored.
* A non-null exit status is now returned if a file could not be opened.
* If the match for a substitution is of length zero, a line overflow is
now avoided when compiled with the 'UNIX(R) Regular Expression Library'.
Release 1/19/05 Release 1/19/05
* The last release erroneously made 'X' work like 'x' in visual mode. It now * The last release erroneously made 'X' work like 'x' in visual mode. It now

4
README
View File

@ -10,7 +10,7 @@ changes were made to get closer to the POSIX.2 guidelines for ex and
vi. Some issues that were clearly bugs and not features have also been vi. Some issues that were clearly bugs and not features have also been
resolved; see the Changes file for details. resolved; see the Changes file for details.
New releases are announced on Fresmeat. If you want to get New releases are announced on Freshmeat. If you want to get
notified by email on each release, use their subscription service at notified by email on each release, use their subscription service at
<http://freshmeat.net/projects/vi/>. <http://freshmeat.net/projects/vi/>.
@ -110,7 +110,7 @@ the erase key once after entering a multibyte character will result in an
incomplete byte sequence. incomplete byte sequence.
Gunnar Ritter 1/29/05 Gunnar Ritter 2/15/05
Freiburg i. Br. Freiburg i. Br.
Germany Germany
<Gunnar.Ritter@pluto.uni-freiburg.de> <Gunnar.Ritter@pluto.uni-freiburg.de>

4
ex.c
View File

@ -77,7 +77,7 @@ char *copyright =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\ "@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n"; All rights reserved.\n";
static char sccsid[] = "@(#)ex.c 1.35 (gritter) 2/13/05"; static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05";
#endif /* DOSCCS */ #endif /* DOSCCS */
#endif /* !lint */ #endif /* !lint */
@ -565,7 +565,7 @@ argend:
setrupt(); setrupt();
intty = isatty(0); intty = isatty(0);
value(PROMPT) = intty; value(PROMPT) = intty;
if (cp = getenv("SHELL")) if ((cp = getenv("SHELL")) != NULL && *cp != '\0')
safecp(shell, cp, sizeof shell, "$SHELL too long"); safecp(shell, cp, sizeof shell, "$SHELL too long");
if (fast || !intty) if (fast || !intty)
setterm("dumb"); setterm("dumb");

3
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
* *
* @(#)ex.h 1.49 (gritter) 1/13/05 * @(#)ex.h 1.50 (gritter) 2/13/05
*/ */
/* /*
@ -437,6 +437,7 @@ var bool verbose; /* -V option; print command input to stderr */
var JMP_BUF vreslab; /* For error throws to a visual catch */ var JMP_BUF vreslab; /* For error throws to a visual catch */
var bool writing; /* 1 if in middle of a file write */ var bool writing; /* 1 if in middle of a file write */
var int xchng; /* Suppresses multiple "No writes" in !cmd */ var int xchng; /* Suppresses multiple "No writes" in !cmd */
var int failed; /* exit with a non-zero status */
/* /*
* Macros * Macros

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_io.c 1.37 (gritter) 12/2/04"; static char sccsid[] = "@(#)ex_io.c 1.38 (gritter) 2/13/05";
#endif #endif
#endif #endif
@ -428,6 +428,7 @@ rop(int c)
return; return;
} }
} }
failed = 1;
syserror(); syserror();
} }
if (fstat(io, &stbuf)) if (fstat(io, &stbuf))

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_re.c 1.44 (gritter) 1/9/05"; static char sccsid[] = "@(#)ex_re.c 1.45 (gritter) 2/13/05";
#endif #endif
#endif #endif
@ -682,6 +682,12 @@ ovflo:
} }
lp = loc2; lp = loc2;
loc2 = sp + (linebuf - genbuf); loc2 = sp + (linebuf - genbuf);
#ifdef UXRE
if (loc1 == lp) {
nextc(c, loc2, n);
loc2 += n;
}
#endif /* UXRE */
while (*sp++ = *lp++) while (*sp++ = *lp++)
if (sp >= &genbuf[LBSIZE]) if (sp >= &genbuf[LBSIZE])
goto ovflo; goto ovflo;

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_subr.c 1.34 (gritter) 1/13/05"; static char sccsid[] = "@(#)ex_subr.c 1.36 (gritter) 2/15/05";
#endif #endif
#endif #endif
@ -659,12 +659,20 @@ qcolumn(register char *lim, register char *gp)
int int
qcount(int c) qcount(int c)
{ {
int sc;
if (c == '\t') { if (c == '\t') {
vcntcol += value(TABSTOP) - vcntcol % value(TABSTOP); vcntcol += value(TABSTOP) - vcntcol % value(TABSTOP);
return c; return c;
} }
vcntcol += c & MULTICOL ? 1 : colsc(c); /*
* Take account of filler characters inserted at the end of
* the visual line if a multi-column character does not fit.
*/
sc = colsc(c);
while (vcntcol < WCOLS && vcntcol + sc - 1 >= WCOLS)
vcntcol++;
vcntcol += c & MULTICOL ? 1 : sc;
return c; return c;
} }
@ -1025,6 +1033,8 @@ exitex(int i)
if (trace) if (trace)
fclose(trace); fclose(trace);
# endif # endif
if (failed != 0 && i == 0)
i = failed;
_exit(i); _exit(i);
/*NOTREACHED*/ /*NOTREACHED*/
return 0; return 0;

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.123 (gritter) 2/13/05 * Sccsid @(#)ex_version.c 1.124 (gritter) 2/15/05
*/ */
#include "ex.h" #include "ex.h"
static char *versionstring = "@(#)Version 4.0 (gritter) 2/13/05"; static char *versionstring = "@(#)Version 4.0 (gritter) 2/15/05";
void void
printver(void) printver(void)

View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_vput.c 1.47 (gritter) 2/4/05"; static char sccsid[] = "@(#)ex_vput.c 1.48 (gritter) 2/15/05";
#endif #endif
#endif #endif
@ -374,7 +374,9 @@ vgoto(register int y, register int x)
} }
#ifdef MB #ifdef MB
if (y >= 0 && y <= WLINES && mb_cur_max > 1 && !insmode) { if (y >= 0 && y <= WLINES && mb_cur_max > 1 && !insmode) {
while (x > 0 && (vtube[y][x]&(MULTICOL|TRIM)) == MULTICOL) while (x > 0 && (vtube[y][x]&(MULTICOL|TRIM)) == MULTICOL &&
vtube[y][x-1] & MULTICOL &&
(vtube[y][x-1]&(MULTICOL|TRIM)) != MULTICOL)
x--; x--;
} }
#endif /* MB */ #endif /* MB */
@ -586,6 +588,7 @@ vinschar(int c)
register cell *tp; register cell *tp;
char *OIM; char *OIM;
bool OXN; bool OXN;
int noim;
insmc1 = colsc(c) - 1; insmc1 = colsc(c) - 1;
if ((!IM || !EI) && ((hold & HOLDQIK) || !value(REDRAW) || value(SLOWOPEN))) { if ((!IM || !EI) && ((hold & HOLDQIK) || !value(REDRAW) || value(SLOWOPEN))) {
@ -739,15 +742,19 @@ vinschar(int c)
tabend, tabslack, linend); tabend, tabslack, linend);
} }
#endif #endif
/*
* This code was used to temporarily disable insert mode for
* multi-column characters because of a bug in a terminal program
* used for development that has been fixed in the meantime. It
* remains here just in case similar problems occur again.
*/
OIM = IM; OIM = IM;
OXN = XN; OXN = XN;
if (0 && insmc1) { noim = 0;
#ifdef MB
if (mb_cur_max > 1) {
for (i = inscol; vtube0[i]; i++)
if (i + 1 >= WCOLS && vtube0[i] & MULTICOL) {
noim = 1;
break;
}
}
#endif /* MB */
if (noim) {
endim(); endim();
IM = 0; IM = 0;
XN = 0; XN = 0;
@ -1072,8 +1079,8 @@ viin(int c)
* *
* You asked for it, you get it. * You asked for it, you get it.
*/ */
tp = vtube0 + inscol + insmc0 + doomed; tp = vtube0 + inscol + doomed;
for (i = inscol + insmc0 + doomed; i < tabstart; i++) for (i = inscol + doomed; i < tabstart; i++)
vputchar(*tp++); vputchar(*tp++);
hold = oldhold; hold = oldhold;
vigotoCL(tabstart + inssiz + insmc0 - doomed); vigotoCL(tabstart + inssiz + insmc0 - doomed);
@ -1235,6 +1242,26 @@ vputchar(register int c)
/* Fix problem of >79 chars on echo line. */ /* Fix problem of >79 chars on echo line. */
if (destcol >= WCOLS-1 && splitw && destline == WECHO) if (destcol >= WCOLS-1 && splitw && destline == WECHO)
pofix(); pofix();
#ifdef MB
if (mb_cur_max > 1) {
if (c == MULTICOL)
return c;
/*
* If a multicolumn character extends beyond the screen
* width, it must be put on the next line. A tilde is
* printed as an indicator but must disappear when the
* text is moved at a later time.
*/
if (c == ('~'|INVBIT|QUOTE))
c = '~'|INVBIT;
else if (c == ('~'|INVBIT))
return c;
else if (destcol < WCOLS && destcol +
colsc(c==QUOTE ? ' ' : c&TRIM&~MULTICOL) - 1
>= WCOLS)
vputchar('~'|INVBIT|QUOTE);
}
#endif /* MB */
if (destcol >= WCOLS) { if (destcol >= WCOLS) {
destline += destcol / WCOLS; destline += destcol / WCOLS;
destcol %= WCOLS; destcol %= WCOLS;
@ -1312,7 +1339,7 @@ def:
* and if we are in hardopen, that the terminal has overstrike. * and if we are in hardopen, that the terminal has overstrike.
*/ */
if ((d & ~MULTICOL) == (c & TRIM & ~MULTICOL) && !insmode && if ((d & ~MULTICOL) == (c & TRIM & ~MULTICOL) && !insmode &&
(state != HARDOPEN || OS)) { (state != HARDOPEN || OS) && c != MULTICOL) {
n = colsc(d); n = colsc(d);
for (m = 1; m < n; m++) for (m = 1; m < n; m++)
if ((tp[m] & (MULTICOL|TRIM)) != MULTICOL) if ((tp[m] & (MULTICOL|TRIM)) != MULTICOL)
@ -1422,8 +1449,7 @@ def:
} }
} }
#ifdef MB #ifdef MB
if (mb_cur_max > 1 && (d = colsc(c&TRIM)) > 1) { if (mb_cur_max > 1 && (d = colsc(c&TRIM&~MULTICOL)) > 1) {
if ((*tp&MULTICOL) == 0) {
if ((hold & HOLDPUPD) == 0) if ((hold & HOLDPUPD) == 0)
*tp |= MULTICOL; *tp |= MULTICOL;
while (--d) { while (--d) {
@ -1433,7 +1459,6 @@ def:
outcol++; outcol++;
} }
} }
}
#endif /* MB */ #endif /* MB */
return c; return c;
} }