Skip to content

Commit 4ad544b

Browse files
committed
core/themes: Add title color styling; Add Category-wise colors.
This commit adds: * color-per-category for each popup box * A sementic option in show_pop_up function call The categories as of now are help, error, message and stream. Fixes #684.
1 parent 305b8b7 commit 4ad544b

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

zulipterminal/config/themes.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
'edit_author': 'bold',
4545
'edit_time': 'bold',
4646
'popup_border': 'standout',
47-
'popup_title': 'bold',
47+
'area:help': 'standout',
48+
'area:msg': 'standout',
49+
'area:stream': 'standout',
50+
'area:error': 'standout',
4851
}
4952

5053

@@ -173,10 +176,16 @@
173176
None, DEF['white'], DEF['black']),
174177
('muted', 'light blue', 'black',
175178
None, DEF['light_blue'], DEF['black']),
176-
('popup_title', 'black', 'white',
177-
None, DEF['black'], DEF['white']),
178179
('popup_border', 'white', 'black',
179180
None, DEF['white'], DEF['black']),
181+
('area:help', 'white', 'dark green',
182+
None, DEF['white'], DEF['dark_green']),
183+
('area:msg', 'white', 'brown',
184+
None, DEF['white'], DEF['brown']),
185+
('area:stream', 'white', 'dark cyan',
186+
None, DEF['white'], DEF['dark_cyan']),
187+
('area:error', 'white', 'dark red',
188+
None, DEF['white'], DEF['dark_red']),
180189
],
181190
'gruvbox_dark': [
182191
# default colorscheme on 16 colors, gruvbox colorscheme
@@ -257,10 +266,16 @@
257266
None, WHITE, BLACK),
258267
('muted', 'light blue', 'black',
259268
None, LIGHTBLUE, BLACK),
260-
('popup_title', 'black', 'white',
261-
None, BLACK, WHITE),
262269
('popup_border', 'white', 'black',
263270
None, WHITE, BLACK),
271+
('area:help', 'black', 'light green',
272+
None, BLACK, LIGHTGREEN),
273+
('area:msg', 'black', 'light red',
274+
None, BLACK, LIGHTRED),
275+
('area:stream', 'black', 'light blue',
276+
None, BLACK, LIGHTBLUE),
277+
('area:error', 'white', 'dark red',
278+
None, WHITE, DARKRED),
264279
],
265280
'zt_light': [
266281
(None, 'black', 'white'),
@@ -301,8 +316,11 @@
301316
('edit_time', 'dark blue', 'white'),
302317
('current_user', 'dark gray', 'white'),
303318
('muted', 'dark gray', 'white'),
304-
('popup_title', 'white', 'black'),
305319
('popup_border', 'black', 'white'),
320+
('area:help', 'white', 'dark green'),
321+
('area:stream', 'white', 'dark cyan'),
322+
('area:msg', 'white', 'brown'),
323+
('area:error', 'white', 'dark red'),
306324
],
307325
'zt_blue': [
308326
(None, 'black', 'light blue'),
@@ -343,8 +361,11 @@
343361
('edit_time', 'dark blue', 'light blue'),
344362
('current_user', 'light gray', 'light blue'),
345363
('muted', 'light gray', 'light blue'),
346-
('popup_title', 'light blue', 'white'),
347364
('popup_border', 'white', 'light blue'),
365+
('area:help', 'white', 'dark green'),
366+
('area:stream', 'white', 'dark cyan'),
367+
('area:msg', 'white', 'brown'),
368+
('area:error', 'white', 'dark red'),
348369
]
349370
} # type: Dict[str, ThemeSpec]
350371

zulipterminal/core.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@ def maximum_popup_dimensions(self) -> Tuple[int, int]:
161161
self.loop.screen.get_cols_rows())
162162
return max_cols, max_rows
163163

164-
def show_pop_up(self, to_show: Any) -> None:
164+
def show_pop_up(self, to_show: Any, category: str) -> None:
165165
border_lines = dict(tlcorner='▛', tline='▀', trcorner='▜',
166166
rline='▐', lline='▌',
167167
blcorner='▙', bline='▄', brcorner='▟')
168168
text = urwid.Text(to_show.title, align='center')
169-
title_map = urwid.AttrMap(urwid.Filler(text), 'popup_title')
169+
title_map = urwid.AttrMap(urwid.Filler(text), category)
170170
title_box_adapter = urwid.BoxAdapter(title_map, height=1)
171171
title_box = urwid.LineBox(
172172
title_box_adapter, tlcorner='▀', tline='▀', trcorner='▀',
173173
rline='', lline='', blcorner='', bline='', brcorner=''
174174
)
175-
title = urwid.AttrMap(title_box, 'popup_title')
175+
title = urwid.AttrMap(title_box, category)
176176
content = urwid.LineBox(to_show, **border_lines)
177177
self.loop.widget = urwid.Overlay(
178178
urwid.AttrMap(urwid.Frame(header=title, body=content),
@@ -191,10 +191,10 @@ def exit_popup(self) -> None:
191191

192192
def show_help(self) -> None:
193193
help_view = HelpView(self, "Help Menu (up/down scrolls)")
194-
self.show_pop_up(help_view)
194+
self.show_pop_up(help_view, 'area:help')
195195

196196
def show_topic_edit_mode(self, button: Any) -> None:
197-
self.show_pop_up(EditModeView(self, button))
197+
self.show_pop_up(EditModeView(self, button), 'area:msg')
198198

199199
def show_msg_info(self, msg: Message,
200200
message_links: 'OrderedDict[str, Tuple[str, int, bool]]',
@@ -203,14 +203,15 @@ def show_msg_info(self, msg: Message,
203203
msg_info_view = MsgInfoView(self, msg,
204204
"Message Information (up/down scrolls)",
205205
message_links, time_mentions)
206-
self.show_pop_up(msg_info_view)
206+
self.show_pop_up(msg_info_view, 'area:msg')
207207

208208
def show_stream_info(self, stream_id: int) -> None:
209209
show_stream_view = StreamInfoView(self, stream_id)
210-
self.show_pop_up(show_stream_view)
210+
self.show_pop_up(show_stream_view, 'area:stream')
211211

212212
def popup_with_message(self, text: str, width: int) -> None:
213-
self.show_pop_up(NoticeView(self, text, width, "NOTICE"))
213+
self.show_pop_up(NoticeView(self, text, width, "NOTICE"),
214+
'area:error')
214215

215216
def show_about(self) -> None:
216217
self.show_pop_up(
@@ -219,7 +220,8 @@ def show_about(self) -> None:
219220
server_feature_level=self.model.server_feature_level,
220221
theme_name=self.theme_name, color_depth=self.color_depth,
221222
autohide_enabled=self.autohide,
222-
footlink_enabled=self.footlinks_enabled)
223+
footlink_enabled=self.footlinks_enabled),
224+
'area:help'
223225
)
224226

225227
def show_edit_history(
@@ -229,7 +231,8 @@ def show_edit_history(
229231
) -> None:
230232
self.show_pop_up(
231233
EditHistoryView(self, message, message_links, time_mentions,
232-
'Edit History (up/down scrolls)')
234+
'Edit History (up/down scrolls)'),
235+
'area:msg'
233236
)
234237

235238
def search_messages(self, text: str) -> None:

0 commit comments

Comments
 (0)