Skip to content

Improve compatibility of vim example#89

Open
mcclure wants to merge 12 commits into
rhysd:mainfrom
mcclure:vimprovements
Open

Improve compatibility of vim example#89
mcclure wants to merge 12 commits into
rhysd:mainfrom
mcclure:vimprovements

Conversation

@mcclure
Copy link
Copy Markdown

@mcclure mcclure commented Nov 26, 2024

The vim example is actually pretty good, and I am using it as the basis of an application. It does have some slight behavior divergences from normal vim, some of which require minimal code to fix.

I have made some changes to make it more vim-like:

  • Support arrow keys in normal mode
  • Fix behavior of a and x when issued on the final character of a line
  • Support J in normal and visual mode
  • Support S in normal and visual mode
  • Support r/R in normal (add a replace mode)
  • Support CTRL-[ as shortcut for ESC (some machines, like my Android tablet, cannot easily type an ESC)

Some notes about these changes:

  • Most of the changes are very minimal in their basic form, they are only complicated when visual mode is supported. If they are too complicated and you would prefer the example to be simple, I could just make visual mode "more wrong" by stripping out commits b2ffbfb, 15bbd68, 43861bf and then this PR would be very short.
  • There is a big incompatibility between normal vim and your "vim" example: In your example, it is possible to move the cursor "one character past" the end of the line in normal mode. In normal vim, this would only be possible in insert mode. I have not attempted to fix this, but if it were fixed, it would obviate my fixes for a and x and make some of the other code simpler.
  • I have also implemented : command line mode in a separate branch, but it is very complicated (and my current version uses a parser library), so I am not going to PR this unless you request it.

Thanks!

@rhysd
Copy link
Copy Markdown
Owner

rhysd commented Dec 3, 2024

Could you rebase this branch onto the latest main branch? Rust 1.83 introduced/enforced some lint rules and they broke our CI.

@mcclure
Copy link
Copy Markdown
Author

mcclure commented Dec 3, 2024

Sure. Do you have a preference between leaving the features in separate commits vs doing a squash commit?

@mcclure
Copy link
Copy Markdown
Author

mcclure commented Dec 3, 2024

I left the commits separate, does that fix it?

@rhysd
Copy link
Copy Markdown
Owner

rhysd commented Dec 4, 2024

Yes, leaving the commits separate is fine. I think you forgot to apply rustfmt.

@mcclure
Copy link
Copy Markdown
Author

mcclure commented Dec 4, 2024

Sorry about that, formatted now. Does that cover everything?

@rhysd
Copy link
Copy Markdown
Owner

rhysd commented Dec 5, 2024

Could you run cargo clippy --examples and fix the lint issues?

@mcclure
Copy link
Copy Markdown
Author

mcclure commented Dec 6, 2024

Again apologies, I should have read Contributing.md more carefully.
fmt and clippy steps now pass.

pm100 added a commit to pm100/ratatui-textarea that referenced this pull request Mar 24, 2026
…trl+[

Port improvements from rhysd/tui-textarea#89:
- Add Replace mode (r for replace-once, R for overtype)
- Add arrow key support alongside hjkl in normal mode
- Add J (join lines) with visual mode support
- Add S (substitute lines) with visual mode support
- Add Ctrl+[ as Escape alias in normal, insert, and replace modes
- Fix x to not delete at end of line
- Fix a to not advance past end of line

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pm100 added a commit to pm100/ratatui-textarea that referenced this pull request Mar 25, 2026
…trl+[

Port improvements from rhysd/tui-textarea#89:
- Add Replace mode (r for replace-once, R for overtype)
- Add arrow key support alongside hjkl in normal mode
- Add J (join lines) with visual mode support
- Add S (substitute lines) with visual mode support
- Add Ctrl+[ as Escape alias in normal, insert, and replace modes
- Fix x to not delete at end of line
- Fix a to not advance past end of line

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pm100 added a commit to ratatui/ratatui-textarea that referenced this pull request Mar 27, 2026
…trl+[ (#22)

Port improvements from rhysd/tui-textarea#89:
- Add Replace mode (r for replace-once, R for overtype)
- Add arrow key support alongside hjkl in normal mode
- Add J (join lines) with visual mode support
- Add S (substitute lines) with visual mode support
- Add Ctrl+[ as Escape alias in normal, insert, and replace modes
- Fix x to not delete at end of line
- Fix a to not advance past end of line

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants