Skip to content

Commit e040ee1

Browse files
committed
initial commit.
1 parent e90c20d commit e040ee1

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

zulipterminal/model.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import imp
12
import json
23
import time
34
from collections import OrderedDict, defaultdict
@@ -54,6 +55,7 @@
5455
)
5556
from zulipterminal.platform_code import notify
5657
from zulipterminal.ui_tools.utils import create_msg_box_list
58+
from zulipterminal.platform_code import notify #FIXME
5759

5860

5961
OFFLINE_THRESHOLD_SECS = 140
@@ -303,7 +305,12 @@ def set_narrow(
303305
raise RuntimeError("Model.set_narrow parameters used incorrectly.")
304306

305307
if new_narrow != self.narrow:
308+
if self.stream_id:
309+
last_active_button = self.controller.view.stream_id_to_button[self.stream_id]
310+
last_active_button.mark_inactive()
306311
self.narrow = new_narrow
312+
stream_button = self.controller.view.stream_id_to_button[self.stream_id_from_name(stream)]
313+
stream_button.mark_active()
307314

308315
if pm_with is not None and new_narrow[0][0] == "pm_with":
309316
users = pm_with.split(", ")

zulipterminal/themes/gruvbox_dark.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
'area:error' : (Color.DARK0_HARD, Color.BRIGHT_RED),
7171
'area:user' : (Color.DARK0_HARD, Color.BRIGHT_YELLOW),
7272
'search_error' : (Color.BRIGHT_RED, Color.DARK0_HARD),
73+
'stream_active' : (Color.DARK0_HARD, Color.BRIGHT_GREEN),
7374
'task:success' : (Color.DARK0_HARD, Color.BRIGHT_GREEN),
7475
'task:error' : (Color.DARK0_HARD, Color.BRIGHT_RED),
7576
'task:warning' : (Color.DARK0_HARD, Color.NEUTRAL_PURPLE),

zulipterminal/themes/zt_blue.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
'area:error' : (Color.WHITE, Color.DARK_RED),
6565
'area:user' : (Color.WHITE, Color.DARK_BLUE),
6666
'search_error' : (Color.LIGHT_RED, Color.LIGHT_BLUE),
67+
'stream_active' : (Color.WHITE, Color.DARK_GREEN),
6768
'task:success' : (Color.WHITE, Color.DARK_GREEN),
6869
'task:error' : (Color.WHITE, Color.DARK_RED),
6970
'task:warning' : (Color.WHITE, Color.BROWN),

zulipterminal/themes/zt_dark.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
'area:error' : (Color.WHITE, Color.DARK_RED),
6565
'area:user' : (Color.WHITE, Color.DARK_BLUE),
6666
'search_error' : (Color.LIGHT_RED, Color.BLACK),
67+
'stream_active' : (Color.WHITE, Color.DARK_GREEN),
6768
'task:success' : (Color.WHITE, Color.DARK_GREEN),
6869
'task:error' : (Color.WHITE, Color.DARK_RED),
6970
'task:warning' : (Color.WHITE, Color.BROWN),

zulipterminal/themes/zt_light.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
'area:error' : (Color.BLACK, Color.LIGHT_RED),
6565
'area:user' : (Color.WHITE, Color.DARK_BLUE),
6666
'search_error' : (Color.LIGHT_RED, Color.WHITE),
67+
'stream_active' : (Color.BLACK, Color.DARK_GREEN),
6768
'task:success' : (Color.BLACK, Color.DARK_GREEN),
6869
'task:error' : (Color.WHITE, Color.DARK_RED),
6970
'task:warning' : (Color.BLACK, Color.YELLOW),

zulipterminal/ui_tools/buttons.py

+18
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ def update_widget(
8282
self.button_suffix.set_text(suffix)
8383
self._w.set_attr_map({None: text_color})
8484

85+
def update_widget_highlight(
86+
self, highlight_style: str
87+
) -> None:
88+
self.original_color = highlight_style
89+
8590
def activate(self, key: Any) -> None:
8691
self.controller.view.show_left_panel(visible=False)
8792
self.controller.view.show_right_panel(visible=False)
@@ -223,6 +228,11 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
223228
self.model.controller.show_stream_info(self.stream_id)
224229
return super().keypress(size, key)
225230

231+
def mark_active(self) -> None:
232+
self.update_widget_highlight("stream_active")
233+
234+
def mark_inactive(self) -> None:
235+
self.update_widget_highlight("header")
226236

227237
class UserButton(TopButton):
228238
def __init__(
@@ -418,6 +428,14 @@ def update_widget(self, caption: str, display_attr: Optional[str] = None) -> Non
418428
# Set cursor position next to len(caption) to avoid the cursor.
419429
icon = urwid.SelectableIcon(caption, cursor_position=len(caption) + 1)
420430
self._w = urwid.AttrMap(icon, display_attr, focus_map="selected")
431+
432+
def update_widget_highlight(
433+
self, highlight: str
434+
) -> None:
435+
"""
436+
Highlight the active stream/topic button
437+
"""
438+
self.original_color = highlight
421439

422440
def handle_link(self, *_: Any) -> None:
423441
"""

0 commit comments

Comments
 (0)