From 2b70d8e5eb31621f0077e5c6f9f3732dcb6c2198 Mon Sep 17 00:00:00 2001 From: Gunnar Ritter Date: Thu, 4 Aug 2005 12:09:59 +0000 Subject: [PATCH] * 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. --- Changes | 5 +++++ README | 8 +++----- config.h | 24 +----------------------- ex.h | 2 +- ex.spec | 4 ++-- ex_argv.h | 2 +- ex_proto.h | 3 ++- ex_re.h | 2 +- ex_temp.h | 2 +- ex_tty.c | 4 +--- ex_tty.h | 2 +- ex_tune.h | 2 +- ex_v.c | 40 ++++++++++++++++++++++++++++++---------- ex_version.c | 16 ++++++++++++---- ex_vis.h | 13 ++++++++++--- 15 files changed, 72 insertions(+), 57 deletions(-) diff --git a/Changes b/Changes index 15c8851..36d51e5 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ +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. + Release 3/25/05 * vi no longer dies with a segmentation fault if a line does not fit on the screen after an insertion. diff --git a/README b/README index 4d0e83d..a2e524e 100644 --- a/README +++ b/README @@ -23,9 +23,7 @@ How to build First look at the Makefile and change the settings there to match your build environment. Explanations are provided directly in this file. -You can tune the sizes of some internal buffers by editing config.h. In -particular, you will have to raise the size of the 'TUBE' constants if -you wish to use really large-sized terminals. +You can tune the sizes of some internal buffers by editing config.h. Then type 'make' and 'make install'. @@ -139,7 +137,7 @@ the erase key once after entering a multibyte character will result in an incomplete byte sequence. -Gunnar Ritter 2/20/05 +Gunnar Ritter 8/4/05 Freiburg i. Br. Germany - + diff --git a/config.h b/config.h index 23f7779..277d636 100644 --- a/config.h +++ b/config.h @@ -70,35 +70,13 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * @(#)config.h 1.12 (gritter) 2/19/05 + * @(#)config.h 1.13 (gritter) 8/4/05 */ /* * Configurable settings for the ex editor. */ -/* - * Maximum screen size in visual mode. - * - * Because the routine "alloca" is not portable, TUBESIZE - * bytes are allocated on the stack each time you go into visual - * and then never freed by the system. Thus if you have no terminals - * which are larger than 24 * 80 you may well want to make TUBESIZE - * smaller. TUBECOLS should stay at 160 at least since this defines - * the maximum length of opening on hardcopies and allows two lines - * of open on terminals like adm3's (glass tty's) where it switches - * to pseudo hardcopy mode when a line gets longer than 80 characters. - */ -#ifndef VMUNIX -#define TUBELINES 70 /* Number of screen lines for visual */ -#define TUBECOLS 160 /* Number of screen columns for visual */ -#define TUBESIZE 6000 /* Maximum screen size for visual */ -#else /* VMUNIX */ -#define TUBELINES 100 -#define TUBECOLS 160 -#define TUBESIZE 16000 -#endif /* VMUNIX */ - /* * Various buffer sizes. */ diff --git a/ex.h b/ex.h index 51ae267..3ec9795 100644 --- a/ex.h +++ b/ex.h @@ -72,7 +72,7 @@ * * from ex.h 7.7.1.1 (Berkeley) 8/12/86 * - * @(#)ex.h 1.53 (gritter) 2/17/05 + * Sccsid @(#)ex.h 1.54 (gritter) 8/4/05 */ /* diff --git a/ex.spec b/ex.spec index 4049671..2a3184a 100644 --- a/ex.spec +++ b/ex.spec @@ -1,5 +1,5 @@ # -# Sccsid @(#)ex.spec 1.7 (gritter) 1/22/05 +# Sccsid @(#)ex.spec 1.8 (gritter) 7/12/05 # Summary: A port of the traditional ex/vi editors Name: ex @@ -8,7 +8,7 @@ Release: 1 License: BSD Source: %{name}-%{version}.tar.bz2 Group: System Environment/Base -Vendor: Gunnar Ritter +Vendor: Gunnar Ritter URL: BuildRoot: %{_tmppath}/%{name}-root diff --git a/ex_argv.h b/ex_argv.h index 04a64ad..2605ded 100644 --- a/ex_argv.h +++ b/ex_argv.h @@ -72,7 +72,7 @@ * * from ex_argv.h 7.3 (Berkeley) 5/31/85 * - * @(#)ex_argv.h 1.8 (gritter) 11/23/04 + * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05 */ /* diff --git a/ex_proto.h b/ex_proto.h index 6af8c18..96202c5 100644 --- a/ex_proto.h +++ b/ex_proto.h @@ -70,7 +70,8 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * @(#)ex_proto.h 1.28 (gritter) 2/19/05 + * + * Sccsid @(#)ex_proto.h 1.29 (gritter) 8/4/05 */ /* diff --git a/ex_re.h b/ex_re.h index 2966ef0..885673b 100644 --- a/ex_re.h +++ b/ex_re.h @@ -72,7 +72,7 @@ * * from ex_re.h 7.3 (Berkeley) 5/31/85 * - * @(#)ex_re.h 1.22 (gritter) 2/19/05 + * Sccsid @(#)ex_re.h 1.23 (gritter) 8/4/05 */ /* diff --git a/ex_temp.h b/ex_temp.h index 8bbb1d1..66d68bc 100644 --- a/ex_temp.h +++ b/ex_temp.h @@ -72,7 +72,7 @@ * * from ex_temp.h 7.4 (Berkeley) 5/31/85 * - * @(#)ex_temp.h 1.8 (gritter) 1/26/02 + * Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05 */ /* diff --git a/ex_tty.c b/ex_tty.c index 05702b6..7d3a7ed 100644 --- a/ex_tty.c +++ b/ex_tty.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_tty.c 1.29 (gritter) 2/17/05"; +static char sccsid[] = "@(#)ex_tty.c 1.30 (gritter) 8/4/05"; #endif #endif @@ -300,8 +300,6 @@ setsize(void) i = TLINES; if (TLINES <= 5) TLINES = 24; - if (TLINES > TUBELINES) - TLINES = TUBELINES; l = TLINES; if (ospeed < B1200) l = 9; /* including the message line at the bottom */ diff --git a/ex_tty.h b/ex_tty.h index 66f0573..79fcf15 100644 --- a/ex_tty.h +++ b/ex_tty.h @@ -72,7 +72,7 @@ * * from ex_tty.h 7.5.1 (2.11BSD GTE) 12/9/94 * - * @(#)ex_tty.h 1.13 (gritter) 12/1/04 + * Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05 */ #include "libterm/libterm.h" diff --git a/ex_tune.h b/ex_tune.h index 2026cea..92a728c 100644 --- a/ex_tune.h +++ b/ex_tune.h @@ -72,7 +72,7 @@ * * from ex_tune.h 7.8.1 (2.11BSD) 1996/10/23 * - * @(#)ex_tune.h 1.12 (gritter) 12/1/04 + * Sccsid @(#)ex_tune.h 1.13 (gritter) 8/4/05 */ /* diff --git a/ex_v.c b/ex_v.c index fe984ee..cce1bba 100644 --- a/ex_v.c +++ b/ex_v.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04"; +static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05"; #endif #endif @@ -126,20 +126,41 @@ static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04"; */ JMP_BUF venv; +static cell *atube; + +/* + * Determine and set the size for visual mode buffers. + */ +static void +tubesizes(void) +{ + TUBELINES = TLINES; + /* + * TUBECOLS should stay at 160 at least since this defines the + * maximum length of opening on hardcopies and allows two lines + * of open on terminals like adm3's (glass tty's) where it + * switches to pseudo hardcopy mode when a line gets longer + * than 80 characters. + */ + TUBECOLS = TCOLUMNS < 160 ? 160 : TCOLUMNS; + TUBESIZE = TLINES * TCOLUMNS; + free(vlinfo); + free(vtube); + free(atube); + vlinfo = malloc((TUBELINES+2) * sizeof *vlinfo); + vtube = malloc(TUBELINES * sizeof *vtube); + atube = malloc((TUBESIZE + LBSIZE) * sizeof *atube); + if (vlinfo == NULL || vtube == NULL || atube == NULL) + error("Screen too large"); +} /* * Enter open mode */ -#ifdef u370 -cell atube[TUBESIZE+LBSIZE]; -#endif void oop(void) { register char *ic; -#ifndef u370 - cell atube[TUBESIZE + LBSIZE]; -#endif struct termios f; /* mjm: was register */ int resize; @@ -150,6 +171,7 @@ oop(void) inopen = 0; addr1 = addr2 = dot; } + tubesizes(); #ifdef SIGWINCH signal(SIGWINCH, onwinch); #endif @@ -258,9 +280,6 @@ void vop(void) { register int c; -#ifndef u370 - cell atube[TUBESIZE + LBSIZE]; -#endif struct termios f; /* mjm: was register */ int resize; @@ -299,6 +318,7 @@ toopen: inopen = 0; addr1 = addr2 = dot; } + tubesizes(); #ifdef SIGWINCH signal(SIGWINCH, onwinch); #endif diff --git a/ex_version.c b/ex_version.c index ccfbb36..a840840 100644 --- a/ex_version.c +++ b/ex_version.c @@ -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.134 (gritter) 6/26/05 + * Sccsid @(#)ex_version.c 1.136 (gritter) 8/4/05 */ #include "ex.h" -static char *versionstring = "@(#)Version 4.0 (gritter) 6/26/05"; +static char *versionstring = "@(#)Version 4.0 (gritter) 8/4/05"; void printver(void) @@ -91,7 +91,9 @@ printver(void) /* SLIST */ /* ex.c:static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05"; +ex.h: * Sccsid @(#)ex.h 1.54 (gritter) 8/4/05 ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.10 (gritter) 2/17/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.29 (gritter) 2/17/05"; @@ -99,17 +101,23 @@ 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.17 (gritter) 2/17/05"; ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.40 (gritter) 2/17/05"; +ex_proto.h: * Sccsid @(#)ex_proto.h 1.29 (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.56 (gritter) 3/25/05"; +ex_re.h: * Sccsid @(#)ex_re.h 1.23 (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.37 (gritter) 2/15/05"; ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.11 (gritter) 11/27/04"; ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.24 (gritter) 11/24/04"; -ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.29 (gritter) 2/17/05"; +ex_temp.h: * Sccsid @(#)ex_temp.h 1.9 (gritter) 8/4/05 +ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.30 (gritter) 8/4/05"; +ex_tty.h: * Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05 +ex_tune.h: * Sccsid @(#)ex_tune.h 1.13 (gritter) 8/4/05 ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.16 (gritter) 11/23/04"; -ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.17 (gritter) 11/27/04"; +ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.18 (gritter) 8/4/05"; ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.11 (gritter) 3/4/05"; ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.29 (gritter) 2/15/05"; +ex_vis.h: * Sccsid @(#)ex_vis.h 1.20 (gritter) 8/4/05 ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.29 (gritter) 2/17/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.26 (gritter) 1/13/05"; diff --git a/ex_vis.h b/ex_vis.h index d6fd99c..df9a526 100644 --- a/ex_vis.h +++ b/ex_vis.h @@ -72,7 +72,7 @@ * * from ex_vis.h 7.4 (Berkeley) 5/31/85 * - * @(#)ex_vis.h 1.18 (gritter) 3/24/05 + * Sccsid @(#)ex_vis.h 1.20 (gritter) 8/4/05 */ /* @@ -99,6 +99,13 @@ var enum { HARDOPEN = 3 } bastate, state; +/* + * Maximum screen size in visual mode, dynamically set as needed. + */ +var short TUBELINES; +var short TUBECOLS; +var short TUBESIZE; + /* * The screen in visual and crtopen is of varying size; the basic * window has top basWTOP and basWLINES lines are thereby implied. @@ -140,7 +147,7 @@ struct vlinfo { short vdepth; /* Depth of displayed line */ /*mjm: was char */ short vflags; /* Is line potentially dirty ? */ }; -var struct vlinfo vlinfo[TUBELINES + 2]; +var struct vlinfo *vlinfo; #define DEPTH(c) (vlinfo[c].vdepth) #define LINE(c) (vlinfo[c].vliny) @@ -170,7 +177,7 @@ var short vcnt; * data itself. It is also rearranged during insert mode across line * boundaries to make incore work easier. */ -var cell *vtube[TUBELINES]; +var cell **vtube; var cell *vtube0; /*