-
Notifications
You must be signed in to change notification settings - Fork 0
/
CenterCurrentLine.py
35 lines (24 loc) · 1.04 KB
/
CenterCurrentLine.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
35
import sublime_plugin
import sublime
class CenterCurrentLineCommand(sublime_plugin.TextCommand):
def __init__(self, view):
self.view = view
settings = sublime.load_settings('Default.sublime-settings')
view.settings().set('center_current_line', settings.get('center_current_line', True))
def run(self, args):
sel = self.view.sel()
if len(sel) == 1 and self.view.settings().get('center_current_line'):
self.view.show_at_center(sel[0])
class CenterCurrentLineOnCommand(sublime_plugin.TextCommand):
def __init__(self, view):
self.view = view
def run(self, args):
self.view.settings().set('center_current_line', True)
class CenterCurrentLineOffCommand(sublime_plugin.TextCommand):
def __init__(self, view):
self.view = view
def run(self, args):
self.view.settings().set('center_current_line', False)
class CenterLineEventHandler(sublime_plugin.EventListener):
def on_selection_modified(self, view):
view.run_command('center_current_line')