# Path: Interface/CmdIntf/functionhandler.py
# class FunctionHandler(object):
#     '''
#         This object contains all known commands.
#         Commands are registered by "registerCommand" before the are available.
#         Evaluation of commands or expressions is done by "evaluate"
#     '''
#     def __init__(self, edit_ctrl, edit_output):
#         '''
#             Defines an dictionary containing all known commands.
#             Member 'registerCommand' add's a command to the table.
#             Member 'evaluate' execute a command by call its call-back or evaluates an expression.
#         '''
#         # Input control
#         self.__edit_ctrl = edit_ctrl
#         # Output Control
#         self.__edit_output=edit_output
#         # current value
#         self._value = None
#         # command table
#         self._command_table = {}
#         # Global inner command evaluation
#         self.evaluateInner=None
#         #Evaluator
#         self._eval=Evaluator(self.printCommand)
# 
#         
#     def registerCommand(self, name, callback):
#         '''
#         Register a command with it's callback in the command table.
#         Commands are executed by a call to the evaluate function.
#         '''
#         # a command is at least one character
#         if len(name) > 0:
#             # the callback is not None
#             if not callback is None:
#                 # commands are always defined in upper case
#                 self._command_table[name.upper()] = callback
# 
#     def evaluate(self, expression):
#         '''
#             Looks up the expression from the command table.
#             If a command is found, it's callback function is called.
#             If it is not a command the expression is evaluated.
#             Return: command exit, the evaluated expression or "*error*"
#         '''
#         # commands are always defined in upper case
#         command = expression.upper()
#         # is it a command from the command table?
#         self.__edit_ctrl.clear()
#         # if self._command_table.has_key(command):    # Interface command evaluation
#         if command in self._command_table:
#             # call function
#             # echo on the comand line
#             self.printCommand(command)
#             self._value = self._command_table[command]()
#         else:
#             try:
#                 # let python evaluate expression
#                 self.printCommand(expression)
#                 self._value = self._eval.evaluate(expression)
#             except:
#                 self._value ="*error*"
#             finally:
#                 self.__edit_ctrl.clear()
#         # show result
#         if self._value :
#             self.printOutput(self._value)
#         return self._value
#             
#     def resetCommand(self, reflect=True):
#         """
#             reset the command if eny are set
#         """
#         if reflect:
#             self.printOutput("Command Ended from the user")
#         
#     def printCommand(self, msg):
#         """
#             print message
#         """
#         msg=str(msg)
#         if len(msg)>0:
#             msg=u">>> "+msg
#             self.__edit_output.printMsg(msg)
#         
#     def printOutput(self, msg):
#         """
#             print a message in the output message windows
#         """
#         msg=str(msg)
#         if len(msg)>0:
#             msg=u"<PythonCAD> : "+msg
#             self.__edit_output.printMsg(msg)


import sip
from PyQt5 import QtCore, QtGui, QtWidgets
from Interface.CmdIntf.functionhandler import FunctionHandler
from Kernel.pycadevent import PyCadEvent
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Ignored)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.dockWidgetContents.sizePolicy().hasHeightForWidth())
        self.dockWidgetContents.setSizePolicy(sizePolicy)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        
        self.textEditOutput = PyCadTextView(self.dockWidgetContents)
        
        self.verticalLayout_2.addWidget(self.textEditOutput)
        self.__edit_ctrl = QtWidgets.QLineEdit(self, returnPressed=self._returnPressed)
        self.__edit_ctrl.keyPressEvent = self._keyPress
        
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.textEditOutput.sizePolicy().hasHeightForWidth())
        self.__edit_ctrl.setSizePolicy(sizePolicy)
        self.verticalLayout_2.addWidget(self.__edit_ctrl)
        self.setWidget(self.dockWidgetContents)
        self.__function_handler = FunctionHandler(self.__edit_ctrl,self.textEditOutput )
        #QtCore.QObject.connect(self.__edit_ctrl, QtCore.SIGNAL("returnPressed()"), self.textEditOutput.centerCursor)
        #
        self.evaluatePressed = PyCadEvent()
        
        self.setObjectName("CmdLineDock") #this is needed for remember toolbar position in cadwindow.writesettings(savestate)
        
    #-------- properties -----------#
    @property

