Skip to content

Commit cf0e4ed

Browse files
committed
enhancement: boxes: Re Stream marker colors rendered.
Style improvements: * Stream prefixes' color rendered. * The topic prefix is not rendered to make equivalence with the webapp. Tests updated and added (marker/color rendering). Partially fixes #783.
1 parent 61ae97d commit cf0e4ed

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tests/ui_tools/test_boxes.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ def test__stream_box_autocomplete(self, mocker, write_box, text, state,
315315
matching_streams)
316316

317317
@pytest.mark.parametrize([
318-
'stream_name', 'stream_id', 'expected_marker', 'is_valid_stream'], [
319-
('Secret stream', 99, STREAM_MARKER_PRIVATE, True),
320-
('Stream 1', 1, STREAM_MARKER_PUBLIC, True),
321-
('Stream 0', 0, STREAM_MARKER_INVALID, False),
318+
'stream_name',
319+
'stream_id',
320+
'expected_marker',
321+
'is_valid_stream',
322+
'expected_color'], [
323+
('Secret stream', 99, STREAM_MARKER_PRIVATE, True, '#ccc'),
324+
('Stream 1', 1, STREAM_MARKER_PUBLIC, True, '#b0a5fd'),
325+
('Stream 0', 0, STREAM_MARKER_INVALID, False, 'general_bar'),
322326
], ids=[
323327
'private_stream',
324328
'public_stream',
@@ -327,7 +331,7 @@ def test__stream_box_autocomplete(self, mocker, write_box, text, state,
327331
def test__set_stream_write_box_style_markers(self, write_box, stream_id,
328332
stream_name, is_valid_stream,
329333
expected_marker, stream_dict,
330-
mocker):
334+
mocker, expected_color):
331335
# FIXME: Needs refactoring?
332336
write_box.model.stream_dict = stream_dict
333337
write_box.stream_id = stream_id
@@ -337,6 +341,7 @@ def test__set_stream_write_box_style_markers(self, write_box, stream_id,
337341
write_box._set_stream_write_box_style(write_box, stream_name)
338342

339343
assert write_box.header_write_box[0].text == expected_marker
344+
assert expected_color in str(write_box.header_write_box[0].get_text())
340345

341346
@pytest.mark.parametrize('text, expected_text', [
342347
('Som', 'Some general stream'),

zulipterminal/ui_tools/boxes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ def stream_box_view(self, stream_id: int, caption: str='', title: str='',
114114
self.title_write_box.set_completer_delims("")
115115

116116
stream_marker = STREAM_MARKER_PUBLIC
117+
color = None
117118
if caption:
119+
color = self.model.stream_dict[self.stream_id]['color']
118120
if self.model.stream_dict[self.stream_id]['invite_only']:
119121
stream_marker = STREAM_MARKER_PRIVATE
120122
self.header_write_box = urwid.Columns([
121-
('pack', urwid.Text(stream_marker)),
123+
('pack', urwid.Text((color, STREAM_MARKER_PUBLIC))),
122124
self.stream_write_box,
123125
('pack', urwid.Text(STREAM_TOPIC_SEPARATOR)),
124126
self.title_write_box], dividechars=1)
@@ -146,14 +148,16 @@ def _set_stream_write_box_style(self, widget: ReadlineEdit,
146148
new_text: str) -> None:
147149
# FIXME: Needs refactoring?
148150
stream_marker = STREAM_MARKER_INVALID
151+
color = 'general_bar'
149152
if self.model.is_valid_stream(new_text):
150153
stream = self.model.stream_dict[
151154
self.model.stream_id_from_name(new_text)]
152155
if stream['invite_only']:
153156
stream_marker = STREAM_MARKER_PRIVATE
154157
else:
155158
stream_marker = STREAM_MARKER_PUBLIC
156-
self.header_write_box[0].set_text(stream_marker)
159+
color = stream['color']
160+
self.header_write_box[0].set_text((color, stream_marker))
157161

158162
def _topic_box_autocomplete(self, text: str, state: Optional[int]
159163
) -> Optional[str]:

0 commit comments

Comments
 (0)