Prechádzať zdrojové kódy

- made sure that the Tcl commands descriptions listed on help command are aligned

Marius Stanciu 5 rokov pred
rodič
commit
334a28fb6a
2 zmenil súbory, kde vykonal 29 pridanie a 1 odobranie
  1. 25 1
      FlatCAMApp.py
  2. 4 0
      README.md

+ 25 - 1
FlatCAMApp.py

@@ -11970,10 +11970,34 @@ class App(QtCore.QObject):
 
                 displayed_text = []
                 try:
+                    # find the maximum length of a command name
+                    max_len = 0
+                    for cmd_name in commands:
+                        curr_len = len(cmd_name)
+                        if curr_len > max_len:
+                            max_len = curr_len
+
                     for cmd_name in sorted(commands):
                         cmd_description = commands[cmd_name]['description']
 
-                        cmd_line_txt = ' %s\t\t%s' % (str(cmd_name), cmd_description)
+                        curr_len = len(cmd_name)
+                        tabs = '\t'
+
+                        # 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' % (str(cmd_name), tabs, cmd_description)
+                        else:
+                            max_tabs = math.ceil(max_len/8)
+                            nr_tabs = 0
+
+                            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' % (str(cmd_name), nr_tabs*tabs, cmd_description)
+
                         displayed_text.append(cmd_line_txt)
                 except Exception as err:
                     log.debug("App.setup_shell.shelp() when run as 'help' --> %s" % str(err))

+ 4 - 0
README.md

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+15.04.2020 
+
+- made sure that the Tcl commands descriptions listed on help command are aligned
+
 14.04.2020 
 
 - lightened the hue of the color for 'success' messages printed in the Tcl Shell browser