aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
9 daysfixed scrolling the command line after clicking in the popupHEADmaster-fmsbw-cimasterRobin Haberkorn4-23/+33
We cannot rely on the central teco_cmdline_update() call per keypress in this case. The analogous call was removed in 4e6ddd6c329d56055a732c6344df019f0d997aaf, so this was a recent regression.
12 daysSciTECO lexer: style comma as operatorRobin Haberkorn1-1/+1
13 daysCurses: fixed displaying the popup with multi-line command linesRobin Haberkorn2-4/+4
2025-11-12updated Scintilla: tabs in command lines and SciTECO buffers are now ↵Robin Haberkorn1-4/+1
rendered as "TAB" without any indentation
2025-11-12Curses: the default rubbed out command line color is COLOR_WHITE nowRobin Haberkorn1-3/+2
0x404040 (COLOR_LBLACK) is a poor choice since on terminal emulators with less than 16 colors, it would be rendered in black (and thus be invisible).
2025-11-12fixed the command line's line end type: it was reset during command line ↵Robin Haberkorn1-28/+26
replacement ({...}) * The line end type and tab mode is apparently a property of the document. Therefore it was lost when exchanging the command line's document during command line replacement. * Instead, the old command line is now stored in a string. * During replacement we delete and append only the part of the command line that changed. This ensures that we don't have to restyle the entire command line with every single replacement (even if it is at the end of the command line).
2025-11-10Curses: the rubbed out command line is now rendered with underlines againRobin Haberkorn1-1/+3
This requires enhanced INDIC_STRAIGHTBOX semantics, which are not yet upstream in Scinterm.
2025-11-10Scinterm updated to v5.5Robin Haberkorn1-60/+86
* This currently needs a yet unmerged patch, fixing the light colors. * Scinterm no longer systematically initializes the color pairs, so we cannot predict their numbers - instead we initialize color pairs on demand and store them in a hash map, very similar to what Scinterm does internally. * Scinterm v5.5 can use arbitrary RGB colors now by automatically allocating curses colors and pairs. We do not expose this in SciTECO yet, although that would also be possible. It has to be decided first whether the special predefined colors will continue to live in the same namespace along with "true" RGB colors.
2025-11-09Curses: fixed positioning of auto completion popups above the command lineRobin Haberkorn1-1/+2
This was broken if you configured a command line with a height > 1.
2025-11-09updated Scintilla to v5.5.8 and renamed SC_LINE_END_TYPE_HIDDEN to ↵Robin Haberkorn1-1/+1
SC_LINE_END_TYPE_NONE
2025-11-09allow configuring the command line height using h,5EJRobin Haberkorn5-21/+51
* This allows for several customizations. * You can simply increase the visible command line history. For that you must also set SCI_SETWRAPMODE(SC_WRAP_CHAR). An example was added to fallback.teco_ini. * You could also set SCI_SETLINEENDTYPESALLOWED(SC_LINE_END_TYPE_DEFAULT) to see the structure of inserted text. * Alternatively we could have introduced a new command like EP or FW and also overload it to replace the current ED&2048 (e.g. -EP and EP). In DEC TECO `W` comes closest to what 5EJ now does.
2025-11-09the SciTECO lexer now tries to avoid unnecessary restylings by styling from ↵Robin Haberkorn1-5/+18
the current line as well * This optimization is unnecessary for regular TECO scripts unless you write stupendously long lines. On the command line macro however, we were always restyling the entire command line with every insertion or rubout since the command line view uses single line mode by default. Even if you enable a multi-line command line with regular line breaks, it's unlikely that you would insert many line breaks except when inserting text into the buffer. * We will now during insertion into the command line view style from the beginning of the last regular command. * During rub out from the command line, we still won't have enough information about where the previous valid start state was, so we will frequently have to restyle the entire command line. This might be worked around by adding a cmdline-view-specific hack if it turns out to be relevant on very long command lines and slow computers.
2025-11-08Curses: replaced getmaxyx(stdscr) with LINES and COLSRobin Haberkorn1-19/+12
These are equivalent, but LINES and COLS are shorter.
2025-11-08added ED flag 2048 to redirect Scintilla messages to the command line view: ↵Robin Haberkorn3-4/+27
enables syntax highlighting on the command line * M[lexer.set.cmdline] can be used to set up syntax highlighting on the command line (if desired). * Color schemes with light-dark themes (solarized.tes) are now responsible to update the command line view as well.
2025-11-08the command line macro is now managed by a Scintilla viewRobin Haberkorn9-345/+271
* Instead of rendering a teco_string_t into a Scintilla view (GTK) and an ncurses window (Curses), it is now a Scintilla view and document that is modified directly. * Reduces redundancies between GTK and Curses UIs. * It will be more efficient on very large command lines, especially on GTK. * We can now redirect Scintilla messages to the command line view in order to configure syntax highlighting, the margin, rubout indicator style and scroll behavior (TODO). * This will also simplify the configuration of multi-line command lines (TODO). * Since INDIC_PLAIN is not supported by Scinterm, rubbed out command lines are now styled with INDIC_STRAIGHTBOX (background color).
2025-11-02render tabs as "TAB" in the command-line and in SciTECO macrosRobin Haberkorn2-3/+16
* This requires the new SCI_SETTABDRAWMODE(SCTD_CONTROLCHAR). * It makes no sense to let TAB indent in TECO code as it can be the insert-with-tab command (^I). On the other hand large `I`-blocks could include TABs which are actually meant as indentations.
2025-11-02GTK: use the new SC_LINE_END_TYPE_HIDDEN for rendering the command lineRobin Haberkorn1-65/+13
This simplifies teco_interface_cmdline_update() and prepares for backing the command line macro itself with a Scintilla view (teco_view_t). The latter will avoid unnecessary recalculations when inserting characters into the command line and to factor out redundancies with the Curses UI.
2025-10-07throw an error immediately after nEB if n != 0Robin Haberkorn2-18/+26
* When typing nEBfilename$ (n != 0) you would find out that the construct is invalid only after typing out the entire command. We now throw an error immediately, ie. only Escape or string termination will be expected in interactive mode. * In batch mode, nothing should have changed.
2025-10-01mention both mailing list and personal mail in `sciteco --help`Robin Haberkorn1-1/+1
2025-09-14ncurses: avoid the middle mouse button workaround in newer ncurses versionsRobin Haberkorn1-2/+2
My patch has been merged, so there is no need to keep the workaround in newer versions. See https://lists.gnu.org/archive/html/bug-ncurses/2025-09/msg00027.html
2025-09-09work around ncurses mouse handling bugsRobin Haberkorn1-53/+102
* We have to process several mouse events for every KEY_MOUSE. * The order of events is sort of arbitrary after clicking the middle mouse button in some terminal emulators like st and Xterm. Therefore BUTTON2_PRESSED is now ignored and resynthesized when receiving BUTTON2_RELEASED. This fixes loosing middle click events. fnkeys.tes only processes the RELEASED event anyway. I am still looking for a fix to contribute to the ncurses project. * In GNOME Terminal and Xterm with the SGR mouse protocol, you can receive bogus BUTTON3_PRESSED events when left scrolling. There is an upstream fix. As a workaround -- we will have to live with outdated ncurses versions anyway -- we prevent resetting the mouse mask unnecessarily. This limits the effects to a single bogus BUTTON3_PRESSED event. Unfortunately, it's not easily possible to force ncurses into using the X10 mouse protocol even if the terminfo entry claims SGR compatibility. See also https://lists.gnu.org/archive/html/bug-ncurses/2025-09/msg00016.html
2025-09-02fixed help for EO (program version) commandRobin Haberkorn1-1/+1
2025-09-02added help topcic for ":O"Robin Haberkorn1-1/+1
We have topics for all colon-modified variants.
2025-09-02fixup 9425ad37ec95a40dc039169031259161c92cc217: fixed error handling in ED hooksRobin Haberkorn1-2/+2
2025-08-31support <:O>: if a label is not found, continue execution after the go-to ↵Robin Haberkorn8-36/+100
statement * this is a SciTECO extension - it's not in TECO-11 * Allows for select-case-like constructs with default-clauses as in :Os.^EQa$ !* default *! !s.foo! !* ... *! !s.bar! !* ... *! * Consistent with nOlabel0,label1,...$ if <n> is out of range. Unfortunately this form of computed goto is not applicable when "selecting" by strings or non-consecutive integers. * In order to continue after the <:O> statement, we must keep the program counter along with the label we were looking for. At the end of the macro, the PC is restored instead of throwing an error. * Since that would be very inefficient in loops - where potentially all iterations would result in rescanning till the end of the macro - we now store a completed-flag in the goto table. If it is set while trying to :O to an unknown label, we can just continue execution.
2025-08-30the computed go-to command (O) is now 0-indexed and all invalid indexes and ↵Robin Haberkorn5-18/+33
empty labels are ignored * This has long been a TECO-11 incompatibility. * The first label in a list has index 0, i.e. `1Ofoo,bar$` jumps to label `!bar!`. Consequently 0 is also implied, so `Olabel$` continues to do what you expect. * `0Ofoo$` was previously also jumping to `!foo!` which was inconsistent: All invalid indexes should do nothing, i.e. execution continues after the go-to command. * Fixed handling of empty labels as in `1Ofoo,,bar$` - execution should also continue after the command. This eases writing "default" clauses immediately after the go-to. * The ED hook values now also begin at 0, so most existing ED hook macros should continue to work. * Similarily, the mouse events returned by -EJ also begin at 0 now, so fnkeys.tes continues to work as expected. * It's still very possible of course that this breaks existing code.
2025-08-28bumped minimum Gtk version to 3.24Robin Haberkorn2-6/+0
* Gtk 3.24 has been introduced accidentally in 9e3746a4 due to GtkEventControllerScroll. * It would be possible to still support v3.12 by partially reversing 9e3746a4 and conditionally including teco_interface_scroll_cb(). But it's probably not worth the trouble.
2025-08-27avoid g_prefix_error_literal(), which requires glib 2.70Robin Haberkorn1-2/+2
This broke builds e.g. on Ubuntu 20.04. Regression was introduced in 51bd183f064d0c0ea5e0184d9f6b6b62e5c01e50.
2025-08-21fully support NetBSD with its native libcursesRobin Haberkorn2-6/+43
* It requires a forced refresh on startup (even though that should be the default). Otherwise, it wouldn't print the info line correctly. * Redirect stdin and pass it to newterm() to fix key queuing. Probably necessary for supporting ncurses on NetBSD as well. * Avoid doupdate() if screen is too small: fixes crashes for very small windows. * Updated Scintilla: There were some implicit typing assumptions, that are broken by this platform.
2025-08-19curses: fixed configuration for native netbsd-curses and ncurses (several ↵Robin Haberkorn1-2/+0
corner cases) * pkg-config check for `ncurses` fails if it failed previously for `ncursesw`. This is the case e.g. for ncurses from NetBSD's pkgsrc. * No longer assume that any libncurses is not enhanced (X/Open compatible). * SciTECO and Scinterm require to find a curses.h in the include paths. The ncurses check must therefore not be limited to the first best ncurses/ncurses.h and the like. * We now always check for X/Open compatibility and always require a curses.h in the standard directories or as given by pkg-config. * AX_WITH_CURSES was radically rewritten and is now called AX_WITH_NCURSES. * --with-interface=netbsd-curses gets its own detection code. It always requires a curses.h in the standard paths and a libcurses. It should now be fixed for real NetBSD installations if the ncurses port is installed as well. * Unified all of the curses-arguments to CURSES_CFLAGS and CURSES_LIBS. There is no reason we need PDCURSES_CFLAGS, XCURSES_CFLAGS etc.
2025-08-16UNIX curses: some clarifications on what is done during ↵Robin Haberkorn2-2/+13
teco_interface_init_screen() User messages printed in interative mode aren't currently fully preserved on stdout/stderr since they are redirected to /dev/null. Only messages that are not flushed out will be preserved. Unless you redirect stdout/stderr of SciTECO of course since in this case no redirection is necessary. This is probably tolerable esp. once we support multi-line messages in the UIs. At least it would be tricky to work around.
2025-08-10allow messages to be of arbitrary length: fixes crashesRobin Haberkorn1-8/+3
* Messages can be arbitrarily long, e.g. the following could provoke crashes in interactive mode `1000<@I/X/> HX$` It's hard to turn into a test case, though, as you could always increase the buffer size in teco_interface_msg(). * The message length is now only limited by RAM. * This implementation is less effective, but code opting for efficience, including all programmable user messages, should not rely on the printf-API anyway but use teco_interface_msg_literal().
2025-08-09Win32: avoid any automatic LF to CRLF conversions when writing to stdoutRobin Haberkorn1-0/+19
* At least the MSVCRT does this by default, i.e. the translation mode of stdout is not _O_BINARY. * This broke piping through SciTECO with --stdin --stdout, as this relies on SciTECO's builtin EOL normalization. Instead, you would get DOS linebreaks on output even if the source stream contains only UNIX linebreaks. * It would also break binary filters. * It seems to be safe to print only LF also for regular stdio (help and error messages), so I simply disaply the stdout (and stdin and stderr) EOL translation globally. * Also fixes Troff warnings due to the .in preprocessor writing output with DOS linebreaks. * Added a test case. All future platforms shouldn't perform any unexpected EOL translations on output.
2025-08-06command-line arguments are no longer passed via the unnamed buffer, but via ↵Robin Haberkorn4-27/+25
special Q-registers ^Ax * The unnamed buffer is also used for reading from --stdin, so you couldn't practically combine --stdin with passing command-line arguments to macros. * The old approach of passing command-line arguments via lines in the unnamed buffer was flawed anyway as it wouldn't work with filenames containing LF. This is just a very ancient feature, written when there weren't even long Q-reg names in SciTECO. * You can now e.g. pipe into SciTECO and edit what was read interactively, e.g. `dmesg | sciteco -i`. You can practically use SciTECO as a pager. * htbl.tes is now a command-line filter (uses -qio). * grosciteco.tes reads Troff intermediate code from stdin, so we no longer need "*.intermediate" temporary files. * added a getopt.tes test case to the testsuite. * This change unfortunately breaks most macros accepting command-line arguments, even if they used getopt.tes. It also requires updating ~/.teco_ini - see fallback.teco_ini.
2025-08-03simplified the htbl.tes preprocessor and the SUBST_MACRO using new --quiet, ↵Robin Haberkorn1-0/+2
--stdin and --stdout options * htbl.tes now reads from stdin and writes to stdout. Allows avoiding temporary `*.htbl` files * grosciteco.tes still cannot be simplified since --stdin cannot be combined with passing command-line arguments (FIXME).
2025-08-03added --quiet, --stdin and --stdout for easier integration into UNIX pipelinesRobin Haberkorn5-1/+114
* In principle --stdin and --stdout could have been done in pure TECO code using the <^T> command. Having built-in command-line arguments however has several advantages: * Significantly faster than reading byte-wise with ^T. * Performs EOL normalization unless specifying --8bit of course. * Significantly shortens command-lines. `sciteco -qio` and `sciteco -qi` can be real replacements for sed and awk. * You can even place SciTECO into the middle of a pipeline while editing interactively: foo | sciteco -qio --no-profile | bar Unfortunately, this will not currently work when munging the profile as command-line parameters are also transmitted via the unnamed buffer. This should be changed to use special Q-registers (FIXME). * --quiet can help to improve the test suite (TODO). Should probably be the default in TE_CHECK(). * --stdin and --stdout allow to simplify many SciTECO scripts, avoiding temporary files, especially for womenpage generation (TODO). * For processing potentially infinite streams, you will still have to read using ^T.
2025-08-02fixed serious bug with certain alternative string termination chars in ↵Robin Haberkorn6-32/+45
commands with multiple string arguments * When `@`-modifying a command with several string arguments and choosing `{` as the alternative string termination character, the parser would get totally confused. Any sequence of `{` would be ignored and only the first non-`{` would become the termination character. Consequently you also couldn't choose a new terminator after the closing `}`. So even a documented code example from sciteco(7) wouldn't work. The same was true when using $ (escape) or ^A as the alternative termination character. * We can now correctly parse e.g. `@FR{foo}{bar}` or `@FR$foo$bar$` (even though the latter one is quite pointless). * has probably been broken forever (has been broken even before v2.0). * Whitespace is now ignored in front of alternative termination characters as in TECO-64, so we can also write `@S /foo/` or even ``` @^Um { !* blabla *! } ``` I wanted to disallow whitespace termination characters, so the alternative would have been to throw an error. The new implementation at least adds some functionality. * Avoid redundancies when parsing no-op characters via teco_is_noop(). I assume that this is inlined and drawn into any jump-table what would be generated for the switch-statement in teco_state_start_input(). * Alternative termination characters are still case-folded, even if they are Unicode glyphs, so `@IЖfooж` would work and insert `foo`. This should perhaps be restricted to ANSI characters?
2025-08-01implemented the ^W command for refreshing the screen in loops, for sleeping ↵Robin Haberkorn5-24/+96
and also the CTRL+L immediate editing command * ^W can be added to loops in order to view progress in interactive mode. It also sleeps for a given number of milliseconds (10ms by default). * In batch mode it is therefore the sleep command. * Since CTRL+W is an immediate editing command, you will usually type it Caret+W. ASCII 23 however will also be accepted. * While ^W only updates the screen, you can force a complete redraw by pressing CTRL+L. This is what most terminal applications use for redrawing. It will make it harder to insert ASCII 12, but this is seldom necessary since it is a form feed. ^L (ASCII 12 and the upcaret variant ) is still a whitespace character and therefore treated as a NOP. * DEC TECO had CTRL+W as the refresh immediate editing command. Video TECO uses <ET> as a regular command for refreshign in loops. I'd rather keep ET reserved as a potential terminal configuration command as in DEC TECO, though.
2025-07-31added -v/--version and <EO> commandRobin Haberkorn2-0/+29
* DEC TECO had an <EO> command. In contrast to DEC TECO's implementation, the value reported by <EO> encodes a major.minor.micro semantic version.
2025-07-31implemented ^H command for returning the current time since midnight: ↵Robin Haberkorn1-13/+29
partially replaces ^B * :^H and ::^H now return the timestamps, while ^B only returns the date. * Pressing CTRL+H will rubout, so you will usually write it in upcaret mode.
2025-07-31implemented ^T command: allows typing by code and getting characters from ↵Robin Haberkorn10-8/+301
stdin or the user * n:^T always prints bytes (cf. :^A) * ^T without arguments returns a codepoint or byte from stdin. In interactive mode, this currentply places a cursor in the message line and waits for a keypress.
2025-07-28`ED&2` can be used to access the program termination flag nowRobin Haberkorn5-14/+17
* `0,2ED` is roughly equivalent to `-EX` * `ED&2` can be used to query whether EX has been run. This is useful if macros can run EX. * `2,0ED` could be used to cancel the effect of EX. * But the real motivation is for implementing a REPL script.
2025-07-28=/==/===: fixed detection of execution from the end of the command-lineRobin Haberkorn2-14/+29
In particular, fixes the test case `3<255=>` which would print only one number in interactive mode.
2025-07-27fixed using the command-line replacement register (ESC) in batch mode: was ↵Robin Haberkorn1-2/+1
causing assertions when entering interactive mode Also added a regression test case.
2025-07-27fixed a,b,c^Uq...$: The arguments where written in the wrong (reverse) orderRobin Haberkorn1-11/+18
* When writing UTF-8, we must first peek in reverse order since we can only write from left to right. * When writing in raw ANSI, we can immediately pop the values from the stack but must write in reverse.
2025-07-26properly document some functions in expressions.c and simplified codeRobin Haberkorn9-93/+79
* Practically all calls to teco_expressions_args() must be preceded by teco_expressions_eval(). * In code paths where we know that teco_expressions_args() > 0, it is safe to call teco_expressions_pop_num(0) instead of teco_expressions_pop_num_calc(). This is both easier and faster. * teco_expressions_pop_num_calc() is for simple applications where you just want to get a command argument with default (implied) values. Since it includes teco_expressions_eval(), we can avoid superfluous calls. * -EC...$ turned out to be broken and is fixed now. A test case has been added.
2025-07-26implemented the <T> (typeout) command for printing to the terminal from the ↵Robin Haberkorn5-32/+108
current buffer * refactored some code that is common with Xq into teco_get_range_args().
2025-07-26support <:^A> to force raw ANSI outputRobin Haberkorn2-4/+16
* ^A uses the default code page without colon, just like ^U/EU. This is usually UTF8, unless you run with --8bit. It would make just as little sense to inherit the codepage from the current document. * Ensures that code like `:^A^E<0xFF>^A` really outputs byte 0xFF. * DEC TECO doesn't have the colon modifier, but it has a colon modifier for ^T to enforce raw output. In SciTECO, the ^T vs. :^T distinction will also be between default codepage and ANSI. It makes sense because ^T should treat its numeric arguments like <I> for consistency.
2025-07-26implemented <:Gq> for printing the Q-Register string as a message instead of ↵Robin Haberkorn2-2/+13
inserting it
2025-07-26use teco_interface_msg_literal() where we're printing raw stringsRobin Haberkorn1-1/+1
* There are some calls of teco_interface_msg() with constant strings, but these are not convenient to convert as the teco_interface_msg_literal() does not yet support -1 for the string length.