feat(SublimeText2.UtilPackages): cache packages
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"caption": "Search Anywhere",
|
||||
"mnemonic": "w",
|
||||
"id": "searchanywhere",
|
||||
"children":
|
||||
[
|
||||
{
|
||||
"command": "search_anywhere_from_selection",
|
||||
"caption": "Search From Selection"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_from_input",
|
||||
"caption": "Search From Input"
|
||||
},
|
||||
{
|
||||
"caption": "-"
|
||||
},
|
||||
{
|
||||
"caption": "Select Search Engine Then",
|
||||
"children":
|
||||
[
|
||||
{
|
||||
"command": "search_anywhere_from_selection_ask",
|
||||
"caption": "Search From Selection"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_from_input_ask",
|
||||
"caption": "Search From Input"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"caption": "-"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_select_default_search_engine",
|
||||
"caption": "Set Default Search Engine"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_select_search_engine_for_type",
|
||||
"caption": "Set Search Engine For File Type"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"caption": "Search Anywhere: From Selection",
|
||||
"command": "search_anywhere_from_selection"
|
||||
},
|
||||
{
|
||||
"caption": "Search Anywhere: From Input",
|
||||
"command": "search_anywhere_from_input"
|
||||
},
|
||||
{
|
||||
"caption": "Search Anywhere: Set Default Search Engine",
|
||||
"command": "search_anywhere_select_default_search_engine"
|
||||
},
|
||||
{
|
||||
"caption": "Search Anywhere: Set Search Engine For File Type",
|
||||
"command": "search_anywhere_select_search_engine_for_type"
|
||||
},
|
||||
{
|
||||
"caption": "Search Anywhere: From Selection (ask Search Engine)",
|
||||
"command": "search_anywhere_from_selection_ask"
|
||||
},
|
||||
{
|
||||
"caption": "Search Anywhere: From Input (ask Search Engine)",
|
||||
"command": "search_anywhere_from_input_ask"
|
||||
}
|
||||
]
|
@@ -0,0 +1,55 @@
|
||||
[
|
||||
{
|
||||
"caption": "Tools",
|
||||
"mnemonic": "t",
|
||||
"id": "tools",
|
||||
"children":
|
||||
[
|
||||
{
|
||||
"caption": "Search Anywhere",
|
||||
"mnemonic": "w",
|
||||
"id": "searchanywhere",
|
||||
"children":
|
||||
[
|
||||
{
|
||||
"command": "search_anywhere_from_selection",
|
||||
"caption": "Search From Selection"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_from_input",
|
||||
"caption": "Search From Input"
|
||||
},
|
||||
{
|
||||
"caption": "-"
|
||||
},
|
||||
{
|
||||
"caption": "Select Search Engine Then",
|
||||
"children":
|
||||
[
|
||||
{
|
||||
"command": "search_anywhere_from_selection_ask",
|
||||
"caption": "Search From Selection"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_from_input_ask",
|
||||
"caption": "Search From Input"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"caption": "-"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_select_default_search_engine",
|
||||
"caption": "Set Default Search Engine"
|
||||
},
|
||||
{
|
||||
"command": "search_anywhere_select_search_engine_for_type",
|
||||
"caption": "Set Search Engine For File Type"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@@ -0,0 +1,25 @@
|
||||
# Sublime Text 2 Search Anywhere Plugin
|
||||
|
||||
A plugin that allows the user to search the web through multiple search engines. Each file type can have its own search engine.
|
||||
|
||||
## Install
|
||||
|
||||
The preferred method is to use the [Sublime Package Manager](http://wbond.net/sublime_packages/package_control). Alternatively, the files can be obtained on github:
|
||||
|
||||
$ https://github.com/ericmartel/Sublime-Text-2-Search-Anywhere-Plugin
|
||||
|
||||
## Complete Documentation
|
||||
|
||||
A website is currently under construction to explain the usage of the plugin in details. In the meantime, please visit this [Web Site](http://www.ericmartel.com/sublime-text-2-search-anywhere/).
|
||||
|
||||
# License
|
||||
|
||||
All of Sublime Text 2 Search Anywhere Plugin is licensed under the MIT license.
|
||||
|
||||
Copyright (c) 2012 Eric Martel <emartel@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"install": "messages/install.txt"
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
Search Anywhere by Eric Martel (emartel@gmail.com / www.ericmartel.com)
|
||||
|
||||
Thank you for installing Search Anywhere. For detailed instructions please visit http://www.ericmartel.com/sublime-text-2-search-anywhere/. All commands are available through menus, context menus and the command palette.
|
||||
|
||||
Please direct any feedback to emartel@gmail.com or through github at https://github.com/ericmartel/Sublime-Text-2-Search-Anywhere-Plugin.
|
||||
|
||||
Thank you for your support.
|
||||
|
||||
Eric Martel
|
@@ -0,0 +1 @@
|
||||
{"url": "http://www.ericmartel.com/sublime-text-2-search-anywhere/", "version": "2012.03.20.16.35.46", "description": "Utility to quickly search on multiple search engines from the current selection or custom input. Default search engine configurable per file type. Search Engines defined through JSON including Google, Yahoo, Bing, Stack Overflow, PHP.net, sitepoint and caniuse.com "}
|
@@ -0,0 +1,160 @@
|
||||
# Written by Eric Martel (emartel@gmail.com / www.ericmartel.com)
|
||||
|
||||
import sublime
|
||||
import sublime_plugin
|
||||
|
||||
import subprocess
|
||||
import webbrowser
|
||||
import threading
|
||||
import os
|
||||
import json
|
||||
|
||||
searchanywhere_dir = os.getcwdu()
|
||||
|
||||
# Helper functions
|
||||
def SearchFor(view, text, searchurl):
|
||||
if not searchurl:
|
||||
# see if we have an extension match first, then use default
|
||||
settings = sublime.load_settings(__name__ + '.sublime-settings')
|
||||
|
||||
filename, ext = os.path.splitext(view.file_name())
|
||||
typesettings = settings.get('searchanywhere_type_searchengine', [])
|
||||
|
||||
foundsetting = False
|
||||
for typesetting in typesettings:
|
||||
if typesetting['extension'] == ext:
|
||||
foundsetting = True
|
||||
searchurl = typesetting['searchurl']
|
||||
|
||||
if not foundsetting:
|
||||
if settings.has('searchanywhere_searchurl'):
|
||||
searchurl = settings.get('searchanywhere_searchurl')
|
||||
else:
|
||||
sublime.error_message(__name__ + ': No Search Engine selected')
|
||||
return
|
||||
else:
|
||||
# search url is provided by the caller
|
||||
pass
|
||||
|
||||
url = searchurl.replace('{0}', text.replace(' ','%20'))
|
||||
webbrowser.open_new_tab(url)
|
||||
|
||||
def ShowSearchEnginesList(window, callback):
|
||||
searchengines = []
|
||||
if os.path.exists(searchanywhere_dir + os.sep + 'searchengines.json'):
|
||||
f = open(searchanywhere_dir + os.sep + 'searchengines.json')
|
||||
searchengineslist = json.load(f)
|
||||
f.close()
|
||||
|
||||
for entry in searchengineslist.get('searchengines'):
|
||||
formattedentry = []
|
||||
formattedentry.append(entry.get('name'))
|
||||
formattedentry.append(entry.get('baseurl'))
|
||||
searchengines.append(formattedentry)
|
||||
|
||||
window.show_quick_panel(searchengines, callback)
|
||||
|
||||
def GetSearchEngineEntry(picked):
|
||||
f = open(searchanywhere_dir + os.sep + 'searchengines.json')
|
||||
searchengineslist = json.load(f)
|
||||
entry = searchengineslist.get('searchengines')[picked]
|
||||
f.close()
|
||||
return entry
|
||||
|
||||
class SearchAnywhereFromSelectionAskCommand(sublime_plugin.TextCommand):
|
||||
def run(self, edit):
|
||||
ShowSearchEnginesList(self.view.window(), self.on_select_done)
|
||||
|
||||
def on_select_done(self, picked):
|
||||
entry = GetSearchEngineEntry(picked)
|
||||
|
||||
for selection in self.view.sel():
|
||||
# if the user didn't select anything, search the currently highlighted word
|
||||
if selection.empty():
|
||||
selection = self.view.word(selection)
|
||||
|
||||
text = self.view.substr(selection)
|
||||
SearchFor(self.view, text, entry.get('searchurl'))
|
||||
|
||||
class SearchAnywhereFromInputAskCommand(sublime_plugin.WindowCommand):
|
||||
def run(self):
|
||||
ShowSearchEnginesList(self.window, self.on_select_done)
|
||||
|
||||
def on_select_done(self, picked):
|
||||
self.entry = GetSearchEngineEntry(picked)
|
||||
|
||||
self.window.show_input_panel('Search on ' + self.entry.get('name') + ' for', '', self.on_done, self.on_change, self.on_cancel)
|
||||
|
||||
def on_done(self, input):
|
||||
SearchFor(self.window.active_view(), input, self.entry.get('searchurl'))
|
||||
|
||||
def on_change(self, input):
|
||||
pass
|
||||
|
||||
def on_cancel(self):
|
||||
pass
|
||||
|
||||
|
||||
class SearchAnywhereFromSelectionCommand(sublime_plugin.TextCommand):
|
||||
def run(self, edit):
|
||||
for selection in self.view.sel():
|
||||
# if the user didn't select anything, search the currently highlighted word
|
||||
if selection.empty():
|
||||
selection = self.view.word(selection)
|
||||
|
||||
text = self.view.substr(selection)
|
||||
SearchFor(self.view, text, None)
|
||||
|
||||
class SearchAnywhereFromInputCommand(sublime_plugin.WindowCommand):
|
||||
def run(self):
|
||||
settings = sublime.load_settings(__name__ + '.sublime-settings')
|
||||
if settings.has('searchanywhere_searchengine'):
|
||||
engine = settings.get('searchanywhere_searchengine')
|
||||
self.window.show_input_panel('Search on ' + engine + ' for', '', self.on_done, self.on_change, self.on_cancel)
|
||||
else:
|
||||
sublime.error_message(__name__ + ': No Search Engine selected')
|
||||
|
||||
def on_done(self, input):
|
||||
SearchFor(self.window.active_view(), input, None)
|
||||
|
||||
def on_change(self, input):
|
||||
pass
|
||||
|
||||
def on_cancel(self):
|
||||
pass
|
||||
|
||||
# Sets the default Search Engine to use
|
||||
class SearchAnywhereSelectDefaultSearchEngineCommand(sublime_plugin.WindowCommand):
|
||||
def run(self):
|
||||
ShowSearchEnginesList(self.window, self.on_select_done)
|
||||
|
||||
def on_select_done(self, picked):
|
||||
entry = GetSearchEngineEntry(picked)
|
||||
|
||||
settings = sublime.load_settings(__name__ + '.sublime-settings')
|
||||
settings.set('searchanywhere_searchengine', entry.get('name'))
|
||||
settings.set('searchanywhere_searchurl', entry.get('searchurl'))
|
||||
sublime.save_settings(__name__ + '.sublime-settings')
|
||||
|
||||
# Sets the default Search Engine to use for files sharing the view's extension
|
||||
class SearchAnywhereSelectSearchEngineForTypeCommand(sublime_plugin.WindowCommand):
|
||||
def run(self):
|
||||
self.filename, self.ext = os.path.splitext(self.window.active_view().file_name())
|
||||
ShowSearchEnginesList(self.window, self.on_select_done)
|
||||
|
||||
def on_select_done(self, picked):
|
||||
entry = GetSearchEngineEntry(picked)
|
||||
|
||||
settings = sublime.load_settings(__name__ + '.sublime-settings')
|
||||
|
||||
typesettings = settings.get('searchanywhere_type_searchengine', [])
|
||||
|
||||
newsetting = {}
|
||||
newsetting['extension'] = self.ext
|
||||
newsetting['name'] = entry.get('name')
|
||||
newsetting['searchurl'] = entry.get('searchurl')
|
||||
|
||||
typesettings.append(newsetting)
|
||||
|
||||
settings.set('searchanywhere_type_searchengine', typesettings)
|
||||
sublime.save_settings(__name__ + '.sublime-settings')
|
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"schema_version": "1.2",
|
||||
"searchengines": [
|
||||
{
|
||||
"name": "Google",
|
||||
"baseurl": "www.google.com",
|
||||
"searchurl": "http://www.google.com/search?q={0}"
|
||||
},
|
||||
{
|
||||
"name": "Stack Overflow",
|
||||
"baseurl": "www.stackoverflow.com",
|
||||
"searchurl": "http://stackoverflow.com/search?tab=relevance&q={0}"
|
||||
},
|
||||
{
|
||||
"name": "PHP",
|
||||
"baseurl": "www.php.net",
|
||||
"searchurl": "http://ca3.php.net/manual-lookup.php?pattern={0}&scope=quickref"
|
||||
},
|
||||
{
|
||||
"name": "Bing",
|
||||
"baseurl": "www.bing.com",
|
||||
"searchurl": "http://www.bing.com/search?q={0}"
|
||||
},
|
||||
{
|
||||
"name": "Yahoo",
|
||||
"baseurl": "www.yahoo.com",
|
||||
"searchurl": "http://search.yahoo.com/search?p={0}"
|
||||
},
|
||||
{
|
||||
"name": "sitepoint",
|
||||
"baseurl": "reference.sitepoint.com",
|
||||
"searchurl": "http://reference.sitepoint.com/html/{0}"
|
||||
},
|
||||
{
|
||||
"name": "When can I use...",
|
||||
"baseurl": "caniuse.com",
|
||||
"searchurl": "http://caniuse.com/#search={0}"
|
||||
},
|
||||
{
|
||||
"name": "Mozilla Developer Network",
|
||||
"baseurl": "developer.mozilla.org",
|
||||
"searchurl": "https://developer.mozilla.org/en-US/search?q={0}"
|
||||
},
|
||||
{
|
||||
"name": "Ruby on Rails",
|
||||
"baseurl": "api.rubyonrails.org",
|
||||
"searchurl": "http://api.rubyonrails.org/?q={0}"
|
||||
},
|
||||
{
|
||||
"name": "Ruby Doc",
|
||||
"baseurl": "www.ruby-doc.org",
|
||||
"searchurl": "http://www.ruby-doc.org/search.html?cx=011815814100681837392%3Awnccv6st5qk&q={0}&sa=Search&cof=FORID%3A9"
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user