Skip to content

Commit bda3637

Browse files
author
Alexey Ermakov
committed
Add new commands to menu and command list
Context menu: remove "get list" command, as it's available in command palette and main menu. Added new gist view commands: rename file, change gist description, delete file, delete gist. Commands themselves are not implemented yet. Main menu: split the Gist submenu into two logical blocks - commands that are always enabled (create gist/open gist) and gist view commands.
1 parent c948a3e commit bda3637

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

Context.sublime-menu

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[
2-
{ "command": "gist", "caption": "Create Public Gist" },
3-
{ "command": "gist_private", "caption": "Create Private Gist" },
4-
{ "command": "gist_list", "caption": "Get Gist List" }
2+
{ "command": "gist", "caption": "Create Public Gist…" },
3+
{ "command": "gist_private", "caption": "Create Private Gist…" }
54
]

Gist.sublime-commands

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
[
22
{
3-
"caption": "Gist (public): Create from Selected Text",
3+
"caption": "Gist: Create Public Gist",
44
"command": "gist"
55
},
66
{
7-
"caption": "Gist (private): Create from Selected Text",
7+
"caption": "Gist: Create Private Gist",
88
"command": "gist_private"
99
},
10+
{
11+
"caption": "Gist: Open Gist",
12+
"command": "gist_list"
13+
},
1014
{
1115
"caption": "Gist: Copy Gist URL",
1216
"command": "gist_copy_url"
@@ -20,7 +24,19 @@
2024
"command": "gist_update"
2125
},
2226
{
23-
"caption": "Gist: Get List",
24-
"command": "gist_list"
27+
"caption": "Gist: Rename File",
28+
"command": "gist_rename_file"
29+
},
30+
{
31+
"caption": "Gist: Change Gist Description",
32+
"command": "gist_rename"
33+
},
34+
{
35+
"caption": "Gist: Delete Gist File",
36+
"command": "gist_delete_file"
37+
},
38+
{
39+
"caption": "Gist: Delete Gist",
40+
"command": "gist_delete"
2541
}
2642
]

Main.sublime-menu

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"caption": "Gist",
1010
"children":
1111
[
12-
{ "command": "gist", "caption": "Create Public Gist" },
13-
{ "command": "gist_private", "caption": "Create Private Gist" },
12+
{ "command": "gist", "caption": "Create Public Gist…" },
13+
{ "command": "gist_private", "caption": "Create Private Gist…" },
14+
{ "command": "gist_list", "caption": "Open Gist…" },
15+
{ "caption": "-" },
1416
{ "command": "gist_copy_url", "caption": "Copy Gist URL" },
1517
{ "command": "gist_open_browser", "caption": "Open Gist In Browser"},
1618
{ "command": "gist_update", "caption": "Update Gist" },
17-
{ "command": "gist_list", "caption": "Get Gist List" }
19+
{ "command": "gist_rename_file", "caption": "Rename File…" },
20+
{ "command": "gist_rename", "caption": "Change Gist Description…" },
21+
{ "command": "gist_delete", "caption": "Delete Gist" }
1822
]
1923
}
2024

gist.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -264,24 +264,20 @@ def on_gist_description(description):
264264
for region in selections:
265265
create_gist_with_text(self.view.substr(region))
266266

267-
class GistCopyUrl(sublime_plugin.TextCommand):
267+
class GistViewCommand(object):
268+
"""A base class for commands operating on a gistified view"""
268269
def is_enabled(self):
269-
return self.view.settings().get("gist_html_url") is not None
270+
return self.view.settings().get("gist_url") is not None
270271

272+
class GistCopyUrl(GistViewCommand, sublime_plugin.TextCommand):
271273
def run(self, edit):
272274
sublime.set_clipboard(self.view.settings().get("gist_html_url"))
273275

274-
class GistOpenBrowser(sublime_plugin.TextCommand):
275-
def is_enabled(self):
276-
return self.view.settings().get("gist_html_url") is not None
277-
276+
class GistOpenBrowser(GistViewCommand, sublime_plugin.TextCommand):
278277
def run(self, edit):
279278
webbrowser.open(self.view.settings().get("gist_html_url"))
280279

281-
class GistUpdateCommand(sublime_plugin.TextCommand):
282-
def is_enabled(self):
283-
return self.view.settings().get("gist_url") is not None
284-
280+
class GistUpdateCommand(GistViewCommand, sublime_plugin.TextCommand):
285281
@catch_errors
286282
def run(self, edit):
287283
text = self.view.substr(sublime.Region(0, self.view.size()))

0 commit comments

Comments
 (0)