Add some more config values
This commit is contained in:
parent
0454dc3a3c
commit
8228d15d60
2 changed files with 123 additions and 13 deletions
|
|
@ -14,6 +14,14 @@ class EuphConfig(TransparentConfig):
|
|||
def room_style(self) -> str:
|
||||
return self["visual.room_style"]
|
||||
|
||||
@property
|
||||
def nick_style(self) -> str:
|
||||
return self["visual.nick_style"]
|
||||
|
||||
@property
|
||||
def own_nick_style(self) -> str:
|
||||
return self["visual.own_nick_style"]
|
||||
|
||||
@property
|
||||
def error_style(self) -> str:
|
||||
return self["visual.error.style"]
|
||||
|
|
@ -22,31 +30,117 @@ class EuphConfig(TransparentConfig):
|
|||
def error_room_style(self) -> str:
|
||||
return self["visual.error.room_style"]
|
||||
|
||||
# meta
|
||||
|
||||
@property
|
||||
def show_year(self) -> bool:
|
||||
return self["visual.meta.show_year"]
|
||||
|
||||
@property
|
||||
def show_seconds(self) -> bool:
|
||||
return self["visual.meta.show_seconds"]
|
||||
|
||||
@property
|
||||
def meta_style(self) -> str:
|
||||
return self["visual.meta.style"]
|
||||
|
||||
# surround
|
||||
|
||||
@property
|
||||
def surround_left(self) -> str:
|
||||
return self["visual.surround.left"]
|
||||
|
||||
@property
|
||||
def surround_right(self) -> str:
|
||||
return self["visual.surround.right"]
|
||||
|
||||
@property
|
||||
def surround_style(self) -> str:
|
||||
return self["visual.surround.style"]
|
||||
|
||||
# cursor
|
||||
|
||||
@property
|
||||
def cursor_surround_left(self) -> str:
|
||||
return self["visual.cursor.surround.left"]
|
||||
|
||||
@property
|
||||
def cursor_surround_right(self) -> str:
|
||||
return self["visual.cursor.surround.right"]
|
||||
|
||||
@property
|
||||
def cursor_surround_style(self) -> str:
|
||||
return self["visual.cursor.surround.style"]
|
||||
|
||||
@property
|
||||
def cursor_own_nick_style(self) -> str:
|
||||
return self["visual.cursor.own_nick_style"]
|
||||
|
||||
@property
|
||||
def cursor_fill_char(self) -> str:
|
||||
return self["visual.cursor.fill.char"]
|
||||
|
||||
@property
|
||||
def cursor_fill_style(self) -> str:
|
||||
return self["visual.cursor.fill.style"]
|
||||
|
||||
@property
|
||||
def palette(self) -> Any:
|
||||
return self["palette"]
|
||||
|
||||
class EuphLoader(TreeLoader):
|
||||
|
||||
STYLE_PROPERTIES = [
|
||||
"visual.room_style",
|
||||
"visual.error.style",
|
||||
"visual.error.room_style",
|
||||
]
|
||||
|
||||
DEFAULT_STYLES = {
|
||||
"none": {},
|
||||
"bold": {"fg": "bold"},
|
||||
"gray": {"fg": "dark gray"},
|
||||
|
||||
"room": {"fg": "bold, light blue"},
|
||||
"nick": {"fg": "light cyan"},
|
||||
"own_nick": {"fg": "yellow"},
|
||||
|
||||
"error": {"fg": "light red"},
|
||||
"error_room": {"fg": "bold, yellow"},
|
||||
}
|
||||
|
||||
# Various conditions
|
||||
SINGLE_CHAR = (lambda x: len(x) == 1, "must be single character")
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.add_option("visual.room_style", Option(Kind.STR, "room"))
|
||||
self.add_option("visual.error.style", Option(Kind.STR, "error"))
|
||||
self.add_option("visual.error.room_style", Option(Kind.STR, "error_room"))
|
||||
self.add_option("styles", Option(Kind.DICT, self.DEFAULT_STYLES))
|
||||
self._styles: Set[str] = set()
|
||||
|
||||
self.add_style("visual.room_style", "room")
|
||||
self.add_style("visual.nick_style", "nick")
|
||||
self.add_style("visual.own_nick_style", "own_nick")
|
||||
|
||||
self.add_style("visual.error.style", "error")
|
||||
self.add_style("visual.error.room_style", "error_room")
|
||||
|
||||
# meta
|
||||
self.add("visual.meta.show_year", Kind.BOOL, False)
|
||||
self.add("visual.meta.show_seconds", Kind.BOOL, False)
|
||||
self.add_style("visual.meta.style", "none")
|
||||
|
||||
# surround
|
||||
self.add("visual.surround.left", Kind.STR, "[", [self.SINGLE_CHAR])
|
||||
self.add("visual.surround.right", Kind.STR, "]", [self.SINGLE_CHAR])
|
||||
self.add_style("visual.surround.style", "none")
|
||||
|
||||
# cursor
|
||||
self.add("visual.cursor.surround.left", 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.own_nick_style", "own_nick")
|
||||
self.add("visual.cursor.fill.char", Kind.STR, " ", [self.SINGLE_CHAR])
|
||||
self.add_style("visual.cursor.fill.style", "none")
|
||||
|
||||
self.add("styles", Kind.DICT, self.DEFAULT_STYLES)
|
||||
|
||||
def add_style(self, name: str, default: str) -> None:
|
||||
self.add(name, Kind.STR, default)
|
||||
self._styles.add(name)
|
||||
|
||||
def load_to(self, config: TransparentConfig, data: Any) -> None:
|
||||
super().load_to(config, data)
|
||||
|
|
@ -58,7 +152,7 @@ class EuphLoader(TreeLoader):
|
|||
def _get_styles(self, config: TransparentConfig) -> Dict[str, Dict[str, str]]:
|
||||
# First, collect all the styles from front to back
|
||||
style_list = []
|
||||
current_config = config
|
||||
current_config: Optional[TransparentConfig] = config
|
||||
while current_config is not None:
|
||||
try:
|
||||
style_list.append(current_config.get("styles"))
|
||||
|
|
@ -117,7 +211,7 @@ class EuphLoader(TreeLoader):
|
|||
styles: Dict[str, Dict[str, str]],
|
||||
) -> None:
|
||||
|
||||
for name in self.STYLE_PROPERTIES:
|
||||
for name in self._styles:
|
||||
style_name = config.get(name)
|
||||
if style_name not in styles:
|
||||
raise ConfigValueException((f"style {style_name!r} is not"
|
||||
|
|
|
|||
|
|
@ -225,7 +225,23 @@ class RoomWidget(urwid.WidgetWrap):
|
|||
# These functions use (or rather: will use) self._conf.
|
||||
|
||||
def _create_euph_renderer(self) -> EuphRenderer:
|
||||
return EuphRenderer("")
|
||||
return EuphRenderer(
|
||||
"",
|
||||
show_year=self.c.show_year,
|
||||
show_seconds=self.c.show_seconds,
|
||||
meta_attrs={"style": self.c.meta_style},
|
||||
surround_left=self.c.surround_left,
|
||||
surround_right=self.c.surround_right,
|
||||
surround_attrs={"style": self.c.surround_style},
|
||||
cursor_surround_left=self.c.cursor_surround_left,
|
||||
cursor_surround_right=self.c.cursor_surround_right,
|
||||
cursor_surround_attrs={"style": self.c.cursor_surround_style},
|
||||
cursor_own_nick_attrs={"style":self.c.cursor_own_nick_style},
|
||||
cursor_fill=self.c.cursor_fill_char,
|
||||
cursor_fill_attrs={"style": self.c.cursor_fill_style},
|
||||
nick_attrs={"style": self.c.nick_style},
|
||||
own_nick_attrs={"style": self.c.own_nick_style},
|
||||
)
|
||||
|
||||
def _create_connecting_widget(self) -> Any:
|
||||
text = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue