forked from facelessuser/BracketHighlighter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bh_remove.py
51 lines (42 loc) · 1.45 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
"""
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.WindowCommand):
"""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.window.run_command(
"bh_key",
{
"plugin": {
"type": ["__all__"],
"command": "bh_modules.bracketremove",
"args": {
"remove_indent": indent,
"remove_block": block,
"remove_content": content
}
}
}
)
def run(self):
"""Show menu of removal options."""
self.window.show_quick_panel(
list(MENU),
self.remove_brackets
)