add settings for the preview.

Need to update the README
This commit is contained in:
Mathieu PATUREL
2017-01-08 17:44:17 +11:00
parent 0143428114
commit 0e6660a331
5 changed files with 50 additions and 8 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>MarkdownLivePreview</string>
<key>patterns</key>
<array>
</array>
<key>scopeName</key>
<string>text.markdown-live-preview</string>
</dict>
</plist>

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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.