Beispiel #1
0
    def __init__(self, parent, project=None):
        QPlainTextEdit.__init__(self)
        EditorGeneric.__init__(self)
        BaseCentralWidget.__init__(self)
        self.parent = parent
        self.completer = Completer(self, project)
        self.setWordWrapMode(QTextOption.NoWrap)
        doc = self.document()
        option = QTextOption()
        option.setFlags(QTextOption.ShowTabsAndSpaces)
        doc.setDefaultTextOption(option)
        self.setDocument(doc)
        self.set_default_font()

        #file modification time POSIX
        self._mtime = None
        #Flag to dont bug the user when answer 'dont show the modification dialog'
        self.ask_if_externally_modified = True

        self.lineNumberArea = self.LineNumberArea(self)
        self.viewport().installEventFilter(self)

        self.highlighter = None
        styles.set_style(self, 'editor')

        self.connect(self, SIGNAL("cursorPositionChanged()"),
                     self.highlight_current_line)
        self.connect(self, SIGNAL("modificationChanged(bool)"),
                     self.modif_changed)
        self.highlight_current_line()
Beispiel #2
0
    def __init__(self, parent, project=None):
        QPlainTextEdit.__init__(self)
        EditorGeneric.__init__(self)
        BaseCentralWidget.__init__(self)
        self.parent = parent
        self.completer = Completer(self, project)
        self.setWordWrapMode(QTextOption.NoWrap)
        doc = self.document()
        option = QTextOption()
        option.setFlags(QTextOption.ShowTabsAndSpaces)
        doc.setDefaultTextOption(option)
        self.setDocument(doc)
        self.set_default_font()

        #file modification time POSIX
        self._mtime = None
        #Flag to dont bug the user when answer 'dont show the modification dialog'
        self.ask_if_externally_modified = True

        self.lineNumberArea = self.LineNumberArea(self)
        self.viewport().installEventFilter(self)

        self.highlighter = None
        styles.set_style(self, 'editor')

        self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line)
        self.connect(self, SIGNAL("modificationChanged(bool)"), self.modif_changed)
        self.highlight_current_line()
Beispiel #3
0
 def set_flags(self):
     self.setWordWrapMode(QTextOption.NoWrap)
     self.setMouseTracking(True)
     doc = self.document()
     option = QTextOption()
     if settings.SHOW_TABS_AND_SPACES:
         option.setFlags(QTextOption.ShowTabsAndSpaces)
     doc.setDefaultTextOption(option)
     self.setDocument(doc)
     self.setCenterOnScroll(settings.CENTER_ON_SCROLL)
Beispiel #4
0
 def togglewhiteSpace(self, state=True):
     """
     Show or hide whitespace and line ending markers
     """
     option = QTextOption()
     if state:
         option.setFlags(QTextOption.ShowTabsAndSpaces |
                         QTextOption.ShowLineAndParagraphSeparators)
     else:
         option.setFlags(option.flags() & ~option.ShowTabsAndSpaces &
                         ~option.ShowLineAndParagraphSeparators)
     self.document().setDefaultTextOption(option)
     settings.set('editor:whiteSpace', state)
Beispiel #5
0
 def togglewhiteSpace(self, state=True):
     """
     Show or hide whitespace and line ending markers
     """
     option = QTextOption()
     if state:
         option.setFlags(QTextOption.ShowTabsAndSpaces
                         | QTextOption.ShowLineAndParagraphSeparators)
     else:
         option.setFlags(option.flags() & ~option.ShowTabsAndSpaces
                         & ~option.ShowLineAndParagraphSeparators)
     self.document().setDefaultTextOption(option)
     settings.set('editor:whiteSpace', state)
Beispiel #6
0
 def set_flags(self):
     if settings.ALLOW_WORD_WRAP:
         self.setWordWrapMode(QTextOption.WrapAtWordBoundaryOrAnywhere)
     else:
         self.setWordWrapMode(QTextOption.NoWrap)
     self.setMouseTracking(True)
     doc = self.document()
     option = QTextOption()
     if settings.SHOW_TABS_AND_SPACES:
         option.setFlags(QTextOption.ShowTabsAndSpaces)
     doc.setDefaultTextOption(option)
     self.setDocument(doc)
     self.setCenterOnScroll(settings.CENTER_ON_SCROLL)
Beispiel #7
0
 def set_flags(self):
     """Set some configuration flags for the Editor."""
     if settings.ALLOW_WORD_WRAP:
         self.setWordWrapMode(QTextOption.WrapAtWordBoundaryOrAnywhere)
     else:
         self.setWordWrapMode(QTextOption.NoWrap)
     self.setMouseTracking(True)
     doc = self.document()
     option = QTextOption()
     if settings.SHOW_TABS_AND_SPACES:
         option.setFlags(QTextOption.ShowTabsAndSpaces)
     doc.setDefaultTextOption(option)
     self.setDocument(doc)
     self.setCenterOnScroll(settings.CENTER_ON_SCROLL)
	def toggleWhiteSpaces(self):
		"""
		Toggles document white spaces display.

		:return: Method success.
		:rtype: bool
		"""

		textOption = self.getDefaultTextOption()
		if textOption.flags().__int__():
			textOption = QTextOption()
			textOption.setTabStop(self.tabStopWidth())
		else:
			textOption.setFlags(
			textOption.flags() | QTextOption.ShowTabsAndSpaces | QTextOption.ShowLineAndParagraphSeparators)
		self.setDefaultTextOption(textOption)
		return True