Skip to content

Commit

Permalink
change behavior for read only
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Aug 27, 2024
1 parent 922cd61 commit f3ed9df
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,23 +540,25 @@ 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

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.
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:
Expand Down

0 comments on commit f3ed9df

Please sign in to comment.