Skip to content

Commit

Permalink
Testing new themes system, ensuring tree cursor is always readable (a…
Browse files Browse the repository at this point in the history
…uto)
  • Loading branch information
darrenburns committed Jul 24, 2024
1 parent c970c15 commit 066e891
Show file tree
Hide file tree
Showing 16 changed files with 338 additions and 441 deletions.
Binary file modified .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Dotenv files are separate from collections, although you may wish to include the
| `focus.on_startup` (`POSTING_FOCUS__ON_STARTUP`) | `"url"`, `"method", "collection"` (Default: `"url"`) | Automatically focus the URL bar, method, or collection browser when the app starts. |
| `focus.on_response` (`POSTING_FOCUS__ON_RESPONSE`) | `"body"`, `"tabs"` (Default: `unset`)| Automatically focus the response tabs or response body text area when a response is received. |
| `text_input.blinking_cursor` (`POSTING_TEXT_INPUT__BLINKING_CURSOR`) | `true`, `false` (Default: `true`) | If enabled, the cursor will blink in input widgets and text area widgets. |
| `themes_directory` (`POSTING_THEMES_DIRECTORY`) | (Default: `${XDG_DATA_HOME}/posting/themes`) | The directory containing user themes. |
| `theme_directory` (`POSTING_THEME_DIRECTORY`) | (Default: `${XDG_DATA_HOME}/posting/themes`) | The directory containing user themes. |
<!-- | `use_xresources` (`POSTING_USE_XRESOURCES`) | `true`, `false` (Default: `false`) | Try to create themes called `xresources-dark` and `xresources-light` (see the section below) | -->

## SSL certificate configuration
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dev-dependencies = [
"syrupy>=4.6.1",
"pytest-xdist>=3.6.1",
"pytest-cov>=5.0.0",
"pytest-textual-snapshot>=1.0.0",
]

[tool.hatch.metadata]
Expand Down
6 changes: 6 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ idna==3.7
iniconfig==2.0.0
# via pytest
jinja2==3.1.4
# via pytest-textual-snapshot
linkify-it-py==2.0.3
# via markdown-it-py
markdown-it-py==3.0.0
Expand Down Expand Up @@ -84,23 +85,28 @@ pyperclip==1.8.2
# via posting
pytest==8.3.1
# via pytest-cov
# via pytest-textual-snapshot
# via pytest-xdist
# via syrupy
pytest-cov==5.0.0
pytest-textual-snapshot==1.0.0
pytest-xdist==3.6.1
python-dotenv==1.0.1
# via posting
# via pydantic-settings
pyyaml==6.0.1
# via posting
rich==13.7.1
# via pytest-textual-snapshot
# via textual
sniffio==1.3.1
# via anyio
# via httpx
syrupy==4.6.1
# via pytest-textual-snapshot
textual==0.73.0
# via posting
# via pytest-textual-snapshot
# via textual-autocomplete
# via textual-dev
textual-autocomplete==3.0.0a9
Expand Down
4 changes: 2 additions & 2 deletions src/posting/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from posting.locations import (
config_file,
default_collection_directory,
themes_directory,
theme_directory,
)


Expand Down Expand Up @@ -82,7 +82,7 @@ def locate(thing_to_locate: str) -> None:
print(default_collection_directory())
elif thing_to_locate == "themes":
print("Themes directory:")
print(themes_directory())
print(theme_directory())
else:
# This shouldn't happen because the type annotation should enforce that
# the only valid options are "config" and "collection".
Expand Down
4 changes: 2 additions & 2 deletions src/posting/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from textual.types import AnimationLevel
import yaml

from posting.locations import config_file, themes_directory
from posting.locations import config_file, theme_directory

from posting.types import PostingLayout

Expand Down Expand Up @@ -89,7 +89,7 @@ class Settings(BaseSettings):
theme: str = Field(default="posting")
"""The name of the theme to use."""

themes_directory: Path = Field(default=themes_directory())
theme_directory: Path = Field(default=theme_directory())
"""The directory containing user themes."""

layout: PostingLayout = Field(default="vertical")
Expand Down
8 changes: 4 additions & 4 deletions src/posting/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def data_directory() -> Path:
return _posting_directory(xdg_data_home())


def themes_directory() -> Path:
def theme_directory() -> Path:
"""Return (possibly creating) the themes directory."""
themes_dir = data_directory() / "themes"
themes_dir.mkdir(exist_ok=True, parents=True)
return themes_dir
theme_dir = data_directory() / "themes"
theme_dir.mkdir(exist_ok=True, parents=True)
return theme_dir


def default_collection_directory() -> Path:
Expand Down
2 changes: 2 additions & 0 deletions src/posting/posting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ TextArea {

Tree {
& > .tree--cursor {
text-style: not dim;
color: $text;
background: $panel-lighten-1 70%;
}
&:focus > .tree--cursor {
Expand Down
4 changes: 2 additions & 2 deletions src/posting/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import yaml
from posting.config import SETTINGS

from posting.locations import themes_directory
from posting.locations import theme_directory


class Theme(BaseModel):
Expand Down Expand Up @@ -33,7 +33,7 @@ def to_color_system(self) -> ColorSystem:

def load_user_themes() -> dict[str, Theme]:
"""Load user themes from "~/.config/posting/themes"."""
directory = SETTINGS.get().themes_directory
directory = SETTINGS.get().theme_directory
themes: dict[str, Theme] = {}
for path in directory.iterdir():
path_suffix = path.suffix
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 066e891

Please sign in to comment.