add clear cache command

This commit is contained in:
Mathieu PATUREL
2017-01-09 12:04:12 +11:00
parent ded9c28096
commit ff8c94bda5
4 changed files with 18 additions and 3 deletions

View File

@ -2,5 +2,9 @@
{ {
"caption": "MarkdownLivePreview: Edit Current File", "caption": "MarkdownLivePreview: Edit Current File",
"command": "new_markdown_live_preview" "command": "new_markdown_live_preview"
},
{
"caption": "MarkdownLivePreview: Clear Cache",
"command": "markdown_live_preview_clear_cache"
} }
] ]

View File

@ -10,17 +10,18 @@ from .lib import markdown2 as md2
from .escape_amp import * from .escape_amp import *
from .functions import * from .functions import *
from .setting_names import * from .setting_names import *
from .image_manager import CACHE_FILE
__folder__ = os.path.dirname(__file__) __folder__ = os.path.dirname(__file__)
STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User',
'MarkdownLivePreview.css') 'MarkdownLivePreview.css')
def plugin_loaded(): def plugin_loaded():
global DEFAULT_STYLE_FILE global DEFAULT_STYLE_FILE
DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/' DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/'
'default.css') 'default.css')
def get_preview_name(md_view): def get_preview_name(md_view):
file_name = md_view.file_name() file_name = md_view.file_name()
@ -82,3 +83,7 @@ def show_html(md_view, preview):
vector[1] = mini(vector[1], 0) vector[1] = mini(vector[1], 0)
vector[1] += preview.line_height() vector[1] += preview.line_height()
preview.set_viewport_position(vector, animate=False) preview.set_viewport_position(vector, animate=False)
def clear_cache():
"""Removes the cache file"""
os.remove(CACHE_FILE)

View File

@ -89,3 +89,9 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
window.set_sidebar_visible(show_sidebar) window.set_sidebar_visible(show_sidebar)
if show_menus is not None: if show_menus is not None:
window.set_menu_visible(show_menus) window.set_menu_visible(show_menus)
class MarkdownLivePreviewClearCacheCommand(sublime_plugin.ApplicationCommand):
def run(self):
clear_cache()

View File

@ -2,7 +2,6 @@ Fast:
☐ sync scroll @needsUpdate(because of images) ☐ sync scroll @needsUpdate(because of images)
☐ cache image in object when used, so that it's faster @needsTest ☐ 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 clear cache command
☐ update README for settings in view ☐ update README for settings in view
@ -22,6 +21,7 @@ Unknown:
___________________ ___________________
Archive: Archive:
✘ call settings listener on_new too - might be too heavy @cancelled Sun 08 Jan 2017 at 19:33 @project(Fast)
✔ fix relative source @done Sun 08 Jan 2017 at 19:22 @project(Medium) ✔ fix relative source @done Sun 08 Jan 2017 at 19:22 @project(Medium)
✔ add settings for the preview @done Sun 08 Jan 2017 at 17:36 @project(Fast) ✔ 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) ✔ regive focus to the right markdown view @done Mon 02 Jan 2017 at 18:34 @project(Fast)