From 985c5eaa7c55ebb6ba4833886119396d2a9d77c5 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 31 Jul 2025 00:07:08 +0300 Subject: repl.tes: added script that reproduces the classic TECO REPL command-line * Unfortunately, this will currently just terminate when some command fails. We require an error catching mechanism to fix this up. --- freebsd/pkg-plist | 1 + lib/Makefile.am | 3 +++ lib/repl.tes | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 lib/repl.tes diff --git a/freebsd/pkg-plist b/freebsd/pkg-plist index 8f99bdd..3fe8a43 100644 --- a/freebsd/pkg-plist +++ b/freebsd/pkg-plist @@ -11,6 +11,7 @@ share/man/man7/%%PROGRAM_PREFIX%%sciteco.7.gz %%DATADIR%%/lib/fnkeys.tes %%DATADIR%%/lib/getopt.tes %%DATADIR%%/lib/lexer.tes +%%DATADIR%%/lib/repl.tes %%LEXILLA%%%%DATADIR%%/lib/lexers/abaqus.tes %%LEXILLA%%%%DATADIR%%/lib/lexers/ada.tes %%LEXILLA%%%%DATADIR%%/lib/lexers/asciidoc.tes diff --git a/lib/Makefile.am b/lib/Makefile.am index c272b0e..194802f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,6 +2,9 @@ dist_scitecolib_DATA = color.tes lexer.tes session.tes opener.tes \ fnkeys.tes string.tes getopt.tes +# standalone scripts +dist_scitecolib_DATA += repl.tes + # Helper script for creating lexer definitions EXTRA_DIST = scite2co.lua diff --git a/lib/repl.tes b/lib/repl.tes new file mode 100644 index 0000000..9cfa8c0 --- /dev/null +++ b/lib/repl.tes @@ -0,0 +1,54 @@ +!* + * This is a stand-alone script that mimics + * classic TECO command lines. + * Requires an ANSI-compatible terminal. + * + * Currently, you must set the terminal characteristics on the outside: + * stty raw opost icrnl && sciteco -m repl.tes + * + * You can launch into interactive mode by typing -u#ex + * + * TODO: + * - Catch errors + * - Support *q + *! +0U#ex +< + * + < + U Q:; + !* erase current command line *! + [.c[.l + 0U.i 0U.l :Q<%.i-1Q-10"=%.l'> + Q.l"> [\.lF | 13 ' +  + ].l].c + !* Handle rub out *! + Q-8"= 127U ' + Q-127"= + :Q"> + !* + * Remove last character from reg  + * Doesn't require EQ which cannot be reliably undone. + *! + [.i 0U.i :Q-1<%.i-1Q:> ].i + ' + | + Q: + ' + !* Redraw command line *! + [.i[.c + 0U.i :Q< %.i-1QU.c + Q.c-10"= 10 F> ' + Q.c-"= $ F> ' + Q.c-32"< ^,(Q.c#64) | Q.c ' + > + ].c].i + !* FIXME: Catch errors *! + Q-"= + Q#">0U# 10 :M  1;' 1|0 + 'U# + > + ED&2"N1;' !* EX called *! + Q#ex:; +> -- cgit v1.2.3