aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-gtk
AgeCommit message (Collapse)AuthorFilesLines
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-01implemented the ^W command for refreshing the screen in loops, for sleeping ↵Robin Haberkorn1-14/+25
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-31implemented ^T command: allows typing by code and getting characters from ↵Robin Haberkorn3-0/+124
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-26implemented the <^A> command for printing arbitrary stringsRobin Haberkorn1-18/+6
* Greatly improved usability as a scripting language. * The command is in DEC TECO, but in contrast to DEC TECO, we also support string building constructs in ^A. * Required some refactoring: As we want it to write everything verbatim to stdout, the per-interface method is now teco_interface_msg_literal() and it has to deal with unprintable characters. When displaying in the UI, we use teco_curses_format_str() and TecoGtkLabel functions/widgets to deal with possible control codes. * Numbers printed with `=` have to be written with a trailing linefeed, which would also be visible as a reverse "LF" in the UI. Not sure whether this is acceptable - the alternative would be to strip the strings before displaying them. * Messages written to stdout are also auto-flushed at the moment. In the future we might want to put flushing under control of the language. Perhaps :^A could inhibit the flushing.
2025-07-18make some array declarations real constantsRobin Haberkorn1-1/+1
* `static const char *p = "FOO"` is not a true constant since the variable p can still be changed. It has to be declared as `static const char *const p = "FOO"`, so that the pointer itself is constant. * In case of string constants, it's easier however to use `static const char p[] = "FOO"`.
2025-07-16the primary clipboard is now chosen by the 10th bit in the ED flagsRobin Haberkorn1-8/+4
* `[q]~` was broken and resulted in crashes since it reset the clipboard character to 0. In fact, if we don't want to break the `[a]b` idiom we cannot use the numeric cell of register `~`. * Therefore we no longer use the numeric part of register `~`. Once the clipboard registers are initialized they completely replace any existing register with the same name that may have been set in the profile. So we still don't leak any memory. (But perhaps it would now be better to fail with an error if one of the clipboard registers already exist?) * Instead, bit 10 (1024) of ED is now used to change the default clipboard to the primary selection. The alternative might have been an EJ flag or even a special register containing the name of the default clipboard register. * partially reverses 8c6de6cc718debf44f6056a4c34c4fbb13bc5020
2025-07-13allow changing the default clipboard by setting the `~` integerRobin Haberkorn1-6/+10
* It continues to default to 67 (C), which is the system clipboard. But you can now overwrite it e.g. by adding `^^PU~` to the profile. * This fixes a minor memory leak: If you set one of the clipboard registers in the profile (initializing them as plain registers), the clipboard register had been leaked. The clipboard registers now replace any existing register, while at the same time preserving the numeric part. * All remaining Q-Reg table insertions use a new function teco_qreg_table_insert_unique() which adds an assertion, so that we notice any future possible memory leaks.
2025-07-01GTK: handle (smooth) scrolling with a scroll controllerRobin Haberkorn1-15/+42
* On interfaces, which only support smooth scrolling, we had to emulate discrete events. Moreover, once we enabled GDK_SMOOTH_SCROLL_MASK, systems that would previously report discrete UP/DOWN events, would suddenly report GDK_SCROLL_SMOOTH. * Converting from smooth scroll events to discrete scroll events turned out to be trickier than anticipated. Scrolling was therefore more sluggish than it used to be before 2f448c976889fe60aba8557b5aa4aa0a0d939281. * Scrolling is therefore now delegated to a GtkEventControllerScroll, which is used to synthesize a discrete GDK_SCROLL event that's fed into the usual event pipeline via teco_interface_input_cb().
2025-06-12GTK: fixed scrolling on systems that only support smooth scrollingRobin Haberkorn1-4/+12
* Apparently, we cannot disable smooth scrolling on a per-application basis, so I have to handle both discrete and smooth scrolling events. * Since SciTECO's scroll API (-EJ) is based on discrete scrolling, we now emulate discrete scroll events by accumulating the delta_y of smooth scroll events. The threshold value of 12 is chosen arbitrarily, but based on an example in the Gtk documentation.
2025-05-02auto-expand folds even after mouse eventsRobin Haberkorn1-3/+2
The ^KMOUSE macro can also change dot and it was possible to place dot into invisible areas at the end of the document.
2025-04-27support folding via F1 and clicks in the folding marginRobin Haberkorn1-0/+3
* Set up the folding margin in the currently empty margin column after the line number. On Gtk, this meant resetting all the marker symbols and their foreground/background colors as well as the margin's colors themselves. This looks like a bug. It's not necessary on Scinterm, which apparently uses the default/linenumber styles by default. Perhaps we should try upgrading Scintilla? * The folding state is considered not to be directly controlled by the language (just like the scroll position and zoom level). That's why we can directly control it by clicking on the margin column. * F1 can be used to toggle all folds globally. * The only support within the C core necessary for folding is to make sure that the current line is unfolded after every keypress. * We might add custom folding commands to the language later on (e.g. F+, F-). In this case, the key macros will have to be changed of course.
2025-04-19Gtk: fixed setting the mouse cursor after changing the active bufferRobin Haberkorn2-2/+12
* The GdkWindow stacking order obviously got messed up when swapping out the child widget in the GtkEventBox. * This was probably also responsible for input events coming through to the Scintilla view even though the GtkEventBox should block all input events from reaching the Scintilla view. The event masking in teco_view_new() is probably no longer necessary - but better keep it to be on the safe side.
2025-04-18Gtk: prevent drag-and-drop interaction and block more possibly dangerous ↵Robin Haberkorn1-1/+12
touch and scroll events * You could drag and drop text into the Scintilla views, which would confuse SciTECO. * In the future, we might actually want to support programmable drag-and-drop support via special key macros.
2025-04-15try hard to preserve the vertical scrolling position when auto-scrolling dotRobin Haberkorn1-2/+8
* There are cases, especially where the entire buffer is piped through some external process or when removing and reinserting large parts of the buffer, that dot changes very little, but the vertical scrolling position gets resets. This is especially noticable with the macro @^U{[: HECcat$ ]:}, but also with M#cf (clang-format wrapper from "Useful macros"). * We now try to preserve the vertical position ("first visible line") before scrolling caret.
2025-04-13Gtk: do not attempt automatic ANSI key translation for dead keysRobin Haberkorn1-0/+5
* At least on Windows it was observed that teco_interface_get_ansi_key() would find ANSI keys on other layouts, but nothing corresponding to the key itself. For instance, for a dead caret (^), we'd find backslash. This made it impossible to type caret in the parser start states. * We clumsily detect whether a keyevent refers to a dead key by checking its symbolic name and pass it down to the input method unmodified. * Fixes entering dead keys, at the very least on Windows, but potentially on all other systems as well.
2025-04-04scroll caret __almost__ always automatically after key pressesRobin Haberkorn1-2/+4
* The old heuristics - scroll if dot changes after key press - turned out to be too simplistic. They broke the clang-format macro (M#cf), which left the view at the top of the document since the entire document is temporarily erased. Other simplified examples of this bug would be: @^Um{[: HECcat$ ]:} Mm Or even: @^Um{[: H@X.aG.a ]:} Mm * Actually, the heuristics could be tricked even without deleting any significant amount of text from the buffer. The following test case replaces the previous character with a linefeed in a single key press: @^Um{-DI^J$} Mm If executed on the last visible line, dot wouldn't be scrolled into the view since it did not change. * At the same time, we'd like to keep the existing mouse scroll behavior from fnkeys.tes, which is allowed to scroll dot outside of the visible area. Therefore, dot is scrolled into view always, except after mouse events. You may have to call SCI_SCROLLCARET manually in the ^KMOUSE macro, which is arguably not always straight forward. * Some macros like M#cf may still leave the vertical scrolling position in unexpected positions. This could either be fixed by eradicating all remaining automatic scrolling from Scintilla or by explicitly restoring the vertical position from the macro (FIXME). * This was broken since the introduction of mouse support, so it wasn't in v2.3.0.
2025-03-02refactored GTK implementation of teco_view_t into its own fileRobin Haberkorn3-96/+127
Also makes sense since all other GObject classes are in separate files.
2025-03-02GTK: always scroll caret when window size changesRobin Haberkorn1-47/+59
* The old implementation would scroll only once for the file first opened and too early. As a result, opening via `sciteco file:number` did not always scroll to the correct position. Also, `?` would usually not scroll the topic into view. * Instead, we now always scroll in all views, but only if the size allocation changed. This ensures, we can still scroll with the mouse wheel. * Therefore, we have to store the current size allocation per view. Instead of allocating a separate heap object, I decided to subclass the Scintilla GTK class. * Some explicit casts are still necessary since teco_view_t is typedefed to `struct teco_view_t`, but we cannot easily rename the GObject instance structure.
2025-03-02GTK: set the mouse cursor on the Scintilla view to signal business and on ↵Robin Haberkorn2-0/+60
the popup entries * By default, use the "text" cursor - this is the default Scintilla cursor, but inhibited by the GtkEventBox I used to catch all input events. * When processing input events, the cursor is changed to "wait". This is done with a small delay in order to avoid flickering during normal typing. The cursor is only changed after 100ms of activity, i.e. only when executing long loops or external programs. * We use the raw GSource API since it's tricky to work with source ids if the source could be removed in the meantime. * The popup entries' cursor is also changed to "pointer" (hand) to give a hint that it can be clicked.
2025-02-24Gtk: fixed MOUSE macro invocation when detecting double/triple clicksRobin Haberkorn1-1/+5
* At the SciTECO API level (-nEJ), there are no double clicks. We must therefore ignore the GDK_2BUTTON_PRESS and GDK_3BUTTON_PRESS events, that are delivered when GTK detects double or triple clicks. They are only sent in addition to GDK_BUTTON_PRESS, so it's safe to simply ignore them. * This was causing spurious RELEASED events, which were confusing the ^KMOUSE macro from fnkeys.tes, causing the wrong buffer range to be inserted into the command line.
2025-02-23support mouse interaction with popup windowsRobin Haberkorn4-16/+76
* Curses allows scrolling with the scroll wheel at least if mouse support is enabled via ED flags. Gtk always supported that. * Allow clicking on popup entries to fully autocomplete them. Since this behavior - just like auto completions - is parser state-dependant, I introduced a new state method (insert_completion_cb). All the implementations are currently in cmdline.c since there is some overlap with the process_edit_cmd_cb implementations. * Fixed pressing undefined function keys while showing the popup. The popup area is no longer redrawn/replaced with the Scintilla view. Instead, continue to show the popup.
2025-02-16only scroll the caret if dot changesRobin Haberkorn1-8/+16
* Fixes scrolling with default ^KMOUSE macro from fnkeys.tes which adjusts the scroll position without changing dot. The unconditional SCI_SCROLLCARET would effectively prevent scrolling to any position that does not contain dot.
2025-02-16implemented mouse support via special ^KMOUSE and <EJ> with negative keysRobin Haberkorn1-23/+117
* You need to set 0,64ED to enable mouse processing in Curses. It is always enabled in Gtk as it should never make the experience worse. sample.teco_ini enables mouse support, since this should be the new default. `sciteco --no-profile` won't have it enabled, though. * On curses, it requires the ncurses mouse protocol version 2, which will also be supported by PDCurses. * Similar to the Curses API, a special key macro ^KMOUSE is inserted if any of the supported mouse events has been detected. * You can then use -EJ to get the type of mouse event, which can be used with a computed goto in the command-line editing macro. Alternatively, this could have been solved with separate ^KMOUSE:PRESSED, ^KMOUSE:RELEASED etc. pseudo-key macros. * The default ^KMOUSE implementation in fnkeys.tes supports the following: * Left click: Edit command line to jump to position. * Ctrl+left click: Jump to beginning of line. * Right click: Insert position or position range (when dragging). * Double right click: insert range for word under cursor * Ctrl+right click: Insert beginning of line * Scroll wheel: scrolls (faster with shift) * Ctrl+scroll wheel: zoom (GTK-only) * Currently, there is no visual feedback when "selecting" ranges via right-click+drag. This would be tricky to do and most terminal emulators do not appear to support continuous mouse updates.
2025-01-13updated copyright to 2025Robin Haberkorn5-5/+5
2024-12-13implemented Scintilla lexer for SciTECO code, i.e. TECO syntax highlightingRobin Haberkorn1-1/+1
* this works by embedding the SciTECO parser and driving it always (exclusively) in parse-only mode. * A new teco_state_t::style determines the Scintilla style for any character accepted in the given state. * Therefore, the SciTECO lexer is always 100% exact and corresponds to the current SciTECO grammer - it does not have to be maintained separately. There are a few exceptions and tweaks, though. * The contents of curly-brace escapes (`@^Uq{...}`) are rendered as ordinary code using a separate parser instance. This can be disabled with the lexer.sciteco.macrodef property. Unfortunately, SciTECO does not currently allow setting lexer properties (FIXME). * Labels and comments are currently styled the same. This could change in the future once we introduce real comments. * Lexers are usually implemented in C++, but I did not want to draw in C++. Especially not since we'd have to include parser.h and other SciTECO headers, that really do not want to keep C++-compatible. Instead, the lexer is implemented "in the container". @ES/SCI_SETILEXER/sciteco/ is internally translated to SCI_SETILEXER(NULL) and we get Scintilla notifications when styling the view becomes necessary. This is then centrally forwarded to the teco_lexer_style() which uses the ordinary teco_view_ssm() API for styling. * Once the command line becomes a Scintilla view even on Curses, we can enabled syntax highlighting of the command line macro.
2024-11-05fully support relocatable binaries, improving AppImagesRobin Haberkorn1-21/+11
* You can now specify `--with-scitecodatadir` as a relative path, that will be interpreted relative to the binary's location. * Win32 binaries already were relocatable, but this was a Windows-specific hack. Win32 binaries are now built with `--with-scitecodatadir=.` since everything is in a single directory. * Ubuntu packages are now also built `--with-scitecodatadir=../share/sciteco`. This is not crucial for ordinary installations, but is meant for AppImage creation. * Since AppImages are now built from relocatable packages, we no longer need the unionfs-workaround from pkg2appimage. This should fix the strange root contents when autocompleting in AppImage builds. * This might also fix the appimage.github.io CI issues. I assume that because I could reproduce the issue on FreeBSD's Linuxulator in dependence of pkg2appimage's "union"-setting. See https://github.com/AppImage/appimage.github.io/pull/3402 * Determining the binary location actually turned out be hard and very platform-dependant. There are now implementations for Windows (which could also read argv[0]), Linux and generic UNIX (which works on FreeBSD, but I am not sure about the others). I believe this could also be useful on Mac OS to create app bundles, but this needs to be tested - currently the Mac OS binaries are installed into fixed locations and don't use relocation.
2024-10-21GTK/Win32: include trailing null byte in gtk_selection_data_set_text()Robin Haberkorn1-1/+6
* This API behaves very strangely and differently compared to UNIX/X11. When getting, it returns a trailing null for all clipboard contents (unless the clipboard is empty) and when setting, we apparently have to include it as well. At least since we cut it off when getting. Even more strangely, setting without the trailing null did work when pasting in external apps. (How they know when it's safe to throw away the trailing null is mysterious.) * In other words, this fixes X~G~.
2024-10-21GTK/Win32: fixed clipboard retrieval (trailing nulls)Robin Haberkorn1-0/+5
* Contrary to the Gtk documentation, the gtk_selection_data_get_length() already includes a trailing null, so we always inserted a bogus null char when using G~ or ^EQ~.
2024-10-05Gtk UI: support setting and getting clipboards containing null bytesRobin Haberkorn1-9/+52
* added TECO_ERROR_CLIPBOARD for all clipboard-related errors
2024-09-12function key macros have been reworked into a more generic key macro featureRobin Haberkorn1-13/+35
* ALL keypresses (the UTF-8 sequences resulting from key presses) can now be remapped. * This is especially useful with Unicode support, as you might want to alias international characters to their corresponding latin form in the start state, so you don't have to change keyboard layouts so often. This is done automatically in Gtk, where we have hardware key press information, but has to be done with key macros in Curses. There is a new key mask 4 (bit 3) for that purpose now. * Also, you might want to define non-ANSI letters to perform special functions in the start state where it won't be accepted by the parser anyway. Suppose you have a macro M→, you could define @^U[^K→]{m→} 1^_U[^K→] This effectively "extends" the parser and allow you to call macro "→" by a single key press. See also #5. * The register prefix has been changed from ^F (for function) to ^K (for key). This is the only thing you have to change in order to migrate existing function key macros. * Key macros are enabled by default. There is no longer any way to disable function key handling in curses, as I never found any reason or need to disable it. Theoretically, the default ESCDELAY could turn out to be too small and function keys don't get through. I doubt that's possible unless on extremely slow serial lines. Even then, you'd have to increase ESCDELAY and instead of disabling function keys simply define an escape surrogate. * The ED flag has been removed and its place is reserved for a future mouse support flag (which does make sense to disable in curses sometimes). fnkeys.tes is consequently also enabled by default in sample.teco_ini. * Key macros are handled as an unit. If one character results in an error, the entire string is rubbed out. This fixes the "CLOSE" key on Gtk. It also makes sure that the original error message is preserved and not overwritten by some subsequent syntax error. It was never useful that we kept inserting characters after the first error.
2024-09-11the SciTECO parser is Unicode-based now (refs #5)Robin Haberkorn1-5/+5
The following rules apply: * All SciTECO macros __must__ be in valid UTF-8, regardless of the the register's configured encoding. This is checked against before execution, so we can use glib's non-validating UTF-8 API afterwards. * Things will inevitably get slower as we have to validate all macros first and convert to gunichar for each and every character passed into the parser. As an optimization, it may make sense to have our own inlineable version of g_utf8_get_char() (TODO). Also, Unicode glyphs in syntactically significant positions may be case-folded - just like ASCII chars were. This is is of course slower than case folding ASCII. The impact of this should be measured and perhaps we should restrict case folding to a-z via teco_ascii_toupper(). * The language itself does not use any non-ANSI characters, so you don't have to use UTF-8 characters. * Wherever the parser expects a single character, it will now accept an arbitrary Unicode/UTF-8 glyph as well. In other words, you can call macros like M§ instead of having to write M[§]. You can also get the codepoint of any Unicode character with ^^x. Pressing an Unicode character in the start state or in Ex and Fx will now give a sane error message. * When pressing a key which produces a multi-byte UTF-8 sequence, the character gets translated back and forth multiple times: 1. It's converted to an UTF-8 string, either buffered or by IME methods (Gtk). On Curses we could directly get a wide char using wget_wch(), but it's not currently used, so we don't depend on widechar curses. 2. Parsed into gunichar for passing into the edit command callbacks. This also validates the codepoint - everything later on can assume valid codepoints and valid UTF-8 strings. 3. Once the edit command handling decides to insert the key into the command line, it is serialized back into an UTF-8 string as the command line macro has to be in UTF-8 (like all other macros). 4. The parser reads back gunichars without validation for passing into the parser callbacks. * Flickering in the Curses UI and Pango warnings in Gtk, due to incompletely inserted and displayed UTF-8 sequences, are now fixed.
2024-09-09Xq and ]q inherit the document encoding from the source document (refs #5)Robin Haberkorn1-1/+1
* ^Uq however always sets an UTF8 register as the source is supposed to be a SciTECO macro which is always UTF-8. * :^Uq preserves the register's encoding * teco_doc_set_string() now also sets the encoding * instead of trying to restore the encoding in teco_doc_undo_set_string(), we now swap out the document in a teco_doc_t and pass it to an undo token. * The get_codepage() Q-Reg method has been removed as the same can now be done with teco_doc_get_string() and the get_string() method.
2024-09-09Gtk: ignore the keyboard layout whereever possible (refs #5)Robin Haberkorn1-22/+78
* Eg. when typing with a Russian layout, CTRL+I will always insert ^I. * Works with all of the start-state command Ex, Fx, ^x commands and string building constructs. This is exactly where process_edit_cmd_cb() case folds case-insensitive characters. The corresponding state therefore sets an is_case_insensitive flag now. * Does not yet work with anything embedded into Q-Register specifications. This could only be realized with a new state callback (is_case_insensitive()?) that chains to the Q-Register and string building states recursively. * Also it doesn't work with Ё on my Russian phonetic layout, probably because the ANSI caret on that same key is considered dead and not returned by gdk_keyval_to_unicode(). Perhaps we should directly wheck the keyval values? * Whenever a non-ANSI key is pressed in an allowed state, we try to check all other keyvals that could be produced by the same hardware keycode, ie. we check all groups (keyboard layouts).
2024-09-09input and displaying of Unicode characters is now possible (refs #5)Robin Haberkorn1-8/+0
* All non-ASCII characters are inserted as Unicode. On Curses, this also requires a properly set up locale. * We still do not need any widechar Curses, as waddch() handles multibyte characters on ncurses. We will see whether there is any Curses variant that strictly requires wadd_wch(). If this will be an exception, we might keep both widechar and non-widechar support. * By convention gsize is used exclusively for byte sizes. Character offsets or lengths use int or long.
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-21updated copyright to 2024Robin Haberkorn5-5/+5
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 Haberkorn1-61/+64
* 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-09fixed CTRL+C interruptions on Windows; optimized CTRL+C polling on Gtk+Robin Haberkorn1-22/+25
* 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-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-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-18no longer try to avoid automatic scrolling - this is patched out of ↵Robin Haberkorn1-5/+2
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-05updated copyright to 2023Robin Haberkorn5-5/+5
2022-11-28fixed a number of crashes due to empty string arguments or uninitialized ↵Robin Haberkorn1-0/+1
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-06-21updated copyright to 2022 and updated TODORobin Haberkorn5-5/+5
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)