Example #1
0
 def __init__(self, document):
     """Create the View for the given document."""
     super(View, self).__init__()
     # to enable mouseMoveEvent to display tooltip
     super(View, self).setMouseTracking(True)
     self.setDocument(document)
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     self.setCursorWidth(2)
     # restore saved cursor position (defaulting to 0)
     document.loaded.connect(self.restoreCursor)
     document.loaded.connect(self.setTabWidth)
     document.closed.connect(self.slotDocumentClosed)
     self.textChanged.connect(self.invalidateCurrentBlock)
     variables.manager(document).changed.connect(self.setTabWidth)
     self.restoreCursor()
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()  # will also call updateCursor
     # line wrap preference is only read on init
     wrap = QSettings().value("view_preferences/wrap_lines", False, bool)
     self.setLineWrapMode(
         QPlainTextEdit.WidgetWidth if wrap else QPlainTextEdit.NoWrap)
     self.installEventFilter(cursorkeys.handler)
     self.toolTipInfo = []
     self.block_at_mouse = None
     self.include_target = []
     app.viewCreated(self)
Example #2
0
 def __init__(self, document):
     """Create the View for the given document."""
     super(View, self).__init__()
     # to enable mouseMoveEvent to display tooltip
     super(View, self).setMouseTracking(True)
     self.setDocument(document)
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     self.setCursorWidth(2)
     # restore saved cursor position (defaulting to 0)
     document.loaded.connect(self.restoreCursor)
     document.loaded.connect(self.setTabWidth)
     document.closed.connect(self.slotDocumentClosed)
     self.textChanged.connect(self.invalidateCurrentBlock)
     variables.manager(document).changed.connect(self.setTabWidth)
     self.restoreCursor()
     app.settingsChanged.connect(self.readSettings)
     self.readSettings() # will also call updateCursor
     # line wrap preference is only read on init
     wrap = QSettings().value("view_preferences/wrap_lines", False, bool)
     self.setLineWrapMode(QPlainTextEdit.WidgetWidth if wrap else QPlainTextEdit.NoWrap)
     self.installEventFilter(cursorkeys.handler)
     self.toolTipInfo = []
     self.block_at_mouse = None
     self.include_target = []
     app.viewCreated(self)
Example #3
0
 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
     self._fridge = ly.lex.Fridge()
     app.settingsChanged.connect(self.rehighlight)
     self._highlighting = metainfo.info(document).highlighting
     document.loaded.connect(self._resetHighlighting)
     self._mode = documentinfo.mode(document, False)
     variables.manager(document).changed.connect(self._variablesChange)
Example #4
0
 def __init__(self, document):
     """Creates the View for the given document."""
     super(View, self).__init__()
     self.setDocument(document)
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     self.setCursorWidth(2)
     # restore saved cursor position (defaulting to 0)
     document.loaded.connect(self.restoreCursor)
     document.loaded.connect(self.setTabWidth)
     document.closed.connect(self.slotDocumentClosed)
     variables.manager(document).changed.connect(self.setTabWidth)
     self.restoreCursor()
     app.settingsChanged.connect(self.readSettings)
     self.readSettings() # will also call updateCursor
     app.viewCreated(self)
Example #5
0
 def lydocinfo(self):
     """Return the lydocinfo instance for our document."""
     if self._lydocinfo is None:
         doc = lydocument.Document(self.document())
         v = variables.manager(self.document()).variables()
         self._lydocinfo = lydocinfo.DocInfo(doc, v)
     return self._lydocinfo
Example #6
0
 def initializeDocument(self):
     """This method is always called by the __init__ method.
     
     The default implementation does nothing for generic QTextDocuments,
     but for document.Document instances it connects to some additional
     signals to keep the mode up-to-date (reading it from the variables if
     needed) and initializes whether to enable visual highlighting from the
     document's metainfo.
     
     """
     document = self.document()
     if hasattr(document, "url"):
         self._highlighting = metainfo.info(document).highlighting
         document.loaded.connect(self._resetHighlighting)
         self._mode = documentinfo.mode(document, False)
         variables.manager(document).changed.connect(self._variablesChange)
Example #7
0
 def initializeDocument(self):
     """This method is always called by the __init__ method.
     
     The default implementation does nothing for generic QTextDocuments,
     but for document.Document instances it connects to some additional
     signals to keep the mode up-to-date (reading it from the variables if
     needed) and initializes whether to enable visual highlighting from the
     document's metainfo.
     
     """
     document = self.document()
     if hasattr(document, 'url'):
         self._highlighting = metainfo.info(document).highlighting
         document.loaded.connect(self._resetHighlighting)
         self._mode = documentinfo.mode(document, False)
         variables.manager(document).changed.connect(self._variablesChange)
Example #8
0
 def __init__(self, document):
     """Creates the View for the given document."""
     super(View, self).__init__()
     self.setDocument(document)
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     self.setCursorWidth(2)
     # restore saved cursor position (defaulting to 0)
     document.loaded.connect(self.restoreCursor)
     document.loaded.connect(self.setTabWidth)
     document.closed.connect(self.slotDocumentClosed)
     variables.manager(document).changed.connect(self.setTabWidth)
     self.restoreCursor()
     app.settingsChanged.connect(self.readSettings)
     self.readSettings() # will also call updateCursor
     # line wrap preference is only read on init
     wrap = QSettings().value("view_preferences/wrap_lines", False, bool)
     self.setLineWrapMode(QPlainTextEdit.WidgetWidth if wrap else QPlainTextEdit.NoWrap)
     app.viewCreated(self)
Example #9
0
 def __init__(self, document):
     """Creates the View for the given document."""
     super(View, self).__init__()
     self.setDocument(document)
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     self.setCursorWidth(2)
     # restore saved cursor position (defaulting to 0)
     document.loaded.connect(self.restoreCursor)
     document.loaded.connect(self.setTabWidth)
     document.closed.connect(self.slotDocumentClosed)
     variables.manager(document).changed.connect(self.setTabWidth)
     self.restoreCursor()
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()  # will also call updateCursor
     # line wrap preference is only read on init
     wrap = QSettings().value("view_preferences/wrap_lines", False, bool)
     self.setLineWrapMode(
         QPlainTextEdit.WidgetWidth if wrap else QPlainTextEdit.NoWrap)
     app.viewCreated(self)
Example #10
0
 def lydocinfo(self):
     """Return the lydocinfo instance for our document."""
     try:
         return self._lydocinfo
     except AttributeError:
         doc = lydocument.Document(self.document())
         v = variables.manager(self.document()).variables()
         info = self._lydocinfo = lydocinfo.DocInfo(doc, v)
         self.document().contentsChanged.connect(self._reset)
         self.document().closed.connect(self._reset)
         return info