ProgerXP / Notepad2e

Word highlighting, simultaneous editing, split views, math evaluation, un/grep, comment reformatting, UAC elevation, complete regexps (PCRE), Lua lexers, DPI awareness and more (XP+)
Other
375 stars 52 forks source link

Overscroll on Arrow keys with ScrollYCaretPolicy #338

Open ProgerXP opened 3 years ago

ProgerXP commented 3 years ago

Currently, when ScrollYCaretPolicy = 1 (enabled and is not 50%, i.e. there are more than 1 line in the middle of the screen that the cursor can move without causing new scrolling) and you press on Arrow keys, the document is scrolled by 1 line. Make it so that it's scrolled by as many lines as possible in the opposite direction (controlled by new boolean setting OverscrollYCaret, enabled by default).

For example, consider a window with 5 lines and arbitrary long document (1, 2, 3, ..., N-1, N), and ScrollYCaretPolicy allowing cursor at lines 2-4 only (i.e. scrolling if cursor is on line 1 or 5):

  1. Cursor is on line 4
  2. Press Down
  3. Cursor is on line 5 and the window is scrolled because of ScrollYCaretPolicy; it now shows lines 2-6
  4. Press Down
  5. Scroll, now showing 3-7

Instead, what should happen:

  1. Cursor is on line 4
  2. Press Down
  3. Cursor is on line 5 but the window is showing lines 4-8 so it was scrolled by 3 lines, not 1
  4. Press Down
  5. Cursor is on line 6 and no scrolling
  6. Press Down
  7. Line 7, no scrolling
  8. Press Down
  9. Line 8, showing lines 7-11

This way, if user is navigating document from top to bottom he will get much less scrolling (instead one scrolling per line traveled).

Likewise, if pressing Up the line with the cursor should appear on the bottom of the screen.

Described behaviour for Arrow keys is the minimum. Ideally, no keys should be exceptional and this behaviour should be applied to any scrolling (F3, etc.): if current scroll position is above new caret line then put caret line on the top, else on bottom.