Skip to content

Commit

Permalink
browsr
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Feb 27, 2024
1 parent 8d5557f commit 7e5554e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
5 changes: 0 additions & 5 deletions browsr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
"""
browsr
"""

from browsr.browsr import Browsr
from browsr.widgets.universal_directory_tree import BrowsrDirectoryTree

__all__ = ["Browsr", "BrowsrDirectoryTree"]
2 changes: 1 addition & 1 deletion browsr/browsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class Browsr(SortedBindingsApp):

def __init__(
self,
*args: Any,
config_object: TextualAppContext | None = None,
*args: Any,
**kwargs: Any,
) -> None:
"""
Expand Down
39 changes: 26 additions & 13 deletions browsr/screens/code_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from __future__ import annotations

import pathlib
from typing import ClassVar, Iterable

from rich import traceback
Expand Down Expand Up @@ -95,7 +94,6 @@ def start_up_app(self) -> None:
self.code_browser.datatable_window.focus()
else:
self.code_browser.show_tree = True
self.code_browser.window_switcher.render_file(file_path=pathlib.Path.cwd())

@on(CurrentFileInfoBar.FileInfoUpdate)
def update_file_info(self, message: CurrentFileInfoBar.FileInfoUpdate) -> None:
Expand Down Expand Up @@ -146,15 +144,30 @@ def action_linenos(self) -> None:

def action_reload(self) -> None:
"""
Refresh the directory.
Refresh the directory and file
"""
directory_tree_open = self.code_browser.has_class("-show-tree")
if not directory_tree_open:
return
self.code_browser.directory_tree.reload()
self.notify(
title="Directory Reloaded",
message=str(self.code_browser.directory_tree.path),
severity="information",
timeout=1,
)
reload_file = self.code_browser.selected_file_path is not None
reload_directory = self.code_browser.has_class("-show-tree")
message_lines = []
if reload_directory:
self.code_browser.directory_tree.reload()
message_lines.append(
"[bold]Directory:[/bold] "
f"[italic]{self.config_object.path.name}[/italic]"
)
if reload_file:
self.code_browser.window_switcher.render_file(
file_path=self.code_browser.selected_file_path,

Check failure on line 160 in browsr/screens/code_browser.py

View workflow job for this annotation

GitHub Actions / lint

Argument "file_path" to "render_file" of "WindowSwitcher" has incompatible type "Any | Path | None"; expected "Path" [arg-type]
scroll_home=False,
)
message_lines.append(
"[bold]File:[/bold] "

Check failure on line 164 in browsr/screens/code_browser.py

View workflow job for this annotation

GitHub Actions / lint

Item "None" of "Any | Path | None" has no attribute "name" [union-attr]
f"[italic]{self.code_browser.selected_file_path.name}[/italic]"
)
if message_lines:
self.notify(
title="Reloaded",
message="\n".join(message_lines),
severity="information",
timeout=1,
)
2 changes: 1 addition & 1 deletion browsr/widgets/code_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def download_selected_file(self) -> None:
message=str(handled_download_path),
title="Download Complete",
severity="information",
timeout=1,
timeout=2,
)

def _get_download_file_name(self) -> pathlib.Path:
Expand Down

0 comments on commit 7e5554e

Please sign in to comment.