Skip to content

Commit

Permalink
make highlighting a setting
Browse files Browse the repository at this point in the history
  • Loading branch information
psifertex committed Apr 6, 2021
1 parent 6ad08c7 commit 5eb1331
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@
from binaryninja.plugin import PluginCommand, MainThreadActionHandler
from binaryninja.mainthread import execute_on_main_thread
from binaryninja.log import (log_error, log_debug)
from binaryninja.settings import Settings
import numbers
from .QCodeEditor import QCodeEditor
from .QCodeEditor import QCodeEditor, Pylighter

Settings().register_group("snippest", "Snippets")
Settings().register_setting("snippets.syntaxHighlight", """
{
"title" : "Syntax highlighting for snippets",
"type" : "boolean",
"default" : true,
"description" : "Whether to syntax highlight (may be performance problems with very large snippets and the current highlighting implementation.)"
}
""")


snippetPath = os.path.realpath(os.path.join(user_plugin_path(), "..", "snippets"))
try:
Expand Down Expand Up @@ -155,7 +167,10 @@ def __init__(self, context, parent=None):
self.browseButton.setIcon(QIcon.fromTheme("edit-undo"))
self.deleteSnippetButton = QPushButton("Delete")
self.newSnippetButton = QPushButton("New Snippet")
self.edit = QCodeEditor()
if Settings().get_bool("snippets.syntaxHighlight"):
self.edit = QCodeEditor(SyntaxHighlighter=Pylighter)
else:
self.edit = QCodeEditor(SyntaxHighlighter=None)
self.edit.setPlaceholderText("python code")
self.resetting = False
self.columns = 3
Expand Down

0 comments on commit 5eb1331

Please sign in to comment.