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

Cannot manually change text? #91

Open
mcclure opened this issue Dec 6, 2024 · 0 comments
Open

Cannot manually change text? #91

mcclure opened this issue Dec 6, 2024 · 0 comments

Comments

@mcclure
Copy link

mcclure commented Dec 6, 2024

This is either a feature request or a support request, I'm not sure.
I believe I need some way to make actual changes to lines(), IE I have a new lines() and I want to replace the old one. I don't think this exists now.

For example, see this¹ fork of your vim example. In this code (branch ami-wv-cat, commit 1443d7f, line 1068) I have added support for the :!cat command from vim (read an entire file, paste it in at the cursor position). To do this I generate a new lines(), but I don't have a way to insert it into the Textarea once I've made it.

Things I've considered:

  • Use TextArea::new() and supply the new lines(). This doesn't work because of private members I can't access: Scroll is reset and also I lose the undo buffer.
  • cut() the old selection away, then put the data in the yank buffer and paste() it. I rejected this because it would stomp the contents of the yank buffer. Actually, I guess I could have copied out the yank buffer, saved it, performed the operation and then restored the yank buffer. But this has other problems: It's less convenient when you're replacing the entire file, like imagine you modified the entire file to uppercase; and it runs into issue Feature request: Should be possible to manipulate (collapse, censor) "Undo" stack items #90 (e.g. it will show up as two steps to the undo stack).

Is there an option I'm missing?

Should there maybe be a function like
textarea.set_lines(lines, clear_styles)?


¹ This is a WIP and currently not "public", I would submit the nascent : support back to tui-textarea but I don't think it would make as good example code as what you have now.

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

No branches or pull requests

1 participant