Compare commits

..

5 Commits

Author SHA1 Message Date
caf932b536 update messages 2017-01-12 11:25:36 +11:00
fa106c8206 fix bug when settings preview's position 2017-01-12 11:24:51 +11:00
0ac9fd9aaa add messages for sync scroll 2017-01-12 09:37:44 +11:00
5bbfb4606d comment code 2017-01-12 09:22:40 +11:00
37703e9bab enable sync scroll #8 2017-01-12 08:48:33 +11:00
6 changed files with 56 additions and 6 deletions

View File

@ -73,14 +73,16 @@ def show_html(md_view, preview):
lambda href: sublime.run_command('open_url', lambda href: sublime.run_command('open_url',
{'url': href})) {'url': href}))
return # get the "ratio" of the markdown view's position.
# set viewport position
# 0 < y < 1 # 0 < y < 1
y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1] y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1]
# set the vector (position) for the preview
vector = [0, y * preview.layout_extent()[1]] vector = [0, y * preview.layout_extent()[1]]
# remove half of the viewport_extent.y to center it on the screen (verticaly) # remove half of the viewport_extent.y to center it on the screen (verticaly)
vector[1] -= preview.viewport_extent()[1] / 2 vector[1] -= preview.viewport_extent()[1] / 2
vector[1] = mini(vector[1], 0) # make sure the minimum is 0
vector[1] = 0 if vector[1] < 0 else vector[1]
# the hide the first line
vector[1] += preview.line_height() vector[1] += preview.line_height()
preview.set_viewport_position(vector, animate=False) preview.set_viewport_position(vector, animate=False)

View File

@ -2,5 +2,5 @@
"install": "messages/install.txt", "install": "messages/install.txt",
"1.1.2": "messages/1.1.2.txt", "1.1.2": "messages/1.1.2.txt",
"2.0.1": "messages/2.0.1.txt", "2.0.1": "messages/2.0.1.txt",
"2.1.1": "messages/2.0.1.txt" "2.2.1": "messages/2.2.0.txt"
} }

View File

@ -3,3 +3,6 @@ Sorry to interrupt you... :(
A settings is now available: `markdown_live_preview_on_open`. If set to true, A settings is now available: `markdown_live_preview_on_open`. If set to true,
it opens the window preview as soon as you open a markdown file. See the it opens the window preview as soon as you open a markdown file. See the
README for more infos. README for more infos.
Tip of the day: `ctrl+w`: closes the current file
`ctrl+shift+w`: closes the current window

8
messages/2.2.0.txt Normal file
View File

@ -0,0 +1,8 @@
Sorry to interrupt you... :(
Something changed on MarkdownLivePreview: the preview is now scrolled to where
you are editing your markdown file! It doesn't scroll back up all the time any
more!
Tip of the day: You can center the screen on your cursor by pressing:
`ctrl+k, ctrl+v` (on OSX `cmd+k, cmd+v`)

View File

@ -2,7 +2,6 @@
Hope you'll enjoy using MarkdownLivePreview! Hope you'll enjoy using MarkdownLivePreview!
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
```python ```python
print('Hello world') print('Hello world')
@ -13,3 +12,41 @@ if DEBUG:
> Only a fool knows everything. A wise man knows how little he knows > 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. The only think I know right now is that Boxy Theme's just awesome.
t
h
i
s
-
i
s
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
-
a
-
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
t
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
e
![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png)
s
t