diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 08:51:02 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 08:51:02 +0300 |
commit | 8ef010da59743fcc4927c790f585ba414ec7b129 (patch) | |
tree | 88b31b9017abc34d0f94209a997413a22788ef95 /src/search.c | |
parent | 8baa1b3ebe163de3a55696e50d49f160529473b3 (diff) | |
download | sciteco-8ef010da59743fcc4927c790f585ba414ec7b129.tar.gz |
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.
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/search.c b/src/search.c index 3ccecde..219ddb2 100644 --- a/src/search.c +++ b/src/search.c @@ -541,9 +541,11 @@ teco_do_search(GRegex *re, gint from, gint to, gint *count, GError **error) } } - if (matched_from >= 0 && matched_to >= 0) + if (matched_from >= 0 && matched_to >= 0) { /* match success */ - teco_interface_ssm(SCI_SETSEL, matched_from, matched_to); + teco_interface_ssm(SCI_SETSELECTIONSTART, matched_from, 0); + teco_interface_ssm(SCI_SETSELECTIONEND, matched_to, 0); + } return TRUE; } @@ -554,10 +556,12 @@ teco_state_search_process(teco_machine_main_t *ctx, const teco_string_t *str, gs static const GRegexCompileFlags flags = G_REGEX_CASELESS | G_REGEX_MULTILINE | G_REGEX_DOTALL | G_REGEX_RAW; - if (teco_current_doc_must_undo()) - undo__teco_interface_ssm(SCI_SETSEL, - teco_interface_ssm(SCI_GETANCHOR, 0, 0), - teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0)); + if (teco_current_doc_must_undo()) { + undo__teco_interface_ssm(SCI_SETSELECTIONEND, + teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0), 0); + undo__teco_interface_ssm(SCI_SETSELECTIONSTART, + teco_interface_ssm(SCI_GETANCHOR, 0, 0), 0); + } teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); g_assert(search_reg != NULL); @@ -648,7 +652,7 @@ teco_state_search_process(teco_machine_main_t *ctx, const teco_string_t *str, gs return TRUE; failure: - teco_interface_ssm(SCI_GOTOPOS, teco_search_parameters.dot, 0); + teco_interface_ssm(SCI_SETEMPTYSELECTION, teco_search_parameters.dot, 0); return TRUE; } @@ -898,8 +902,8 @@ teco_state_search_kill_done(teco_machine_main_t *ctx, const teco_string_t *str, gint anchor = teco_interface_ssm(SCI_GETANCHOR, 0, 0); if (teco_current_doc_must_undo()) - undo__teco_interface_ssm(SCI_GOTOPOS, dot, 0); - teco_interface_ssm(SCI_GOTOPOS, anchor, 0); + undo__teco_interface_ssm(SCI_SETEMPTYSELECTION, dot, 0); + teco_interface_ssm(SCI_SETEMPTYSELECTION, anchor, 0); teco_interface_ssm(SCI_DELETERANGE, teco_search_parameters.dot, anchor - teco_search_parameters.dot); |