FlatCAMShell.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. import termwidget
  9. class FCShell(termwidget.TermWidget):
  10. def __init__(self, sysShell, *args):
  11. termwidget.TermWidget.__init__(self, *args)
  12. self._sysShell = sysShell
  13. def is_command_complete(self, text):
  14. def skipQuotes(text):
  15. quote = text[0]
  16. text = text[1:]
  17. endIndex = str(text).index(quote)
  18. return text[endIndex:]
  19. while text:
  20. if text[0] in ('"', "'"):
  21. try:
  22. text = skipQuotes(text)
  23. except ValueError:
  24. return False
  25. text = text[1:]
  26. return True
  27. def child_exec_command(self, text):
  28. self._sysShell.exec_command(text)