You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Initial undo related machinery added to TextArea
* Initial undo implementation
* Basic undo and redo
* Some more fleshing out of undo and redo
* Skeleton code for managing TextArea history
* Initial implementation of undo & redo checkpointing in TextArea
* Increase checkpoint characters
* Restoring the selection in the TextArea and then restoring it on undo
* Adding docstrings to undo_batch and redo_batch in the TextArea
* Batching edits of the same type
* Batching edits of the same type
* Keeping edits containing newlines in their own batch
* Checking for newline characters in insertion or replacement during undo checkpoint creation. Updating docstrings in history.py
* Fix mypy warning
* Performance improvement
* Add history checkpoint on cursor movement
* Fixing merge conflict in Edit class
* Fixing error in merge conflict resolution
* Remove unused test file
* Remove unused test file
* Initial testing of undo and redo
* Testing for undo redo
* Updating lockfile
* Add an extra test
* Fix: setting the `text` property programmatically should invalidate the edit history
* Improving docstrings
* Rename EditHistory.reset() to EditHistory.clear()
* Add docstring to an exception
* Add a pause after focus/blur in a test
* Forcing CI colour
* Update focus checkpoint test
* Try to force color in pytest by setting --color=yes in PYTEST_ADDOPTS in env var on Github Actions
* Add extra assertion in a test
* Toggle text_area has focus to trigger checkpoint in history
* Apply grammar/wording suggestions from code review
Co-authored-by: Rodrigo Girão Serrão <[email protected]>
* Making max checkpoints configurable in TextArea history
* Improve a docstring
* Update changelog
* Spelling fixes
* More spelling fixes
* Americanize spelling of tab_behaviour (->tab_behavior)
* Update CHANGELOG regarding `tab_behaviour`->`tab_behavior`
* Various fixes
* Various fixes and improvements
* Updating tests to account for themes always being non-None
* Update CHANGELOG.
* Add TextArea.read_only to reactive attr table in TextArea docs
* Update TextArea docs regarding new features
* Cleaning up some typing issues
* Add actions for undo and redo
* Fix a typo
* Fix wording in docs/widgets/text_area.md
Co-authored-by: Rodrigo Girão Serrão <[email protected]>
* Re-add return type hint
* PR feedback and fixing typos
* Mark breaking change in CHANGELOG
* Add undo/redo to docstring
* Add note on undo/redo bindings
---------
Co-authored-by: Rodrigo Girão Serrão <[email protected]>
After creating a `TextArea`, you can change the theme by setting the [`theme`][textual.widgets._text_area.TextArea.theme]
@@ -212,7 +212,12 @@ On setting this attribute the `TextArea` will immediately refresh to display the
212
212
213
213
#### Custom themes
214
214
215
-
Using custom (non-builtin) themes is two-step process:
215
+
!!! note
216
+
217
+
Custom themes are only relevant for people who are looking to customize syntax highlighting.
218
+
If you're only editing plain text, and wish to recolor aspects of the `TextArea`, you should use the [provided component classes][textual.widgets.TextArea.COMPONENT_CLASSES].
219
+
220
+
Using custom (non-builtin) themes is a two-step process:
216
221
217
222
1. Create an instance of [`TextAreaTheme`][textual.widgets.text_area.TextAreaTheme].
218
223
2. Register it using [`TextArea.register_theme`][textual.widgets._text_area.TextArea.register_theme].
@@ -297,6 +302,27 @@ The character(s) inserted when you press tab is controlled by setting the `inden
297
302
298
303
If `indent_type == "spaces"`, pressing ++tab++ will insert up to `indent_width` spaces in order to align with the next tab stop.
299
304
305
+
### Undo and redo
306
+
307
+
`TextArea` offers `undo` and `redo` methods.
308
+
By default, `undo` is bound to <kbd>Ctrl</kbd>+<kbd>Z</kbd> and `redo` to <kbd>Ctrl</kbd>+<kbd>Y</kbd>.
309
+
310
+
The `TextArea` uses a heuristic to place _checkpoints_ after certain types of edit.
311
+
When you call `undo`, all of the edits between now and the most recent checkpoint are reverted.
312
+
You can manually add a checkpoint by calling the [`TextArea.history.checkpoint()`][textual.widgets.text_area.EditHistory.checkpoint] instance method.
313
+
314
+
The undo and redo history uses a stack-based system, where a single item on the stack represents a single checkpoint.
315
+
In memory-constrained environments, you may wish to reduce the maximum number of checkpoints that can exist.
316
+
You can do this by passing the `max_checkpoints` argument to the `TextArea` constructor.
317
+
318
+
### Read-only mode
319
+
320
+
`TextArea.read_only` is a boolean reactive attribute which, if `True`, will prevent users from modifying content in the `TextArea`.
321
+
322
+
While `read_only=True`, you can still modify the content programmatically.
323
+
324
+
While this mode is active, the `TextArea` receives the `-read-only` CSS class, which you can use to supply custom styles for read-only mode.
325
+
300
326
### Line separators
301
327
302
328
When content is loaded into `TextArea`, the content is scanned from beginning to end
@@ -459,7 +485,6 @@ If you notice some highlights are missing after registering a language, the issu
459
485
The names assigned in tree-sitter highlight queries are often reused across multiple languages.
460
486
For example, `@string` is used in many languages to highlight strings.
461
487
462
-
463
488
#### Navigation and wrapping information
464
489
465
490
If you're building functionality on top of `TextArea`, it may be useful to inspect the `navigator` and `wrapped_document` attributes.
@@ -473,14 +498,15 @@ A detailed view of these classes is out of scope, but do note that a lot of the
@@ -496,7 +522,6 @@ The `TextArea` widget defines the following bindings:
496
522
show_root_heading: false
497
523
show_root_toc_entry: false
498
524
499
-
500
525
## Component classes
501
526
502
527
The `TextArea` defines component classes that can style various aspects of the widget.
@@ -513,11 +538,11 @@ Styles from the `theme` attribute take priority.
513
538
-[`TextAreaTheme`][textual.widgets.text_area.TextAreaTheme] - theming the `TextArea`
514
539
-[`DocumentNavigator`][textual.widgets.text_area.DocumentNavigator] - guides cursor movement
515
540
-[`WrappedDocument`][textual.widgets.text_area.WrappedDocument] - manages wrapping the document
541
+
-[`EditHistory`][textual.widgets.text_area.EditHistory] - manages the undo stack
516
542
- The tree-sitter documentation [website](https://tree-sitter.github.io/tree-sitter/).
517
543
- The tree-sitter Python bindings [repository](https://github.com/tree-sitter/py-tree-sitter).
518
544
-`py-tree-sitter-languages`[repository](https://github.com/grantjenks/py-tree-sitter-languages) (provides binary wheels for a large variety of tree-sitter languages).
519
545
520
-
521
546
## Additional notes
522
547
523
548
- To remove the outline effect when the `TextArea` is focused, you can set `border: none; padding: 0;` in your CSS.
0 commit comments