-
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: Add render_symbols to test symbol rendering.
This commit adds a new folder `scripts/` to ship scripts that are meant for users. This commit also adds a new script that enables users to check how the various symbols listed in `config/symbols.py` render on their terminal emulator. The need for this script has arisen from the observed issues on the Windows Terminal, where with varying fonts, symbol rendering has also varied.
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import sys | ||
|
||
import urwid | ||
from urwid import set_encoding | ||
|
||
from zulipterminal.config import symbols | ||
|
||
|
||
set_encoding('utf-8') | ||
|
||
palette = [ | ||
('header', 'white, bold', 'light blue'), | ||
('footer', 'black', 'white'), | ||
] | ||
|
||
variables = vars(symbols) | ||
symbol_dict = {symbol: variables[symbol] for symbol in variables | ||
if not symbol.startswith('__') and not symbol.endswith('__')} | ||
|
||
symbol_names_list = [urwid.Text(name, align='center') | ||
for name in symbol_dict.keys()] | ||
symbols_list = [urwid.Text(symbol) for symbol in symbol_dict.values()] | ||
|
||
# given_width is hardcoded based on the longest symbol name (26 characters). | ||
# TODO: Update the width if we have a longer name for a symbol. | ||
symbols_display_box = urwid.Columns([ | ||
(27, urwid.Pile(symbol_names_list)), | ||
(3, urwid.Pile(symbols_list)) | ||
], dividechars=9) | ||
|
||
line_box = urwid.LineBox(symbols_display_box, | ||
title="Render Symbols", | ||
title_attr='header') | ||
info_box = urwid.Text(('footer', u" Exit: ^C "), align='center') | ||
display_box = urwid.Pile([ | ||
line_box, | ||
info_box | ||
]) | ||
|
||
# Allot a width of 45 to the display_box. line_box occupies about 39 characters | ||
# so we consider that as a maximum. Use extra width to make it look cleaner. | ||
body = urwid.Filler(urwid.Padding(display_box, align='center', width=45), | ||
valign='middle') | ||
|
||
|
||
def main() -> None: | ||
try: | ||
loop = urwid.MainLoop(body, palette) | ||
loop.run() | ||
finally: | ||
sys.exit(0) |