Beispiel #1
0
    def __init__(self, parent=None):
        """
        Creates the widget.

        :param parent: Optional parent widget
        """
        QWidget.__init__(self, parent)
        StyledObject.__init__(self)
        #: The designer ui (public so that user may access the internal ui (this might be useful for e.g. people who
        #  would to replace the default actions icons)
        self.ui = editor_ui.Ui_Form()
        self.ui.setupUi(self)

        # setup a weakref on the code edit widget
        self.codeEdit.editor = weakref.ref(self)

        #: Map of installed modes
        self.__modes = {}

        #: Map of installed panels
        self.__panels = {}
        self.ui.layoutLeft.setDirection(QBoxLayout.RightToLeft)
        self.ui.layoutTop.setDirection(QBoxLayout.BottomToTop)

        # Maps the ui layouts to a zone key
        self.__zones = {
            self.PANEL_ZONE_TOP:    self.ui.layoutTop,
            self.PANEL_ZONE_BOTTOM: self.ui.layoutBottom,
            self.PANEL_ZONE_LEFT:   self.ui.layoutLeft,
            self.PANEL_ZONE_RIGHT:  self.ui.layoutRight}

        self.__logger = logging.getLogger(
            __name__ + "." + self.__class__.__name__)
Beispiel #2
0
    def __init__(self, name, description):
        """
        Creates the extension.

        :param name: Extension name (used as an identifier)

        :param description: A description of the extension (mainly used for gui (settings about the extension)).
        """
        StyledObject.__init__(self)
        #: Extension name
        self.name = name
        #: Extension description
        self.description = description
        #: Extension enables state (subclasses must implement _onStateChanged to disconnect their slots to
        # disable any actions)
        self.__enabled = False
        #: Editor instance
        self.__editor = None
Beispiel #3
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()