-
Notifications
You must be signed in to change notification settings - Fork 818
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
Ability to replace text while keeping TextArea history #4257
Comments
It makes sense to me that What problem would this solve rather than using the existing |
Thanks for pointing out this function that I missed. from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, TextArea
class TextAreaApp(App):
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Header()
yield TextArea("Initial text", classes="maintext")
yield Footer()
def on_mount(self):
textArea = self.query_one(TextArea)
textArea.insert("Updated text with insert 1")
textArea.text = "Updated text with load_text"
textArea.replace("Updated with replace", (0,0), (textArea.document.line_count, len(textArea.document.get_line(textArea.document.line_count-1))))
textArea.insert("Updated text with insert 2")
if __name__ == "__main__":
app = TextAreaApp()
app.run() |
This is slightly shorter: end=(text_area.document.line_count, len(text_area.document[-1])), But perhaps a convenience "document end" property would be useful. |
A |
Yes it's perfect! Thanks a lot! 😊 |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
When you replace text in a TextArea with
TextArea.text
setter or withload_text
, it could be great to not clean the history of the TextArea widget.In this MRE I would like to be able to use Ctrl-Z in the TextArea and come back to the
Updated text with insert 1
text.The text was updated successfully, but these errors were encountered: