-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommands.py
127 lines (90 loc) · 3.3 KB
/
commands.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import sublime, sublime_plugin
from .ts import util, persist
import subprocess
textsync = persist.textsync()
class TextsyncStartSync(sublime_plugin.WindowCommand):
def is_enabled(self):
return not persist.textsync().enabled()
def run(self):
persist.textsync().enabled(True)
class TextsyncStopSync(sublime_plugin.WindowCommand):
def is_enabled(self):
return persist.textsync().enabled()
def run(self):
persist.textsync().enabled(False)
def runProcess(exe):
p = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while(True):
retcode = p.poll() #returns None while subprocess is running
line = p.stdout.readline()
yield line
if(retcode is not None):
break
import os
class TextsyncStartServer(sublime_plugin.WindowCommand):
def is_enabled(self):
return not persist.server_state()
def run(self):
persist.start_server()
print("Start", persist.server_state())
persist.server_state(True)
class TextsyncStopServer(sublime_plugin.WindowCommand):
def is_enabled(self):
return persist.server_state()
def run(self):
persist.storage.server.stop()
class TextsyncChooseSyncModeSlow(sublime_plugin.WindowCommand):
def run(self, value=None):
persist.speed_setting("Slow")
persist.settings.set("minSyncInterval", 800)
persist.settings.set("syncInterval", 1000)
persist.settings.set("maxSyncInterval", 2000)
persist.settings.save()
def is_checked(self):
return persist.speed_setting() == "Slow"
class TextsyncChooseSyncModeNormal(sublime_plugin.WindowCommand):
def run(self, value=None):
persist.speed_setting("Normal")
persist.settings.set("minSyncInterval", 400)
persist.settings.set("syncInterval", 700)
persist.settings.set("maxSyncInterval", 1500)
persist.settings.save()
def is_checked(self):
return persist.speed_setting() == "Normal"
class TextsyncChooseSyncModeFast(sublime_plugin.WindowCommand):
def run(self, value=None):
persist.speed_setting("Fast")
persist.settings.set("minSyncInterval", 200)
persist.settings.set("syncInterval", 400)
persist.settings.set("maxSyncInterval", 800)
persist.settings.save()
def is_checked(self):
return persist.speed_setting() == "Fast"
class TextsyncChooseCursorStyle(sublime_plugin.WindowCommand):
def style_name(self):
return None
def run(self, value=None):
persist.settings.set("ghost_cursor", self.style_name())
persist.settings.save()
def is_checked(self):
return persist.settings.get("ghost_cursor") == self.style_name()
class TextsyncChooseCursorStyleFill(TextsyncChooseCursorStyle):
def style_name(self):
return "fill"
class TextsyncChooseCursorStyleOutline(TextsyncChooseCursorStyle):
def style_name(self):
return "outline"
class TextsyncChooseCursorStyleSolidUnderline(TextsyncChooseCursorStyle):
def style_name(self):
return "solid underline"
class TextsyncChooseCursorStyleSquigglyUnderline(TextsyncChooseCursorStyle):
def style_name(self):
return "squiggly underline"
class TextsyncChooseCursorStyleStippledUnderline(TextsyncChooseCursorStyle):
def style_name(self):
return "stippled underline"
class TextsyncToggleDebug(sublime_plugin.WindowCommand):
def run(self, value=None):
print("Setting debug mode:",not persist.settings.get("debug"))
persist.settings.set("debug", not persist.settings.get("debug"))
persist.settings.save()