Add even more config values
This commit is contained in:
parent
c99eddee62
commit
f3bbd42420
2 changed files with 92 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List, Optional, TypeVar
|
from typing import Any, Dict, List, Optional, Set, TypeVar
|
||||||
|
|
||||||
from ..config import (ConfigValueException, Kind, Option, TransparentConfig,
|
from ..config import (ConfigValueException, Kind, Option, TransparentConfig,
|
||||||
TreeLoader)
|
TreeLoader)
|
||||||
|
|
@ -10,6 +10,8 @@ class EuphConfig(TransparentConfig):
|
||||||
def __init__(self, parent: Optional[TransparentConfig] = None) -> None:
|
def __init__(self, parent: Optional[TransparentConfig] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
# basic styles
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def room_style(self) -> str:
|
def room_style(self) -> str:
|
||||||
return self["visual.room_style"]
|
return self["visual.room_style"]
|
||||||
|
|
@ -84,6 +86,46 @@ class EuphConfig(TransparentConfig):
|
||||||
def cursor_fill_style(self) -> str:
|
def cursor_fill_style(self) -> str:
|
||||||
return self["visual.cursor.fill.style"]
|
return self["visual.cursor.fill.style"]
|
||||||
|
|
||||||
|
# indent
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_width(self) -> int:
|
||||||
|
return self["visual.indent.width"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_char(self) -> str:
|
||||||
|
return self["visual.indent.char"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_fill(self) -> str:
|
||||||
|
return self["visual.indent.fill"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_style(self) -> str:
|
||||||
|
return self["visual.indent.style"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_cursor_char(self) -> str:
|
||||||
|
return self["visual.indent.cursor.char"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_cursor_corner(self) -> str:
|
||||||
|
return self["visual.indent.cursor.corner"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_cursor_fill(self) -> str:
|
||||||
|
return self["visual.indent.cursor.fill"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indent_cursor_style(self) -> str:
|
||||||
|
return self["visual.indent.cursor.style"]
|
||||||
|
|
||||||
|
# other
|
||||||
|
|
||||||
|
@property
|
||||||
|
def scrolloff(self) -> int:
|
||||||
|
return self["visual.scrolloff"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def palette(self) -> Any:
|
def palette(self) -> Any:
|
||||||
return self["palette"]
|
return self["palette"]
|
||||||
|
|
@ -95,6 +137,8 @@ class EuphLoader(TreeLoader):
|
||||||
"bold": {"fg": "bold"},
|
"bold": {"fg": "bold"},
|
||||||
"gray": {"fg": "dark gray"},
|
"gray": {"fg": "dark gray"},
|
||||||
|
|
||||||
|
"cursor": {"fg": "bold, light green"},
|
||||||
|
|
||||||
"room": {"fg": "bold, light blue"},
|
"room": {"fg": "bold, light blue"},
|
||||||
"nick": {"fg": "light cyan"},
|
"nick": {"fg": "light cyan"},
|
||||||
"own_nick": {"fg": "yellow"},
|
"own_nick": {"fg": "yellow"},
|
||||||
|
|
@ -105,12 +149,15 @@ class EuphLoader(TreeLoader):
|
||||||
|
|
||||||
# Various conditions
|
# Various conditions
|
||||||
SINGLE_CHAR = (lambda x: len(x) == 1, "must be single character")
|
SINGLE_CHAR = (lambda x: len(x) == 1, "must be single character")
|
||||||
|
AT_LEAST_0 = (lambda x: x >= 0, "must be at least 0")
|
||||||
|
AT_LEAST_1 = (lambda x: x >= 1, "must be at least 1")
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._styles: Set[str] = set()
|
self._styles: Set[str] = set()
|
||||||
|
|
||||||
|
# basic styles
|
||||||
self.add_style("visual.room_style", "room")
|
self.add_style("visual.room_style", "room")
|
||||||
self.add_style("visual.nick_style", "nick")
|
self.add_style("visual.nick_style", "nick")
|
||||||
self.add_style("visual.own_nick_style", "own_nick")
|
self.add_style("visual.own_nick_style", "own_nick")
|
||||||
|
|
@ -124,18 +171,31 @@ class EuphLoader(TreeLoader):
|
||||||
self.add_style("visual.meta.style", "none")
|
self.add_style("visual.meta.style", "none")
|
||||||
|
|
||||||
# surround
|
# surround
|
||||||
self.add("visual.surround.left", Kind.STR, "[", [self.SINGLE_CHAR])
|
self.add("visual.surround.left", Kind.STR, "[", self.SINGLE_CHAR)
|
||||||
self.add("visual.surround.right", Kind.STR, "]", [self.SINGLE_CHAR])
|
self.add("visual.surround.right", Kind.STR, "]", self.SINGLE_CHAR)
|
||||||
self.add_style("visual.surround.style", "none")
|
self.add_style("visual.surround.style", "bold")
|
||||||
|
|
||||||
# cursor
|
# cursor
|
||||||
self.add("visual.cursor.surround.left", Kind.STR, "<", [self.SINGLE_CHAR])
|
self.add("visual.cursor.surround.left", Kind.STR, "<", self.SINGLE_CHAR)
|
||||||
self.add("visual.cursor.surround.right", Kind.STR, ">", [self.SINGLE_CHAR])
|
self.add("visual.cursor.surround.right", Kind.STR, ">", self.SINGLE_CHAR)
|
||||||
self.add_style("visual.cursor.surround.style", "none")
|
self.add_style("visual.cursor.surround.style", "cursor")
|
||||||
self.add_style("visual.cursor.own_nick_style", "own_nick")
|
self.add_style("visual.cursor.own_nick_style", "cursor")
|
||||||
self.add("visual.cursor.fill.char", Kind.STR, " ", [self.SINGLE_CHAR])
|
self.add("visual.cursor.fill.char", Kind.STR, " ", self.SINGLE_CHAR)
|
||||||
self.add_style("visual.cursor.fill.style", "none")
|
self.add_style("visual.cursor.fill.style", "none")
|
||||||
|
|
||||||
|
# indent
|
||||||
|
self.add("visual.indent.width", Kind.INT, 2, self.AT_LEAST_1)
|
||||||
|
self.add("visual.indent.char", Kind.STR, "│", self.SINGLE_CHAR)
|
||||||
|
self.add("visual.indent.fill", Kind.STR, " ", self.SINGLE_CHAR)
|
||||||
|
self.add_style("visual.indent.style", "gray")
|
||||||
|
self.add("visual.indent.cursor.char", Kind.STR, "┃", self.SINGLE_CHAR)
|
||||||
|
self.add("visual.indent.cursor.corner", Kind.STR, "┗", self.SINGLE_CHAR)
|
||||||
|
self.add("visual.indent.cursor.fill", Kind.STR, "━", self.SINGLE_CHAR)
|
||||||
|
self.add_style("visual.indent.cursor.style", "cursor")
|
||||||
|
|
||||||
|
# other
|
||||||
|
self.add("visual.scrolloff", Kind.INT, 3, self.AT_LEAST_0)
|
||||||
|
|
||||||
self.add("styles", Kind.DICT, self.DEFAULT_STYLES)
|
self.add("styles", Kind.DICT, self.DEFAULT_STYLES)
|
||||||
|
|
||||||
def add_style(self, name: str, default: str) -> None:
|
def add_style(self, name: str, default: str) -> None:
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@ import asyncio
|
||||||
from typing import Any, Awaitable, Callable, List, Optional, Tuple, TypeVar
|
from typing import Any, Awaitable, Callable, List, Optional, Tuple, TypeVar
|
||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
import yaboli
|
import yaboli
|
||||||
|
|
||||||
from ..attributed_text_widget import ATWidget
|
from ..attributed_text_widget import ATWidget
|
||||||
from ..cursor_rendering import CursorTreeRenderer
|
from ..cursor_rendering import CursorRenderer, CursorTreeRenderer
|
||||||
from ..cursor_tree_widget import CursorTreeWidget
|
from ..cursor_tree_widget import CursorTreeWidget
|
||||||
from ..element import Message, RenderedMessage
|
from ..element import Message, RenderedMessage
|
||||||
from ..element_supply import InMemorySupply
|
from ..element_supply import ElementSupply, InMemorySupply
|
||||||
from .euph_config import EuphConfig
|
|
||||||
from ..markup import AT, AttributedText, Attributes
|
from ..markup import AT, AttributedText, Attributes
|
||||||
from .edit_widgets import EditWidget
|
from .edit_widgets import EditWidget
|
||||||
|
from .euph_config import EuphConfig
|
||||||
from .euph_renderer import EuphRenderer
|
from .euph_renderer import EuphRenderer
|
||||||
|
|
||||||
__all__ = ["RoomWidget"]
|
__all__ = ["RoomWidget"]
|
||||||
|
|
@ -185,7 +186,8 @@ class RoomWidget(urwid.WidgetWrap):
|
||||||
|
|
||||||
self._supply = InMemorySupply[Message]()
|
self._supply = InMemorySupply[Message]()
|
||||||
self._renderer = self._create_euph_renderer()
|
self._renderer = self._create_euph_renderer()
|
||||||
self._tree = CursorTreeRenderer[Message](self._supply, self._renderer)
|
self._tree = self._create_cursor_tree_renderer(self._supply,
|
||||||
|
self._renderer)
|
||||||
|
|
||||||
# All of the widgets
|
# All of the widgets
|
||||||
|
|
||||||
|
|
@ -243,6 +245,23 @@ class RoomWidget(urwid.WidgetWrap):
|
||||||
own_nick_attrs={"style": self.c.own_nick_style},
|
own_nick_attrs={"style": self.c.own_nick_style},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _create_cursor_tree_renderer(self,
|
||||||
|
supply: ElementSupply,
|
||||||
|
renderer: CursorRenderer,
|
||||||
|
) -> CursorTreeRenderer:
|
||||||
|
|
||||||
|
return CursorTreeRenderer(supply, renderer,
|
||||||
|
indent_width=self.c.indent_width,
|
||||||
|
indent=self.c.indent_char,
|
||||||
|
indent_fill=self.c.indent_fill,
|
||||||
|
indent_attrs={"style": self.c.indent_style},
|
||||||
|
cursor_indent=self.c.indent_cursor_char,
|
||||||
|
cursor_corner=self.c.indent_cursor_corner,
|
||||||
|
cursor_fill=self.c.indent_cursor_fill,
|
||||||
|
cursor_indent_attrs={"style": self.c.indent_cursor_style},
|
||||||
|
scrolloff=self.c.scrolloff,
|
||||||
|
)
|
||||||
|
|
||||||
def _create_connecting_widget(self) -> Any:
|
def _create_connecting_widget(self) -> Any:
|
||||||
text = (
|
text = (
|
||||||
AT("Connecting to ") +
|
AT("Connecting to ") +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue