| Summary: | KDE 5: low level API to control scrolling | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-ktexteditor | Reporter: | Thomas Friedrichsmeier <thomas.friedrichsmeier> |
| Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | CC: | christoph, loh.tar, waqar.17a |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Untested patch | ||
|
Description
Thomas Friedrichsmeier
2006-12-18 12:09:47 UTC
Thomas, if you still need that, it should be done for KDE 5. What functions do you need exaclty? KTextEditor::View::scrollUp(), pageUp(), toTop() or something like that? Hi Dominik, this is not a high priority, but yes, this would still be nice to have. Basically, the use case that I have, goes like this: QPoint saved_pos = KTextEditor::View::currentScrollPosition(); // do something which may affect scrolling position, implicitly KTextEditor::View::setScrollPosition(saved_pos); This is assuming pixel based positions. However, thinking about it, scrolling could also be based on the cursor position (at the top-left corner of the viewport). This would be almost as good for my use-case, and would conceivably come in handy in many other situations, as well. I.e.: /** Return the cursor position at the top left of the view. */ KTextEditor::Cursor KTextEditor::View::currentScrollPosition(); /** Scroll the view so that pos is visible at the top left corner of the view, without changing the active cursor position. @note: If the given position is near the bottom / right of the document, the actual scrolling position may be adjusted to the top / left. However, it is guaranteed that the given cursor position will be inside the visible range, after scrolling. */ KTextEditor::View::setScrollPosition(const KTextEditor::Cursor &pos); How to interpret columns in the position is clear for fixed fonts, but not for non-fixed fonts. If it's only about lines, simple ints for the lines would be enough. If you build Kate according to http://www.kate-editor.org/get-it/, you can run your RKWard with ./run.sh rkward (or the correct app name), and the new Kate Part will be loaded. This way, you can very easily provide a patch that works for you, if you want. Created attachment 63849 [details]
Untested patch
At this moment, kate git does not compile for me due to an unrelated problem. Therefore, the patch I'm attaching is entirely untested. But if my guesses aren't entirely wrong, then it's actually quite simple, since KateViewInternal already provides this functionality.
Pulling KateViewInternal::makeVisible() into the public API (perhaps as KTextEditor::View::ensurePositionVisible()) might also be worth while.
In KF5 we can very easy add that functions, if they really do the job, can somebody test that? From the initial posting, I guess this is related to BUG: 399014 BUG: 306745 or better, it may fixed by the Patch https://phabricator.kde.org/D17857 Frankly, I'm not sure, I understand that PR. However, to clarify, my (somewhat esoteric) usecase: 1) User selects something near the top of the document, implicitly changing cursor position. 2) I need to set the cursor back to the very end of the document (not editing anything, though). I would like to have a way to accomplish step 2 *without* apparent scrolling, i.e. the view should remain scrolled where ever it was scrolled to by the user. It should not jump to make last line visible. OK. Then I may misunderstood something. You mentioned "using setCursorPosition()" and I had a change noted there https://phabricator.kde.org/D17857#425268 Not sure that this effect your wish. Can you try it? Since 2006 there may have many thing changed. Perhaps is something new in stock to solve you problem(?) Since the request is about "low-level" api, please have a look at the class "KateScrollBarRestorer" in the patch here: https://invent.kde.org/utilities/kate/-/merge_requests/556 |