Skip to content

Commit 1f7ea59

Browse files
committed
Rework with new settings format, and addressing #19 with hanging editor instances
1 parent 5671586 commit 1f7ea59

File tree

8 files changed

+250
-356
lines changed

8 files changed

+250
-356
lines changed

Main.sublime-menu

Lines changed: 41 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,43 @@
11
[
2-
{
3-
"caption": "Tools",
4-
"mnemonic": "T",
5-
"id": "tools",
6-
"children":
7-
[
8-
{
9-
"command": "view_in_browser",
10-
"caption": "View in Browser"
11-
}
12-
]
13-
},
14-
{
15-
"caption": "Preferences",
16-
"mnemonic": "n",
17-
"id": "preferences",
18-
"children":
19-
[
20-
{
21-
"caption": "Package Settings",
22-
"mnemonic": "P",
23-
"id": "package-settings",
24-
"children":
25-
[
26-
{
27-
"caption": "View in Browser",
28-
"children":
29-
[
30-
{
31-
"command": "open_file",
32-
"args": {"file": "${packages}/View In Browser/View In Browser.sublime-settings"},
33-
"caption": "Settings – Default"
34-
},
35-
{
36-
"command": "open_file",
37-
"args": {"file": "${packages}/User/View In Browser.sublime-settings"},
38-
"caption": "Settings – User"
39-
},
40-
{ "caption": "-" },
41-
{
42-
"command": "open_file",
43-
"args": {
44-
"file": "${packages}/View in Browser/Default (OSX).sublime-keymap",
45-
"platform": "OSX"
46-
},
47-
"caption": "Key Bindings – Default"
48-
},
49-
{
50-
"command": "open_file",
51-
"args": {
52-
"file": "${packages}/View in Browser/Default (Linux).sublime-keymap",
53-
"platform": "Linux"
54-
},
55-
"caption": "Key Bindings – Default"
56-
},
57-
{
58-
"command": "open_file",
59-
"args": {
60-
"file": "${packages}/View in Browser/Default (Windows).sublime-keymap",
61-
"platform": "Windows"
62-
},
63-
"caption": "Key Bindings – Default"
64-
},
65-
{
66-
"command": "open_file",
67-
"args": {
68-
"file": "${packages}/User/Default (OSX).sublime-keymap",
69-
"platform": "OSX"
70-
},
71-
"caption": "Key Bindings – User"
72-
},
73-
{
74-
"command": "open_file",
75-
"args": {
76-
"file": "${packages}/User/Default (Linux).sublime-keymap",
77-
"platform": "Linux"
78-
},
79-
"caption": "Key Bindings – User"
80-
},
81-
{
82-
"command": "open_file",
83-
"args": {
84-
"file": "${packages}/User/Default (Windows).sublime-keymap",
85-
"platform": "Windows"
86-
},
87-
"caption": "Key Bindings – User"
88-
},
89-
{ "caption": "-" }
90-
]
91-
}
92-
]
93-
}
94-
]
95-
}
2+
{
3+
"caption": "Tools",
4+
"mnemonic": "T",
5+
"id": "tools",
6+
"children": [
7+
{
8+
"command": "view_in_browser",
9+
"caption": "View in Browser"
10+
}
11+
]
12+
},
13+
{
14+
"caption": "Preferences",
15+
"mnemonic": "n",
16+
"id": "preferences",
17+
"children": [
18+
{
19+
"caption": "Package Settings",
20+
"mnemonic": "P",
21+
"id": "package-settings",
22+
"children": [
23+
{
24+
"caption": "View in Browser",
25+
"children": [
26+
{
27+
"command": "open_file",
28+
"args": {"file": "${packages}/View In Browser/View In Browser.sublime-settings"},
29+
"caption": "Settings – Default"
30+
},
31+
{
32+
"command": "open_file",
33+
"args": {"file": "${packages}/User/View In Browser.sublime-settings"},
34+
"caption": "Settings – User"
35+
},
36+
{ "caption": "-" }
37+
]
38+
}
39+
]
40+
}
41+
]
42+
}
9643
]

README.md

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
11
# Sublime Text - View In Browser
22

