aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2025-03-29^W also rubs out/in `@` and `:` modifiersRobin Haberkorn1-0/+15
* It makes little sense to e.g. rub out until `I` in `@I/foo/`, but leave the `@` modifier. Modifiers have to be considered part of the command, even though the state machine is not currently modelled like that.
2025-03-29added `@W`, `@P`, `@V` and `@Y` command variantsRobin Haberkorn3-134/+138
* They swap the default order of skipping characters. For positive arguments: first non-word chars, then word chars. * This is especially useful after executing the non-at-modified versions. For instance, at the beginning of a word, `@W` jumps to its end. `@V` would delete the remainder of the word. * Since they have to evaluate the at-modifier, which has syntactic significance, the command implementations can no longer use transition tables, so they are in the switch-statements instead.
2025-03-23the ES command (send Scintilla message) now supports passing both wParam and ↵Robin Haberkorn2-18/+44
lParam as null-terminated strings * Being able to embed null bytes into the lParam string is practically useless - there aren't any messages where this is useful and where there are no native SciTECO counterparts - so this case is now catched and the null-byte separates wParam from lParam. * wParam can be the empty string, but it is not supported to pass wParam as a string and lParam as the empty string. If the second string argument ends in ^@, lParam is popped from the stack instead. * This is a temporary workaround until we can properly parse the Scintilla.iface and generate more elegant per-message wrappers. * It in particular unlocks the SCI_SETREPRESENTATION and SCI_SETPROPERTY messages. The former allows us to write a special hex-editor macro which sets hexadecimal character representations, while the latter allows you to set lexer properties. * The C-based lexers ("cpp" in Lexilla) can now take preprocessor definitions into account. This is disabled by default, unless you set lexer.c.defines before opening a file. You can also set it interactively and re-set the lexer. For instance: ^U[lexer.c.defines]NDEBUG$ M[lexer.set.c]
2025-03-23refactored Lexilla/Scintillua support: it's now in teco_create_lexer()Robin Haberkorn1-59/+80
2025-03-23the ^W immediate editing command now mimics `Y` more closely and also rubs ↵Robin Haberkorn3-6/+28
out no-op commands (whitespace) * In string arguments, ^W first rubs out non-word chars (usually whitespace), so it makes sense if ^W would work analogously at the command level. A non-command would be one of the no-ops.
2025-03-22added `P` command as a reverse form of `W`Robin Haberkorn3-4/+38
* All the movement commands have shortcuts for their negative forms: `R` instead of `-C`, `B` instead of `-L`. Therefore there was always the need for a `-W` shortcut as well. * `P` is a good choice because it is a file IO command in TECO-11, that does not make sense supporting. In Video TECO it toggles between display windows (ie. split screens) and I do not plan to support multiple windows in SciTECO. * Added to the cheat sheet.
2025-03-22factored out all cursor movement and deletion commands into the new ↵Robin Haberkorn4-599/+676
compilation unit move-commands.c * This made sense to include both `W` and `V`, so we also included `D` and `K`. `^Q` is included since it converts between lines and glyphs. * These are all single-letter commands, so they aren't complete parser states but callbacks to be referenced in teco_machine_main_transition_t.
2025-03-22harmonized all word-movement and deletion commands: they move/delete until ↵Robin Haberkorn3-22/+95
the beginning of words now * All commands and their documentations were inconsistent. * ^W rubbed out to the beginning of words. * Shift+Right (fnkeys.tes) moved to the beginning of the next word if invoked at the beginning of a word and to the end of the next word otherwise. * <W> (and <V> and <Y> by extension) moved to the end of the next word. * The cheat sheet would claim that <W> moves to the beginning of the next word. * Video TECO's <W> command would differ again from everything else. With positive arguments, it moved to the beginning of words, while with negative it moved to end of words. I decided not to copy this behavior. * It has been decided to adopt a consistent beginning-of-words policy. -W therefore differs from Video TECO in moving to the beginning of the current or previous word. * teco_find_words() is now based on parsing the document pointer, instead of relying on SCI_WORDENDPOSITION, since the latter cannot actually be used to skip strictly non-word characters. This requires a constant amount of Scintilla messages but will require fewer messages only when moving for more than 3 words. * The semantics of <W> are therefore now consistent with Vim and Emacs as well. * Shift+Right/Left is still based on SCI_WORDENDPOSITION, so it's behavior differs slightly from <W> for instance at the end of lines, as it will stop at linebreaks. * Unfortunately, these changes will break lots of macros, among others the M#rf, M#sp and git.blame macros ("Useful macros" from the wiki).
2025-03-21fixed rubout of Q-Register specificationsRobin Haberkorn4-4/+12
* This was a regression introduced by 257a0bf128e109442dce91c4aaa1d97fed17ad1a. * The undo token that frees newly allocated teco_machine_qregspec_t must actually reset the pointer as well since any subsequent token, pushed by teco_undo_qregspec_own(), will expect a valid pointer. * Could have been done via ctx->expectqreg = NULL; teco_undo_qregspec_own(ctx->expectqreg); but using a special clear function requires less memory and is easier to understand. * Added test case. This wouldn't always crash, but should definitely show up in Valgrind.
2025-03-21don't use TECO_DEFINE_UNDO_OBJECT_OWN() for what are essentially scalarsRobin Haberkorn2-8/+14
* The "own" objects are tricky to work with and have special requirements, so try to avoid them. * Also, wrap the push functions in macros like all other scalars. * This is a purely cosmetic change, but avoids some confusion.
2025-03-19fixup cddc9bf83eb5cd2c69626b31ae7373342523b626: errors must be printed ↵Robin Haberkorn1-6/+4
before cleaning up the interface This fixes crashes on Gtk.
2025-03-19fixup cddc9bf83eb5cd2c69626b31ae7373342523b626: avoid g_prefix_error_literal()Robin Haberkorn1-1/+1
This function requires glib v2.70, which impacted portability.
2025-03-19fixed leaking data on ruboutRobin Haberkorn4-16/+26
* Objects, that are restored with TECO_DEFINE_UNDO_OBJECT_OWN(), could actually leak memory on rubout since the old object was not deleted when overwriting it. * Now that it is, it is crucial to at least nullify objects/pointers after calling the corresponding push-function. These conditions are now explicitly documented. * The test suite now runs successfully under Valgrind even with full leak checking.
2025-03-17fixed leaking partially built string arguments in case of errorsRobin Haberkorn1-0/+1
* E.g. `@I/foo^EQ%/` whould fail if register `%` is missing. In batch mode, this would currently escalate and terminate the program. Only in this case, memory has been "leaked". This is not critical but was causing false positives in Valgrind. * Also, cleaning up properly might come in handy once we add error-catching constructs to the language.
2025-03-17free some global objects even in the error case, in order to appease ValgrindRobin Haberkorn1-14/+18
* If building with --enable-debug, we should always free all heap objects, even if they would be freed on program termination anway, so they won't appear as "possibly lost" in Valgrind. I had this missing if munged or evaled macro failed, which resulted in lots of false positives when running the testsuite under Valgrind. * Also fixes possible crashes due to reusing already set GError variables. This could theoretically happen if a munged script terminates with ^C and its "quit" ED-hook would also throw any error.
2025-03-17fixed memory leak when seeing an existing label (exactly the same or ↵Robin Haberkorn1-17/+15
redefinition) This could actually be reproduced by `./testsuite --valgrind` and by the Address Sanitizer.
2025-03-16further improved monochrome terminal support: fixed reverse text on reverse ↵Robin Haberkorn4-28/+72
backgrounds * Unfortunately we cannot use `wbkgdset(win, A_REVERSE)` if we plan to use reverse text on this background, i.e. if we want to cancel out the background A_REVERSE. * SciTECO therefore no longer uses background attributes, but only foreground attributes. When setting a reverse text, we XOR A_REVERSE into the previous attributes. * This fixes control characters especially in the info line and popups, as well as rendering of the popup scroll bars. * The command-line should now be rendered properly even on a dark-on-bright color theme (which does not yet exist).
2025-03-15Curses: use special ellipsis symbol instead of "..." when truncating stringsRobin Haberkorn3-15/+38
This requires Unicode icon support to be enabled via ED. The ellipsis symbol is shorter and more distinctive, allowing more of the original text to be preserved before truncation.
2025-03-13updated Scinterm: my monochrome patch was merged only with some modificationsRobin Haberkorn1-7/+11
* SCI_COLOR_PAIR() is now a function teco_color_pair() since it also became an inline function in Scinterm.
2025-03-13rewrote <W> command on the same basis as <V> and <Y>Robin Haberkorn1-61/+57
* <W> was also using keyboard movement commands. * This fixes an inconsistency between the handling of punctuation characters, e.g. "(word" followed by -W vs. Y.
2025-03-08added "email" lexer for writing mailsRobin Haberkorn1-0/+1
* Highlights both 1st level and 2nd level quotes and signatures. * This also sets the edge to 78 columns, as is recommended for email and enables word wrapping. The edge mode is not set, since it kind of looks ugly in Scinterm. * Helps when using SciTECO as the email editor for instance in the Aerc mail client. * Unfortunately, we cannot set up Scintilla to automatically break words after 78 columns (or perhaps that's a good thing). You can use the M#rf reformat-paragraph macro to reflow paragraphs before sending the mail. This will take the edge column into account even if no edge mode is set.
2025-03-08fixed the `Y` command: no longer delete any characters after dotRobin Haberkorn1-31/+23
* This has __always__ been broken. It's been especially annoying when pressing `Y` at the end of a line with trailing whitespace since the linebreak would also be deleted. This was because `Y` always deleted the entire word or non-word character-span. This was inconsistent with `V`. * We now use SCI_WORDSTART|ENDPOSITION instead of the keyboard commands. It therefore also requires less Scintilla messages (4+2*n vs. 4+4*n). Most importantly, we can now check for errors before changing the buffer, so there is no need to undo anything in case of errors. This should always be the preferred strategy. * Added test case.
2025-03-07ncurses: support monochrome terminalsRobin Haberkorn1-11/+26
* If the background color would be non-black, render text in reverse video. ncurses doesn't do that automatically. * Fixes rendering under historical terminals like VT100 and VT240, but also all of the monochrome versions of modern emulators in terminfo. * This also improves the situation when $TERM is set to something conservative, e.g. when connecting via RS232. * Scinterm is temporarily changed to my own fork, which already contains a monochrome patch.
2025-03-03rename sample.teco_ini to fallback.teco_ini and mung it by defaultRobin Haberkorn1-2/+24
* After installation, SciTECO will therefore start into a more userfriendly mode even if the user does not create a custom ~/.teco_ini. It is hoped that this will scare away less of new users, who are not willing to read through all of the documentation. Still, users are warned in the absence of ~/.teco_ini. This warning however, might not be immediately visible, especially not when running gsciteco without an attached console. (This will change once I redo the UI and allow a number of messages to be queued in the message area.) * Theoretically, you could also just extend fallback.teco_ini from ~/.teco_ini, but that would require installing it into $SCITECOPATH. * Since the fallback profile will now be munged automatically on a wide range of systems, we set up xclip only when detecting X11 ($DISPLAY is non-empty). E.g. when running under Wayland or the Linux console, you still won't get the clipboard registers, which is probably better than having the clipboard operations fail once you try to use them. * xclip is now "suggested" on Debian/Ubuntu. Unfortunately we cannot pull it in only in the presence of X11.
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-03-01fixed clicking the file completion popup in ~/Robin Haberkorn2-1/+5
* Popup entries are added with expanded directory names, so we have to skip the expanded directory names from the clicked popup entries.
2025-02-27implemented ncurses clipboard support via external processesRobin Haberkorn1-39/+210
* As an alternative to OSC-52, which is rarely supported by terminal emulators. * Makes the new mouse support much more useful since you rely on good builtin clipboard support. You can no longer e.g. just double-click a word to copy it into the "primary" selection as terminal emulators do by default. * Set $SCITECO_CLIPBOARD_SET/GET e.g. to xclip, way-copy, pbcopy or some wrapper script. * This is currently using POSIX-specific popen() API, so it behaves a bit different to command execution via EC/EG. I am not sure if it's worth rewriting with the GSpawn-API, since it will be used only on POSIX anyway and a GSpawn-based implementation is likely to be a bit larger. * Should there be some small command-line utility for interacting (esp. pasting) via OSC-52, built-in OSC-52 support could well be removed from SciTECO. Currently, I know only of https://github.com/theimpostor/osc/ and it requires very recent Go compilers. (I still haven't tested it. Quite possibly, pasting when run as a piped command is impossible.)
2025-02-27EC/EG command: check for null-bytes in $COMSPEC/$SHELLRobin Haberkorn1-6/+10
Environment variables will of course never contain null-bytes. However you can always set them later on from TECO code and include nulls. We therefore everywhere check for null-bytes in all registers used as null-terminated strings to avoid unexpected behavior.
2025-02-24fixed rubbing out `?` (help) after editing a Q-RegisterRobin Haberkorn1-2/+2
* Test case: @EQa// @?/EX/ -- Rubout should return you to the Q-Register view. * The test suite has been extended. Unfortunately we cannot currently directly check whether we're editing a Q-Register. But we add a magic number of characters to the Q-Register, that we can check afterwards.
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-24Curses: fixed flickering when scrolling through the auto-completion popup ↵Robin Haberkorn2-8/+14
(or generally when keeping it on screen even unchanged) * Turns out that updating the hardware cursor - which is not displayed anyway - would cause premature screen updates in teco_interface_refresh(), thus causing flickering, for instance when quickly cycling through the auto completion popup. Or even just when clicking its borders which does not change it. * Touching the popup window is actually important and expected since Scinterm is also touching its window by completely redrawing it. Touching the popup window makes sure, it's still copied into newscr and overlaps the Scintilla view even if the popup did not change - e.g. when pressing an unassigned function key or clicking on the popup borders.
2025-02-24Curses: avoid completing filenames when clicking the upper border of the ↵Robin Haberkorn1-0/+4
popup window
2025-02-23support mouse interaction with popup windowsRobin Haberkorn20-55/+431
* 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 Haberkorn2-15/+28
* 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 Haberkorn6-61/+354
* 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-02-15redefining labels is a warning nowRobin Haberkorn3-63/+80
* Allowing label redefinitions might have been useful when used as comments, since you will want to be able to define arbitrary comments. However as flow control constructs, this introduced a certain ambiguity since gotos might jump to different locations, depending on the progression of the parser. * On the other hand, making label redefinition an error might disqualify labels as comments when writing or porting classic TECO code. Therefore, it has been made a warning as a compromise. * Added test case
2025-01-19support :EF for saving a file before closing itRobin Haberkorn3-45/+60
Analoguous to :EX, but always saves the file like EW$, not only if it's dirty.
2025-01-19file and directory auto completions can now be case-insensitiveRobin Haberkorn1-7/+69
* This is not simply determined at compile-time but queries the concrete path at least on Windows and OS X. * The Windows implementation is kind of hacky and relies on undocumented behavior. It's also not even tested yet! * On Linux and FreeBSD completions will always be case-sensitive as they used to be. There does not appear to be any API to query case sensitivity of a given path or even the entire file system. At most, we could white-list a number of case-insensitive file systems.
2025-01-13updated copyright to 2025Robin Haberkorn65-65/+65
2024-12-30support +line[,column] and filename:line:column syntaxes when opening filesRobin Haberkorn1-12/+33
* This is done via the new opener.tes in the standard library. * Some programs that use $EDITOR expect the +line syntax to work. * You can copy filename:line:column directly from GCC error messages and filename:line from grep output. * Since there may be safe file names beginning with "+" or containing colons, there needs to be a way to turn this off, especially for scripts that don't know anything about the filenames to open. This is done with "--". Unfortunately, the first "--", that stops parameter processing, is always removed from the command line and not passed down into TECO land. This is not a problem for stand-alone scripts, since the script filename is already stopping option processing, so "--" would get passed down. But when calling the profile via `sciteco -- ...`, you could prevent leading minus signs to cause problems but since the `--` is removed, opener.tes cannot use it as a hint. Therefore, we introduced `-S` as a new alternative to `--`, that's always passed down as `--` (i.e. it is equivalent to "-- --"). In other words, `sciteco -S *` will always open exactly the specified files without any danger of misinterpreting certain file names. Should we ever switch to a custom option parsing algorithm, we might preserve "--" (unless after --mung) and thus get rid of "-S". * This advanced behavior can be tweaked by the user relatively easily. In the easiest case, we could replace M[opener] with <:L;R 0X.f [* @EB/^EN.f/ ]* L> in ~/.teco_ini to completely disable the special syntax.
2024-12-28avoid some compiler warningsRobin Haberkorn2-3/+3
2024-12-24introduced true block and EOL commentsRobin Haberkorn2-26/+85
* The previous convention of !* ... *! are now true block comments, i.e. they are parsed faster, don't spam the goto table and allow embedding of exclamation marks - only "*!" terminates the comment. * It is therefore now forbidden to have goto labels beginning with "*". * Also support "!!" to introduce EOL comments (like C++'s //). This disallows empty labels, but they weren't useful anyway. This is the shortest way to begin a comment. * All comment labels have been converted to true comments, to ensure that syntax highlighting works correctly. EOL comments are used for single line commented-out code, since it's easiest to uncomment - you don't have to jump to the line end. This is a pure convention / coding style. Other people might do it differently. * It's of course still possible to abuse goto labels as comments as TECO did for ages. * In lexing / syntax highlighting, labels and comments are highlighted differently. * When syntax highlighting, a single "!" will first be highlighted as a label since it's not yet unambiguous. Once you type the second character (* or !), the first character is retroactively styled as a comment as well.
2024-12-22Curses: fixed inserting null-byte (^@) by pressing Ctrl+@Robin Haberkorn1-3/+3
* g_utf8_get_char_validated() returns -2 for null-bytes (sometimes!?)
2024-12-22fixed lexing (syntax highlighting) of the null-character (^@) in SciTECO codeRobin Haberkorn3-4/+8
* Apparently g_utf8_get_char_validated() sometimes(!) returns -2 for null-characters, so it was considered an invalid byte sequence. * What's strange and unexplainable is that other uses of the function, as are behind nA and nQq, did not cause problems and returned 0 for null-bytes. * This also fixes syntax higlighting of .teco_session files which use the null-byte as the string terminator. (.teco_session files are not highlighted automatically, though.)
2024-12-22fixed indention in interface-curses/interface.cRobin Haberkorn1-9/+9
This is a purely cosmetic change.
2024-12-22fixed crashes while setting special Q-Registers with EU (string-building ↵Robin Haberkorn2-7/+8
characters) * The teco_qreg_vtable_t::get_string() method should support returning the length optionally (may be NULL). This already worked with teco_doc_get_string(), even though it wasn't documented, and therefore didn't cause problems with regular Q-Registers.
2024-12-22support external Scintilla lexer libraries and Scintillua in particularRobin Haberkorn2-8/+109
* @ES/SCI_SETILEXER/lib^@name/ now opens the lexer <name> in library <lib>. * You need to define the environment variable $SCITECO_SCINTILLUA_LEXERS to point to the lexers/ subdirectory (containing the *.lua files). Perhaps this should default to the dirname of <lib>? * The semantics of SCI_NAMEOFSTYLE have been changed: It now returns style ids when given style names, so you can actually write Scintillua lexer *.tes files. This will be superfluous if we had a way to return strings from Scintilla messages into Q-Registers, e.g. 23@EPq/SCI_NAMEOFSTYLE/. * We now depend on gmodule as well, but it should always be part of glib. It does not change the library dependencies of any package. It might result in gmodule shared libraries to be bundled in the Win32 and Mac OS packages if they weren't already.
2024-12-17sped up opening very large UTF-8 files by temporarily disabling the ↵Robin Haberkorn1-11/+33
line-character index * checks for character consistency (of UTF-8 byte sequences) were slowing down things significantly in Scintilla * It got even worse if the file indeed contained non-ANSI codepoints as reading in chunks of 1024 would sometimes mean that incomplete byte sequences would be read. Some large 160mb test files wouldn't load even after minutes. They now load in seconds. * This does NOT yet solve the slowdowns when operating on very long lines.