|
24 | 24 | from binaryninja.plugin import PluginCommand, MainThreadActionHandler
|
25 | 25 | from binaryninja.mainthread import execute_on_main_thread
|
26 | 26 | from binaryninja.log import (log_error, log_debug)
|
| 27 | +from binaryninja.settings import Settings |
27 | 28 | import numbers
|
28 |
| -from .QCodeEditor import QCodeEditor |
| 29 | +from .QCodeEditor import QCodeEditor, Pylighter |
| 30 | + |
| 31 | +Settings().register_group("snippest", "Snippets") |
| 32 | +Settings().register_setting("snippets.syntaxHighlight", """ |
| 33 | + { |
| 34 | + "title" : "Syntax highlighting for snippets", |
| 35 | + "type" : "boolean", |
| 36 | + "default" : true, |
| 37 | + "description" : "Whether to syntax highlight (may be performance problems with very large snippets and the current highlighting implementation.)" |
| 38 | + } |
| 39 | + """) |
| 40 | + |
29 | 41 |
|
30 | 42 | snippetPath = os.path.realpath(os.path.join(user_plugin_path(), "..", "snippets"))
|
31 | 43 | try:
|
@@ -155,7 +167,10 @@ def __init__(self, context, parent=None):
|
155 | 167 | self.browseButton.setIcon(QIcon.fromTheme("edit-undo"))
|
156 | 168 | self.deleteSnippetButton = QPushButton("Delete")
|
157 | 169 | self.newSnippetButton = QPushButton("New Snippet")
|
158 |
| - self.edit = QCodeEditor() |
| 170 | + if Settings().get_bool("snippets.syntaxHighlight"): |
| 171 | + self.edit = QCodeEditor(SyntaxHighlighter=Pylighter) |
| 172 | + else: |
| 173 | + self.edit = QCodeEditor(SyntaxHighlighter=None) |
159 | 174 | self.edit.setPlaceholderText("python code")
|
160 | 175 | self.resetting = False
|
161 | 176 | self.columns = 3
|
|
0 commit comments