From cd906491116ec876d89458f0031caa33aeeb465f Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 21 Jun 2019 06:31:37 +0000 Subject: [PATCH] Add even more config options --- cheuph/euphoria/euph_config.py | 74 ++++++++++++++++++++++++++++++---- cheuph/euphoria/room_widget.py | 17 ++++++-- 2 files changed, 81 insertions(+), 10 deletions(-) diff --git a/cheuph/euphoria/euph_config.py b/cheuph/euphoria/euph_config.py index 562e287..a8f2dff 100644 --- a/cheuph/euphoria/euph_config.py +++ b/cheuph/euphoria/euph_config.py @@ -120,11 +120,51 @@ class EuphConfig(TransparentConfig): def indent_cursor_style(self) -> str: return self["visual.indent.cursor.style"] - # other + # scroll @property def scrolloff(self) -> int: - return self["visual.scrolloff"] + return self["visual.scroll.scrolloff"] + + @property + def vertical_scroll(self) -> int: + return self["visual.scroll.vertical"] + + @property + def horizontal_scroll(self) -> int: + return self["visual.scroll.horizontal"] + + @property + def half_page_scroll(self) -> bool: + return self["visual.scroll.half_page"] + + # borders + + @property + def room_name_separator(self) -> str: + return self["visual.borders.room_name_separator"] + + @property + def room_name_split(self) -> str: + return self["visual.borders.room_name_split"] + + @property + def nick_list_separator(self) -> str: + return self["visual.borders.nick_list_separator"] + + @property + def nick_list_split(self) -> str: + return self["visual.borders.nick_list_split"] + + @property + def edit_separator(self) -> str: + return self["visual.borders.edit_separator"] + + @property + def borders_style(self) -> str: + return self["visual.borders.style"] + + # other @property def palette(self) -> Any: @@ -176,8 +216,10 @@ class EuphLoader(TreeLoader): self.add_style("visual.surround.style", "bold") # 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("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", "cursor") self.add_style("visual.cursor.own_nick_style", "cursor") self.add("visual.cursor.fill.char", Kind.STR, " ", self.SINGLE_CHAR) @@ -189,13 +231,31 @@ class EuphLoader(TreeLoader): 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.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) + # scroll + self.add("visual.scroll.scrolloff", Kind.INT, 3, self.AT_LEAST_0) + self.add("visual.scroll.vertical", Kind.INT, 2, self.AT_LEAST_1) + self.add("visual.scroll.horizontal", Kind.INT, 8, self.AT_LEAST_1) + self.add("visual.scroll.half_page", Kind.BOOL, True) + # borders + self.add("visual.borders.room_name_separator", Kind.STR, "═", + self.SINGLE_CHAR) + self.add("visual.borders.room_name_split", Kind.STR, "╤", + self.SINGLE_CHAR) + self.add("visual.borders.nick_list_separator", Kind.STR, "│", + self.SINGLE_CHAR) + self.add("visual.borders.nick_list_split", Kind.STR, "┤", + self.SINGLE_CHAR) + self.add("visual.borders.edit_separator", Kind.STR, "─", + self.SINGLE_CHAR) + self.add_style("visual.borders.style", "gray") + + # other self.add("styles", Kind.DICT, self.DEFAULT_STYLES) def add_style(self, name: str, default: str) -> None: diff --git a/cheuph/euphoria/room_widget.py b/cheuph/euphoria/room_widget.py index ea44c0c..7772df0 100644 --- a/cheuph/euphoria/room_widget.py +++ b/cheuph/euphoria/room_widget.py @@ -287,7 +287,11 @@ class RoomWidget(urwid.WidgetWrap): ) def _create_tree_widget(self) -> Any: - return CursorTreeWidget(self._tree) + return CursorTreeWidget(self._tree, + vertical_scroll_step=self.c.vertical_scroll, + horizontal_scroll_step=self.c.vertical_scroll, + half_page_scroll=self.c.half_page_scroll, + ) def _create_edit_widget(self) -> Any: return urwid.Edit(multiline=True) @@ -301,10 +305,17 @@ class RoomWidget(urwid.WidgetWrap): tree: Any, edit: Any, ) -> Any: - return RoomLayout(room_name, nick_list, tree, edit) + return RoomLayout(room_name, nick_list, tree, edit, + border_attrs={"style": self.c.borders_style}, + room_name_separator=self.c.room_name_separator, + room_name_split=self.c.room_name_split, + nick_list_separator=self.c.nick_list_separator, + nick_list_split=self.c.nick_list_split, + edit_separator=self.c.edit_separator, + ) def _create_edit_nick_widget(self) -> Any: - return EditWidget("Choose a nick: ", "@") + return EditWidget("Choose a nick: ", "@", style=self.c.own_nick_style) ## Room life cycle