# Path: Interface/CmdIntf/functionhandler.py
# class FunctionHandler(object):
#     '''
#         This object contains all known commands.
#         Commands are registered by "registerCommand" before the are available.
#         Evaluation of commands or expressions is done by "evaluate"
#     '''
#     def __init__(self, edit_ctrl, edit_output):
#         '''
#             Defines an dictionary containing all known commands.
#             Member 'registerCommand' add's a command to the table.
#             Member 'evaluate' execute a command by call its call-back or evaluates an expression.
#         '''
#         # Input control
#         self.__edit_ctrl = edit_ctrl
#         # Output Control
#         self.__edit_output=edit_output
#         # current value
#         self._value = None
#         # command table
#         self._command_table = {}
#         # Global inner command evaluation
#         self.evaluateInner=None
#         #Evaluator
#         self._eval=Evaluator(self.printCommand)
# 
#         
#     def registerCommand(self, name, callback):
#         '''
#         Register a command with it's callback in the command table.
#         Commands are executed by a call to the evaluate function.
#         '''
#         # a command is at least one character
#         if len(name) > 0:
#             # the callback is not None
#             if not callback is None:
#                 # commands are always defined in upper case
#                 self._command_table[name.upper()] = callback
# 
#     def evaluate(self, expression):
#         '''
#             Looks up the expression from the command table.
#             If a command is found, it's callback function is called.
#             If it is not a command the expression is evaluated.
#             Return: command exit, the evaluated expression or "*error*"
#         '''
#         # commands are always defined in upper case
#         command = expression.upper()
#         # is it a command from the command table?
#         self.__edit_ctrl.clear()
#         # if self._command_table.has_key(command):    # Interface command evaluation
#         if command in self._command_table:
#             # call function
#             # echo on the comand line
#             self.printCommand(command)
#             self._value = self._command_table[command]()
#         else:
#             try:
#                 # let python evaluate expression
#                 self.printCommand(expression)
#                 self._value = self._eval.evaluate(expression)
#             except:
#                 self._value ="*error*"
#             finally:
#                 self.__edit_ctrl.clear()
#         # show result
#         if self._value :
#             self.printOutput(self._value)
#         return self._value
#             
#     def resetCommand(self, reflect=True):
#         """
#             reset the command if eny are set
#         """
#         if reflect:
#             self.printOutput("Command Ended from the user")
#         
#     def printCommand(self, msg):
#         """
#             print message
#         """
#         msg=str(msg)
#         if len(msg)>0:
#             msg=u">>> "+msg
#             self.__edit_output.printMsg(msg)
#         
#     def printOutput(self, msg):
#         """
#             print a message in the output message windows
#         """
#         msg=str(msg)
#         if len(msg)>0:
#             msg=u"<PythonCAD> : "+msg
#             self.__edit_output.printMsg(msg)


# Path: Interface/CmdIntf/cmdlinedock.py
import sip
from PyQt5 import QtCore, QtGui, QtWidgets
from Interface.CmdIntf.functionhandler import FunctionHandler
from Kernel.pycadevent import PyCadEvent

        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Ignored)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.dockWidgetContents.sizePolicy().hasHeightForWidth())
        self.dockWidgetContents.setSizePolicy(sizePolicy)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        
        self.textEditOutput = PyCadTextView(self.dockWidgetContents)
        
        self.verticalLayout_2.addWidget(self.textEditOutput)
        self.__edit_ctrl = QtWidgets.QLineEdit(self, returnPressed=self._returnPressed)
        self.__edit_ctrl.keyPressEvent = self._keyPress
        
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.textEditOutput.sizePolicy().hasHeightForWidth())
        self.__edit_ctrl.setSizePolicy(sizePolicy)
        self.verticalLayout_2.addWidget(self.__edit_ctrl)
        self.setWidget(self.dockWidgetContents)
        self.__function_handler = FunctionHandler(self.__edit_ctrl,self.textEditOutput )
        #QtCore.QObject.connect(self.__edit_ctrl, QtCore.SIGNAL("returnPressed()"), self.textEditOutput.centerCursor)
        #
        self.evaluatePressed = PyCadEvent()
        
        self.setObjectName("CmdLineDock") #this is needed for remember toolbar position in cadwindow.writesettings(savestate)
        
    #-------- properties -----------#
    @property

    def FunctionHandler(self):