aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.h
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2025-11-07 21:39:12 +0100
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2025-11-08 13:00:47 +0100
commit4e6ddd6c329d56055a732c6344df019f0d997aaf (patch)
treeb426e5de13142442669981d90b07d10fc6999d89 /src/cmdline.h
parent1391e9c6ea1f9bef965f96e70f4e27141abcb5cd (diff)
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).
Diffstat (limited to 'src/cmdline.h')
-rw-r--r--src/cmdline.h47
1 files changed, 37 insertions, 10 deletions
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 <glib.h>
#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
*/