mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 06:44:00 -06:00
ui/urwid: drop customizing color palettes
This commit is contained in:
@@ -45,15 +45,6 @@ def parse_args() -> argparse.Namespace:
|
|||||||
help="Disable color highlighting in curses interface",
|
help="Disable color highlighting in curses interface",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"--no-config",
|
|
||||||
dest="use_config",
|
|
||||||
action="store_false",
|
|
||||||
help=(
|
|
||||||
"Don't load or save configuration files from $XDG_CONFIG_HOME "
|
|
||||||
"(player data will still be saved)"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-save",
|
"--no-save",
|
||||||
dest="use_saves",
|
dest="use_saves",
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import typing as T
|
import typing as T
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
import xdg
|
|
||||||
|
|
||||||
from pqcli import lingo, random
|
from pqcli import lingo, random
|
||||||
from pqcli.mechanic import Player
|
from pqcli.mechanic import Player
|
||||||
@@ -30,21 +28,6 @@ PALETTE: T.List[T.Tuple[str, ...]] = [
|
|||||||
("scrollable", "", ""),
|
("scrollable", "", ""),
|
||||||
("scrollable-focus", "", ""),
|
("scrollable-focus", "", ""),
|
||||||
]
|
]
|
||||||
PALETTE_PATH = Path(xdg.XDG_CONFIG_HOME) / "pqcli" / "palette.json"
|
|
||||||
|
|
||||||
|
|
||||||
def load_palette() -> bool:
|
|
||||||
global PALETTE
|
|
||||||
if PALETTE_PATH.exists():
|
|
||||||
PALETTE = json.loads(PALETTE_PATH.read_text())
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def save_palette() -> None:
|
|
||||||
global PALETTE
|
|
||||||
PALETTE_PATH.parent.mkdir(exist_ok=True, parents=True)
|
|
||||||
PALETTE_PATH.write_text(json.dumps(PALETTE, indent=4))
|
|
||||||
|
|
||||||
|
|
||||||
class ConfirmExitDialog(ConfirmView):
|
class ConfirmExitDialog(ConfirmView):
|
||||||
@@ -69,10 +52,6 @@ class UrwidUserInterface(BaseUserInterface):
|
|||||||
|
|
||||||
bind_commands()
|
bind_commands()
|
||||||
|
|
||||||
if args.use_config:
|
|
||||||
if not load_palette():
|
|
||||||
save_palette() # create a file for the user to edit
|
|
||||||
|
|
||||||
self.loop = urwid.MainLoop(
|
self.loop = urwid.MainLoop(
|
||||||
None, PALETTE, unhandled_input=self.unhandled_input
|
None, PALETTE, unhandled_input=self.unhandled_input
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user