-
-
Notifications
You must be signed in to change notification settings - Fork 245
/
bh_remove.py
52 lines (43 loc) · 1.49 KB
/
bh_remove.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
BracketHighlighter.
Copyright (c) 2013 - 2016 Isaac Muse <[email protected]>
License: MIT
"""
import sublime_plugin
from collections import namedtuple
MENU = namedtuple("Menu", "simple content block block_indent")(
"Remove Brackets",
"Remove Brackets and Content",
"Remove Brackets: Block",
"Remove Brackets: Indented Block"
)
class BhRemoveBracketsCommand(sublime_plugin.TextCommand):
"""Command to remove current highlighted brackets and optionally content."""
def remove_brackets(self, value):
"""Perform removal of brackets."""
if value != -1:
menu_item = MENU[value]
indent = menu_item == MENU.block_indent
block = menu_item == MENU.block or menu_item == MENU.block_indent
content = menu_item == MENU.content
self.view.run_command(
"bh_key",
{
"plugin": {
"type": ["__all__"],
"command": "bh_modules.bracketremove",
"args": {
"remove_indent": indent,
"remove_block": block,
"remove_content": content
}
}
}
)
def run(self, edit):
"""Show menu of removal options."""
self.window = self.view.window()
self.window.show_quick_panel(
list(MENU),
self.remove_brackets
)