Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh scrollbars on style changes. #545

Merged
merged 3 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/textual/css/stylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from rich.syntax import Syntax
from rich.text import Text

from textual.widget import Widget
from .errors import StylesheetError
from .match import _check_selectors
from .model import RuleSet
Expand Down Expand Up @@ -304,6 +305,8 @@ def apply(self, node: DOMNode, animate: bool = False) -> None:
},
)
self.replace_rules(node, node_rules, animate=animate)
if isinstance(node, Widget):
node._refresh_scrollbars()

@classmethod
def replace_rules(
Expand Down
1 change: 1 addition & 0 deletions src/textual/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def get_pseudo_classes(self) -> Iterable[str]:
return ()

def reset_styles(self) -> None:
"""Reset styles back to their initial state"""
from .widget import Widget

for node in self.walk_children():
Expand Down
15 changes: 1 addition & 14 deletions src/textual/widgets/text_input.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import time
from typing import Callable

from rich.cells import cell_len
Expand Down Expand Up @@ -135,7 +134,7 @@ def __init__(
super().__init__(name=name, id=id, classes=classes)
self.placeholder = placeholder
self._editor = TextEditorBackend(initial, 0)
self.visible_range: tuple[int, int] | None = None
self.visible_range: tuple[int, int] = (0, 0)
self.autocompleter = autocompleter
self._suggestion_suffix = ""

Expand Down Expand Up @@ -282,18 +281,6 @@ def on_key(self, event: events.Key) -> None:
if visible_content_to_cursor_cell_len + key_cell_len >= available_width:
self.visible_range = start + key_cell_len, end + key_cell_len
self._update_suggestion(event)
elif (
key == "ctrl+x"
): # TODO: This allows us to query and print the text input state
self.log(start=start)
self.log(end=end)
self.log(visible_content=visible_content)
self.log(visible_content_cell_len=visible_content_cell_len)
self.log(
visible_content_to_cursor_cell_len=visible_content_to_cursor_cell_len
)
self.log(available_width=available_width)
self.log(cursor_index=self._editor.cursor_index)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way that code tells a story... A dreadful story of a complex feature development.... 😅

elif key == "enter" and self._editor.content:
self.post_message_no_wait(TextInput.Submitted(self, self._editor.content))
elif key == "right":
Expand Down