riched 1.3.2__tar.gz → 1.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {riched-1.3.2 → riched-1.3.3}/.gitignore +2 -0
- {riched-1.3.2 → riched-1.3.3}/PKG-INFO +1 -1
- {riched-1.3.2 → riched-1.3.3}/pyproject.toml +1 -1
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/editor.py +13 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_dirty_buffers.py +30 -0
- {riched-1.3.2 → riched-1.3.3}/.python-version +0 -0
- {riched-1.3.2 → riched-1.3.3}/AGENTS.md +0 -0
- {riched-1.3.2 → riched-1.3.3}/README.md +0 -0
- {riched-1.3.2 → riched-1.3.3}/docs/command-palette.svg +0 -0
- {riched-1.3.2 → riched-1.3.3}/docs/markdown-preview.svg +0 -0
- {riched-1.3.2 → riched-1.3.3}/docs/python-buffer.svg +0 -0
- {riched-1.3.2 → riched-1.3.3}/docs/search-replace.svg +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/__init__.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/app.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/bindings.yaml +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/cli.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/formatting.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/keybindings.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/quick_open.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/screens.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/settings.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/src/rich_editor/syntax.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/__init__.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/helpers.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/runner.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_cli.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_command_palette.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_create_file.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_editor_shortcuts.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_file_io.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_file_tree.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_footer.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_formatting.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_markdown_preview.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_quick_open.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_refresh.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_replace.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/tests/test_syntax.py +0 -0
- {riched-1.3.2 → riched-1.3.3}/uv.lock +0 -0
|
@@ -4,6 +4,7 @@ from collections.abc import Callable
|
|
|
4
4
|
import re
|
|
5
5
|
from typing import Protocol, cast
|
|
6
6
|
|
|
7
|
+
from textual import events
|
|
7
8
|
from textual.widgets import TextArea
|
|
8
9
|
|
|
9
10
|
from .keybindings import build_static_bindings
|
|
@@ -54,6 +55,18 @@ class RichedTextArea(TextArea):
|
|
|
54
55
|
|
|
55
56
|
BINDINGS = build_static_bindings("editor")
|
|
56
57
|
|
|
58
|
+
async def _on_key(self, event: events.Key) -> None:
|
|
59
|
+
if event.key == "escape":
|
|
60
|
+
from .app import RichedApp
|
|
61
|
+
|
|
62
|
+
app = self.app
|
|
63
|
+
if isinstance(app, RichedApp) and not app._is_file_tree_visible():
|
|
64
|
+
app.action_file_tree_quit_check()
|
|
65
|
+
event.stop()
|
|
66
|
+
event.prevent_default()
|
|
67
|
+
return
|
|
68
|
+
await super()._on_key(event) # type: ignore[misc]
|
|
69
|
+
|
|
57
70
|
def _clamp_location(self, location: tuple[int, int]) -> tuple[int, int]:
|
|
58
71
|
row, column = location
|
|
59
72
|
row = max(0, min(row, self.document.line_count - 1))
|
|
@@ -68,6 +68,36 @@ async def test_quit_dirty_discard_keeps_file() -> None:
|
|
|
68
68
|
assert f.read_text() == "orig"
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
async def test_editor_escape_visible_tree_does_nothing() -> None:
|
|
72
|
+
_, f, app = _file_app("editor-escape-visible.txt", "foo", root_is_tmp=True)
|
|
73
|
+
async with app.run_test() as pilot:
|
|
74
|
+
await pilot.pause()
|
|
75
|
+
await _press(pilot, "escape")
|
|
76
|
+
assert app.path == f, app.path
|
|
77
|
+
assert list(app.query("#editor"))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def test_editor_escape_hidden_tree_clean_shows_quit_confirmation() -> None:
|
|
81
|
+
_, f, app = _file_app("editor-escape-clean.txt", "foo", root_is_tmp=True)
|
|
82
|
+
async with app.run_test() as pilot:
|
|
83
|
+
await pilot.pause()
|
|
84
|
+
await _press(pilot, "super+b")
|
|
85
|
+
await pilot.pause()
|
|
86
|
+
await _press(pilot, "escape")
|
|
87
|
+
assert isinstance(app.screen, mod.QuitConfirmationScreen)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
async def test_editor_escape_hidden_tree_dirty_shows_unsaved_changes() -> None:
|
|
91
|
+
_, f, app = _file_app("editor-escape-dirty.txt", "orig", root_is_tmp=True)
|
|
92
|
+
async with app.run_test() as pilot:
|
|
93
|
+
await pilot.pause()
|
|
94
|
+
await _make_dirty(app, pilot)
|
|
95
|
+
await _press(pilot, "super+b")
|
|
96
|
+
await pilot.pause()
|
|
97
|
+
await _press(pilot, "escape")
|
|
98
|
+
assert isinstance(app.screen, mod.UnsavedChangesScreen)
|
|
99
|
+
|
|
100
|
+
|
|
71
101
|
async def test_file_tree_escape_clean_shows_quit_confirmation_then_cancel() -> None:
|
|
72
102
|
_, f, app = _file_app("tree-escape-clean.txt", "foo", root_is_tmp=True)
|
|
73
103
|
async with app.run_test() as pilot:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|