From 4e6ddd6c329d56055a732c6344df019f0d997aaf Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 7 Nov 2025 21:39:12 +0100 Subject: the command line macro is now managed by a Scintilla view * 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). --- src/cmdline.h | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/cmdline.h') diff --git a/src/cmdline.h b/src/cmdline.h index abe9b53..1ec891b 100644 --- a/src/cmdline.h +++ b/src/cmdline.h @@ -19,10 +19,13 @@ #include #include "sciteco.h" -#include "string-utils.h" #include "parser.h" +#include "view.h" #include "undo.h" +/** Indicator number used for the rubbed out part of the command line */ +#define INDICATOR_RUBBEDOUT (INDICATOR_CONTAINER+0) + typedef struct { /** * State machine used for interactive mode (commandline macro). @@ -34,16 +37,14 @@ typedef struct { teco_machine_main_t machine; /** - * String containing the current command line - * (both effective and rubbed out). - */ - teco_string_t str; - /** - * Effective command line length. - * The length of the rubbed out part of the command line - * is (teco_cmdline.str.len - teco_cmdline.effective_len). + * Command-line Scintilla view. + * It's document contains the current command line macro. + * The current position (cursor) marks the end of the + * "effective" command line, while everything afterwards + * is the rubbed out part of the command line. + * The rubbed out part should be highlighted with an indicator. */ - gsize effective_len; + teco_view_t *view; /** Program counter within the command-line macro */ gsize pc; @@ -60,6 +61,30 @@ typedef struct { extern teco_cmdline_t teco_cmdline; +void teco_cmdline_init(void); + +static inline sptr_t +teco_cmdline_ssm(unsigned int iMessage, uptr_t wParam, sptr_t lParam) +{ + return teco_view_ssm(teco_cmdline.view, iMessage, wParam, lParam); +} + +/** + * Update scroll beavior on command line after window resizes. + * + * This should ensure that the caret jumps to the middle of the command line. + * + * @param width Window (command line view) width in pixels or columns. + * + * @fixme + * On the other hand this limits how you can customize the scroll behavior. + */ +static inline void +teco_cmdline_resize(guint width) +{ + teco_cmdline_ssm(SCI_SETXCARETPOLICY, CARET_SLOP | CARET_EVEN, width/2); +} + gboolean teco_cmdline_keypress(const gchar *data, gsize len, GError **error); typedef enum { @@ -84,6 +109,8 @@ teco_cmdline_keymacro_c(gchar key, GError **error) return TRUE; } +void teco_cmdline_cleanup(void); + /* * Command states */ -- cgit v1.2.3