Skip to content
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

textarea: misc improvements #210

Merged
merged 4 commits into from Aug 19, 2022
Merged

Conversation

knz
Copy link
Contributor

@knz knz commented Aug 14, 2022

I'm working to make textarea closer to readline/editline conventions (e.g. as used on a shell command line or emacs).

  • search prev/next word should find words on the prev/next line if there's no word remaining on the current line.
  • Alt+u to uppercase cur/next word
  • Alt+l to lowercase cur/next word
  • Alt+c to capitalize cur/next word
  • Ctrl+t to transpose previous 2 characters

cc @maaslalani

@knz
Copy link
Contributor Author

knz commented Aug 14, 2022

Using this in https://github.com/knz/bubbline

@knz knz mentioned this pull request Aug 15, 2022
34 tasks
m.SetCursor(m.col + 1)
i++
} else {
func (m *Model) doWordRight(fn func(firstChar bool, pos int)) {
Copy link
Member

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?

Suggested change
func (m *Model) doWordRight(fn func(firstChar bool, pos int)) {
func (m *Model) doWordRight(fn func(start int, pos int)) {

Copy link
Contributor Author

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.

Copy link
Member

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!

@maaslalani
Copy link
Member

@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.

@knz
Copy link
Contributor Author

knz commented Aug 19, 2022

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: a.bcdef

And then you press Ctrl+T continuously multiple times, you get the a to move to the end.

@maaslalani
Copy link
Member

maaslalani commented Aug 19, 2022

Another (hopefully quick) question. If I am inside a word:

the qu|ick fox

And, I press alt+c to capitalize the word.
Should the result be:

the Quick fox

or

the quIck fox

@maaslalani
Copy link
Member

Just tested out in emacs looks like the implemented behaviour is correct (matches emacs) so this looks great! Thank you @knz for adding this change ❤️

@maaslalani maaslalani merged commit 1c26128 into charmbracelet:master Aug 19, 2022
@muesli muesli added the enhancement New feature or request label Aug 19, 2022
knz added a commit to knz/bubbline that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants