Skip to content

Commit

Permalink
Make TextArea respond to app.theme changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggozad committed Jan 10, 2024
1 parent e646916 commit fcb6bc9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,17 @@ def gutter_width(self) -> int:
)
return gutter_width

def _retheme(self) -> None:
"""Swap between a dark and light theme when the app theme changes."""
self.theme = "vscode_dark" if self.app.dark else "github_light"

def _on_mount(self, _: events.Mount) -> None:
self.blink_timer = self.set_interval(
0.5,
self._toggle_cursor_blink_visible,
pause=not (self.cursor_blink and self.has_focus),
)
self.watch(self.app, "dark", self._retheme)

def _on_blur(self, _: events.Blur) -> None:
self._pause_blink(visible=True)
Expand Down

0 comments on commit fcb6bc9

Please sign in to comment.