aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2024-02-08fixed expressions like `1,(2)` or `(1),(2)`: they are reported as two ↵Robin Haberkorn1-0/+3
numbers now * Instead of TECO_OP_NEW, there should perhaps simply be a flag of whether `,` was used.
2024-02-06fixed the power (^*) operator: did not handle corner cases and was inefficientRobin Haberkorn1-1/+22
* in fact, with a negative exponent the previous naive implementation would even hang indefinitely! * Now uses the squaring algorithm. This is slightly longer but significantly more efficient. * added test cases
2024-02-06avoid Groff warnings due to `\` escapesRobin Haberkorn1-2/+2
* It's generally a bad idea to pass backslashes as a glyph in macro arguments, even as `\\` since this could easily be interpreted as an escape. * Instead we now always use `\[rs]`.
2024-02-06use bool instead of guint for 1-bit fieldsRobin Haberkorn2-7/+10
* gboolean cannot be used since it is a signed type * bool is still more readable, even though we mostly use glib typedefs. * AFAIK the glib types are deprecated, so sooner or later we will switch to stdint/stdbool types anyway.
2024-02-03GTK: allow disabling client-side decorations by setting $GTK_CSD=0Robin Haberkorn1-7/+2
* This is the same variable used by gtk3-nocsd, but we will now work even without preloading any libraries. Also, it turns out that gtk3-nocsd does not ship as a FreeBSD port and hasn't been updated in a long time. * Setting this in .teco_ini wouldn't have been easy since the teco_interface_init() is called before any TECO code. Also, you might not even want disable this globally but depending on the window manager. * Therefore, you are advised to `export GTK_CSD=0` in ~/.xsession. * The --no-csd command line option is kept for the time being, but probably serves no more purpose.
2024-02-03Gtk: set icons a bit later after calling gtk_widget_show()Robin Haberkorn1-39/+44
* Also turns out, I will have to use gtk_window_set_icon_list(). * This fixes icons in tabbed and st (when embedding SciTECO).
2024-01-28cursor movement via fnkeys.tes now preserves the column as in most text editorsRobin Haberkorn1-1/+18
* Horizontal movements (left/right cursor keys) establish the current column and vertical movements (up/down) will try to keep on that column. * This has long been problematic in SciTECO as it requires state that gets reversed when the command line replacement takes place. * I experimented with encoding the current horizontal position into the braced movement operations as in (123C5U$), but I decided that this was clumsy and I generally did not want these expressions to become even larger. * Instead I decided to add some minimal support to the C core in the form of 4EJ which is like a number register only that it does NOT get reversed on rubout. This is exploited by the fnkeys.tes macros by storing the current position beyond replacements. * In theory, this should be a property of the document, but we cannot easily store custom parameters per document. So instead, there is just one global variable. When editing another buffer, it gets reset to .ESGETCOLUMN$$. sample.teco_ini has been updated. * The current X position only makes sense in the context of fnkeys.tes, as TECO commands like <C> are not necessarily "horizonal" movements. For the same reason, the core does not try to initialize 4EJ automatically when editing new buffers. It's entirely left to the TECO macros. * The commandline replacement is more robust now as it checks braced expressions at the end of the command line more thorougly. It will no longer swallow all preceding braced expressions. Only if they are at least 4 characters in length and end in `C)` or `R)`.
2024-01-21updated copyright to 2024Robin Haberkorn61-61/+61
2024-01-20fixed Clang warnings about one-bit-wide boolean integers ↵Robin Haberkorn2-7/+7
(-Wsingle-bit-bitfield-constant-conversion) * gboolean is defined as gint which is a signed type. A gboolean 1-bit-wide bitfield cannot have the values 0 and 1 but only 0 and -1. * This wasn't practically a bug unless you would try to compare one of those bitfields with TRUE. * All of those bitfields are now guint, even though this is less self-documenting.
2024-01-13fixed <EC$> assertions: specifying empty command strings was undefinedRobin Haberkorn1-19/+18
* passing an empty command string down to the shell would always do nothing, so it doesn't make sense to support that. * for the time being, we generate a proper error * in the future, it might make sense to define some special behavior like repeating the last command - but EC does not currently save the command line anywhere. * The generated documentation is currently ugly (FIXME). mandatory parameters are not properly detected by tedoc and we cannot keep apart Q-Registers from mandatory parameters either. Also, we should allow <param> markup in command summaries.
2023-07-06fixed ]$ and ]~ (pop from Q-Reg stack to special Q-Registers)Robin Haberkorn1-164/+84
* This was setting only the teco_doc but wasn't calling the necessary set_string() methods. * The idiom [$ FG...$ ]$ to change the working directory temporarily now works. * Similarily you can now write [~ ^U~...$ ]~ to change the clipboard temporarily. * Added test suite cases. The clipboard is not tested since it's not supported everywhere and would interfer with the host system. * Resolved lots of redundancies in qreg.c. The clipboard and workingdir Q-Regs have lots in common. This is now abstracted in the "external" Q-Reg base "class" (ie. via initializer TECO_INIT_QREG_EXTERNAL()). It uses vtable calls which is slightly more inefficient than per register implementations, but avoiding redundancies is probably more important.
2023-07-03introduced TECO_DEBUG_CLEANUP to mark destructors that should only be used ↵Robin Haberkorn9-25/+19
for debug builds * There is cleanup that is not strictly necessary, because it only frees memory which is freed on program termination anyway. * However, it helps to explicitly free everything for debugging memory leaks via Valgrind. * The new macro reduces the number of #ifdef statements. * On NDEBUG, the code of these functions will still be eliminated. * If functions are referenced only from the destructor, there will be no unused function warnings, even in NDEBUG.
2023-06-19distribute sciteco.desktopRobin Haberkorn2-2/+10
* Useful for packaging on platforms where we can only build from tarballs (FreeBSD) * I don't know whether it's always safe and correct to install this file into $DATADIR/applications, so the file is only distributed but not installed yet. * It contains a hardcoded binary name "gsciteco". This could actually differ depending on the concrete --program-prefix and it would be good to include the exact installation path. This however is not possible as long as we do not install this file.
2023-06-19the SciTECO data installation path is now configurable via --with-scitecodatadirRobin Haberkorn1-1/+1
* This is also the base of $SCITECOPATH. * Changing it is useful for packaging where it is not possible to factor out the common files between Curses and Gtk builds into a "sciteco-common" package. As an alternative, you can now create disjunct sciteco-curses and sciteco-gtk packages. * You will most likely want to use this for Gtk builds as in: --with-interface=gtk --program-prefix=g --with-scitecodatadir=/usr/local/share/gsciteco.
2023-06-18fixed caret scrolling on startupRobin Haberkorn2-91/+93
* Since Scintilla no longer automatically scrolls the caret (see 941f48da6dde691a7800290cc729aaaacd051392), the caret wouldn't always end up in the view on startup. * Added teco_interface_refresh() which includes SCI_SCROLLCARET and is invoked on startup. This helps with the Curses backend. It also reduces code redundancies. * On Gtk, the caret cannot be easily scrolled on startup as long as no size is allocated to the window, so we also added a size-allocate callback to the window's event box. Sizes are less often allocated to the event box than to the window itself for some strange reason.
2023-05-14resolved warning in gtk-label.c due to wrong enum typeRobin Haberkorn1-1/+1
* This probably did not cause any bugs.
2023-05-14FreeBSD: fixed the poll-thread memory limiting implementation - it's the ↵Robin Haberkorn1-4/+17
default now * On FreeBSD both the dlmalloc replacement and poll-thread via sysctl() work but the poll-thread has been benchmarked to be significantly faster, at least on my machine. You can still ./configure --enable-malloc-replacement of course. * Interestingly, the RSS of the process visible via htop does not decrease after OOMs or command-line terminations - with neither of the implementations.
2023-05-12fixup EC on Win32 and interruptions via CTRL+CRobin Haberkorn1-33/+82
* This especially fixes spawning on 0,128ED-mode broken since f557af9a9112955d3b65f6ad0d54c0791189f961. * The process is added to a job object now, which allows us to kill the entire process tree. Previously we we were leaving around orphaned processes.
2023-05-09fixup: building on UNIXRobin Haberkorn1-1/+1
2023-05-09fixed CTRL+C interruptions on Windows; optimized CTRL+C polling on Gtk+Robin Haberkorn5-88/+125
* teco_interrupt() turned out to be unsuitable to kill child processes (eg. when <EB> hangs). Instead, we have Win32-specific code now. * Since SIGINT can be ignored on UNIX, pressing CTRL+C was not guaranteed to kill the child process (eg. when <EB> hangs). At the same time, it makes sense to send SIGINT first, so programs can terminate gracefully. The behaviour has therefore been adapted: Interrupting with CTRL+C the first time will kill gracefully. The second time, a more agressive signal is sent to kill the child process. Unfortunately, this would be relatively tricky and complicated to do on Windows, so CTRL+C will always "hard-kill" the child process. * Moreover, teco_interrupt() killed the entire process on Windows when called the second time. This resulted in any interruption to terminate SciTECO unexpectedly when tried the second time on Gtk/Win32. * teco_sigint_occurred renamed to teco_interrupted: There may be several different sources for setting this flag. * Checking for CTRL+C on Gtk involves driving the main event loop repeatedly. This is a very expensive operation. We now do that only every 100ms. This is still sufficient since keyboard input comes from humans. This optimization saves 75% runtime on Windows and 90% on Linux. * The same optimization turned out to be contraproductive on PDCurses/WinGUI.
2023-04-29fixed <EC> interruptions on Gtk+ (and probably on PDCurses/Win32)Robin Haberkorn2-6/+30
* test case: ECwhile true; do true; done$ * Some platforms require polling via teco_interface_is_interrupted() for detecting interruptions, so we added an idle watcher to the Glib event loop in spawn.c. * On platforms that do not require polling key presses (like Unix/ncurses), the idle watcher won't do any harm.
2023-04-27Gtk: fixed scrolling in the command line widgetRobin Haberkorn1-7/+2
* The caret wasn't always kept out of the UZ and at some point would totally leave the view. This was apparently cause by executing two SCI_SCROLLCARETs per teco_interface_cmdline_update(). * Instead, we now use a CARET_EVEN scroll policy which also works sufficiently well.
2023-04-27Gtk: fixed entering dead keysRobin Haberkorn1-25/+63
* This is using an Input Method now. * Entering dead keys has probably always been broken in Gtk which I only did not notice because I use a keyboard layout without dead keys. This affects the ^ and ` keys on a German layout. * Once we support Unicode input, it would make sense to abuse Scintilla's already existing input method support. Unfortunately, forwarding keyboard events to the Scintilla view breaks event freezing and results in flickering.
2023-04-20Curses: do not allow typing any non-ASCII characters - fixes crashes on ↵Robin Haberkorn1-1/+1
PDCurses/WinGUI * we can neither display, nor parse Unicode characters properly, so this does not worsen anything * makes it harder to confuse the parser as long as we do not support Unicode. * behaves like on Gtk: pressing a non-ASCII char will simply be ignored * Most importantly, this fixes crashes on PDCurses/WinGUI. It apparently couldn't handle the negative integers that resulted from passing a value >= 0x80 <= 0xFF into gchar (which is a signed integer). Changing everything into guchar is not worth the effort - we need full Unicode support anyway.
2023-04-19fixup: reverted the last Scintilla patch and unref Scintilla objects via ↵Robin Haberkorn1-9/+1
g_object_unref() * Turns out that using gtk_widget_destroy(), the finalize handler never gets called!? This means we were leaking memory. * Using g_object_unref() fixes that and the initial Scintilla patch is no longer necessary. * There have previously been use-after-free bugs when *not* using gtk_widget_destroy(). This has apparently been fixed in the meantime in Scintilla.
2023-04-18fixup a6b5394086260c262e393dd113057916fd14134b: emit undo tokens for insert_lenRobin Haberkorn1-11/+14
* Turns out it is impossible - or at least very tricky - to avoid undo token emission for insert_len. I therefore opt for stability rather than saving memory. * The old workaround introduced in a6b5394086260c262e393dd113057916fd14134b would actually fail if you do not rub out the string argument completely after interruption. I.e. You type <Ihello^J$>, interrupt - insert_len may be != 0 at this point - and _partially_ rubout the insert-command and continue typing. This could still crash the editor.
2023-04-18no longer try to avoid automatic scrolling - this is patched out of ↵Robin Haberkorn7-44/+30
Scintilla now * The patch avoids all automatic scrolling consistently, including in SCI_UNDO. This speads up Undo (especially after interruptions). * Also, the patch disables a very costly and pointless (in SciTECO) algorithm that effectively made <Ix$> uninterruptible. * Effectively reverts large parts of 8ef010da59743fcc4927c790f585ba414ec7b129. I have never liked using unintuitive Scintilla messages to avoid scrolling.
2023-04-16updated Scintilla to v5.3.4, Scinterm to v4.1 and Lexilla to v5.2.4Robin Haberkorn1-0/+11
* actually everything is updated to their current HEADs but the aforementioned versions are close. * Scintilla uses threads now, so we added checks for pthread. To be on the safe side, we imported AX_PTHREAD from the Autoconf archives. The flags are kept out of the ordinary build system, though and used only for compiling Scintilla and for linking. SciTECO may also use threads, but via Glib. * Scinterm removed SCI_COLOR_PAIR(), so we re-added it to src/interface-curses/interface.c. * There is an Asciidoc lexer now. * The <Ix$> interruption bug (see TODO) is not fixed by this upgrade. Perhaps the Mac OS version runs better now. Feedback is needed (refs #12).
2023-04-16fixed interruptions of commands with string arguments in interactive modeRobin Haberkorn1-4/+12
* In order to provoke this bug, there must be a loop with a string command. For instance <Ifoobar^J$>. When interrupting this loop, ctx->expectstring.insert_len might end up > 0. This breaks an optimization that avoids undo tokens for insert_len since it is usually reset to 0 after every keypress. Once you rubout everything and retype `I`, you can crash SciTECO. * I am not sure if this solution is ideal. An alternative might be adding teco_state_expectstring_initial(), but we would have to chain to it from some child states that have their own initial() callback. Of course, we could also simply teco_undo_gsize(insert_len) at the cost of undo tokens.
2023-04-14allow disabling Lexilla (Lexer) support by specifying --without-lexillaRobin Haberkorn2-4/+14
* This does not make sense for most SciTECO builds, but only when you want to optimize for size as the lexers take up 50% of the compressed binary size. Without Lexilla, it should be possible get it compiled in about 500kb. * It can be useful for instance when building for embedded distributions. * When Lexilla is disabled, symbols-scilexer.c is also not generated (we assume that the Lexilla sources are not available and it also doesn't serve any purpose). * Consequently, most of the lexer configuration scripts are also not installed under --without-lexilla.
2023-04-13cmdline.c: fixed rubbing out words (^W) and possible chrashesRobin Haberkorn1-17/+10
* This would sometimes rub out more than expected due to reading undefined memory. Actually even crashes were not impossible. * This is because SCI_GETWORDCHARS does not null-terminate the buffer it writes but this was assumed. In effect, we could easily read beyond the allocated memory in wchars if there doesn't happen to be a null-char following the buffer. * Consequently, null-chars in word chars were also not supported, although this would hardly trouble anybody. * Instead, we now store the word chars in a teco_string_t which supports non-null-terminated strings natively. Still we null-terminate the string to keep teco_string_t's promises about degrading to null-terminated char *. This is currently not necessary. * teco_is_wordchar() has been replaced by teco_string_contains().
2023-04-13cmdline.c: simplified the rubin-caseRobin Haberkorn2-13/+6
* We no longer need special NULL-values for teco_cmdline_insert(), as teco_cmdline_rubin() will simply take a character from the rubbed-out command line and is equivalent to typing a character from the rubbed-out command-line.
2023-04-13fixed typing in characters of the rubbed-out command-lineRobin Haberkorn1-11/+12
* The rubbed out command line should not be discarded. * This has been broken since 432ad24e382681f1c13b07e8486e91063dd96e2e (C conversion).
2023-04-05updated copyright to 2023Robin Haberkorn61-61/+61
2023-04-05default font is now "Monospace" instead of CourierRobin Haberkorn1-1/+1
* Courier has the quirk that letter sequences like "fi" are turned into ligatures which breaks the monospaced nature of the display. * We assume that "Monospace" is also more portable, although it hasn't yet been tested on Windows. * only relevant for the Gtk UI of course * It might be a good idea to set SCI_STYLESETCHECKMONOSPACED as well (FIXME?)
2022-12-10fixed pass-through loops: especially :> and :F<Robin Haberkorn1-15/+46
* fixes test cases like 3<%a:> * you can now use :F< in pass-through loops as well * F> outside of loops will now exit the current macro level. This is analogous to what TECO-11 did. In interactive mode, F> is currently also equivalent to $$ (terminates command line).
2022-11-28fixed a number of crashes due to empty string arguments or uninitialized ↵Robin Haberkorn9-5/+18
registers * An empty but valid teco_string_t can contain NULL pointers. More precisely, a state's done_cb() can be invoked with such empty strings in case of empty string arguments. Also a registers get_string() can return the NULL pointer for existing registers with uninitialized string parts. * In all of these cases, the language should treat "uninitialized" strings exactly like empty strings. * Not doing so, resulted in a number of vulnerabilities. * EN$$ crashed if "_" was uninitialized * The ^E@q and ^ENq string building constructs would crash for existing but uninitialized registers q. * ?$ would crash * ESSETILEXER$$ would crash * This is now fixed. Test cases have been added. * I cannot guarantee that I have found all such cases. Generally, it might be wise to change our definitions and make sure that every teco_string_t must have an associated heap object to be valid. All functions returning pointer+length pairs should consequently also never return NULL pointers.
2022-11-20bumped required PDCursesMod version to v4.3.4 or laterRobin Haberkorn1-16/+0
* allows us to get rid of some workarounds * the workarounds themselves required relatively recent PDCursesMod versions, so we can just as well bump the version yet another time. We are probably the only ones building it (via Github actions) anyway. * With v4.3.4 you should be able to link dynamically, but we are still linking statically for nightly builds to keep binary sizes small. Unfortunately, the glib builds shipping with MinGW still have dynamically linked helper executables.
2022-11-20fixed teco_qreg_table_set_environ() on Win32: sometimes keys unexpectedly ↵Robin Haberkorn1-1/+13
begin with an equals character * Has been observed on Windows Server 2008 with Glib 2.74.1-1, but not on the Github CI runner.
2022-11-20teco_qreg_table_set_environ() will now use g_get_environ() instead of ↵Robin Haberkorn1-9/+5
g_listenv() * This is assumed to fix current Windows CI build problems caused by g_getenv() returning NULL for keys contained in g_listenv(), which is probably a new Glib bug. * Using g_get_environ() is more efficient since we do not have to repeatedly search through the environment array with g_getenv(). * Windows 2000 - which supposedly relied on the old code because of its own bugs - is no longer supported by our minimum Glib version anyway.
2022-06-22PDCursesMod/WinGUI now uses the polling fallback again with a temporary ↵Robin Haberkorn1-76/+14
workaround * The keyboard hook required polling as well and was actually much less performant than the generic getch() polling fallback. Furthemore it did at least not work on Wine. * We instead now release the WinGUI-internal mutex and yield the thread giving it some time to process new key presses. * This workaround is temporary and will probably be part of the the next PDCursesMod-release (v4.3.4). We still want to support the latest MSYS/MinGW version though which is currently at v4.3.2. The fix will also currently only work when statically linking in libpdcurses_wingui.a. This is what we do for nightly builds. See also https://github.com/Bill-Gray/PDCursesMod/issues/197 * Once the fix is released upstream and into MSYS, we should probably bump our minimal required PDCursesMod version. The color-table workaround (cf9ffc0cec0d2e55930238d1752209bca659c96d) can then also be removed. * We should also consider dropping official support for the classic PDCurses and support only PDCursesMod - this will allow us to simplify interfaces-curses/interface.c a bit. Support for classic PDCurses is probably broken by now anyway and trying to support it is just too much.
2022-06-21updated copyright to 2022 and updated TODORobin Haberkorn61-61/+61
2022-06-21avoid unnecessary creation of undo tokensRobin Haberkorn2-5/+8
2022-06-21fixed rubout of certain constructs like Ifoo$FRX$$Robin Haberkorn3-4/+17
* avoid emitting SCI_UNDO undo tokens if the Scintilla undo action would actually be empty
2022-06-21better support recent versions of PDCursesMod (used to be the Win32a-port)Robin Haberkorn1-1/+2
* PDCursesMod is now the recommended PDCurses variant * you should use at least v4.3.2 since earlier versions have problems inserting CTRL+C and CTRL+V. * We now check for PDC_get_version() since initscr() was name-mangled at least for some time. The maintainers have now reverted to name-mangling endwin(), we still check for PDC_get_version() as it is probably safer in the future. * Properly define PDC_FORCE_UTF8 now. * We no longer have to check for PDC_set_resize_limits() since PDCursesMod now defines its own macro __PDCURSESMOD__ in curses.h.
2022-06-21PDCursesMod: fixed the light black color on all GUI backends (e.g. WinGUI)Robin Haberkorn1-0/+4
* This is already fixed upstream, but we still include the workaround, so we can build with the current MSYS package and during CI.
2022-06-21PDCurses: fixed CTRL+C interruptions on WinCON and WinGUIRobin Haberkorn1-28/+87
* Due to regressions, the Control handler needs to be installed later (PDCursesMod installs its own control handler). * We no longer have to manually set the control mode - at least on PDCursesMod/WinCON. It's not worth keeping the workaround for the original PDCurses. * For WinGUI neither the control handler, nor the polling-fallback will work, therefore we introduced yet another version based on keyboard hooks. See https://github.com/Bill-Gray/PDCursesMod/issues/197 This version may even become the default on all Win32-ports but I need to think this through more thorougly.
2022-06-21Gtk+: fixed interpretation of Alt-Gr-keypressesRobin Haberkorn1-1/+6
* this is a regression in Gtk+ 3 * nowadays, Alt-Gr-keycombos are sometimes reported as Ctrl+Alt which resulted in control characters to be inserted
2022-06-21Gtk+: Stop memory limiting when idlingRobin Haberkorn1-0/+8
* the same is done in the Curses UI * important for platforms that require busy polling of memory usage (Win32)
2022-01-15fixup: use a dedicated input queue data structures (teco_interface.input_queue)Robin Haberkorn1-22/+35
* Using ungetch() was of course broken and could easily result in hangs as wgetch() would never return ERR. * This wastes some bytes on platforms that do not need the teco_interface_is_interrupted() fallback. * introduced teco_interface_blocking_getch() * FIXME: This is still way too slow on PDCurses/GUI on Windows but this can potentially be fixed upstream.