Closes #1152. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1154
-- Commit Summary --
* Add support for keeping the cursor a number of lines from the edges
-- File Changes --
M data/geany.glade (48) M doc/geany.txt (7) M src/editor.c (9) M src/editor.h (1) M src/keyfile.c (2)
-- Patch Links --
https://github.com/geany/geany/pull/1154.patch https://github.com/geany/geany/pull/1154.diff
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154
@@ -5169,6 +5170,12 @@ void editor_apply_update_prefs(GeanyEditor *editor) /* virtual space */ SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space, 0);
- /* caret Y policy */
- caret_y_policy = CARET_EVEN;
- if (editor_prefs.scroll_lines_around_cursor > 0)
caret_y_policy |= CARET_SLOP | CARET_STRICT;
See http://www.scintilla.org/ScintillaDoc.html#SCI_SETYCARETPOLICY for why the options are different: if the *caret slop* is set to 0 and `CARET_STRICT` is set, it would keep the caret centered, which is not what we want. So use Scintilla's default unless we set the *caret slop* to something non-zero, in which case these additional flags keep it working the same, but adding an *unwanted zone* near the top and bottom edges.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154/files/4ad652aa7d3179dc6da1dcd077d11...
Please forgive me, if this is the wrong place to ask this question:
How will I as a user eventually be able to set the variable `editor_prefs.scroll_lines_around_cursor`?
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154#issuecomment-236293160
Through the additional UI this patch adds to *Preferences/Editor/Display*, or manually editing the configuration file if the user's fearless.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154#issuecomment-236293450
Erm, you answered too fast, :wink: else I would have edited my question to say that for me it would be absolutely sufficient to edit a configuration file.
But the phrasing of your answer makes me curious: Is this additional UI added automatically, that is, is there no further programming needed?
If further programming in fact is needed, see my first sentence.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154#issuecomment-236295884
But the phrasing of your answer makes me curious: Is this additional UI added automatically, that is, is there no further programming needed?
The UI isn't totally automatic no: the [patch alters the UI definition](/geany/geany/pull/1154/files#diff-f9ff4afa371beea3ec6d322f3655fa7a) to add the new UI (I did that with a UI tool, Glade). The connection to the UI is pretty much automatic though, it's only [the 5th argument to `stash_group_add_spin_button_integer()`](https://github.com/geany/geany/pull/1154/files#diff-f9ff4afa371beea3ec6d322f...).
[…] for me it would be absolutely sufficient to edit a configuration file.
Well, yeah it's okay-ish for power users that know how to edit the configuration and which key to set to what, but if it's something meant to be used it's better to have UI for it. It's also fairly easy to add the UI, so unless other people think it's a *bad* idea to make it visible and easy to use, I think UI is better.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154#issuecomment-236297898
Thank you very much for the explanation!
And I surely don't say it's a bad idea to have it visible in the UI!
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/1154#issuecomment-236300504
@codebrainz @elextr any opinion on that? Otherwise I'll merge it tomorrow (or sooner if you like it and speak).
I don't really understand what purpose this serves (other than working around a bug in Ubuntu overlay scrollbars), but if it's off by default, and people want it, it doesn't bother me. The only thing I'd change is to make it a various preference instead of further cluttering the main prefs UI with such a specialized and unlikely to ever be used setting.
The point is to keep the cursor "in context" as the Scintilla docs say. I indeed never actually wished I had that, but OTOH I do from time to time scroll a little further to see where I'm at, and go back to the line I actually want after I saw. If I had this and was accustomed to it, I wouldn't have to do that.
So I don't care so much, but I understand why the feature can be useful.
@@ -2254,6 +2254,13 @@ Stop scrolling at last line When enabled Geany stops scrolling when at the last line of the document. Otherwise you can scroll one more page even if there are no real lines.
+Lines visible around the cursor
- The number of lines to keep visible above and below the line on which the
- cursor is when automatically scrolling the view. This allows to prevent
- the cursor from going near the top and bottom edges in order to keep it in
- some context. If *Stop scrolling at last line* is disabled, the cursor will
- never reach the bottom edge when this value is greater than 0.
"The number of lines to maintain between the cursor and the top and bottom edges of the view. This allows some context around the cursor to always be visible. If..."
Minor English fix, otherwise LGBI, but I also probably won't actually use it.
@@ -2254,6 +2254,13 @@ Stop scrolling at last line When enabled Geany stops scrolling when at the last line of the document. Otherwise you can scroll one more page even if there are no real lines.
+Lines visible around the cursor
- The number of lines to keep visible above and below the line on which the
- cursor is when automatically scrolling the view. This allows to prevent
- the cursor from going near the top and bottom edges in order to keep it in
- some context. If *Stop scrolling at last line* is disabled, the cursor will
- never reach the bottom edge when this value is greater than 0.
"This allows some _lines_ of context..."
Should I drop the UI? I added it because I felt like this could be something useful to many if they knew it existed, but apparently not even @fdg-org care about the proper UI, so…
@b4n pushed 1 commit.
2d2af79 Improve documentation wording
Should I drop the UI?
Your call. IMO it should be a various preference, but I don't feel strongly at all.
My 2ct: Because you, @b4n, have done all that work already, I would love to have the UI, and I think the same as you about people using it.
But a possible problem arising from this just came to my mind: What happens when the setting is set to, say, 30 and the editor pane can only show, say, 40 lines?
What happens when the setting is set to, say, 30 and the editor pane can only show, say, 40 lines?
Should show nothing on the screen except "IDIOT" in big letters :)
@b4n, if you have the UI might as well leave it, as you say it makes it slightly more discoverable.
What happens when the setting is set to, say, 30 and the editor pane can only show, say, 40 lines?
A too high value is not really a problem, it will simply always have the current line exactly in the middle of the view. If you really liked that behavior, you can set that to like 100 and play :)
Merged #1154.
github-comments@lists.geany.org