Skip to content

Commit 5eb1331

Browse files
committed
make highlighting a setting
1 parent 6ad08c7 commit 5eb1331

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,20 @@
2424
from binaryninja.plugin import PluginCommand, MainThreadActionHandler
2525
from binaryninja.mainthread import execute_on_main_thread
2626
from binaryninja.log import (log_error, log_debug)
27+
from binaryninja.settings import Settings
2728
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+
2941

3042
snippetPath = os.path.realpath(os.path.join(user_plugin_path(), "..", "snippets"))
3143
try:
@@ -155,7 +167,10 @@ def __init__(self, context, parent=None):
155167
self.browseButton.setIcon(QIcon.fromTheme("edit-undo"))
156168
self.deleteSnippetButton = QPushButton("Delete")
157169
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)
159174
self.edit.setPlaceholderText("python code")
160175
self.resetting = False
161176
self.columns = 3

0 commit comments

Comments
 (0)