feat(ST2.EditorPackages): bump up all packages
- Refresh PackageCache with latest versions of everything
@@ -3,7 +3,7 @@ import sublime
|
||||
import sublime_plugin
|
||||
from time import time, sleep
|
||||
import thread
|
||||
import re
|
||||
import ure
|
||||
from bh_plugin import BracketPlugin, BracketRegion, ImportModule
|
||||
from collections import namedtuple
|
||||
import traceback
|
||||
@@ -398,8 +398,8 @@ class ScopeDefinition(object):
|
||||
"""
|
||||
|
||||
self.style = bracket.get("style", "default")
|
||||
self.open = re.compile("\\A" + bracket.get("open", "."), re.MULTILINE | re.IGNORECASE)
|
||||
self.close = re.compile(bracket.get("close", ".") + "\\Z", re.MULTILINE | re.IGNORECASE)
|
||||
self.open = ure.compile("\\A" + bracket.get("open", "."), ure.MULTILINE | ure.IGNORECASE)
|
||||
self.close = ure.compile(bracket.get("close", ".") + "\\Z", ure.MULTILINE | ure.IGNORECASE)
|
||||
self.name = bracket["name"]
|
||||
sub_search = bracket.get("sub_bracket_search", "false")
|
||||
self.sub_search_only = sub_search == "only"
|
||||
@@ -537,7 +537,7 @@ class BhCore(object):
|
||||
self.last_id_view = None
|
||||
self.last_id_sel = None
|
||||
self.view_tracker = (None, None)
|
||||
self.ignore_threshold = override_thresh
|
||||
self.ignore_threshold = override_thresh or bool(self.settings.get("ignore_threshold", False))
|
||||
self.adj_only = adj_only if adj_only is not None else bool(self.settings.get("match_only_adjacent", False))
|
||||
self.auto_selection_threshold = int(self.settings.get("auto_selection_threshold", 10))
|
||||
self.no_multi_select_icons = bool(self.settings.get("no_multi_select_icons", False))
|
||||
@@ -668,8 +668,8 @@ class BhCore(object):
|
||||
"(?:%s)\n" % '|'.join(self.find_regex) +
|
||||
"(?:%s)" % '|'.join(self.sub_find_regex)
|
||||
)
|
||||
self.sub_pattern = re.compile("(?:%s)" % '|'.join(self.sub_find_regex), re.MULTILINE | re.IGNORECASE)
|
||||
self.pattern = re.compile("(?:%s)" % '|'.join(self.find_regex), re.MULTILINE | re.IGNORECASE)
|
||||
self.sub_pattern = ure.compile("(?:%s)" % '|'.join(self.sub_find_regex), ure.MULTILINE | ure.IGNORECASE)
|
||||
self.pattern = ure.compile("(?:%s)" % '|'.join(self.find_regex), ure.MULTILINE | ure.IGNORECASE)
|
||||
self.enabled = True
|
||||
|
||||
def init_match(self):
|
||||
@@ -810,9 +810,13 @@ class BhCore(object):
|
||||
|
||||
if view == None:
|
||||
return
|
||||
|
||||
view.settings().set("BracketHighlighterBusy", True)
|
||||
|
||||
if not GLOBAL_ENABLE:
|
||||
for region_key in view.settings().get("bh_regions", []):
|
||||
view.erase_regions(region_key)
|
||||
view.settings().set("BracketHighlighterBusy", False)
|
||||
return
|
||||
|
||||
if self.keycommand:
|
||||
@@ -834,11 +838,13 @@ class BhCore(object):
|
||||
|
||||
# Nothing to search for
|
||||
if not self.enabled:
|
||||
view.settings().set("BracketHighlighterBusy", False)
|
||||
return
|
||||
|
||||
# Abort if selections are beyond the threshold
|
||||
if self.use_selection_threshold and num_sels >= self.selection_threshold:
|
||||
self.highlight(view)
|
||||
view.settings().set("BracketHighlighterBusy", False)
|
||||
return
|
||||
|
||||
multi_select_count = 0
|
||||
@@ -859,6 +865,7 @@ class BhCore(object):
|
||||
self.highlight(view)
|
||||
if self.count_lines:
|
||||
sublime.status_message('In Block: Lines ' + str(self.lines) + ', Chars ' + str(self.chars))
|
||||
view.settings().set("BracketHighlighterBusy", False)
|
||||
|
||||
def save_incomplete_regions(self, left, right, regions):
|
||||
"""
|
||||
@@ -926,7 +933,9 @@ class BhCore(object):
|
||||
|
||||
if left is not None and right is not None:
|
||||
bracket = self.brackets[left.type]
|
||||
left, right, regions = self.run_plugin(bracket.name, left, right, regions)
|
||||
left, right, regions, nobracket = self.run_plugin(bracket.name, left, right, regions)
|
||||
if nobracket:
|
||||
return True
|
||||
|
||||
# Matched brackets
|
||||
if left is not None and right is not None and bracket is not None:
|
||||
@@ -946,7 +955,7 @@ class BhCore(object):
|
||||
regions = [sublime.Region(sel.a, sel.b)]
|
||||
|
||||
if left is not None and right is not None:
|
||||
left, right, regions = self.run_plugin(bracket.name, left, right, regions)
|
||||
left, right, regions, _ = self.run_plugin(bracket.name, left, right, regions)
|
||||
if left is None and right is None:
|
||||
self.store_sel(regions)
|
||||
return True
|
||||
@@ -971,7 +980,7 @@ class BhCore(object):
|
||||
|
||||
if left is not None and right is not None:
|
||||
bracket = self.brackets[left.type]
|
||||
left, right, regions = self.run_plugin(bracket.name, left, right, regions)
|
||||
left, right, regions, _ = self.run_plugin(bracket.name, left, right, regions)
|
||||
|
||||
# Matched brackets
|
||||
if left is not None and right is not None and bracket is not None:
|
||||
@@ -1113,16 +1122,17 @@ class BhCore(object):
|
||||
|
||||
lbracket = BracketRegion(left.begin, left.end)
|
||||
rbracket = BracketRegion(right.begin, right.end)
|
||||
nobracket = False
|
||||
|
||||
if (
|
||||
("__all__" in self.transform or name in self.transform) and
|
||||
self.plugin != None and
|
||||
self.plugin.is_enabled()
|
||||
):
|
||||
lbracket, rbracket, regions = self.plugin.run_command(self.view, name, lbracket, rbracket, regions)
|
||||
lbracket, rbracket, regions, nobracket = self.plugin.run_command(self.view, name, lbracket, rbracket, regions)
|
||||
left = left.move(lbracket.begin, lbracket.end) if lbracket is not None else None
|
||||
right = right.move(rbracket.begin, rbracket.end) if rbracket is not None else None
|
||||
return left, right, regions
|
||||
return left, right, regions, nobracket
|
||||
|
||||
def match_scope_brackets(self, bfr, sel):
|
||||
"""
|
||||
|
@@ -9,9 +9,10 @@
|
||||
// this defines if the unmatched bracket should be shown.
|
||||
"show_unmatched" : true,
|
||||
|
||||
// High visibilty style and color for high visibility mode
|
||||
// High visibility style and color for high visibility mode
|
||||
// (solid|outline|underline)
|
||||
"high_visibility_style": "outline",
|
||||
|
||||
// (scope|__default__|__bracket__)
|
||||
"high_visibility_color": "__bracket__",
|
||||
|
||||
@@ -21,6 +22,9 @@
|
||||
// Character threshold to search
|
||||
"search_threshold": 5000,
|
||||
|
||||
// Ignore threshold
|
||||
"ignore_threshold": false,
|
||||
|
||||
// Set mode for string escapes to ignore (regex|string)
|
||||
"bracket_string_escape_mode": "string",
|
||||
|
||||
@@ -215,15 +219,26 @@
|
||||
"find_in_sub_search": "only",
|
||||
"enabled": false
|
||||
},
|
||||
// Angle
|
||||
// PHP Angle
|
||||
{
|
||||
"name": "angle",
|
||||
"open": "(<)",
|
||||
"close": "(>)",
|
||||
"name": "php_angle",
|
||||
"open": "(<\\?)(?:php)?",
|
||||
"close": "(\\?>)",
|
||||
"style": "angle",
|
||||
"scope_exclude": ["string", "comment", "keyword.operator"],
|
||||
"language_filter": "whitelist",
|
||||
"language_list": ["HTML", "HTML 5", "XML", "PHP", "HTML+CFML", "ColdFusion", "ColdFusionCFC"],
|
||||
"language_list": ["HTML", "HTML 5", "PHP"],
|
||||
"enabled": true
|
||||
},
|
||||
// Angle
|
||||
{
|
||||
"name": "angle",
|
||||
"open": "(<)(?!\\?)",
|
||||
"close": "(?<!\\?)(>)",
|
||||
"style": "angle",
|
||||
"scope_exclude": ["string", "comment", "keyword.operator", "source.ruby.rails.embedded.html", "source.ruby.embedded.html"],
|
||||
"language_filter": "whitelist",
|
||||
"language_list": ["HTML", "HTML 5", "XML", "PHP", "HTML (Rails)", "HTML (Jinja Templates)", "HTML (Twig)", "HTML+CFML", "ColdFusion", "ColdFusionCFC"],
|
||||
"plugin_library": "bh_modules.tags",
|
||||
"enabled": true
|
||||
},
|
||||
@@ -238,16 +253,29 @@
|
||||
"language_list": ["CSS"],
|
||||
"enabled": true
|
||||
},
|
||||
// Ruby embedded HTML
|
||||
{
|
||||
"name": "ruby_embedded_html",
|
||||
"open": "((?:(?<=<%)|(?<=^))\\s*\\b(?:if|case|until|unless|while|begin|class|module|def\\b[\\p{Ll}\\p{Lu}]*)|\\bdo)\\b",
|
||||
"close": "\\b(end)\\b",
|
||||
"style": "default",
|
||||
"scope_exclude": ["text.html", "source", "comment", "string"],
|
||||
"scope_exclude_exceptions": ["source.ruby.rails.embedded.html", "source.ruby.embedded.html"],
|
||||
"plugin_library": "bh_modules.rubykeywords",
|
||||
"language_filter": "whitelist",
|
||||
"language_list": ["HTML", "HTML 5", "PHP", "HTML (Rails)"],
|
||||
"enabled": true
|
||||
},
|
||||
// Ruby conditional statements
|
||||
{
|
||||
"name": "ruby",
|
||||
"open": "(^\\s*\\b(?:if|case|until|unless|while|begin|class|module|def\\b\\s*[a-zA-Z_\\d]+)|\\bdo)\\b",
|
||||
"open": "(^\\s*\\b(?:if|case|until|unless|while|begin|class|module|def\\b[\\p{Ll}\\p{Lu}]*)|\\bdo)\\b",
|
||||
"close": "\\b(end)\\b",
|
||||
"style": "default",
|
||||
"scope_exclude": ["string", "comment"],
|
||||
"plugin_library": "bh_modules.rubykeywords",
|
||||
"language_filter": "whitelist",
|
||||
"language_list": ["Ruby", "Ruby on Rails", "HTML (Rails)"],
|
||||
"language_list": ["Ruby", "Ruby on Rails"],
|
||||
"enabled": true
|
||||
},
|
||||
// C/C++ compile switches
|
||||
@@ -300,6 +328,8 @@
|
||||
// use the color from the "default" style.
|
||||
"default": {
|
||||
"icon": "dot",
|
||||
// BH1's original default color for reference
|
||||
// "color": "entity.name.class",
|
||||
"color": "brackethighlighter.default",
|
||||
"style": "underline"
|
||||
},
|
||||
@@ -366,7 +396,7 @@
|
||||
// Determine which style of tag-matching to use in which syntax
|
||||
"tag_mode": {
|
||||
"xhtml": ["XML"],
|
||||
"html": ["HTML", "HTML 5", "PHP"],
|
||||
"html": ["HTML", "HTML 5", "PHP", "HTML (Jinja Templates)", "HTML (Rails)", "HTML (Twig)"],
|
||||
"cfml": ["HTML+CFML", "ColdFusion", "ColdFusionCFC"]
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ class BracketRemove(bh_plugin.BracketPluginCommand):
|
||||
|
||||
self.left = None
|
||||
self.right = None
|
||||
self.nobracket = True
|
||||
|
||||
|
||||
def plugin():
|
||||
|
@@ -6,25 +6,38 @@ DEFAULT_TAGS = ["cfml", "html", "angle"]
|
||||
|
||||
class SelectBracket(bh_plugin.BracketPluginCommand):
|
||||
def run(self, edit, name, select='', tags=DEFAULT_TAGS):
|
||||
current_left, current_right = self.selection[0].begin(), self.selection[0].end()
|
||||
left, right = self.left, self.right
|
||||
first, last = left.end, right.begin
|
||||
if select == 'left':
|
||||
if name in tags and left.size() > 1:
|
||||
first, last = left.begin + 1, left.begin + 1
|
||||
if first == current_left and last == current_right:
|
||||
first, last = left.begin, left.begin
|
||||
else:
|
||||
first, last = left.end, left.end
|
||||
if first == current_left and last == current_right:
|
||||
first, last = left.begin, left.begin
|
||||
elif select == 'right':
|
||||
if left.end != right.end:
|
||||
if name in tags and left.size() > 1:
|
||||
first, last = right.begin + 1, right.begin + 1
|
||||
if first == current_left and last == current_right:
|
||||
first, last = right.end, right.end
|
||||
else:
|
||||
first, last = right.begin, right.begin
|
||||
if first == current_left and last == current_right:
|
||||
first, last = right.end, right.end
|
||||
else:
|
||||
# There is no second bracket, so just select the first
|
||||
if name in tags and left.size() > 1:
|
||||
first, last = left.begin + 1, left.begin + 1
|
||||
else:
|
||||
first, last = right.end, right.end
|
||||
if first == current_left and last == current_right:
|
||||
first, last = right.end, right.end
|
||||
elif first == current_left and last == current_right:
|
||||
first, last = left.begin, right.end
|
||||
|
||||
self.selection = [sublime.Region(first, last)]
|
||||
|
||||
|
@@ -5,8 +5,9 @@ def post_match(view, name, style, first, second, center, bfr, threshold):
|
||||
if first is not None:
|
||||
# Strip whitespace from the beginning of first bracket
|
||||
open_bracket = bfr[first.begin:first.end]
|
||||
print (open_bracket)
|
||||
if open_bracket != "do":
|
||||
m = re.match(r"^(\s*\b)[\w\W]*", open_bracket)
|
||||
m = re.match(r"(\s*\b)[\w\W]*", open_bracket)
|
||||
if m:
|
||||
first = first.move(first.begin + m.end(1), first.end)
|
||||
return first, second, style
|
||||
|
@@ -6,8 +6,14 @@ BracketRemove = ImpMod.import_from("bh_modules.bracketremove", "BracketRemove")
|
||||
class SwapBrackets(BracketRemove):
|
||||
def run(self, edit, name, remove_content=False, remove_indent=False, remove_block=False):
|
||||
offset = self.left.toregion().size()
|
||||
self.selection = [sublime.Region(self.left.begin, self.right.begin - offset)]
|
||||
selection = [sublime.Region(self.left.begin, self.right.begin - offset)]
|
||||
left = self.left.move(self.left.end, self.left.end)
|
||||
right = self.right.move(self.right.begin, self.right.begin)
|
||||
super(SwapBrackets, self).run(edit, name)
|
||||
self.selection = selection
|
||||
self.left = left
|
||||
self.right = right
|
||||
self.nobracket = False
|
||||
|
||||
|
||||
def plugin():
|
||||
|
@@ -115,16 +115,18 @@ class BracketPlugin(object):
|
||||
setattr(plugin, "right", right)
|
||||
setattr(plugin, "view", view)
|
||||
setattr(plugin, "selection", selection)
|
||||
setattr(plugin, "nobracket", False)
|
||||
edit = view.begin_edit()
|
||||
self.args["edit"] = edit
|
||||
self.args["name"] = name
|
||||
try:
|
||||
nobracket = False
|
||||
plugin.run(**self.args)
|
||||
left, right, selection = plugin.left, plugin.right, plugin.selection
|
||||
left, right, selection, nobracket = plugin.left, plugin.right, plugin.selection, plugin.nobracket
|
||||
except Exception:
|
||||
print "BracketHighlighter: Plugin Run Error:\n%s" % str(traceback.format_exc())
|
||||
view.end_edit(edit)
|
||||
return left, right, selection
|
||||
return left, right, selection, nobracket
|
||||
|
||||
|
||||
class BracketPluginCommand(object):
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import sublime
|
||||
import sublime_plugin
|
||||
import bh_wrapping
|
||||
|
||||
@@ -14,6 +15,13 @@ class SwapBrackets(bh_wrapping.WrapBrackets):
|
||||
|
||||
|
||||
class SwapBracketsCommand(sublime_plugin.WindowCommand):
|
||||
def finalize(self, callback):
|
||||
if self.view is not None:
|
||||
if not self.view.settings().get("BracketHighlighterBusy", False):
|
||||
callback()
|
||||
else:
|
||||
sublime.set_timeout(lambda: self.finalize(callback), 100)
|
||||
|
||||
def swap_brackets(self, value):
|
||||
if value < 0:
|
||||
return
|
||||
@@ -29,7 +37,10 @@ class SwapBracketsCommand(sublime_plugin.WindowCommand):
|
||||
}
|
||||
}
|
||||
)
|
||||
self.wrap.wrap(value)
|
||||
|
||||
self.view = self.window.active_view()
|
||||
|
||||
sublime.set_timeout(lambda: self.finalize(lambda: self.wrap.wrap(value)), 100)
|
||||
|
||||
def run(self):
|
||||
view = self.window.active_view()
|
||||
|
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 420 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 288 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 342 B |
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 371 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 443 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 334 B |
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 288 B |
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 378 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 325 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 325 B |
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 334 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 394 B |
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 373 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 300 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 206 B |
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 477 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 370 B |
@@ -1 +1 @@
|
||||
{"url": "https://github.com/facelessuser/BracketHighlighter", "version": "2013.03.27.09.00.08", "description": "Bracket and tag highlighter for Sublime Text 2"}
|
||||
{"url": "https://github.com/facelessuser/BracketHighlighter", "version": "2013.09.15.18.40.20", "description": "Bracket and tag highlighter for Sublime Text 2"}
|
@@ -1,3 +1,22 @@
|
||||
# Table of Contents
|
||||
- [About](#about)
|
||||
- [Sublime Text 3 Support?](#sublime-text-3-support)
|
||||
- [Overview](#overview)
|
||||
- [Feature List](#feature-list)
|
||||
- [General Use](#general-use)
|
||||
- [Built-in Supported brackets](#built-in-supported-brackets)
|
||||
- [Additional Features](#additional-features)
|
||||
- [Bracket Plugin](#bracket-plugin)
|
||||
- [Shortcuts](#shortcuts)
|
||||
- [Customizing BracketHighligher](#costumizing-brackethighlighter)
|
||||
- [Configuring Brackets](#cnfiguring-brackets)
|
||||
- [Configuring Highlight Style](#configuring-highlight-style)
|
||||
- [Bracket Plugin API](#bracket-plugin-api)
|
||||
- ['Defintion' Plugins](#definition-plugins)
|
||||
- [Run Instance Plugins](#run-instance-plugins)
|
||||
- [Credits](#credits)
|
||||
- [Changelog](#changelog)
|
||||
|
||||
# About
|
||||
This is a fork of pyparadigm's _SublimeBrackets_ and _SublimeTagmatcher_ (both are no longer available). I forked this to fix some issues I had and to add some features I wanted. I also wanted to improve the efficiency of the matching. This cuts down on the parallel searching that is now streamlined in one search. Since then, I have rewritten the entire code base to bring more flexibility, speed, and features.
|
||||
|
||||
@@ -9,7 +28,7 @@ ST3 support is found here (at the present time): https://github.com/facelessuse
|
||||
## Overview
|
||||
Bracket Highlighter matches a variety of brackets such as: ```[]```, ```()```, ```{}```, ```""```, ```''```, ```<tag></tag>```, and even custom brackets.
|
||||
|
||||
# FeatureList
|
||||
# Feature List
|
||||
- Customizable to highlight almost any bracket
|
||||
- Customizable bracket highlight style
|
||||
- High visibility bracket highlight mode
|
||||
@@ -23,7 +42,7 @@ Bracket Highlighter matches a variety of brackets such as: ```[]```, ```()```, `
|
||||
- Bracket plugins that can jump between bracket ends, select content, remove brackets and/or content, wrap selectios with brackets, swap brackets, swap quotes (handling quote escaping between the main quotes), fold/unfold conent between brackets, toggle through tag attribute selecection, select both the opening and closing tag name to change both simultaneously.
|
||||
|
||||
# General Use
|
||||
In general BracketHighligher (BH) will automatically highlight brackets (or defined bracket like start and end blocks) its between. By default, BH will but opening and closing icons in the gutter of the corresponding line containing open or closising bracket. BH, by default, will underline the closing and opening bracket as well.
|
||||
In general, BracketHighligher (BH) will highlight brackets (or defined bracket like start and end blocks) surrounding the cursor. By default, BH will put opening and closing icons in the gutter of the corresponding line containing open or closising bracket. BH, by default, will underline the closing and opening bracket as well.
|
||||
|
||||
## Built-in Supported brackets
|
||||
Currently BH supports the following brackets out of the box:
|
||||
@@ -70,7 +89,7 @@ These are the basic settings you can change:
|
||||
// this defines if the unmatched bracket should be shown.
|
||||
"show_unmatched" : true,
|
||||
|
||||
// High visibilty style and color for high visibility mode
|
||||
// High visibility style and color for high visibility mode
|
||||
// (solid|outline|underline)
|
||||
"high_visibility_style": "outline",
|
||||
// (scope|__default__|__bracket__)
|
||||
@@ -93,7 +112,7 @@ These are the basic settings you can change:
|
||||
```
|
||||
|
||||
### Bracket Plugins
|
||||
Bh is also extendable via plugins and provides an number of plugins by default. See ```Bracket Plugins``` to learn more about the included plugins.
|
||||
Bh is also extendable via plugins and provides an number of plugins by default. See [Bracket Plugins](#bracket-plugins) to learn more about the included plugins.
|
||||
|
||||
## Bracket Plugin
|
||||
BH provides a number of built in Bracket Plugins that take advantage of BH's matching to provide additional features. Most plugin features are available via the Tools->Packages->BracketHighlighter menu or the command palette. To see how to configure shortcuts, see the ```Example.sublime-settings``` file.
|
||||
@@ -108,10 +127,10 @@ Removes the surrounding brackets.
|
||||
Folds the content of the current surrounding brackets.
|
||||
|
||||
### Swap Quotes Plugin
|
||||
Swap the quotes style of surrounding quotes from double to single or vice versa. It also handlings escaping and unescaping of sub quotes.
|
||||
Swap the quotes style of surrounding quotes from double to single or vice versa. It also handles escaping and unescaping of sub quotes.
|
||||
|
||||
### Tag Plugin
|
||||
Plugin used to help highlight tags
|
||||
Plugin used to help highlight tags.
|
||||
|
||||
Additional tag settings found in ```bh_core.sublime-settings```:
|
||||
```javascript
|
||||
@@ -150,7 +169,7 @@ By default BH provides no shortcuts to avoid shortcut conflicts, but you can vie
|
||||
BH is extremely flexible and be customized and extended to fit a User's needs. The first step is to copy the ```bh_core.sublime-settings``` to your ```User``` folder.
|
||||
|
||||
## Configuring Brackets
|
||||
BH has been written to allow users to define any brackets they would like to have highlighted. There are two kinds of brackets you can define ```scope_brackets``` (search file for scope regions and then use regex to test for opening and closing brackets) and ```brackets``` (use regex to find opening and closing brackets). ```bracket``` type should usually be the preferred type. ```scope_brackets``` are usually used for brackets whose opening and closing are the same and not distinguishable form one another by regex; scope brackets must be contained in a continuous scope region like string for quotes etc.
|
||||
BH has been written to allow users to define any brackets they would like to have highlighted. There are two kinds of brackets you can define: ```scope_brackets``` (search file for scope regions and then use regex to test for opening and closing brackets) and ```brackets``` (use regex to find opening and closing brackets). ```bracket``` should usually be the preferred type. ```scope_brackets``` are usually used for brackets whose opening and closing are the same and not distinguishable form one another by regex; scope brackets must be contained in a continuous scope region like string for quotes etc.
|
||||
|
||||
### Configuring Brackets
|
||||
Brackets are defined under ```brackets``` in ```bh_core.sublime-settings```.
|
||||
@@ -228,7 +247,7 @@ Python Single Quote bracket will be used as an eample (not all options are shown
|
||||
- **plugin_library (optional)**: defines plugin to use for determining matches (see Bracket Plugin API for more info on matching plugins)
|
||||
|
||||
## Configuring Highlight Style
|
||||
Each bracket definition (described in ```Configuring Scope Brackets``` and ```Configuring Brackets```) has a ```style``` setting that you give a style definition to. Style definitions are defined under ```bracket_styles``` in ```bh_core.sublime-settings```.
|
||||
Each bracket definition (described in [Configuring Scope Brackets](#configuring-scope-brackets) and [Configuring Brackets](#configuring-brackets)) has a ```style``` setting that you give a style definition to. Style definitions are defined under ```bracket_styles``` in ```bh_core.sublime-settings```.
|
||||
|
||||
There are two special style definitions whose names are reserved: ```default``` and ```unmatched```, but you can configure them. All other custom style definitions follow the same pattern (see ```curly``` below and compare to the special style defintions; format is the same) All custom styles follow this pattern. See description below:
|
||||
|
||||
@@ -260,7 +279,8 @@ There are two special style definitions whose names are reserved: ```default```
|
||||
},
|
||||
```
|
||||
|
||||
- **icon**: icon to show in gutter. Available options are (angle|round|curly|square|tag|star|dot|bookmark|question|quote|double_quote|single_quote|single_quote_offset|double_quote_offset|none)
|
||||
- **icon**: icon to show in gutter. Available options are (angle|round|curly|square|tag|star|dot|bookmark|question|quote|double_quote|single_quote|single_quote_offset|
|
||||
double_quote_offset|none)
|
||||
- **color**: scope to define color
|
||||
- **style**: higlight style. Available options are (solid|outline|underline|none)
|
||||
|
||||
@@ -316,7 +336,7 @@ Methods of BracketRegion:
|
||||
These are plugins that are attached to the bracket definition and aid in processing the brackets. These kids of plugins have two methods you can provide ```post_match``` and/or ```compare```.
|
||||
|
||||
### compare
|
||||
```compare``` is run when comparing the opening bracket with closing brackets. This allows you to provide logic to accept or regect a the pairing of an opening bracket with a closing bracket. You should not change the text in the view during this operation.
|
||||
```compare``` is run when comparing the opening bracket with closing brackets. This allows you to provide logic to accept or reject the pairing of an opening bracket with a closing bracket. You should not change the text in the view during this operation.
|
||||
|
||||
The ```compare``` method receives the following paramters:
|
||||
|
||||
@@ -463,8 +483,10 @@ def plugin():
|
||||
- pyparadigm: for his original efforts with SublimeBrackets and SublimeTagmatcher which originally BracketHighlighter was built off of and the inspiration behind the current implementation.
|
||||
- BoundInCode: for his Tag icon
|
||||
|
||||
# Version 2.0.0
|
||||
# Changelog
|
||||
|
||||
#### Version 2.0.0
|
||||
- Re-write of BracketHighlighter
|
||||
|
||||
# Version Older
|
||||
#### Older Versions
|
||||
- See [Complete Changelog](https://github.com/facelessuser/BracketHighlighter/blob/BH2/CHANGELOG.md)
|
||||
|
@@ -0,0 +1,207 @@
|
||||
"""
|
||||
ure - unicode re
|
||||
|
||||
A simple script that wraps the re interface with methods to handle unicode properties.
|
||||
Patterns will all have re.UNICODE enabled and unicode property formats will be replaced
|
||||
with the unicode characters in that category.
|
||||
|
||||
Example:
|
||||
r"\p{Ll}\p{Lu}"
|
||||
|
||||
Licensed under MIT
|
||||
Copyright (c) 2013 Isaac Muse <isaacmuse@gmail.com>
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
from os.path import dirname
|
||||
try:
|
||||
import unicodedata
|
||||
except:
|
||||
sys.path.append(dirname(sys.executable))
|
||||
import unicodedata
|
||||
|
||||
PY3 = sys.version_info[0] >= 3
|
||||
uchr = chr if PY3 else unichr
|
||||
|
||||
DEBUG = re.DEBUG
|
||||
I = re.I
|
||||
IGNORECASE = re.IGNORECASE
|
||||
L = re.L
|
||||
LOCALE = re.LOCALE
|
||||
M = re.M
|
||||
MULTILINE = re.MULTILINE
|
||||
S = re.S
|
||||
DOTALL = re.DOTALL
|
||||
U = re.U
|
||||
UNICODE = re.UNICODE
|
||||
X = re.X
|
||||
VERBOSE = re.VERBOSE
|
||||
escape = re.escape
|
||||
purge = re.purge
|
||||
|
||||
_unicode_properties = None
|
||||
_unicode_key_pattern = None
|
||||
|
||||
|
||||
def _build_unicode_property_table(unicode_range):
|
||||
"""
|
||||
Build property table for unicode range.
|
||||
"""
|
||||
table = {}
|
||||
p = None
|
||||
for i in range(*unicode_range):
|
||||
try:
|
||||
c = uchr(i)
|
||||
p = unicodedata.category(c)
|
||||
except:
|
||||
continue
|
||||
if p[0] not in table:
|
||||
table[p[0]] = {}
|
||||
if p[1] not in table[p[0]]:
|
||||
table[p[0]][p[1]] = []
|
||||
table[p[0]][p[1]].append(c)
|
||||
|
||||
# Join as one string
|
||||
for k1, v1 in table.items():
|
||||
for k2, v2 in v1.items():
|
||||
v1[k2] = ''.join(v2)
|
||||
|
||||
return table
|
||||
|
||||
|
||||
def _build_unicode_key_pattern():
|
||||
"""
|
||||
Build regex key pattern
|
||||
"""
|
||||
unicode_prop = r"\p\{(%s)\}"
|
||||
unicode_keys = []
|
||||
for k1, v1 in _unicode_properties.items():
|
||||
unicode_keys.append("%s(?:%s)" % (k1, "|".join(v1.keys())))
|
||||
return re.compile(unicode_prop % "|".join(unicode_keys), re.UNICODE)
|
||||
|
||||
|
||||
def _init_unicode():
|
||||
"""
|
||||
Prepare unicode property tables and key pattern
|
||||
"""
|
||||
global _unicode_properties
|
||||
global _unicode_key_pattern
|
||||
_unicode_properties = _build_unicode_property_table((0x0000, 0x10FFFF))
|
||||
_unicode_key_pattern = _build_unicode_key_pattern()
|
||||
|
||||
|
||||
def find_char_groups(s):
|
||||
"""
|
||||
Find character groups
|
||||
"""
|
||||
pos = 0
|
||||
groups = []
|
||||
escaped = False
|
||||
found = False
|
||||
first = None
|
||||
for c in s:
|
||||
if c == "\\":
|
||||
escaped = not escaped
|
||||
elif escaped:
|
||||
escaped = False
|
||||
elif c == "[" and not found:
|
||||
found = True
|
||||
first = pos
|
||||
elif c == "]" and found:
|
||||
groups.append((first, pos))
|
||||
pos += 1
|
||||
return groups
|
||||
|
||||
|
||||
def get_unicode_category(prop):
|
||||
"""
|
||||
Retrieve the unicode category from the table
|
||||
"""
|
||||
p1, p2 = (prop[0], prop[1]) if len(prop) > 1 else (prop[0], None)
|
||||
return ''.join([x for x in _unicode_properties[p1].values()]) if p2 is None else _unicode_properties[p1][p2]
|
||||
|
||||
|
||||
def parse_unicode_properties(re_pattern):
|
||||
"""
|
||||
Replaces regex property notation with unicode values
|
||||
"""
|
||||
char_groups = find_char_groups(re_pattern)
|
||||
ure_pattern = re_pattern
|
||||
for p in reversed(list(_unicode_key_pattern.finditer(re_pattern))):
|
||||
v = get_unicode_category(p.group(1))
|
||||
brackets = True
|
||||
if v is None:
|
||||
continue
|
||||
for g in char_groups:
|
||||
if p.start(0) >= g[0] and p.end(0) <= g[1]:
|
||||
brackets = False
|
||||
break
|
||||
if brackets:
|
||||
v = "[" + v + "]"
|
||||
ure_pattern = ure_pattern[:p.start(0) - 1] + v + ure_pattern[p.end(0): len(ure_pattern)]
|
||||
return ure_pattern
|
||||
|
||||
|
||||
def compile(pattern, flags=0):
|
||||
"""
|
||||
compile after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
return re.compile(parse_unicode_properties(pattern), flags | re.UNICODE)
|
||||
|
||||
|
||||
def search(pattern, string, flags=0):
|
||||
"""
|
||||
search after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.search(parse_unicode_properties(pattern), string, flags | re.UNICODE)
|
||||
|
||||
|
||||
def match(pattern, string, flags=0):
|
||||
"""
|
||||
match after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.match(parse_unicode_properties(pattern), string, flags | re.UNICODE)
|
||||
|
||||
|
||||
def split(pattern, string, maxsplit=0, flags=0):
|
||||
"""
|
||||
split after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.split(parse_unicode_properties(pattern), string, maxsplit, flags | re.UNICODE)
|
||||
|
||||
|
||||
def findall(pattern, string, flags=0):
|
||||
"""
|
||||
findall after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.findall(parse_unicode_properties(pattern), string, flags | re.UNICODE)
|
||||
|
||||
|
||||
def finditer(pattern, string, flags=0):
|
||||
"""
|
||||
finditer after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.finditer(parse_unicode_properties(pattern), string, flags | re.UNICODE)
|
||||
|
||||
|
||||
def sub(pattern, repl, string, count=0, flags=0):
|
||||
"""
|
||||
sub after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.sub(parse_unicode_properties(pattern), repl, string, count, flags | re.UNICODE)
|
||||
|
||||
|
||||
def subn(pattern, repl, string, count=0, flags=0):
|
||||
"""
|
||||
subn after parsing unicode properties and set flag to unicode
|
||||
"""
|
||||
re.subn(parse_unicode_properties(pattern), repl, string, flags | re.UNICODE)
|
||||
|
||||
|
||||
_init_unicode()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Testing ure's unicode properties replacement")
|
||||
print(parse_unicode_properties(r"[\p{Ll}\p{Lu}]"))
|
||||
print(parse_unicode_properties(r"\p{Ll}\p{Lu}"))
|