Added Option Classes.

This commit is contained in:
Andrew Bastien 2019-04-11 10:12:16 -04:00
parent 1678db2435
commit 5bc9a42bb5
9 changed files with 472 additions and 66 deletions

View file

@ -883,14 +883,15 @@ class CmdStyle(COMMAND_DEFAULT_CLASS):
self.set()
def list_styles(self):
styles_table = self.style_table('Option', 'Description', 'Type', 'Value')
for k, v in self.account.option.options_dict.items():
styles_table.add_row(k, v[0], v[1], v[2])
styles_table = self.style_table('Option', 'Description', 'Type', 'Value', width=78)
for op_key in self.account.options.options_dict.keys():
op_found = self.account.options.get(op_key, return_obj=True)
styles_table.add_row(op_key, op_found.description, op_found.expect_type, op_found.display())
self.msg(str(styles_table))
def set(self):
try:
result = self.account.option.set(self.lhs, self.rhs)
result = self.account.options.set(self.lhs, self.rhs, account=self.account)
except ValueError as e:
self.msg(str(e))
return

View file

@ -236,8 +236,8 @@ class MuxCommand(Command):
return self.session.protocol_flags['SCREENWIDTH'][0]
def style_table(self, *args, **kwargs):
border_color = self.account.option.get('border_color')
column_color = self.account.option.get('column_names_color')
border_color = self.account.options.get('border_color')
column_color = self.account.options.get('column_names_color')
colornames = ['|%s%s|n' % (column_color, col) for col in args]
@ -267,9 +267,9 @@ class MuxCommand(Command):
def render_header(self, header_text=None, fill_character=None, edge_character=None,
mode='header', color_header=True):
colors = dict()
colors['border'] = self.account.option.get('border_color')
colors['headertext'] = self.account.option.get('%s_text_color' % mode)
colors['headerstar'] = self.account.option.get('%s_star_color' % mode)
colors['border'] = self.account.options.get('border_color')
colors['headertext'] = self.account.options.get('%s_text_color' % mode)
colors['headerstar'] = self.account.options.get('%s_star_color' % mode)
width = self.width()
if edge_character:
@ -288,7 +288,7 @@ class MuxCommand(Command):
else:
center_string = ''
fill_character = self.account.option.get('%s_fill' % mode)
fill_character = self.account.options.get('%s_fill' % mode)
remain_fill = width - len(center_string)
if remain_fill % 2 == 0: