Skip to content

Commit 3778b21

Browse files
committed
✨ browsr upgrade
1 parent 4d4eecb commit 3778b21

21 files changed

+1404
-1123
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
fail-fast: true
2424
matrix:
2525
include:
26+
- { name: Python 3.13, python: "3.13" }
2627
- { name: Python 3.12, python: "3.12" }
2728
- { name: Python 3.11, python: "3.11" }
2829
- { name: Python 3.10, python: "3.10" }
2930
- { name: Python 3.9, python: "3.9" }
30-
- { name: Python 3.8, python: "3.8" }
3131
steps:
3232
- name: Set up Github Workspace
3333
uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
default_stages: [commit]
2-
fail_fast: false
3-
41
repos:
52
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.4.0
3+
rev: v6.0.0
74
hooks:
85
- id: trailing-whitespace
96
exclude: '\.ambr$'
@@ -15,13 +12,13 @@ repos:
1512
- id: mixed-line-ending
1613

1714
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
18-
rev: v2.8.0
15+
rev: v2.15.0
1916
hooks:
2017
- id: pretty-format-toml
2118
args: [--autofix]
2219

2320
- repo: https://github.com/pre-commit/mirrors-prettier
24-
rev: v3.0.0-alpha.9-for-vscode
21+
rev: v4.0.0-alpha.8
2522
hooks:
2623
- id: prettier
2724
args: [--print-width=88, --tab-width=4]

browsr/base.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
from dataclasses import dataclass, field
1010
from typing import Any, ClassVar
1111

12-
from textual.app import App
13-
from textual.binding import Binding
14-
from textual.dom import DOMNode
12+
from textual.binding import ActiveBinding
13+
from textual.screen import Screen
1514
from textual_universal_directorytree import UPath
1615

1716
from browsr.utils import handle_github_url
@@ -54,15 +53,15 @@ def path(self) -> UPath:
5453
return path.resolve()
5554

5655

57-
class SortedBindingsApp(App[str]):
56+
class SortedBindingsScreen(Screen):
5857
"""
5958
Textual App with Sorted Bindings
6059
"""
6160

6261
BINDING_WEIGHTS: ClassVar[dict[str, int]] = {}
6362

6463
@property
65-
def namespace_bindings(self) -> dict[str, tuple[DOMNode, Binding]]:
64+
def active_bindings(self) -> dict[str, ActiveBinding]:
6665
"""
6766
Return the namespace bindings, optionally sorted by weight
6867
@@ -87,7 +86,7 @@ def namespace_bindings(self) -> dict[str, tuple[DOMNode, Binding]]:
8786
dict[str, tuple[DOMNode, Binding]]
8887
A dictionary of bindings
8988
"""
90-
existing_bindings = super().namespace_bindings
89+
existing_bindings = super().active_bindings
9190
if not self.BINDING_WEIGHTS:
9291
return existing_bindings
9392
builtin_index = 500

browsr/browsr.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
from typing import Any, ClassVar
1313

1414
from textual import on
15+
from textual.app import App
1516
from textual.binding import Binding, BindingType
1617
from textual.events import Mount
1718

1819
from browsr.__about__ import __application__
1920
from browsr.base import (
20-
SortedBindingsApp,
2121
TextualAppContext,
2222
)
2323
from browsr.screens import CodeBrowserScreen
2424

2525

26-
class Browsr(SortedBindingsApp):
26+
class Browsr(App[str]):
2727
"""
2828
Textual code browser app.
2929
"""
@@ -34,18 +34,6 @@ class Browsr(SortedBindingsApp):
3434
Binding(key="q", action="quit", description="Quit"),
3535
Binding(key="d", action="toggle_dark", description="Dark Mode"),
3636
]
37-
BINDING_WEIGHTS: ClassVar[dict[str, int]] = {
38-
"ctrl+c": 1,
39-
"q": 2,
40-
"f": 3,
41-
"t": 4,
42-
"n": 5,
43-
"d": 6,
44-
"r": 995,
45-
".": 996,
46-
"c": 997,
47-
"x": 998,
48-
}
4937

