diff --git a/.sublime/MarkdownLivePreview.hidden-tmLanguage b/.sublime/MarkdownLivePreview.hidden-tmLanguage new file mode 100644 index 0000000..8544295 --- /dev/null +++ b/.sublime/MarkdownLivePreview.hidden-tmLanguage @@ -0,0 +1,14 @@ + + + + + name + MarkdownLivePreview + + patterns + + + scopeName + text.markdown-live-preview + + diff --git a/MLPApi.py b/MLPApi.py index f09e5f5..d1a6c99 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -34,6 +34,8 @@ def create_preview(window, file_name): preview.set_name(get_preview_name(file_name)) preview.set_scratch(True) + preview.set_syntax_file('Packages/MarkdownLivePreview/.sublime/' + 'MarkdownLivePreview.hidden-tmLanguage') return preview diff --git a/MarkdownLivePreview.py b/MarkdownLivePreview.py index ffe8164..ab4c88d 100644 --- a/MarkdownLivePreview.py +++ b/MarkdownLivePreview.py @@ -42,7 +42,7 @@ class NewMarkdownLivePreviewCommand(sublime_plugin.ApplicationCommand): class MarkdownLivePreviewListener(sublime_plugin.EventListener): - def on_modified(self, view): + def update(self, view): if not is_markdown_view(view): # faster than getting the settings return vsettings = view.settings() @@ -56,10 +56,36 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener): raise ValueError('The preview is None (id: {})'.format(id)) show_html(view, preview) + return view, preview + + def on_modified(self, view): + self.update(view) def on_window_command(self, window, command, args): if command == 'close' and window.settings().get(PREVIEW_WINDOW): return 'close_window', {} def on_load_async(self, view): - self.on_modified(view) + try: + md_view, preview = self.update(view) + except TypeError: + return + window = preview.window() + psettings = preview.settings() + + show_tabs = psettings.get('show_tabs') + show_minimap = psettings.get('show_minimap') + show_status_bar = psettings.get('show_status_bar') + show_sidebar = psettings.get('show_sidebar') + show_menus = psettings.get('show_menus') + + if show_tabs is not None: + window.set_tabs_visible(show_tabs) + if show_minimap is not None: + window.set_minimap_visible(show_minimap) + if show_status_bar is not None: + window.set_status_bar_visible(show_status_bar) + if show_sidebar is not None: + window.set_sidebar_visible(show_sidebar) + if show_menus is not None: + window.set_menu_visible(show_menus) diff --git a/MarkdownLivePreview.tasks b/MarkdownLivePreview.tasks index c9f9ec7..fb6c7b7 100644 --- a/MarkdownLivePreview.tasks +++ b/MarkdownLivePreview.tasks @@ -4,7 +4,6 @@ Fast: ☐ cache image in object when used, so that it's faster @needsTest ☐ call settings listener on_new too - might be too heavy ☐ add clear cache command - ☐ add settings for the preview Medium: ☐ auto refresh preview if loading images @@ -23,6 +22,7 @@ Unknown: ___________________ Archive: + ✔ add settings for the preview @done Sun 08 Jan 2017 at 17:36 @project(Fast) ✔ regive focus to the right markdown view @done Mon 02 Jan 2017 at 18:34 @project(Fast) ✔ try/except for 404 @done Mon 02 Jan 2017 at 18:03 @project(Fast) ✔ fix bug when empty `src` @done Mon 02 Jan 2017 at 17:15 @project(Fast) diff --git a/sample.md b/sample.md index 7d21412..d13d719 100644 --- a/sample.md +++ b/sample.md @@ -1,15 +1,11 @@ # DuckDuckGo - The Search engine you'll fall in love -This is cool. The stylesheet's back! - -This is a test, and this is pretty cool! - Hope you'll enjoy using MarkdownLivePreview! ![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png) ```python -print(hello world) +print('Hello world') if DEBUG: print('DEBUG_MODE on') ``` @@ -17,3 +13,7 @@ if DEBUG: > Only a fool knows everything. A wise man knows how little he knows The only think I know right now is that Boxy Theme's just awesome. + +this is a test, hello world, I know this, it's cool + +Hello world, this is a test, and it's working also.