Open
Conversation
- Add two helper functions in text.c based on textbswidth, textbacklinewidth(text, nlines) which returns the length between the cursor and the previous BOL, and textforwardlinewidth(text, nlines) which returns the length between the cursor and the next BOL. Each accepts an nlines parameter to ignore the \n n times before returning the full length. - Rewrite Kup and Kdown handlers to move to the same offset on the next or previous lines, using these helpers. Kup backs up two lines, then goes forward until reaching the same offset or encountering a newline. Kdown goes forward one line then goes forward until reaching the same offset or encountering a newline.
The textbacklinewidthtext and forwardlinewidth functions have been extended to optionally expand \t into tabstop in the returned width, and the Kup and Kdown handlers have been updated to decrement the offset width by tabstop when encountering a \t. This enables up/down to move in a vertical line even if the line above or below has more or less indentation.
|
Just look like cursor addressing |
|
i hope this will not get merged as default behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remap the up and down arrow keys to navigate to the same position on the next or previous lines in the current window, instead of scrolling up or down. The corresponding position on the next and previous lines are calculated based on the number of characters, where
\tcounts astabstopcharacters.When using a monospace font, up and down move in a straight line when navigating lines with varying indentation. In my personal testing this performs well in code, and the user no longer needs to move their hand from the keyboard to the mouse, only to move them back to the keyboard after moving up or down a line.
This feature does not attempt to address visual width with regard to variable width fonts, combining characters, zero-width characters, wrapped lines, etc. I think the cursor could end up in between combining characters. This feature does not attempt to remember position or bounce back when the next line is shorter, so going from line 1 position 40 to line 2 of length 30 to line 3 of length 50 will place your cursor on line 3 position 30. This is most noticeable with blank lines.
It may be wise to place this functionality behind a flag.