forked from SublimeText-Markdown/MarkdownEditing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistraction_free_mode.py
34 lines (26 loc) · 1.13 KB
/
distraction_free_mode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
This file contains some "distraction free" mode improvements. However they can be
used in normal mode, too. These features can be enabled/disabled via settings files.
In order to target "distraction free" mode, FullScreenStatus plugin must be installed:
https://github.com/maliayas/SublimeText_FullScreenStatus
"""
import sublime
import sublime_plugin
try:
from MarkdownEditing.mdeutils import *
except ImportError:
from mdeutils import *
def on_distraction_free():
return sublime.active_window().settings().get('fss_on_distraction_free')
class KeepCurrentLineCentered(sublime_plugin.EventListener):
def on_modified_async(self, view):
# One of the MarkdownEditing syntax files must be in use.
if not view_is_markdown(view):
return False
if on_distraction_free():
if not view.settings().get('mde.distraction_free_mode', {}) \
.get('mde.keep_centered', True):
return False
elif not view.settings().get('mde.keep_centered', False):
return False
view.show_at_center(view.sel()[0].begin())