From f3ed9df5db8132e850f2c89bd389151decbf17e5 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 27 Aug 2024 15:50:41 +0100 Subject: [PATCH] change behavior for read only --- src/textual/widgets/_text_area.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/textual/widgets/_text_area.py b/src/textual/widgets/_text_area.py index 626eb05f80..c80acbeeca 100644 --- a/src/textual/widgets/_text_area.py +++ b/src/textual/widgets/_text_area.py @@ -540,8 +540,8 @@ def _get_builtin_highlight_query(language_name: str) -> str: Path(_HIGHLIGHTS_PATH.resolve()) / f"{language_name}.scm" ) highlight_query = highlight_query_path.read_text() - except OSError as e: - log.warning(f"Unable to load highlight query. {e}") + except OSError as error: + log.warning(f"Unable to load highlight query. {error}") highlight_query = "" return highlight_query @@ -549,7 +549,7 @@ def _get_builtin_highlight_query(language_name: str) -> str: def check_consume_key(self, key: str) -> bool: """Check if the widget may consume the given key. - As an text area we are expecting to capture printable keys. + As a textarea we are expecting to capture printable keys. Args: key: A key identifier. @@ -557,6 +557,8 @@ def check_consume_key(self, key: str) -> bool: Returns: `True` if the widget may capture the key in it's `Key` message, or `False` if it won't. """ + if self.read_only: + return False return len(key) == 1 and key.isprintable() def _build_highlight_map(self) -> None: