Ejemplo n.º 1
0
    def __init__(self):
        # super(CodeEditor, self).__init__()
        QPlainTextEdit.__init__(self)
        self.lineNumberArea = LineNumberArea(self)
        self.setTabStopWidth(20)
        self.blockCountChanged.connect(self.updateLineNumberAreaWidth)
        self.updateRequest.connect(self.updateLineNumberArea)
        self.cursorPositionChanged.connect(self.highlightCurrentLine)
        self.updateLineNumberAreaWidth(0)
        self.highlightCurrentLine()
        self.highlighter = PythonHighlighter(self.document())
        self.dirty = False

        # Determine if the line number area needs to be shown or not
        lineNumbersCheckedState = FreeCAD.ParamGet(
            "User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module"
        ).GetBool("showLineNumbers")
        if lineNumbersCheckedState:
            self.showLineNumberArea()
        else:
            self.hideLineNumberArea()

        # self.overlay = FinderOverlay(self)
        # self.overlay.hide()

        self.initUI()
Ejemplo n.º 2
0
 def __init__(self, title):
     """
     Constructeur.
     Paramétrisation de la console.
     """
     QPlainTextEdit.__init__(self)
     self.setWindowTitle(str(title))
     self.setWindowIcon(QIcon(WINDOW_ICO_PATH))
     self.setReadOnly(True)
     self.show_request.connect(self.show_listener)
Ejemplo n.º 3
0
        def __init__(self, parent, *args):

            QPlainTextEdit.__init__(self, *args)
            self.parent = parent
            self.config_main = self.parent.config_main
            self.config_theme = self.parent.config_theme
            self.tools = self.parent.tools
            self.lvars = self.parent.lvars

            self._loaded = False

            self.setFrameStyle(QFrame.NoFrame)
            self.setLineWrapMode(QPlainTextEdit.NoWrap)

            self._setup_ui()

            self._casts_marked = False
            self._casts_selections = None

            self.cursorPositionChanged.connect(
                self._on_cursor_position_changed)

            self._bracket_info = hrdev_plugin.include.helper.AttributeDict()
            self._bracket_info.saved_bracket = None
            self._bracket_info.depth = 0
            self._bracket_info.seeking_nl = False
            self._bracket_info.open_brackets = ['[', '{', '(']
            self._bracket_info.closed_brackets = [']', '}', ')']
            self._bracket_info.pairs_closed = {']': '[', '}': '{', ')': '('}
            self._bracket_info.pairs_open = {'[': ']', '{': '}', '(': ')'}
            self._bracket_info.ignore_stack_left = []
            self._bracket_info.ignore_stack_right = []

            self._left_selected_bracket = QTextEdit.ExtraSelection()
            self._right_selected_bracket = QTextEdit.ExtraSelection()

            toolTipWidget = QtGui.QLabel()
            toolTipWidget.setStyleSheet(
                "QLabel { background-color : #ffffcc; color : #222; padding: 5px; }"
            )
            toolTipWidget.setFrameShape(QtGui.QFrame.StyledPanel)
            toolTipWidget.setWindowFlags(QtCore.Qt.ToolTip)
            toolTipWidget.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
            toolTipWidget.hide()
            self._toolTipWidget = toolTipWidget

            self._timer = QtCore.QBasicTimer()
            self._timer.start(2000, self)

            self._min_marker_len = self.config_main.getint(
                'editor', 'min_marker_len')
            return
Ejemplo n.º 4
0
        def __init__(self, parent, *args):

            QPlainTextEdit.__init__(self, *args)
            self.parent = parent
            self.config_main = self.parent.config_main
            self.config_theme = self.parent.config_theme
            self.tools = self.parent.tools
            self.lvars = self.parent.lvars

            self._loaded = False

            self.setFrameStyle(QFrame.NoFrame)
            self.setLineWrapMode(QPlainTextEdit.NoWrap)

            self._setup_ui()

            self._casts_marked = False
            self._casts_selections = None

            self.cursorPositionChanged.connect(
                self._on_cursor_position_changed)

            self._bracket_info = hrdev_plugin.include.helper.AttributeDict()
            self._bracket_info.saved_bracket = None
            self._bracket_info.depth = 0
            self._bracket_info.seeking_nl = False
            self._bracket_info.open_brackets = ['[', '{', '(']
            self._bracket_info.closed_brackets = [']', '}', ')']
            self._bracket_info.pairs_closed = {']': '[', '}': '{', ')': '('}
            self._bracket_info.pairs_open = {'[': ']', '{': '}', '(': ')'}
            self._bracket_info.ignore_stack_left = []
            self._bracket_info.ignore_stack_right = []

            self._left_selected_bracket = QTextEdit.ExtraSelection()
            self._right_selected_bracket = QTextEdit.ExtraSelection()

            toolTipWidget = QtGui.QLabel()
            toolTipWidget.setStyleSheet("QLabel { background-color : #ffffcc; color : #222; padding: 5px; }")
            toolTipWidget.setFrameShape(QtGui.QFrame.StyledPanel)
            toolTipWidget.setWindowFlags(QtCore.Qt.ToolTip)
            toolTipWidget.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
            toolTipWidget.hide()
            self._toolTipWidget = toolTipWidget

            self._timer = QtCore.QBasicTimer()
            self._timer.start(2000, self)

            self._min_marker_len = self.config_main.getint('editor',
                                                           'min_marker_len')
            return
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        """
        Creates the widget.

        :param parent: Optional parent widget
        """
        QPlainTextEdit.__init__(self, parent)
        StyledObject.__init__(self)
        #: Tag member used to remeber the filename of the edited text if any
        self.tagFilename = None
        #: Tag member used to remeber the filename of the edited text if any
        self.tagEncoding = 'utf8'
        #: Weakref to the editor
        self.editor = None

        self.__originalText = ""

        #: dirty flag
        self.__dirty = False
        #: our custom context menu
        self.__context_menu = QMenu()
        #: The list of active extra-selections (TextDecoration)
        self.__selections = []
        self.__numBlocks = -1

        self.visible_blocks = []

        #: Shortcut to the fontMetrics
        self.fm = self.fontMetrics()

        self.textChanged.connect(self.__onTextChanged)
        self.blockCountChanged.connect(self.__onBlocksChanged)
        self.verticalScrollBar().valueChanged.connect(self.__onBlocksChanged)
        self.newTextSet.connect(self.__onBlocksChanged)
        self.cursorPositionChanged.connect(self.__onBlocksChanged)
        self.setLineWrapMode(QPlainTextEdit.NoWrap)
        self.setMouseTracking(True)

        self._onStyleChanged()
Ejemplo n.º 6
0
        def __init__(self, parent, *args):

            QPlainTextEdit.__init__(self, *args)
            self.parent = parent
            self.config_main = self.parent.config_main
            self.config_theme = self.parent.config_theme
            self.tools = self.parent.tools

            self._loaded = False

            self.setFrameStyle(QFrame.NoFrame)
            self.setLineWrapMode(QPlainTextEdit.NoWrap)

            self._setup_ui()

            self._casts_marked = False
            self._casts_selections = None

            self.cursorPositionChanged.connect(
                self._on_cursor_position_changed)

            self._bracket_info = include.helper.AttributeDict()
            self._bracket_info.saved_bracket = None
            self._bracket_info.depth = 0
            self._bracket_info.seeking_nl = False
            self._bracket_info.open_brackets = ['[', '{', '(']
            self._bracket_info.closed_brackets = [']', '}', ')']
            self._bracket_info.pairs_closed = {']': '[', '}': '{', ')': '('}
            self._bracket_info.pairs_open = {'[': ']', '{': '}', '(': ')'}
            self._bracket_info.ignore_stack_left = []
            self._bracket_info.ignore_stack_right = []

            self._left_selected_bracket = QTextEdit.ExtraSelection()
            self._right_selected_bracket = QTextEdit.ExtraSelection()

            self._min_marker_len = self.config_main.getint('editor',
                                                           'min_marker_len')
            return
Ejemplo n.º 7
0
 def __init__(self,*args,**kwargs):
     QPlainTextEdit.__init__(self,*args,**kwargs)
Ejemplo n.º 8
0
 def __init__(self, parent=None):
     QPlainTextEdit.__init__(self, parent)
     self.setReadOnly(True)
     self.process = None