Exemple #1
0
import weakref

from PyQt4.QtCore import QEvent, QSettings, Qt, QTimer, pyqtSignal
from PyQt4.QtGui import (
    QApplication, QContextMenuEvent, QKeySequence, QPainter, QPlainTextEdit,
    QTextCursor)

import app
import homekey
import metainfo
import textformats
import cursortools
import variables


metainfo.define('auto_indent', True)
metainfo.define('position', 0)


class View(QPlainTextEdit):
    """View is the text editor widget a Document is displayed and edited with.
    
    It is basically a QPlainTextEdit with some extra features:
    - it draws a grey cursor when out of focus
    - it reads basic palette colors from the preferences
    - it determines tab width from the document variables (defaulting to 8 characters)
    - it stores the cursor position in the metainfo
    - it runs the auto_indenter when enabled (also checked via metainfo)
    - it can display a widget in the bottom using showWidget and hideWidget.
    
    """
Exemple #2
0
from PyQt4.QtGui import QColor, QSyntaxHighlighter, QTextBlockUserData, QTextCharFormat, QTextCursor, QTextDocument


import ly.lex
import ly.colorize

import app
import cursortools
import textformats
import metainfo
import plugin
import variables
import documentinfo


metainfo.define("highlighting", True)


def mapping(data):
    """Return a dictionary mapping token classes from ly.lex to QTextCharFormats.
    
    The QTextFormats are queried from the specified TextFormatData instance.
    The returned dictionary is a ly.colorize.Mapping instance.
    
    """
    return ly.colorize.Mapper(
        (cls, data.textFormat(mode, style.name))
        for mode, styles in ly.colorize.default_mapping()
        for style in styles
        for cls in style.classes
    )
Exemple #3
0
"""
Manages the progress bar in the status bar of ViewSpaces.
"""

from __future__ import unicode_literals

from PyQt4.QtCore import Qt, QTimeLine, QTimer
from PyQt4.QtGui import QProgressBar

import app
import plugin
import jobmanager
import metainfo
import widgets.progressbar

metainfo.define('buildtime', 0.0, float)


class ProgressBar(plugin.ViewSpacePlugin):
    """A Simple progress bar to show a Job is running."""
    def __init__(self, viewSpace):
        bar = self._bar = widgets.progressbar.TimedProgressBar()
        bar.setMaximumHeight(14)
        viewSpace.status.layout().addWidget(bar, 1)
        bar.hide()
        viewSpace.viewChanged.connect(self.viewChanged)
        app.jobStarted.connect(self.jobStarted)
        app.jobFinished.connect(self.jobFinished)
        
    def viewChanged(self, view):
        self.showProgress(view.document())
