forked from apiad/sublime-browser-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser_integration_select.py
61 lines (43 loc) · 1.68 KB
/
browser_integration_select.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
53
54
55
56
57
58
59
60
61
from .browser_integration import *
class BrowserIntegrationSelectCommand(sublime_plugin.WindowCommand):
plugin_name = "Select by CSS"
plugin_description = "Select DOM elements by CSS selector."
@staticmethod
def visible():
return browser.connected()
@async
@require_browser
def run(self):
old_selector = browser.old_css_selector
@async
def cancel():
browser.unselect()
if old_selector:
browser.browser.select_css(old_selector)
view = self.window.show_input_panel('CSS Selector',
browser.old_css_selector,
None, self.highlight, cancel)
view.sel().add(sublime.Region(0, view.size()))
def highlight(self, selector):
browser.select_css(selector)
class BrowserIntegrationSelectxpathCommand(sublime_plugin.WindowCommand):
plugin_name = "Select by XPath"
plugin_description = "Select DOM elements by XPath selector."
@staticmethod
def visible():
return browser.connected()
@async
@require_browser
def run(self):
old_selector = browser.old_xpath_selector
@async
def cancel():
browser.unselect()
if old_selector:
browser.browser.select_xpath(old_selector)
view = self.window.show_input_panel('CSS Selector',
browser.old_xpath_selector,
None, self.highlight, cancel)
view.sel().add(sublime.Region(0, view.size()))
def highlight(self, selector):
browser.select_xpath(selector)