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"""
# KeepMiddle Sublime Text 3 plugin
Always keeps the current line in the middle of the screen for context and focus.
Requires package MouseEventListener to fix selecting text with mouse.
"""
import sublime, sublime_plugin
try:
import mouse_event_listener
except:
pass
class KeepMiddle(sublime_plugin.EventListener):
isDisabled = False
counter = 0
def on_pre_mouse_down(self, view):
self.isDisabled = True
self.counter = 3
def on_selection_modified(self, view):
self.counter -= 1
if(view.sel()[0].a == view.sel()[0].b and self.counter <= 0):
self.isDisabled = False
self.counter = 0
if(self.isDisabled):
return
if(self.counter <= 0):
view.show_at_center(view.sel()[0])