示例#1
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of this lexer
        """
        QsciLexerHTML.__init__(self, parent)
        Lexer.__init__(self)

        self.streamCommentString = {'start': '<!-- ', 'end': ' -->'}
示例#2
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of this lexer
        """
        QsciLexerHTML.__init__(self, parent)
        Lexer.__init__(self)

        self.streamCommentString = {"start": "<!-- ", "end": " -->"}
示例#3
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent parent widget of this lexer
     """
     QsciLexerHTML.__init__(self, parent)
     Lexer.__init__(self)
     
     self.streamCommentString = {
         'start': '<!-- ',
         'end': ' -->'
     }
示例#4
0
文件: editor.py 项目: watrt/mu
 def __init__(self, path, text, newline=NEWLINE):
     super().__init__()
     self.setUtf8(True)
     self.path = path
     self.setText(text)
     self.newline = newline
     self.check_indicators = {  # IDs are arbitrary
         "error": {"id": 19, "markers": {}},
         "style": {"id": 20, "markers": {}},
     }
     self.search_indicators = {"selection": {"id": 21, "positions": []}}
     self.DEBUG_INDICATOR = 22  # Arbitrary
     self.BREAKPOINT_MARKER = 23  # Arbitrary
     self.previous_selection = {
         "line_start": 0,
         "col_start": 0,
         "line_end": 0,
         "col_end": 0,
     }
     if self.path:
         if self.path.endswith(".css"):
             self.lexer = CssLexer()
         elif self.path.endswith(".html") or self.path.endswith(".htm"):
             self.lexer = QsciLexerHTML()
             self.lexer.setDjangoTemplates(True)
         else:
             self.lexer = PythonLexer()
     else:
         self.lexer = PythonLexer()
     self.api = None
     self.has_annotations = False
     self.setModified(False)
     self.breakpoint_handles = set()
     self.configure()
示例#5
0
 def defaultKeywords(self, kwSet):
     """
     Public method to get the default keywords.
     
     @param kwSet number of the keyword set (integer)
     @return string giving the keywords (string) or None
     """
     return QsciLexerHTML.keywords(self, kwSet)
示例#6
0
    def __init__(self):
        super().__init__(None)

        self.setWrapMode(QsciScintilla.WrapWord)

        self.editable = True

        self.setLexer(QsciLexerHTML())
示例#7
0
 def defaultKeywords(self, kwSet):
     """
     Public method to get the default keywords.
     
     @param kwSet number of the keyword set (integer)
     @return string giving the keywords (string) or None
     """
     return QsciLexerHTML.keywords(self, kwSet)
示例#8
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of this lexer
        """
        QsciLexerHTML.__init__(self, parent)
        Lexer.__init__(self)

        self.streamCommentString = {'start': '<!-- ', 'end': ' -->'}

        self.keywordSetDescriptions = [
            self.tr("HTML elements and attributes"),
            self.tr("JavaScript keywords"),
            self.tr("VBScript keywords"),
            self.tr("Python keywords"),
            self.tr("PHP keywords"),
            self.tr("SGML and DTD keywords"),
        ]
示例#9
0
    def setup_markdown_editor(self):
        self.renderers = {}
        self.fallback_renderer = PlainRenderer()
        self.add_renderer(self.fallback_renderer)
        self.add_renderer(MarkdownRenderer())
        self.add_renderer(ReSTRenderer())

        # Set up Markdown editor
        self.setup_lexer()
        self.setup_scintilla(self.ui.markdownEditor)

        # Set up our custom page to open external links in a browser
        page = CustomWebPage(self)
        self.ui.markdownPreview.setPage(page)
        QWebEngineSettings.globalSettings().setAttribute(
            QWebEngineSettings.FocusOnNavigationEnabled, False)
        # self.ui.markdownPreview.

        # Set up the web channel to intercept clicks on links
        channel = QWebChannel(self)
        self.channel_proxy = WebChannelProxy(self)
        channel.registerObject("proxy", self.channel_proxy)
        page.setWebChannel(channel)

        self.channel_proxy.link_clicked.connect(self.link_clicked)

        # Set up HTML preview
        self.ui.htmlPreview.setLexer(QsciLexerHTML())

        # Connect signals
        self.ui.actionUndo.triggered.connect(self.undo)
        self.ui.actionRedo.triggered.connect(self.redo)

        self.ui.actionSave.triggered.connect(self.save_article)
        self.ui.actionCommit.triggered.connect(self.commit_article)
        self.ui.actionEdit.toggled.connect(self.edit_toggled)
        self.ui.actionFullscreen.triggered.connect(self.show_fullscreen_editor)
        self.ui.actionAutoLink.triggered.connect(self.auto_link_word)
        self.ui.actionAutoLinkAll.triggered.connect(self.auto_link_all)

        self.ui.markdownEditor.installEventFilter(self)

        # Load Github style
        style_file = QFile(':/styles/github.css')
        style_file.open(QIODevice.ReadOnly)
        self.style = QTextStream(style_file).readAll()
        style_file.close()

        self.current_article = None
        self.ui.markdownEditor.hide()

        self.ui.actionUndo.setEnabled(False)
        self.ui.actionRedo.setEnabled(False)

        self.update_toolbar()
示例#10
0
    def checkExtensionToHighlight(self, path, editor):
        _, extension = os.path.splitext(path)

        if extension == '.py':
            editor.setLexer(QsciLexerPython(self))
        elif extension == '.html':
            editor.setLexer(QsciLexerHTML(self))
        elif extension == '.java':
            editor.setLexer(QsciLexerJava(self))
        elif extension == '.cs':
            editor.setLexer(QsciLexerCSharp(self))
        elif extension == '.bat':
            editor.setLexer(QsciLexerBatch(self))
示例#11
0
 def html_highlighter(self):
     lexer = QsciLexerHTML()
     self.setDefaultSettings(lexer)