diff --git a/bh_core.sublime-settings b/bh_core.sublime-settings index 9d3b8c65..f66e05d6 100755 --- a/bh_core.sublime-settings +++ b/bh_core.sublime-settings @@ -559,6 +559,30 @@ "language_filter": "whitelist", "language_list": ["CMake"], "enabled": true + }, + // SINUMERIK 840D SL G-Code + { + "name": "s840d_gcode", + "open": "\\b(IF(?!.*GOTO)|FOR|WHILE|REPEAT(?!.*GOTO))\\b", + "close": "\\b(END(?:IF|FOR|WHILE)|UNTIL)\\b", + "style": "tag", + "scope_exclude": ["string", "comment"], + "plugin_library": "bh_modules.s840d_gcode", + "language_filter": "whitelist", + "language_list": ["s840d_gcode"], + "enabled": true + }, + // SINUMERIK 840D SL RunMyHmi + { + "name": "s840d_hmi", + "open": "^\\s*(//[ABGMS]|ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b", + "close": "^\\s*(//END|END_(?:ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB))\\b", + "style": "tag", + "scope_exclude": ["string", "comment"], + "plugin_library": "bh_modules.s840d_hmi", + "language_filter": "whitelist", + "language_list": ["s840d_hmi"], + "enabled": true } ], diff --git a/bh_modules/bashsupport.py b/bh_modules/bashsupport.py index b05d1396..ba07aa1a 100644 --- a/bh_modules/bashsupport.py +++ b/bh_modules/bashsupport.py @@ -7,6 +7,8 @@ from BracketHighlighter.bh_plugin import import_module lowercase = import_module("bh_modules.lowercase") +BASH_KEYWORDS = ("select", "for", "while", "until") + def validate(*args): """Check if bracket is lowercase.""" @@ -22,7 +24,7 @@ def compare(name, first, second, bfr): match = False if o == "if" and c == "fi": match = True - elif o in ["select", "for", "while", "until"] and c == "done": + elif o in BASH_KEYWORDS and c == "done": match = True elif o == "case" and c == "esac": match = True diff --git a/bh_modules/s840d_gcode.py b/bh_modules/s840d_gcode.py new file mode 100644 index 00000000..042e3b5a --- /dev/null +++ b/bh_modules/s840d_gcode.py @@ -0,0 +1,20 @@ +""" +BracketHighlighter. + +Copyright (c) 2013 - 2016 Deathaxe +License: MIT +""" + + +def compare(name, first, second, bfr): + """Ensure correct open is paired with correct close.""" + + o = bfr[first.begin:first.end].lower() + c = bfr[second.begin:second.end].lower() + + match = False + if o == "repeat" and c == "until": + match = True + elif c == "end" + o: + match = True + return match diff --git a/bh_modules/s840d_hmi.py b/bh_modules/s840d_hmi.py new file mode 100644 index 00000000..8f47c05a --- /dev/null +++ b/bh_modules/s840d_hmi.py @@ -0,0 +1,24 @@ +""" +BracketHighlighter. + +Copyright (c) 2013 - 2016 Deathaxe +License: MIT +""" + +S840D_HMI_CLASSES = ("//a", "//b", "//g", "//m", "//s") + + +def compare(name, first, second, bfr): + """Ensure correct open is paired with correct close.""" + + o = bfr[first.begin:first.end].lower() + c = bfr[second.begin:second.end].lower() + + match = False + # classes + if o in S840D_HMI_CLASSES and c == "//end": + match = True + # methods + elif c == "end_" + o: + match = True + return match