1
1
# -*- coding: utf-8 -*-
2
2
3
- import sys , os , subprocess , codecs , shutil , json
3
+ import sys , os , subprocess , shutil , json
4
4
5
5
import sublime , sublime_plugin
6
6
from .haxe_parse_completion_list import *
@@ -17,6 +17,8 @@ def run_process( args ):
17
17
#startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
18
18
return subprocess .Popen (args , stdout = subprocess .PIPE , startupinfo = startupinfo ).communicate ()[0 ]
19
19
20
+ def panel (_window , options , done , flags = 0 , sel_index = 0 , on_highlighted = None ):
21
+ sublime .set_timeout (lambda : _window .show_quick_panel (options , done , flags , sel_index , on_highlighted ), 10 )
20
22
21
23
22
24
class FlowCompletionCallbackCommand ( sublime_plugin .WindowCommand ):
@@ -34,9 +36,15 @@ def __init__(self):
34
36
35
37
self .flow_path = "flow"
36
38
self .flow_file = ""
39
+ self .target = ""
37
40
self .info_json = None
38
41
self .completion_data = None
39
42
43
+ self .system = self .get_system ()
44
+ self .target = self .system
45
+ self .build_debug = False
46
+ self .build_verbose = False
47
+
40
48
def __del__ (self ):
41
49
print ("[flow] __del__" )
42
50
FlowProject .flow = None
@@ -46,22 +54,26 @@ def __del__(self):
46
54
del FlowProject .flow
47
55
del self
48
56
57
+
49
58
def set_flow_file ( self , file_name ):
50
59
print ("[flow] set flow file to " + file_name )
51
60
sublime .status_message ('set flow file to ' + file_name )
61
+
52
62
self .flow_file = file_name
53
63
self .refresh_info ()
54
64
65
+ def set_flow_target_by_index ( self , index ):
66
+ _targets = self .get_targets ()
67
+ _target = _targets [index ]
68
+ self .target = _target [0 ].lower ()
69
+ print ("[flow] set build target to " + self .target )
55
70
56
71
def refresh_info (self ):
57
72
print ("[flow] refresh info/hxml on " + self .flow_file )
58
73
59
74
self .info_json_src = run_process ([
60
- "haxelib" ,
61
- "run" ,
62
- "flow" ,
63
- "info" ,
64
- "--project" , self .flow_file
75
+ "haxelib" , "run" , "flow" ,
76
+ "info" , "--project" , self .flow_file
65
77
]).decode ("utf-8" );
66
78
67
79
if self .info_json_src :
@@ -190,7 +202,62 @@ def on_modified_async(self, view):
190
202
fname = view .file_name ()
191
203
self .completion (view , fname )
192
204
205
+ def get_status (self ):
206
+
207
+ _result = []
208
+
209
+ if self .flow_file :
210
+ _result .append (['flow file' , self .flow_file ])
211
+ else :
212
+ _result .append (['no flow file' , 'specify a flow file first' ])
213
+ return _result
214
+
215
+ if self .target :
216
+ _result .append (['flow target' , self .target ])
217
+ else :
218
+ _result .append (['flow target' , self .system ])
219
+
220
+ _result .append (['Toggle debug build' , "currently debug : " + str (self .build_debug ).lower () ])
221
+ _result .append (['Toggle verbose build' , "currently verbose : " + str (self .build_verbose ).lower () ])
222
+
223
+ return _result
224
+
225
+ def get_system (self ):
226
+
227
+ _result = ""
228
+ _system = sys .platform
229
+
230
+ if _system == "win32" or _system == "cygwin" :
231
+ _result = "windows"
232
+ elif _system == "darwin" :
233
+ _result = "mac"
234
+ else :
235
+ _system = "linux"
236
+
237
+ return _result
238
+
239
+
240
+ def get_targets (self ):
241
+
242
+ _result = []
243
+
244
+ if not self .flow_file :
245
+ return _result
246
+
247
+ _result .append (['Mac' , 'desktop, native mac app' ])
248
+ _result .append (['Linux' , 'desktop, native linux app' ])
249
+ _result .append (['Windows' , 'desktop, native windows app' ])
250
+ _result .append (['Android' , 'mobile, native android app' ])
251
+ _result .append (['iOS' , 'mobile, native ios project' ])
252
+ _result .append (['Web' , 'web, web based app' ])
253
+
254
+ _invalid = self .info_json ['targets_invalid' ]
255
+
256
+ _result [:] = [_item for _item in _result if not _item [0 ].lower () in _invalid ]
257
+
258
+ _result .insert (0 , ['unavailable from ' + self .system , ", " .join (_invalid ) ])
193
259
260
+ return _result
194
261
195
262
print ("[flow] hello flow" )
196
263
from .commands import *
0 commit comments