5038
def __init__(
5139
self,

browsr/screens/code_browser.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@
1111
from textual.binding import Binding, BindingType
1212
from textual.containers import Horizontal
1313
from textual.events import Mount
14-
from textual.screen import Screen
1514
from textual.widget import Widget
1615
from textual.widgets import Footer, Header
1716
from textual_universal_directorytree import UPath
1817

19-
from browsr.base import TextualAppContext
18+
from browsr.base import SortedBindingsScreen, TextualAppContext
2019
from browsr.utils import get_file_info
2120
from browsr.widgets.code_browser import CodeBrowser
2221
from browsr.widgets.files import CurrentFileInfoBar
2322

2423

25-
class CodeBrowserScreen(Screen):
24+
class CodeBrowserScreen(SortedBindingsScreen):
2625
"""
2726
Code Browser Screen
2827
"""
@@ -35,6 +34,19 @@ class CodeBrowserScreen(Screen):
3534
Binding(key=".", action="parent_dir", description="Parent Directory"),
3635
]
3736

37+
BINDING_WEIGHTS: ClassVar[dict[str, int]] = {
38+
"ctrl+c": 1,
39+
"q": 2,
40+
"f": 3,
41+
"t": 4,
42+
"n": 5,
43+
"d": 6,
44+
"r": 995,
45+
".": 996,
46+
"c": 997,
47+
"x": 998,
48+
}
49+
3850
def __init__(
3951
self,
4052
config_object: TextualAppContext | None = None,

browsr/widgets/windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def file_to_image(self, file_path: UPath) -> Pixels:
6969
"""
7070
Load a file into an image
7171
"""
72-
screen_width = self.app.size.width / 4
72+
screen_width = self.app.size.width / 2
7373
content = open_image(document=file_path, screen_width=screen_width)
7474
return content
7575

pyproject.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,49 @@ classifiers = [
1010
"Development Status :: 4 - Beta",
1111
"Operating System :: OS Independent",
1212
"Programming Language :: Python",
13-
"Programming Language :: Python :: 3.8",
1413
"Programming Language :: Python :: 3.9",
1514
"Programming Language :: Python :: 3.10",
1615
"Programming Language :: Python :: 3.11",
1716
"Programming Language :: Python :: 3.12",
17+
"Programming Language :: Python :: 3.13",
1818
"Programming Language :: Python :: Implementation :: CPython",
1919
"Programming Language :: Python :: Implementation :: PyPy"
2020
]
2121
dependencies = [
22-
"art~=6.1",
22+
"art~=6.5",
2323
"click~=8.1.7",
2424
"pandas>2,<3",
25-
"rich~=13.7.1",
26-
"rich-click~=1.7.4",
27-
"rich-pixels~=2.2.0",
28-
"textual==0.53.1",
29-
"textual-universal-directorytree~=1.5.0",
30-
"universal-pathlib~=0.2.2",
31-
"Pillow>=10.2.0",
32-
"PyMuPDF~=1.23.26",
33-
"pyperclip~=1.8.2"
25+
"rich>=14,<15",
26+
"rich-click~=1.8.9",
27+
"rich-pixels~=3.0.1",
28+
"textual>=5,<6",
29+
"textual-universal-directorytree~=1.6.0",
30+
"universal-pathlib~=0.2.6",
31+
"Pillow>=11.3.0",
32+
"PyMuPDF~=1.26.3",
33+
"pyperclip~=1.9.0"
3434
]
3535
description = "TUI File Browser App"
3636
dynamic = ["version"]
3737
keywords = []
3838
license = "MIT"
3939
name = "browsr"
4040
readme = "README.md"
41-
requires-python = ">=3.8,<4.0"
41+
requires-python = ">=3.9,<4.0"
4242

4343
[project.optional-dependencies]
4444
all = [
45-
"pyarrow~=15.0.2",
46-
"textual-universal-directorytree[remote]~=1.5.0"
45+
"pyarrow~=21.0.0",
46+
"textual-universal-directorytree[remote]~=1.6.0"
4747
]
4848
data = [
49-
"pyarrow~=15.0.2"
49+
"pyarrow~=21.0.0"
5050
]
5151
parquet = [
52-
"pyarrow~=15.0.2"
52+
"pyarrow~=21.0.0"
5353
]
5454
remote = [
55-
"textual-universal-directorytree[remote]~=1.5.0"
55+
"textual-universal-directorytree[remote]~=1.6.0"
5656
]
5757

5858
[project.scripts]
@@ -91,7 +91,7 @@ pip-compile-constraint = ""
9191
template = "test"
9292

9393
[[tool.hatch.envs.all.matrix]]
94-
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
94+
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
9595

9696
[tool.hatch.envs.default]
9797
features = ["all"]

0 commit comments

Comments
 (0)