From fe996632f7b24dcfe21bf292337819369aa6044c Mon Sep 17 00:00:00 2001 From: Borja Penuelas Date: Sat, 5 Aug 2017 19:49:05 +0200 Subject: [PATCH] Add toggle running command Toggle between running and stop in a single command. Comes in handy when working with many key bindings. --- StinoCommands.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/StinoCommands.py b/StinoCommands.py index 92daedc..b66d339 100644 --- a/StinoCommands.py +++ b/StinoCommands.py @@ -1218,6 +1218,32 @@ def is_enabled(self): return state +class StinoSerialMonitorToggleRunningCommand(sublime_plugin.WindowCommand): + """.""" + + def run(self): + """.""" + if stino.arduino_info['init_done']: + serial_port = stino.arduino_info['selected'].get('serial_port', '') + if serial_port: + monitor = \ + stino.arduino_info['serial_monitors'].get(serial_port, + None) + if monitor and monitor.is_running(): + monitor.stop() + elif not monitor or not monitor.is_running(): + stino.start_serial_monitor(serial_port) + + def is_enabled(self): + """.""" + state = False + if stino.arduino_info['init_done']: + serial_port = stino.arduino_info['selected'].get('serial_port', '') + if serial_port: + state = True + return state + + class StinoSerialMonitorToggleScrollCommand(sublime_plugin.WindowCommand): """."""