From 8ef010da59743fcc4927c790f585ba414ec7b129 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 11 Oct 2021 08:51:02 +0300 Subject: optimized caret scrolling: this is a costly operation and is now done only once per keypress * Esp. costly since Scintilla 5. * We now avoid any Scintilla message that automatically scrolls the caret (makes the caret visible) and instead call SCI_SCROLLCARET only once after every keypress in the interface implementation. * From nowon, use * SCI_SETEMPTYSELECTION instead of SCI_GOTOPOS * SCI_SETEMPTYSELECTION(SCI_POSITIONFROMLINE(...)) instead of SCI_GOTOLINE * SCI_SETSELECTIONSTART and SCI_SETSELECTIONEND instead of SCI_SETSEL * With these optimizations we are significantly faster than before the Scintilla upgrade (6e67f5a682ff46d69888fec61b94bf45cec46721). It is now even safe to execute the Gtk test suite during CI. --- src/doc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/doc.c') diff --git a/src/doc.c b/src/doc.c index 9485f13..832eb90 100644 --- a/src/doc.c +++ b/src/doc.c @@ -45,7 +45,8 @@ teco_doc_edit(teco_doc_t *ctx) (sptr_t)teco_doc_get_scintilla(ctx)); teco_view_ssm(teco_qreg_view, SCI_SETFIRSTVISIBLELINE, ctx->first_line, 0); teco_view_ssm(teco_qreg_view, SCI_SETXOFFSET, ctx->xoffset, 0); - teco_view_ssm(teco_qreg_view, SCI_SETSEL, ctx->anchor, (sptr_t)ctx->dot); + teco_view_ssm(teco_qreg_view, SCI_SETSELECTIONSTART, ctx->anchor, 0); + teco_view_ssm(teco_qreg_view, SCI_SETSELECTIONEND, ctx->dot, 0); /* * NOTE: Thanks to a custom Scintilla patch, se representations @@ -64,7 +65,8 @@ teco_doc_undo_edit(teco_doc_t *ctx) */ //undo__teco_view_set_representations(teco_qreg_view); - undo__teco_view_ssm(teco_qreg_view, SCI_SETSEL, ctx->anchor, (sptr_t)ctx->dot); + undo__teco_view_ssm(teco_qreg_view, SCI_SETSELECTIONEND, ctx->dot, 0); + undo__teco_view_ssm(teco_qreg_view, SCI_SETSELECTIONSTART, ctx->anchor, 0); undo__teco_view_ssm(teco_qreg_view, SCI_SETXOFFSET, ctx->xoffset, 0); undo__teco_view_ssm(teco_qreg_view, SCI_SETFIRSTVISIBLELINE, ctx->first_line, 0); undo__teco_view_ssm(teco_qreg_view, SCI_SETDOCPOINTER, 0, -- cgit v1.2.3