Skip to content

Commit b6da997

Browse files
committed
feat: New changelog command
Now the `Changelog` command will open the changelog as a sublime text tab.
1 parent 8872738 commit b6da997

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

changes.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Changelog."""
2+
import sublime
3+
import sublime_plugin
4+
import mdpopups
5+
6+
CSS = '''
7+
.mt-config-changes { {{'.background'|css}} margin: 0; padding: 0; }
8+
.mt-config-changes ul li, .bracket-hightlighter p { {{'.foreground'|css}} }
9+
.mt-config-changes a { color: #4B67FF; }
10+
.mt-config-changes h1, .mt-config-changes h2, .mt-config-changes h3,
11+
.mt-config-changes h4, .mt-config-changes h5, .mt-config-changes h6 {
12+
{{'.string'|css('color')}}
13+
}
14+
.mt-config-changes h1, .mt-config-changes h2 { margin-top: 50px; }
15+
.mt-config-changes h3, .mt-config-changes h4 { margin-top: 30px; }
16+
.mt-config-changes blockquote { {{'.foreground'|css('color')}} }
17+
'''
18+
19+
20+
class MtChangesCommand(sublime_plugin.WindowCommand):
21+
"""Changelog command."""
22+
23+
def run(self):
24+
"""Show the changelog in a new view."""
25+
text = sublime.load_resource('Packages/Material Theme/CHANGELOG.md')
26+
view = self.window.new_file()
27+
view.set_name('Material Theme - Changelog')
28+
view.settings().set('gutter', False)
29+
html = '<div class="mt-config-changes">%s</div>' % mdpopups.md2html(view, text)
30+
mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=CSS)
31+
view.set_read_only(True)
32+
view.set_scratch(True)
33+
34+
def is_enabled(self):
35+
"""Check if is enabled."""
36+
return (mdpopups.version() >= (1, 7, 3)) and (int(sublime.version()) >= 3118)
37+
38+
is_visible = is_enabled

urls.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,4 @@ class MtIssuesCommand(sublime_plugin.WindowCommand):
1717

1818
def run(self):
1919
"""Show the changelog in a new view."""
20-
webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/issues')
21-
22-
23-
class MtChangesCommand(sublime_plugin.WindowCommand):
24-
"""Changelog command."""
25-
26-
def run(self):
27-
"""Show the changelog in a new view."""
28-
webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/blob/master/CHANGELOG.md')
20+
webbrowser.open_new_tab('https://github.com/equinusocio/material-theme/issues')

0 commit comments

Comments
 (0)