33
*<a href="http://adampresley.github.io/sublime-view-in-browser/">View In Browser</a>* is a Sublime Text plugin that will open whatever is in your
4-
current view/tab. If the file current open is new and has not been saved a temporary
5-
file is created (in your default temp directory for your OS) with the extension of
6-
**.htm** and your browser will open it. However if the current open file is saved
7-
and has a name this plugin will open it in whatever you have set to handle
8-
its type.
4+
current view/tab. If the file current open is new and has not been saved a temporary file is created (in your default temp directory for your OS) with the extension of **.htm** and your browser will open it. However if the current open file is saved and has a name this plugin will open it in whatever you have set to handle its type.
95

106
By default the keystroke assigned to this plugin is *CTRL + ALT + V*.
117

128
## Installation
13-
Using the Sublime Text Package Control plugin (http://wbond.net/sublime_packages/package_control)
14-
press *CTRL + SHIFT + P* and find **Package Control: Install Package** and press *Enter*.
15-
Find this plugin in the list by name **View In Browser**.
9+
Using the Sublime Text Package Control plugin (http://wbond.net/sublime_packages/package_control) press *CTRL + SHIFT + P* and find **Package Control: Install Package** and press *Enter*. Find this plugin in the list by name **View In Browser**.
1610

1711
## Configuring Browsers
1812
By default this plugin will open files in Firefox. You can configure it to open
1913
using another browser of your choice. To do this, choose *Settings - User* from *Preferences > Package Settings > View In Browser*.
2014

21-
The browser you wish to use to open files is set in the key named **selectedBrowser**. The list of browsers
22-
you can use and configure are in the key named **supportedBrowsers**.
15+
The browser you wish to use to open files is set in the key named **browser**. The following is a list of browsers configured for use out of the box.
2316

24-
The **supportedBrowsers** values can be configured to have paths to your browser installations.
25-
Each browser listed is an array (list) of configurations that allow you to setup a browser
26-
for multiple operating systems. For example under *chrome* there are two configurations.
27-
The first is for your average Linux system. The second is for Windows.
17+
* Firefox - Mac OS, Linux, Windows
18+
* Chrome - Mac OS, Linux, Windows
19+
* Chrome64 - Windows
20+
* Safari - Mac OS
21+
* Internet Explorer - Windows
22+
* Chromium - Linux
2823

2924
## Other Browsers
30-
View In Browser also provides key bindings to open your current view in browser other than
31-
your **selectedBrowser**. Below is a listing of the keys and what browser open with
32-
those key bindings.
25+
View In Browser also provides key bindings to open your current view in browser other than your **browser** setting. Below is a listing of the keys and what browser open with those key bindings.
3326

3427
* *CTRL + ALT + F* - Firefox
3528
* *CTRL + ALT + C* - Chrome
3629
* *CTRL + ALT + I* - Internet Explorer
3730
* *CTRL + ALT + S* - Safari
3831

39-
Like any other key binding in Sublime these can be changed. Below is an example of the
40-
key configuration. You can remap these in your User key bindings configuration file.
32+
Like any other key binding in Sublime these can be changed. Below is an example of the key configuration. You can remap these in your User key bindings configuration file.
4133

4234
```javascript
4335
[
@@ -50,11 +42,7 @@ key configuration. You can remap these in your User key bindings configuration f
5042
```
5143

5244
### Windows Considerations
53-
One of the things you may notice in the Windows configuration for *chrome* is a variable in
54-
the command path that looks like: **%Local AppData%**. This is a reference to your Windows
55-
installation's **AppData** folder in your user profile directory. There is a variable
56-
there because this value will differ for each user on your computer, and Chrome installs
57-
to your **AppData** folder.
45+
One of the things you may notice in the Windows configuration for *chrome* is a variable in the command path that looks like: **%Local AppData%**. This is a reference to your Windows installation's **AppData** folder in your user profile directory. There is a variable there because this value will differ for each user on your computer, and Chrome installs to your **AppData** folder.
5846

5947
Here is a list of supported variables:
6048

@@ -67,19 +55,12 @@ Here is a list of supported variables:
6755
* **My Pictures** - Path to your pictures location
6856
* **My Music** - Path to your music location
6957

70-
Note that many of these are not terribly useful for determining browser location, unless you
71-
have decided to install Firefox in your My Music folder.
72-
58+
Note that many of these are not terribly useful for determining browser location, unless you have decided to install Firefox in your My Music folder.
7359

7460
## Configure to View on Local Server
75-
The View In Browser plugin also supports the ability to view files in the context of
76-
a local server. So if you have a local Apache, Tomcat, or some other server application running
77-
you can configure this plugin to open your file prefixed with a URL.
61+
The View In Browser plugin also supports the ability to view files in the context of a local server. So if you have a local Apache, Tomcat, or some other server application running you can configure this plugin to open your file prefixed with a URL.
7862

79-
To configure this the View In Browser plugin reads the configuration of your currently
80-
loaded project. You can edit a project file by opening the *sublime-project* file
81-
by choosing **Project** -> **Edit Project**. In your project file you will need to specify
82-
two things:
63+
To configure this the View In Browser plugin reads the configuration of your currently loaded project. You can edit a project file by opening the *sublime-project* file by choosing **Project** -> **Edit Project**. In your project file you will need to specify two things:
8364

8465
* **baseUrl** - The root URL to prefix files with
8566
* **basePath** - The base path where your site/application lives
@@ -103,15 +84,16 @@ Here's how that looks.
10384
}
10485
```
10586

106-
Notice the key named **settings** which is a dictionary that contains another key named
107-
**sublime-view-in-browser**. This is where you will put your **baseUrl** and **basePath**
108-
settings.
87+
Notice the key named **settings** which is a dictionary that contains another key named **sublime-view-in-browser**. This is where you will put your **baseUrl** and **basePath** settings.
10988

110-
Now when you activate View In Browser your file will open with the HTTP protocol instead
111-
of the FILE protocol.
89+
Now when you activate View In Browser your file will open with the HTTP protocol instead of the FILE protocol.
11290

11391
## Change History
11492

93+
* 10/06/2014:
94+
* Rewrite for version 2.0.0
95+
* Using subprocess instead of webbrowser. Seems to solve #19
96+
* Smaller, simplier sublime-settings file
11597
* 05/15/2014:
11698
* Current view only saves if there are modifications
11799
* 07/03/2013:

View In Browser.sublime-settings

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,27 @@
11
{
2-
"supportedBrowsers": {
3-
"firefox": [
4-
{
5-
"osname": "posix",
6-
"platform": ".*",
7-
"command": "firefox"
8-
},
9-
{
10-
"osname": "posix",
11-
"platform": "darwin",
12-
"command": "open -a \"/Applications/Firefox.app\""
13-
},
14-
{
15-
"osname": "nt",
16-
"platform": "win32",
17-
"command": "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
18-
}
19-
],
20-
"safari": [
21-
{
22-
"osname": "posix",
23-
"platform": "darwin",
24-
"command": "open -a \"/Applications/Safari.app\""
25-
}
26-
],
27-
"iexplore": [
28-
{
29-
"osname": "nt",
30-
"platform": "win32",
31-
"command": "C:/Program Files/Internet Explorer/iexplore.exe"
32-
}
33-
],
34-
"chrome": [
35-
{
36-
"osname": "posix",
37-
"platform": "darwin",
38-
"command": "open -a \"/Applications/Google Chrome.app\""
39-
},
40-
{
41-
"osname": "posix",
42-
"platform": "linux.*",
43-
"command": "google-chrome"
44-
},
45-
{
46-
"osname": "nt",
47-
"platform": "win32",
48-
"command": "%Local AppData%/Google/Chrome/Application/chrome.exe"
49-
}
50-
],
51-
"chromium": [
52-
{
53-
"osname": "posix",
54-
"platform": "linux.*",
55-
"command": "chromium"
56-
}
57-
]
2+
"posix": {
3+
"linux": {
4+
"firefox": "firefox -new-tab",
5+
"chrome": "google-chrome",
6+
"chrome64": "google-chrome",
7+
"chromium": "chromium"
8+
},
9+
10+
"darwin": {
11+
"firefox": "open -a \"/Applications/Firefox.app\"",
12+
"safari": "open -a \"/Applications/Safari.app\"",
13+
"chrome": "open -a \"/Applications/Google Chrome.app\"",
14+
"chrome64": "open -a \"/Applications/Google Chrome.app\""
15+
}
16+
},
17+
"nt": {
18+
"win32": {
19+
"firefox": "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -new-tab",
20+
"iexplore": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
21+
"chrome": "%Local AppData%\\Google\\Chrome\\Application\\chrome.exe",
22+
"chrome64": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
23+
}
5824
},
5925

60-
"selectedBrowser": "firefox"
26+
"browser": "firefox"
6127
}

ViewInBrowser.sublime-commands

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
{ "caption": "View In Browser", "command": "view_in_browser" }
2+
{ "caption": "View In Browser", "command": "view_in_browser" }
33
]

0 commit comments

Comments
 (0)