forked from Robot-Will/Stino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StinoStarter.py
662 lines (567 loc) · 22.9 KB
/
StinoStarter.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
#-*- coding: utf-8 -*-
# StinoStarter.py
import os
import sublime
import sublime_plugin
st_version = int(sublime.version())
if st_version < 3000:
import app
else:
from . import app
class SketchListener(sublime_plugin.EventListener):
def on_activated(self, view):
pre_active_sketch = app.constant.global_settings.get('active_sketch', '')
if not app.sketch.isInEditor(view):
return
app.active_file.setView(view)
active_sketch = app.active_file.getSketchName()
app.constant.global_settings.set('active_sketch', active_sketch)
if app.active_file.isSrcFile():
app.active_serial_listener.start()
temp_global = app.constant.global_settings.get('temp_global', False)
if temp_global:
app.constant.global_settings.set('global_settings', False)
app.constant.global_settings.set('temp_global', False)
global_settings = app.constant.global_settings.get('global_settings', True)
if not global_settings:
if not (active_sketch == pre_active_sketch):
folder = app.active_file.getFolder()
app.constant.sketch_settings.changeFolder(folder)
app.arduino_info.refresh()
app.main_menu.refresh()
else:
app.active_serial_listener.stop()
global_settings = app.constant.global_settings.get('global_settings', True)
if not global_settings:
app.constant.global_settings.set('global_settings', True)
app.constant.global_settings.set('temp_global', True)
folder = app.constant.stino_root
app.constant.sketch_settings.changeFolder(folder)
app.arduino_info.refresh()
app.main_menu.refresh()
def on_close(self, view):
if app.serial_monitor.isMonitorView(view):
name = view.name()
serial_port = name.split('-')[1].strip()
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
cur_serial_monitor.stop()
app.constant.serial_in_use_list.remove(serial_port)
class ShowArduinoMenuCommand(sublime_plugin.WindowCommand):
def run(self):
show_arduino_menu = not app.constant.global_settings.get('show_arduino_menu', True)
app.constant.global_settings.set('show_arduino_menu', show_arduino_menu)
app.main_menu.refresh()
def is_checked(self):
state = app.constant.global_settings.get('show_arduino_menu', True)
return state
class NewSketchCommand(sublime_plugin.WindowCommand):
def run(self):
caption = app.i18n.translate('Name for New Sketch')
self.window.show_input_panel(caption, '', self.on_done, None, None)
def on_done(self, input_text):
sketch_name = input_text
if sketch_name:
sketch_file = app.base.newSketch(sketch_name)
if sketch_file:
self.window.open_file(sketch_file)
app.arduino_info.refresh()
app.main_menu.refresh()
else:
app.output_console.printText('A sketch (or folder) named "%s" already exists. Could not create the sketch.\n' % sketch_name)
class OpenSketchCommand(sublime_plugin.WindowCommand):
def run(self, folder):
app.sketch.openSketchFolder(folder)
class ImportLibraryCommand(sublime_plugin.WindowCommand):
def run(self, folder):
view = app.active_file.getView()
self.window.active_view().run_command('save')
app.sketch.importLibrary(view, folder)
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class ShowSketchFolderCommand(sublime_plugin.WindowCommand):
def run(self):
folder = app.active_file.getFolder()
url = 'file://' + folder
sublime.run_command('open_url', {'url': url})
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class SetExtraFlagCommand(sublime_plugin.WindowCommand):
def run(self):
extra_flag = app.constant.sketch_settings.get('extra_flag', '')
caption = app.i18n.translate('Extra compilation flags:')
self.window.show_input_panel(caption, extra_flag, self.on_done, None, None)
def on_done(self, input_text):
extra_flag = input_text
stino.constant.sketch_settings.set('extra_flag', extra_flags)
class CompileSketchCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.active_view().run_command('save')
cur_folder = app.active_file.getFolder()
cur_project = app.sketch.Project(cur_folder)
args = app.compiler.Args(cur_project, app.arduino_info)
compiler = app.compiler.Compiler(app.arduino_info, cur_project, args)
compiler.run()
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class UploadSketchCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.active_view().run_command('save')
cur_folder = app.active_file.getFolder()
cur_project = app.sketch.Project(cur_folder)
args = app.compiler.Args(cur_project, app.arduino_info)
compiler = app.compiler.Compiler(app.arduino_info, cur_project, args)
compiler.run()
uploader = app.uploader.Uploader(args, compiler)
uploader.run()
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class UploadUsingProgrammerCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.active_view().run_command('save')
cur_folder = app.active_file.getFolder()
cur_project = app.sketch.Project(cur_folder)
args = app.compiler.Args(cur_project, app.arduino_info)
compiler = app.compiler.Compiler(app.arduino_info, cur_project, args)
compiler.run()
uploader = app.uploader.Uploader(args, compiler, mode = 'programmer')
uploader.run()
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
platform_list = app.arduino_info.getPlatformList()
platform_id = app.constant.sketch_settings.get('platform', -1)
if (platform_id > 0) and (platform_id < len(platform_list)):
platform = platform_list[platform_id]
programmer_list = platform.getProgrammerList()
if programmer_list:
state = True
return state
class ChooseBoardCommand(sublime_plugin.WindowCommand):
def run(self, platform, board):
cur_platform = app.arduino_info.getPlatformList()[platform]
app.constant.sketch_settings.set('platform', platform)
app.constant.sketch_settings.set('platform_name', cur_platform.getName())
app.constant.sketch_settings.set('board', board)
app.main_menu.refresh()
app.constant.sketch_settings.set('full_compilation', True)
def is_checked(self, platform, board):
state = False
chosen_platform = app.constant.sketch_settings.get('platform', -1)
chosen_board = app.constant.sketch_settings.get('board', -1)
if platform == chosen_platform and board == chosen_board:
state = True
return state
class ChooseBoardOptionCommand(sublime_plugin.WindowCommand):
def run(self, board_option, board_option_item):
has_setted = False
chosen_platform = app.constant.sketch_settings.get('platform')
chosen_board = app.constant.sketch_settings.get('board')
board_id = str(chosen_platform) + '.' + str(chosen_board)
board_option_settings = app.constant.sketch_settings.get('board_option', {})
if board_id in board_option_settings:
cur_board_option_setting = board_option_settings[board_id]
if board_option < len(cur_board_option_setting):
has_setted = True
if not has_setted:
platform_list = app.arduino_info.getPlatformList()
cur_platform = platform_list[chosen_platform]
board_list = cur_platform.getBoardList()
cur_board = board_list[chosen_board]
board_option_list = cur_board.getOptionList()
board_option_list_number = len(board_option_list)
cur_board_option_setting = []
for i in range(board_option_list_number):
cur_board_option_setting.append(0)
cur_board_option_setting[board_option] = board_option_item
board_option_settings[board_id] = cur_board_option_setting
app.constant.sketch_settings.set('board_option', board_option_settings)
app.constant.sketch_settings.set('full_compilation', True)
def is_checked(self, board_option, board_option_item):
state = False
chosen_platform = app.constant.sketch_settings.get('platform', -1)
chosen_board = app.constant.sketch_settings.get('board', -1)
board_id = str(chosen_platform) + '.' + str(chosen_board)
board_option_settings = app.constant.sketch_settings.get('board_option', {})
if board_id in board_option_settings:
cur_board_option_setting = board_option_settings[board_id]
if board_option < len(cur_board_option_setting):
chosen_board_option_item = cur_board_option_setting[board_option]
if board_option_item == chosen_board_option_item:
state = True
return state
class ChooseProgrammerCommand(sublime_plugin.WindowCommand):
def run(self, platform, programmer):
programmer_settings = app.constant.sketch_settings.get('programmer', {})
programmer_settings[str(platform)] = programmer
app.constant.sketch_settings.set('programmer', programmer_settings)
def is_checked(self, platform, programmer):
state = False
programmer_settings = app.constant.sketch_settings.get('programmer', {})
if str(platform) in programmer_settings:
chosen_programmer = programmer_settings[str(platform)]
if programmer == chosen_programmer:
state = True
return state
class BurnBootloaderCommand(sublime_plugin.WindowCommand):
def run(self):
cur_folder = app.active_file.getFolder()
cur_project = app.sketch.Project(cur_folder)
args = app.compiler.Args(cur_project, app.arduino_info)
bootloader = app.uploader.Bootloader(cur_project, args)
bootloader.burn()
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class ChooseSerialPortCommand(sublime_plugin.WindowCommand):
def run(self, serial_port):
app.constant.sketch_settings.set('serial_port', serial_port)
def is_checked(self, serial_port):
state = False
chosen_serial_port = app.constant.sketch_settings.get('serial_port', -1)
if serial_port == chosen_serial_port:
state = True
return state
class StartSerialMonitorCommand(sublime_plugin.WindowCommand):
def run(self):
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port_list = app.serial.getSerialPortList()
serial_port = serial_port_list[serial_port_id]
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
else:
cur_serial_monitor = app.serial_monitor.SerialMonitor(serial_port)
app.constant.serial_in_use_list.append(serial_port)
app.constant.serial_monitor_dict[serial_port] = cur_serial_monitor
cur_serial_monitor.start()
self.window.run_command('send_serial_text')
def is_enabled(self):
state = False
serial_port_list = app.serial.getSerialPortList()
if serial_port_list:
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port = serial_port_list[serial_port_id]
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
if not cur_serial_monitor.isRunning():
state = True
else:
state = True
return state
class StopSerialMonitorCommand(sublime_plugin.WindowCommand):
def run(self):
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port_list = app.serial.getSerialPortList()
serial_port = serial_port_list[serial_port_id]
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
cur_serial_monitor.stop()
def is_enabled(self):
state = False
serial_port_list = app.serial.getSerialPortList()
if serial_port_list:
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port = serial_port_list[serial_port_id]
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
if cur_serial_monitor.isRunning():
state = True
return state
class SendSerialTextCommand(sublime_plugin.WindowCommand):
def run(self):
self.caption = 'Send'
self.window.show_input_panel(self.caption, '', self.on_done, None, None)
def on_done(self, input_text):
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port_list = app.serial.getSerialPortList()
serial_port = serial_port_list[serial_port_id]
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
cur_serial_monitor.send(input_text)
self.window.show_input_panel(self.caption, '', self.on_done, None, None)
def is_enabled(self):
state = False
serial_port_list = app.serial.getSerialPortList()
if serial_port_list:
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port = serial_port_list[serial_port_id]
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
if cur_serial_monitor.isRunning():
state = True
return state
class ChooseLineEndingCommand(sublime_plugin.WindowCommand):
def run(self, line_ending):
app.constant.sketch_settings.set('line_ending', line_ending)
def is_checked(self, line_ending):
state = False
chosen_line_ending = app.constant.sketch_settings.get('line_ending', 0)
if line_ending == chosen_line_ending:
state = True
return state
class ChooseDisplayModeCommand(sublime_plugin.WindowCommand):
def run(self, display_mode):
app.constant.sketch_settings.set('display_mode', display_mode)
def is_checked(self, display_mode):
state = False
chosen_display_mode = app.constant.sketch_settings.get('display_mode', 0)
if display_mode == chosen_display_mode:
state = True
return state
class ChooseBaudrateCommand(sublime_plugin.WindowCommand):
def run(self, baudrate):
app.constant.sketch_settings.set('baudrate', baudrate)
def is_checked(self, baudrate):
state = False
chosen_baudrate = app.constant.sketch_settings.get('baudrate', -1)
if baudrate == chosen_baudrate:
state = True
return state
def is_enabled(self):
state = True
serial_port_list = app.serial.getSerialPortList()
if serial_port_list:
serial_port_id = app.constant.sketch_settings.get('serial_port', 0)
serial_port = serial_port_list[serial_port_id]
if serial_port in app.constant.serial_in_use_list:
cur_serial_monitor = app.constant.serial_monitor_dict[serial_port]
if cur_serial_monitor.isRunning():
state = False
return state
class AutoFormatCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('reindent', {'single_line': False})
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class ArchiveSketchCommand(sublime_plugin.WindowCommand):
def run(self):
root_list = app.fileutil.getOSRootList()
self.top_folder_list = root_list
self.folder_list = self.top_folder_list
self.level = 0
self.show_panel()
def show_panel(self):
folder_name_list = app.fileutil.getFolderNameList(self.folder_list)
sublime.set_timeout(lambda: self.window.show_quick_panel(folder_name_list, self.on_done), 10)
def on_done(self, index):
is_finished = False
if index == -1:
return
if self.level != 0 and index == 0:
chosen_folder = self.folder_list[index]
chosen_folder = chosen_folder.split('(')[1]
chosen_folder = chosen_folder[:-1]
source_folder = app.active_file.getFolder()
sketch_name = app.active_file.getSketchName()
zip_file_name = sketch_name + '.zip'
zip_file = os.path.join(chosen_folder, zip_file_name)
return_code = app.tools.archiveSketch(source_folder, zip_file)
if return_code == 0:
app.output_console.printText(app.i18n.translate('Writing {0} done.\n', [zip_file]))
else:
app.output_console.printText(app.i18n.translate('Writing {0} failed.\n', [zip_file]))
else:
(self.folder_list, self.level) = app.fileutil.enterNextLevel(index, self.folder_list, self.level, self.top_folder_list)
self.show_panel()
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class ChooseArduinoFolderCommand(sublime_plugin.WindowCommand):
def run(self):
root_list = app.fileutil.getOSRootList()
self.top_folder_list = root_list
self.folder_list = self.top_folder_list
self.level = 0
self.show_panel()
def show_panel(self):
folder_name_list = app.fileutil.getFolderNameList(self.folder_list)
sublime.set_timeout(lambda: self.window.show_quick_panel(folder_name_list, self.on_done), 10)
def on_done(self, index):
is_finished = False
if index == -1:
return
chosen_folder = self.folder_list[index]
if app.base.isArduinoFolder(chosen_folder):
app.output_console.printText(app.i18n.translate('Arduino Application is found at {0}.\n', [chosen_folder]))
app.constant.sketch_settings.set('arduino_folder', chosen_folder)
app.arduino_info.refresh()
app.main_menu.refresh()
app.output_console.printText('Arduino %s.\n' % app.arduino_info.getVersionText())
app.constant.sketch_settings.set('full_compilation', True)
else:
(self.folder_list, self.level) = app.fileutil.enterNextLevel(index, self.folder_list, self.level, self.top_folder_list)
self.show_panel()
class ChangeSketchbookFolderCommand(sublime_plugin.WindowCommand):
def run(self):
root_list = app.fileutil.getOSRootList()
self.top_folder_list = root_list
self.folder_list = self.top_folder_list
self.level = 0
self.show_panel()
def show_panel(self):
folder_name_list = app.fileutil.getFolderNameList(self.folder_list)
sublime.set_timeout(lambda: self.window.show_quick_panel(folder_name_list, self.on_done), 10)
def on_done(self, index):
is_finished = False
if index == -1:
return
if self.level != 0 and index == 0:
chosen_folder = self.folder_list[index]
chosen_folder = chosen_folder.split('(')[1]
chosen_folder = chosen_folder[:-1]
app.output_console.printText(app.i18n.translate('Sketchbook is changed to {0}.\n', [chosen_folder]))
app.constant.global_settings.set('sketchbook_folder', chosen_folder)
app.arduino_info.refresh()
app.main_menu.refresh()
app.constant.sketch_settings.set('full_compilation', True)
else:
(self.folder_list, self.level) = app.fileutil.enterNextLevel(index, self.folder_list, self.level, self.top_folder_list)
self.show_panel()
class ChooseBuildFolderCommand(sublime_plugin.WindowCommand):
def run(self):
root_list = app.fileutil.getOSRootList()
self.top_folder_list = root_list
self.folder_list = self.top_folder_list
self.level = 0
self.show_panel()
def show_panel(self):
folder_name_list = app.fileutil.getFolderNameList(self.folder_list)
sublime.set_timeout(lambda: self.window.show_quick_panel(folder_name_list, self.on_done), 10)
def on_done(self, index):
is_finished = False
if index == -1:
return
if self.level != 0 and index == 0:
chosen_folder = self.folder_list[index]
chosen_folder = chosen_folder.split('(')[1]
chosen_folder = chosen_folder[:-1]
app.output_console.printText(app.i18n.translate('Build folder is changed to {0}.\n', [chosen_folder]))
app.constant.sketch_settings.set('build_folder', chosen_folder)
app.constant.sketch_settings.set('full_compilation', True)
else:
(self.folder_list, self.level) = app.fileutil.enterNextLevel(index, self.folder_list, self.level, self.top_folder_list)
self.show_panel()
class ChooseLanguageCommand(sublime_plugin.WindowCommand):
def run(self, language):
pre_language = app.constant.global_settings.get('language', -1)
if language != pre_language:
app.constant.global_settings.set('language', language)
app.i18n.refresh()
app.main_menu.refresh()
def is_checked(self, language):
state = False
chosen_language = app.constant.global_settings.get('language', -1)
if language == chosen_language:
state = True
return state
class SetGlobalSettingCommand(sublime_plugin.WindowCommand):
def run(self):
if app.active_file.isSrcFile():
global_settings = not app.constant.global_settings.get('global_settings', True)
app.constant.global_settings.set('global_settings', global_settings)
if global_settings:
folder = app.constant.stino_root
else:
folder = app.active_file.getFolder()
app.constant.sketch_settings.changeFolder(folder)
app.arduino_info.refresh()
app.main_menu.refresh()
else:
temp_global = not app.constant.global_settings.get('temp_global', False)
app.constant.global_settings.set('temp_global', temp_global)
def is_checked(self):
state = app.constant.global_settings.get('global_settings', True)
return state
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class SetFullCompilationCommand(sublime_plugin.WindowCommand):
def run(self):
full_compilation = not app.constant.sketch_settings.get('full_compilation', True)
app.constant.sketch_settings.set('full_compilation', full_compilation)
def is_checked(self):
state = app.constant.sketch_settings.get('full_compilation', True)
return state
class ShowCompilationOutputCommand(sublime_plugin.WindowCommand):
def run(self):
show_compilation_output = not app.constant.sketch_settings.get('show_compilation_output', False)
app.constant.sketch_settings.set('show_compilation_output', show_compilation_output)
def is_checked(self):
state = app.constant.sketch_settings.get('show_compilation_output', False)
return state
class ShowUploadOutputCommand(sublime_plugin.WindowCommand):
def run(self):
show_upload_output = not app.constant.sketch_settings.get('show_upload_output', False)
app.constant.sketch_settings.set('show_upload_output', show_upload_output)
def is_checked(self):
state = app.constant.sketch_settings.get('show_upload_output', False)
return state
class VerifyCodeCommand(sublime_plugin.WindowCommand):
def run(self):
verify_code = not app.constant.sketch_settings.get('verify_code', False)
app.constant.sketch_settings.set('verify_code', verify_code)
def is_checked(self):
state = app.constant.sketch_settings.get('verify_code', False)
return state
class OpenRefCommand(sublime_plugin.WindowCommand):
def run(self, url):
url = app.base.getUrl(url)
sublime.run_command('open_url', {'url': url})
class FindInReferenceCommand(sublime_plugin.WindowCommand):
def run(self):
ref_list = []
keyword_ref_dict = app.arduino_info.getKeywordRefDict()
view = app.active_file.getView()
selected_word_list = app.base.getSelectedWordList(view)
for selected_word in selected_word_list:
if selected_word in keyword_ref_dict:
ref = keyword_ref_dict[selected_word]
if not ref in ref_list:
ref_list.append(ref)
for ref in ref_list:
url = app.base.getUrl(ref)
sublime.run_command('open_url', {'url': url})
def is_enabled(self):
state = False
if app.active_file.isSrcFile():
state = True
return state
class AboutStinoCommand(sublime_plugin.WindowCommand):
def run(self):
sublime.run_command('open_url', {'url': 'https://github.com/Robot-Will/Stino'})
class PanelOutputCommand(sublime_plugin.TextCommand):
def run(self, edit, text):
pos = self.view.size()
self.view.insert(edit, pos, text)
self.view.show(pos)
class InsertIncludeCommand(sublime_plugin.TextCommand):
def run(self, edit, include_text):
view_size = self.view.size()
region = sublime.Region(0, view_size)
src_text = self.view.substr(region)
include_list = app.preprocess.genIncludeList(src_text)
if include_list:
last_include = include_list[-1]
index = src_text.index(last_include) + len(last_include)
else:
index = 0
self.view.insert(edit, index, include_text)