aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rw-r--r--teco.h2
-rw-r--r--tecterm.c42
3 files changed, 40 insertions, 17 deletions
diff --git a/README.md b/README.md
index a9e6b18..de7a4ab 100644
--- a/README.md
+++ b/README.md
@@ -68,14 +68,13 @@ set up correctly (`. owsetenv.sh`):
### Features and limitations
-* Being ported from UNIX, it outputs escape sequences and requires
+* Being ported from UNIX, it outputs escape sequences and requires an ANSI driver like
[ANSI.SYS](https://en.wikipedia.org/wiki/ANSI.SYS),
[NANSI.SYS](http://www.kegel.com/nansi/) or
[ANSIPLUS](http://www.sweger.com/ansiplus/).
- There is special NANSI.SYS support, so that driver is preferred.
- Video TECO has a builtin termcap "database", but you can
- set the `TERMCAP` environment variable to a custom termcap definition file
- to tweak definitions.
+ ANSIPLUS is detected automatically, which enables some optimizations.
+ To enable NANSI.SYS-specific optimizations, try `set TECO_TERM=nansi.sys`.
+ You can also set the TERMCAP environment variable to a custom termcap definition file.
* The console size/resolution is automatically detected.
* It supports the same Csh-like wildcard expansions as on UNIX for
command-line parameters.
@@ -99,6 +98,7 @@ set up correctly (`. owsetenv.sh`):
### TODO
+- [ ] Make use of ANSIPLUS scroll regions.
- [ ] Re-evaluate Video TECO's lookaside buffers.
But they probably don't make sense considering the memory constraints.
- [ ] Dosbox has problems with drawing the command line cursor.
@@ -106,6 +106,7 @@ set up correctly (`. owsetenv.sh`):
so a moving reverse `' '` leaks the attribute to the preceding or following
cell.
It also cannot deal with more than 25 rows.
+ Interestingly, this persists even after loading ANSIPLUS.
But perhaps it's not so important to support Dosbox.
-- [ ] Command line help (`-h`)
+- [ ] ommand line help (`-h`)
- [ ] SvarDOS package
diff --git a/teco.h b/teco.h
index 29736e8..6f22e9a 100644
--- a/teco.h
+++ b/teco.h
@@ -84,7 +84,7 @@
#ifndef AUTO_DATE
/* should be passed in from the build system */
-#define AUTO_DATE "$Date: 2025/05/06 00:03:29 $"
+#define AUTO_DATE "$Date: 2025/05/07 16:57:28 $"
#endif
/*
diff --git a/tecterm.c b/tecterm.c
index 88ff362..8a1404c 100644
--- a/tecterm.c
+++ b/tecterm.c
@@ -1073,7 +1073,7 @@ term_flush()
static int
term_isvga(void)
{
- union REGS regs;
+ union REGS regs = {0};
regs.x.ax = 0x1a00;
int86(VIDEO, &regs, &regs);
return regs.h.al == 0x1a && regs.h.bl > 6;
@@ -1082,7 +1082,7 @@ term_isvga(void)
static int
term_isega(void)
{
- union REGS regs;
+ union REGS regs = {0};
if(term_isvga()) return 0;
regs.h.ah = 0x12;
regs.h.bl = 0x10;
@@ -1090,16 +1090,38 @@ term_isega(void)
return regs.h.bl != 0x10;
}
+#if 0
/**
- * Detect NANSI.SYS (4.0c or later).
+ * Returns true if any of ANSI.SYS, NANSI.SYS (4.0c or later)
+ * or ANSIPLUS (2.0 or later) are detected.
*/
static inline int
-term_have_nansi(void)
+term_have_ansi_driver(void)
{
- union REGS regs;
+ union REGS regs = {0};
regs.x.ax = 0x1a00;
int86(0x2f, &regs, &regs);
- return regs.h.al == 0xFF;
+ return regs.h.al == 0xff;
+}
+#endif
+
+/**
+ * Returns true if ANSIPLUS driver is installed.
+ */
+static inline int
+term_have_ansiplus(void)
+{
+ union REGS regs = {0};
+ regs.x.ax = 0x1a00;
+ regs.x.bx = ('A' << 8) | 'N';
+ regs.x.cx = ('S' << 8) | 'I';
+ regs.x.dx = ('+' << 8) | '+';
+ int86(0x2f, &regs, &regs);
+ /*
+ * NOTE: The ANSIPLUS documentation is wrong.
+ * AL won't be 0.
+ */
+ return regs.h.al == 0xff && regs.x.cx != (('S' << 8) | 'I');
}
#endif /* MSDOS */
@@ -1410,8 +1432,8 @@ char *termcap =
*/
":cd=\\E[2J:te=\\E[2J:"
/*
- * Some NANSI.SYS extensions, i.e. not supported by MS-DOS ANSI.SYS.
- * They are enabled dynamically by overwriting the leading null byte.
+ * Some NANSI.SYS/ANSIPLUS extensions, i.e. not supported by MS-DOS ANSI.SYS.
+ * They may be enabled dynamically by overwriting the leading null byte.
*/
"\0al=\\E[1L:AL=\\E[%dL:dl=\\E[1M:DL=\\E[%dM:ic=\\E[1@:dc=\\E[1P:";
#endif /* MSDOS */
@@ -1459,8 +1481,8 @@ FILE *fd;
if(cp == NULL){
cp = termcap;
#ifdef MSDOS
- /* enable extended NANSI.SYS definitions */
- if(term_have_nansi()) *strchr(cp, '\0') = ':';
+ /* enable extended ANSIPLUS definitions */
+ if(!strcmp(term_name,"nansi.sys") || term_have_ansiplus()) *strchr(cp, '\0') = ':';
#endif
}
dp = current_termcap_description = buffer;