Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 46 lines (40 sloc) 1.395 kB
14d203d @facelessuser Add Swap Bracket plugin
authored
1 import bracket_plugin
2 import sublime
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
3 import sublime_plugin
14d203d @facelessuser Add Swap Bracket plugin
authored
4
5
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
6 class swap_brackets_transform(bracket_plugin.BracketPluginCommand):
7 def run(self, bracket, content, selection, bracket_type="square"):
8 brackets = {
9 "square": ["[", "]"],
10 "round": ["(", ")"],
11 "angle": ["<", ">"],
12 "curly": ["{", "}"]
13 }
14 edit = self.view.begin_edit()
15 self.view.replace(edit, sublime.Region(bracket.begin(), bracket.begin() + 1), brackets[bracket_type][0])
16 self.view.replace(edit, sublime.Region(bracket.end() - 1, bracket.end()), brackets[bracket_type][1])
17 self.view.end_edit(edit)
14d203d @facelessuser Add Swap Bracket plugin
authored
18
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
19
20 class SwapBracketsCommand(sublime_plugin.WindowCommand):
14d203d @facelessuser Add Swap Bracket plugin
authored
21 def swap_brackets(self, value):
22 brackets = [
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
23 "square",
24 "round",
25 "angle",
26 "curly"
14d203d @facelessuser Add Swap Bracket plugin
authored
27 ]
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
28 self.window.run_command(
29 "bracket_highlighter_key", {
30 "plugin": {
31 "type": ["bracket"],
9d42d32 @facelessuser Version 1.5
authored
32 "command": "bracket_plugins.swap_brackets_transform",
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
33 "args": {"bracket_type": brackets[value]}
34 }
35 }
36 )
14d203d @facelessuser Add Swap Bracket plugin
authored
37
de2ce0e @facelessuser Multi-select for Bracket Swap / Add Fold by Brackets Plugin
authored
38 def run(self):
39 self.window.show_quick_panel(
14d203d @facelessuser Add Swap Bracket plugin
authored
40 [
41 "[] square", "() round",
42 "<> angle", "{} curly"
43 ],
44 self.swap_brackets
45 )
Something went wrong with that request. Please try again.