Add ASCII mode

This commit is contained in:
Dimitri John Ledkov 2019-10-04 16:31:25 +01:00
parent 60a1d88c2e
commit 3f548665e1
2 changed files with 29 additions and 0 deletions

View File

@ -35,12 +35,23 @@ def parse_options(argv):
parser = argparse.ArgumentParser(
description='SUbiquity - Ubiquity for Servers',
prog='subiquity')
try:
ascii_default = os.ttyname(0) == "/dev/ttysclp0"
except OSError:
ascii_default = False
parser.set_defaults(ascii=ascii_default)
parser.add_argument('--dry-run', action='store_true',
dest='dry_run',
help='menu-only, do not call installer function')
parser.add_argument('--serial', action='store_true',
dest='run_on_serial',
help='Run the installer over serial console.')
parser.add_argument('--ascii', action='store_true',
dest='ascii',
help='Run the installer in ascii mode.')
parser.add_argument('--unicode', action='store_false',
dest='ascii',
help='Run the installer in unicode mode.')
parser.add_argument('--machine-config', metavar='CONFIG',
dest='machine_config',
help="Don't Probe. Use probe data file")

View File

@ -164,6 +164,19 @@ def make_screen(colors, is_linux_tty):
return TwentyFourBitScreen(_urwid_name_to_rgb)
def extend_dec_special_charmap():
urwid.escape.DEC_SPECIAL_CHARMAP.update({
ord('\N{BLACK RIGHT-POINTING SMALL TRIANGLE}'): '>',
ord('\N{BLACK LEFT-POINTING SMALL TRIANGLE}'): '<',
ord('\N{BLACK DOWN-POINTING SMALL TRIANGLE}'): 'v',
ord('\N{BLACK UP-POINTING SMALL TRIANGLE}'): '^',
ord('\N{check mark}'): '+',
ord('\N{bullet}'): '*',
ord('\N{lower half block}'): '=',
ord('\N{upper half block}'): '=',
})
class KeyCodesFilter:
"""input_filter that can pass (medium) raw keycodes to the application
@ -567,6 +580,11 @@ class Application:
input_filter=self.input_filter.filter,
unhandled_input=self.unhandled_input)
if self.opts.ascii:
urwid.util.set_encoding('ascii')
extend_dec_special_charmap()
self.toggle_color()
self.base_model = self.make_model()