Skip to content

Commit c97cc19

Browse files
committed
snapshots
1 parent 1998ed4 commit c97cc19

File tree

4 files changed

+357
-5
lines changed

4 files changed

+357
-5
lines changed

src/textual/widgets/_text_area.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,12 @@ def _redo_batch(self, edits: Sequence[Edit]) -> None:
15981598

15991599
async def _on_key(self, event: events.Key) -> None:
16001600
"""Handle key presses which correspond to document inserts."""
1601+
16011602
self._restart_blink()
16021603

1604+
if self.read_only:
1605+
return
1606+
16031607
key = event.key
16041608
insert_values = {
16051609
"enter": "\n",
@@ -1616,9 +1620,6 @@ async def _on_key(self, event: events.Key) -> None:
16161620
insert_values["tab"] = " " * self._find_columns_to_next_tab_stop()
16171621

16181622
if event.is_printable or key in insert_values:
1619-
if self.read_only:
1620-
self.app.bell()
1621-
return
16221623
event.stop()
16231624
event.prevent_default()
16241625
insert = insert_values.get(key, event.character)
@@ -2076,7 +2077,7 @@ def get_cursor_up_location(self) -> Location:
20762077
def action_cursor_line_end(self, select: bool = False) -> None:
20772078
"""Move the cursor to the end of the line."""
20782079
if not self._has_cursor:
2079-
self.scroll_x = self.max_scroll_x
2080+
self.scroll_end()
20802081
return
20812082
location = self.get_cursor_line_end_location()
20822083
self.move_cursor(location, select=select)
@@ -2092,7 +2093,7 @@ def get_cursor_line_end_location(self) -> Location:
20922093
def action_cursor_line_start(self, select: bool = False) -> None:
20932094
"""Move the cursor to the start of the line."""
20942095
if not self._has_cursor:
2095-
self.scroll_x = 0
2096+
self.scroll_home()
20962097
return
20972098
target = self.get_cursor_line_start_location(smart_home=True)
20982099
self.move_cursor(target, select=select)
@@ -2355,6 +2356,9 @@ def action_delete_left(self) -> None:
23552356
23562357
If there's a selection, then the selected range is deleted."""
23572358

2359+
if self.read_only:
2360+
return
2361+
23582362
selection = self.selection
23592363
start, end = selection
23602364

@@ -2367,6 +2371,8 @@ def action_delete_right(self) -> None:
23672371
"""Deletes the character to the right of the cursor and keeps the cursor at the same location.
23682372
23692373
If there's a selection, then the selected range is deleted."""
2374+
if self.read_only:
2375+
return
23702376

23712377
selection = self.selection
23722378
start, end = selection
@@ -2378,6 +2384,8 @@ def action_delete_right(self) -> None:
23782384

23792385
def action_delete_line(self) -> None:
23802386
"""Deletes the lines which intersect with the selection."""
2387+
if self.read_only:
2388+
return
23812389
self._delete_cursor_line()
23822390

23832391
def _delete_cursor_line(self) -> EditResult | None:

0 commit comments

Comments
 (0)