Skip to content

Commit

Permalink
Merge pull request #46 from darrenburns/textual-update
Browse files Browse the repository at this point in the history
Update Textual version
  • Loading branch information
darrenburns authored Jul 19, 2024
2 parents 66dd868 + 3d2b8c1 commit e4911ea
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"pydantic-settings==2.3.4",
"python-dotenv==1.0.1",
"textual-autocomplete>=3.0.0a9",
"textual[syntax]==0.72.0",
"textual[syntax]==0.73.0",
]
readme = "README.md"
requires-python = ">= 3.11"
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ rich==13.7.1
sniffio==1.3.1
# via anyio
# via httpx
textual==0.72.0
textual==0.73.0
# via posting
# via textual-autocomplete
# via textual-dev
Expand Down
2 changes: 1 addition & 1 deletion requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ rich==13.7.1
sniffio==1.3.1
# via anyio
# via httpx
textual==0.72.0
textual==0.73.0
# via posting
# via textual-autocomplete
textual-autocomplete==3.0.0a9
Expand Down
9 changes: 1 addition & 8 deletions src/posting/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class AppBody(Vertical):


class MainScreen(Screen[None]):
AUTO_FOCUS = None
BINDINGS = [
Binding("ctrl+j", "send_request", "Send"),
Binding("ctrl+t", "change_method", "Method"),
Expand Down Expand Up @@ -583,11 +584,6 @@ def __init__(


class Posting(PostingApp):
# TODO - working around a Textual bug where the command palette
# doesnt auto focus the input by itself. When that bug is fixed,
# the AUTO_FOCUS setting should be set to None!!
# https://github.com/Textualize/textual/pull/4763
AUTO_FOCUS = "CommandInput"
COMMANDS = {PostingProvider}
CSS_PATH = Path(__file__).parent / "posting.scss"
BINDINGS = [
Expand Down Expand Up @@ -830,9 +826,6 @@ def watch__jumping(self, jumping: bool) -> None:
focused_before = self.focused
if focused_before is not None:
self.set_focus(None, scroll_visible=False)
# TODO - the call below is working around a Textual bug
# that is fixed in https://github.com/Textualize/textual/pull/4771
self.screen._update_focus_styles(None, blurred=focused_before)

def handle_jump_target(target: str | Widget | None) -> None:
if isinstance(target, str):
Expand Down
1 change: 0 additions & 1 deletion src/posting/jump_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class JumpOverlay(ModalScreen[str | Widget | None]):
or a reference to the widget. Is dismissed with None if the user dismissed
the overlay without making a selection."""

AUTO_FOCUS = None
DEFAULT_CSS = """\
JumpOverlay {
background: black 25%;
Expand Down
18 changes: 15 additions & 3 deletions src/posting/widgets/collection/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ def _handle_new_request_data(new_request_data: NewRequestData | None) -> None:

# Attach to the relevant node
new_node = self.add_request(
new_request, parent_node if pointer is self.root else pointer
new_request,
parent_node if pointer is self.root else pointer,
after=None if parent_node == cursor_node else cursor_node,
before=0
if parent_node == cursor_node and len(parent_node.children) > 0
else None,
)
self.currently_open = new_node

Expand All @@ -286,6 +291,7 @@ def _handle_new_request_data(new_request_data: NewRequestData | None) -> None:
)

def post_new_request() -> None:
self.screen.set_focus(focused_before)
self.select_node(new_node)
self.scroll_to_node(new_node, animate=False)

Expand All @@ -307,11 +313,17 @@ def post_new_request() -> None:
)

def add_request(
self, request: RequestModel, parent_node: TreeNode[CollectionNode]
self,
request: RequestModel,
parent_node: TreeNode[CollectionNode],
after: TreeNode[CollectionNode] | int | None = None,
before: TreeNode[CollectionNode] | int | None = None,
) -> TreeNode[CollectionNode]:
"""Add a new request to the tree, and cache data from it."""
self.cache_request(request)
return parent_node.add_leaf(request.name, data=request)
return parent_node.add_leaf(
request.name, data=request, after=after, before=before
)

def cache_request(self, request: RequestModel) -> None:
def get_base_url(url: str) -> str | None:
Expand Down
5 changes: 3 additions & 2 deletions src/posting/widgets/text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,9 @@ def action_cursor_bottom(self) -> None:

def action_cursor_to_matched_bracket(self) -> None:
# If we're already on a bracket which has a match, just jump to it and return.
if self._matching_bracket_location:
self.selection = Selection.cursor(self._matching_bracket_location)
matching_bracket_location = self.matching_bracket_location
if matching_bracket_location:
self.selection = Selection.cursor(matching_bracket_location)
return

# Look for a bracket on the rest of the cursor line.
Expand Down

0 comments on commit e4911ea

Please sign in to comment.