From e371b5fc710c597e175e6b7d7645b3a224a731a1 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 25 Sep 2026 01:43:56 +0200 Subject: instead of relying on Scintilla undo actions, use SciTECO undo tokens exclusively Previously we were using both Scintilla undo actions and our own undo tokens and both had to be coordinated via `undo__teco_interface_ssm(SCI_UNDO, 0, 0)`. This was error prone since we have to predict when an undo action is actually generated. Furthermore, you had to update SCI_SETUNDOCOLLECTION on all buffers and the Q-Reg view whenever switching to and from interactive mode. Also, this probably wasted memory for the doubled undo bookkeeping. Now, we always set SCI_SETUNDOCOLLECTION(FALSE), even in interactive mode. teco_undo_view_insert() was introduced to undo text deletions. While this saves almost no lines of code, it's just a clearer and simpler architecture. --- src/view.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/view.h') diff --git a/src/view.h b/src/view.h index 887642a..e7c6fa7 100644 --- a/src/view.h +++ b/src/view.h @@ -44,14 +44,6 @@ void undo__teco_view_ssm(teco_view_t *, unsigned int, uptr_t, sptr_t); void teco_view_set_representations(teco_view_t *ctx); -/** @memberof teco_view_t */ -static inline void -teco_view_set_scintilla_undo(teco_view_t *ctx, gboolean state) -{ - teco_view_ssm(ctx, SCI_EMPTYUNDOBUFFER, 0, 0); - teco_view_ssm(ctx, SCI_SETUNDOCOLLECTION, state, 0); -} - gboolean teco_view_load_from_channel(teco_view_t *ctx, GIOChannel *channel, gboolean clear, GError **error); gboolean teco_view_load_from_file(teco_view_t *ctx, const gchar *filename, @@ -92,4 +84,6 @@ teco_int_t teco_view_bytes2glyphs_rel(teco_view_t *ctx, teco_int_t pos_glyphs, teco_int_t teco_view_get_character(teco_view_t *ctx, gsize pos, gsize len); +void teco_undo_view_insert(teco_view_t *view, gsize pos, gsize len); + void teco_view_process_notify(teco_view_t *ctx, const SCNotification *notify); -- cgit v1.2.3