Exemple #4
0
Manages the progress bar in the status bar of ViewSpaces.
"""

from __future__ import division

from PyQt5.QtCore import Qt, QTimeLine, QTimer
from PyQt5.QtWidgets import QProgressBar

import app
import plugin
import jobmanager
import jobattributes
import metainfo
import widgets.progressbar

metainfo.define('buildtime', 0.0, float)


class ProgressBar(plugin.ViewSpacePlugin):
    """A Simple progress bar to show a Job is running."""
    def __init__(self, viewSpace):
        bar = self._bar = widgets.progressbar.TimedProgressBar()
        viewSpace.status.layout().addWidget(bar, 0, Qt.AlignCenter)
        bar.hide()
        viewSpace.viewChanged.connect(self.viewChanged)
        app.jobStarted.connect(self.jobStarted)
        app.jobFinished.connect(self.jobFinished)

    def viewChanged(self, view):
        self.showProgress(view.document())
Exemple #5
0
import ly.lex
import ly.lex.lilypond
import ly.lex.scheme
import ly.lex.html
import ly.lex.texinfo

import app
import textformats
import metainfo
import plugin
import variables
import documentinfo


metainfo.define('highlighting', True)


def highlighter(document):
    """Returns the Highlighter for this document."""
    return Highlighter.instance(document)


_highlightFormats = None

def highlightFormats():
    global _highlightFormats
    if _highlightFormats is None:
        _highlightFormats = HighlightFormats(textformats.formatData('editor'))
    return _highlightFormats
    
Exemple #6
0
from PyQt4.QtGui import (QColor, QSyntaxHighlighter, QTextBlockUserData,
                         QTextCharFormat, QTextCursor, QTextDocument)

import ly.lex
import ly.colorize

import app
import cursortools
import textformats
import metainfo
import plugin
import variables
import documentinfo

metainfo.define('highlighting', True)


def mapping(data):
    """Return a dictionary mapping token classes from ly.lex to QTextCharFormats.
    
    The QTextFormats are queried from the specified TextFormatData instance.
    The returned dictionary is a ly.colorize.Mapping instance.
    
    """
    return ly.colorize.Mapper(
        (cls, data.textFormat(mode, style.name))
        for mode, styles in ly.colorize.default_mapping() for style in styles
        for cls in style.classes)

Exemple #7
0
from __future__ import unicode_literals

import weakref

from PyQt4.QtCore import QEvent, QSettings, Qt, QTimer, pyqtSignal
from PyQt4.QtGui import (QApplication, QContextMenuEvent, QKeySequence,
                         QPainter, QPlainTextEdit, QTextCursor)

import app
import homekey
import metainfo
import textformats
import cursortools
import variables

metainfo.define('auto_indent', True)
metainfo.define('position', 0)


class View(QPlainTextEdit):
    """View is the text editor widget a Document is displayed and edited with.
    
    It is basically a QPlainTextEdit with some extra features:
    - it draws a grey cursor when out of focus
    - it reads basic palette colors from the preferences
    - it determines tab width from the document variables (defaulting to 8 characters)
    - it stores the cursor position in the metainfo
    - it runs the auto_indenter when enabled (also checked via metainfo)
    - it can display a widget in the bottom using showWidget and hideWidget.
    
    """
Exemple #8
0
import bisect
import json

from PyQt5.QtGui import QTextCursor

import metainfo
import signals
import plugin

types = (
    'mark',
    'error',
)


metainfo.define('bookmarks', json.dumps(None))


def bookmarks(document):
    """Returns the Bookmarks instance for the document."""
    return Bookmarks.instance(document)


class Bookmarks(plugin.DocumentPlugin):
    """Manages bookmarks (marked lines) for a Document.
    
    The marks are stored in the metainfo for the Document.
    
    """
    marksChanged = signals.Signal()
    
Exemple #9
0
import bisect
import json

from PyQt4.QtGui import QTextCursor

import metainfo
import signals
import plugin

types = (
    'mark',
    'error',
)

metainfo.define('bookmarks', json.dumps(None))


def bookmarks(document):
    """Returns the Bookmarks instance for the document."""
    return Bookmarks.instance(document)


class Bookmarks(plugin.DocumentPlugin):
    """Manages bookmarks (marked lines) for a Document.
    
    The marks are stored in the metainfo for the Document.
    
    """
    marksChanged = signals.Signal()
Exemple #10
0
Manages the progress bar in the status bar of ViewSpaces.
"""

from __future__ import unicode_literals

from PyQt4.QtCore import Qt, QTimeLine, QTimer
from PyQt4.QtGui import QProgressBar

import app
import plugin
import jobmanager
import jobattributes
import metainfo
import widgets.progressbar

metainfo.define("buildtime", 0.0, float)


class ProgressBar(plugin.ViewSpacePlugin):
    """A Simple progress bar to show a Job is running."""

    def __init__(self, viewSpace):
        bar = self._bar = widgets.progressbar.TimedProgressBar()
        viewSpace.status.layout().addWidget(bar, 1, Qt.AlignCenter)
        bar.hide()
        viewSpace.viewChanged.connect(self.viewChanged)
        app.jobStarted.connect(self.jobStarted)
        app.jobFinished.connect(self.jobFinished)

    def viewChanged(self, view):
        self.showProgress(view.document())