aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-31 00:07:08 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-31 00:33:43 +0300
commit985c5eaa7c55ebb6ba4833886119396d2a9d77c5 (patch)
tree3103ce3ae167f78955e606456cb84ee7d4b1a3ce
parent2ec568579823c991b919fa3a2c8583a8db21cb81 (diff)
downloadsciteco-985c5eaa7c55ebb6ba4833886119396d2a9d77c5.tar.gz
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.
-rw-r--r--freebsd/pkg-plist1
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/repl.tes54
3 files changed, 58 insertions, 0 deletions
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:;
+>