From de2ed1d4bfc55dcca30f74790a3b4f7931b08032 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 18 Apr 2023 11:58:19 +0300 Subject: disable automatic scrolling and choosing the X that caret sticks to * SciTECO needs to avoid automatic scrolling as an optimization. While this works partially by avoiding certain messages like SCI_GOTOPOS (in favor of SCI_SETEMPTYSELECTION), there aren't alternatives for all messages that scroll. For instance SCI_UNDO will always call EnsureCaretVisible(). Also, even if we could avoid all scrolling messages, there is no guarantee that will not suddenly and unexpectedly break in the future. * Instead, every scrolling is now disabled except for an explicit SCI_SCROLLCARET. SciTECO can therefore use the more intuitive messages like SCI_GOTOPOS. * SetLastXChosen() (choosing the X that caret sticks to) has been found to be a major slow down during UNDO and serves no purpose on SciTECO anyway - we have to implement such an algorithm at the SciTECO language level. We therefore simply disable SetLastXChosen(). --- src/Editor.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Editor.cxx b/src/Editor.cxx index d547c468b..ab5aadc97 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -918,8 +918,10 @@ Point Editor::PointMainCaret() { * as it moves up and down. */ void Editor::SetLastXChosen() { +#if 0 const Point pt = PointMainCaret(); lastXChosen = static_cast(pt.x) + xOffset; +#endif } void Editor::ScrollTo(Sci::Line line, bool moveThumb) { @@ -1393,11 +1395,13 @@ void Editor::ScrollRange(SelectionRange range) { } void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { +#if 0 SetXYScroll(XYScrollToMakeVisible(SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret), (useMargin?XYScrollOptions::useMargin:XYScrollOptions::none)| (vert?XYScrollOptions::vertical:XYScrollOptions::none)| (horiz?XYScrollOptions::horizontal:XYScrollOptions::none), caretPolicies)); +#endif } void Editor::ShowCaretAtCurrentPosition() { @@ -6369,7 +6373,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { break; case Message::ScrollCaret: - EnsureCaretVisible(); + SetXYScroll(XYScrollToMakeVisible(SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret), + XYScrollOptions::useMargin | XYScrollOptions::vertical | XYScrollOptions::horizontal, + caretPolicies)); break; case Message::SetReadOnly: -- cgit v1.2.3