-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sublime-text-2-wpseek.py
59 lines (48 loc) · 1.73 KB
/
sublime-text-2-wpseek.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Oliver Schlöbe
# @Date: 2014-07-05 14:36:00
# @Last Modified by: Oliver Schlöbe
# @Last Modified time: 2014-11-01 17:43:00
# @Author URL: http://www.schloebe.de/
# @Plugin URL: https://github.com/AlphawolfWMP/sublime-text-2-wpseek
# @License: GPL 3+
# available commands
# wpseek_com_open_selection
# wpseek_com_search_selection
# wpseek_com_search_from_input
import sublime
import sublime_plugin
import subprocess
import webbrowser
def SearchWPSFor(text):
url = 'http://wpseek.com/' + text.replace(' ','%20') + '/'
webbrowser.open_new_tab(url)
def OpenWPSFunctionReference(text):
url = 'http://wpseek.com/' + text.replace(' ','%20') + '/'
webbrowser.open_new_tab(url)
class WPSeekComOpenSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
if selection.empty():
selection = self.view.word(selection)
text = self.view.substr(selection)
OpenWPSFunctionReference(text)
class WPSeekComSearchSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
if selection.empty():
selection = self.view.word(selection)
text = self.view.substr(selection)
SearchWPSFor(text)
class WPSeekComSearchFromInputCommand(sublime_plugin.WindowCommand):
def run(self):
# Get the search item
self.window.show_input_panel('Search wpseek.com for', '',
self.on_done, self.on_change, self.on_cancel)
def on_done(self, input):
SearchWPSFor(input)
def on_change(self, input):
pass
def on_cancel(self):
pass