textarea: misc improvements#210
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.
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.
Done, ready for another look.
There was a problem hiding this comment.
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