-
Notifications
You must be signed in to change notification settings - Fork 304
textarea: misc improvements #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
... if there's no word on the current line to find any more.
Using this in https://github.com/knz/bubbline |
textarea/textarea.go
Outdated
m.SetCursor(m.col + 1) | ||
i++ | ||
} else { | ||
func (m *Model) doWordRight(fn func(firstChar bool, pos int)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having doWordRight
take a function with a firstChar bool
, I'd suggest it take a index of the start of the word so that it is a bit more flexible for stuff like deleting words / referencing the start of the word index later while still being able to do start == pos
to get whether the current character is the first character, what do you think?
func (m *Model) doWordRight(fn func(firstChar bool, pos int)) { | |
func (m *Model) doWordRight(fn func(start int, pos int)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, ready for another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @knz, this looks absolutely fantastic! Will merge soon after a quick review!
@knz quick question (since I don't use emacs) is the ctrl+t transpose supposed to move the cursor forward or should it stay in the same place after the transpose. |
It transposes the last two characters, then moves the cursor forward. The point is that if your cursor is at this position: And then you press Ctrl+T continuously multiple times, you get the |
Another (hopefully quick) question. If I am inside a word:
And, I press alt+c to capitalize the word.
or
|
Just tested out in |
... as discussed in charmbracelet/bubbles#210
…t#210) * Extract char navigation in separate function. * Make wordLeft/wordRight find words on the prev/next line ... if there's no word on the current line to find any more. * Support uppercase/lowercase/capitalize commands. * Add transpose
I'm working to make textarea closer to readline/editline conventions (e.g. as used on a shell command line or emacs).
cc @maaslalani