Skip to content
This repository was archived by the owner on May 6, 2023. It is now read-only.

Commit e09c7cb

Browse files
committed
Fix #6 Add option to choose a default browser
This commit add a settings option where you can define the default browser to open the can i use page.
1 parent 1568bee commit e09c7cb

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

Can I Use.sublime-settings

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"default_browser": ""
3+
4+
// Type Name Class Name Notes
5+
// 'mozilla' Mozilla('mozilla')
6+
// 'firefox' Mozilla('mozilla')
7+
// 'netscape' Mozilla('netscape')
8+
// 'galeon' Galeon('galeon')
9+
// 'epiphany' Galeon('epiphany')
10+
// 'skipstone' BackgroundBrowser('skipstone')
11+
// 'kfmclient' Konqueror() (1)
12+
// 'konqueror' Konqueror() (1)
13+
// 'kfm' Konqueror() (1)
14+
// 'mosaic' BackgroundBrowser('mosaic')
15+
// 'opera' Opera()
16+
// 'grail' Grail()
17+
// 'links' GenericBrowser('links')
18+
// 'elinks' Elinks('elinks')
19+
// 'lynx' GenericBrowser('lynx')
20+
// 'w3m' GenericBrowser('w3m')
21+
// 'windows-default' WindowsDefault (2)
22+
// 'internet-config' InternetConfig (3)
23+
// 'macosx' MacOSX('default') (4)
24+
}
25+

Main.sublime-menu

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[
2+
{
3+
"id": "tools",
4+
"children":
5+
[
6+
{
7+
"caption": "Can I Use",
8+
"children":
9+
[
10+
{ "caption": "Command name", "command": "useIt" }
11+
]
12+
}
13+
]
14+
},
15+
{
16+
"caption": "Preferences",
17+
"mnemonic": "n",
18+
"id": "preferences",
19+
"children":
20+
[
21+
{
22+
"caption": "Package Settings",
23+
"mnemonic": "P",
24+
"id": "package-settings",
25+
"children":
26+
[
27+
{
28+
"caption": "Can I Use",
29+
"children":
30+
[
31+
{
32+
"command": "open_file",
33+
"args": {"file": "${packages}/Can I Use/Can I Use.sublime-settings"},
34+
"caption": "Settings – Default"
35+
},
36+
{
37+
"command": "open_file",
38+
"args": {"file": "${packages}/User/Can I Use.sublime-settings"},
39+
"caption": "Settings – User"
40+
},
41+
{ "caption": "-" }
42+
]
43+
}
44+
]
45+
}
46+
]
47+
}
48+
]

useIt.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import sublime
12
import sublime_plugin
3+
4+
import sys
25
import re
36
import webbrowser
47

@@ -15,6 +18,9 @@ class UseItCommand(sublime_plugin.TextCommand):
1518
"""
1619

1720
def run(self, edit):
21+
s = sublime.load_settings("Can I Use.sublime-settings")
22+
default_browser = s.get('default_browser', '')
23+
1824
for region in self.view.sel():
1925
# Get the start point of the region of the selection
2026
point = region.begin()
@@ -26,4 +32,7 @@ def run(self, edit):
2632
re_search = CLEAN_CSS_PATTERN.search(search)
2733
if re_search:
2834
search = re_search.group()
29-
webbrowser.open_new_tab(BASE_URL + search)
35+
36+
37+
browser = webbrowser.get(default_browser)
38+
browser.open_new_tab(BASE_URL + search)

0 commit comments

Comments
 (0)