- aligned the Tcl commands display when the Help Tcl command is run without parameters

This commit is contained in:
Marius Stanciu 2020-04-23 03:10:03 +03:00 committed by Marius
parent 1f36ed9369
commit bfd938e577
2 changed files with 12 additions and 14 deletions

View File

@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
- on launching the Tcl Shell the Edit line will take focus immediately
- in App.on_mouse_move_over_plot() method no longer will be done a setFocus() on every move, only when it is needed
- added an extra check if old preferences files are detected, a check if the type of the values is the same with the type in the current preferences file. If the type is not the same then the current type is preferred.
- aligned the Tcl commands display when the Help Tcl command is run without parameters
22.04.2020

View File

@ -82,31 +82,28 @@ class TclCommandHelp(TclCommand):
curr_len = len(cmd_name)
if curr_len > max_len:
max_len = curr_len
max_tabs = math.ceil(max_len / 8)
h_space = " "
cnt = 0
for cmd_name in sorted(self.app.tcl_commands_storage):
cmd_description = "<span>%s</span>" % self.app.tcl_commands_storage[cmd_name]['description']
curr_len = len(cmd_name)
tabs = '\t'
cmd_name_colored = "<span style=\" font-weight: bold; color: red;\" >%s</span>" % str(cmd_name)
# make sure to add the right number of tabs (1 tab = 8 spaces) so all the commands
# descriptions are aligned
if curr_len == max_len:
cmd_line_txt = ' %s%s%s' % (cmd_name_colored, tabs, cmd_description)
else:
nr_tabs = 0
nr_chars = max_len - curr_len
for x in range(max_tabs):
if curr_len < (x * 8):
nr_tabs += 1
# nr_tabs = 2 if curr_len <= 8 else 1
cmd_line_txt = ' %s%s%s' % (cmd_name_colored, nr_tabs * tabs, cmd_description)
cmd_line_txt = '%s%s&nbsp;&nbsp;%s' % (cmd_name_colored, nr_chars * h_space, cmd_description)
displayed_text.append(cmd_line_txt)
# group commands by 4 adding a line break after 4 commands
if cnt == 3:
cnt = 0
displayed_text.append(' ')
else:
cnt += 1
except Exception as err:
self.app.log.debug("App.setup_shell.shelp() when run as 'help' --> %s" % str(err))
displayed_text = ['> %s\n' % cmd for cmd in sorted(self.app.tcl_commands_storage)]