# Path: commands/deviot_history.py
# class History:
# class InputTextHistoryCommand(TextCommand):
#     def insert(self, user_input):
#     def roll(self, backwards=False):
#     def last(self):
#     def get(self, index=None):
#     def reset_index(self):
#     def run(self, edit, backwards=False):


from sublime_plugin import TextCommand
from ..libraries import serial
from ..libraries.tools import get_setting
from .deviot_history import history


class DeviotSendSerialMonitorCommand(TextCommand):
    text_send = None
    output_console = None
    window = None

    def run(self, edit):
        self.window = self.view.window()
        caption = 'send'
        v = self.window.show_input_panel(
            caption, '', self.on_done, None, self.on_cancel)
        v.settings().set('deviotInputText', True)

    def on_done(self, text):
        history.insert(text)
        self.text_send(text)
        self.window.run_command('deviot_send_serial_monitor')

        if(self.output_console):
            self.window.run_command('deviot_show_console')

    def on_cancel(self):

# Path: commands/deviot_history.py
# class History:
# class InputTextHistoryCommand(TextCommand):
#     def insert(self, user_input):
#     def roll(self, backwards=False):
#     def last(self):
#     def get(self, index=None):
#     def reset_index(self):
#     def run(self, edit, backwards=False):


# Path: commands/deviot_send_serial_monitor.py
from sublime_plugin import TextCommand
from ..libraries import serial
from ..libraries.tools import get_setting
from .deviot_history import history



class DeviotSendSerialMonitorCommand(TextCommand):
    text_send = None
    output_console = None
    window = None

    def run(self, edit):
        self.window = self.view.window()
        caption = 'send'
        v = self.window.show_input_panel(
            caption, '', self.on_done, None, self.on_cancel)
        v.settings().set('deviotInputText', True)

    def on_done(self, text):
        history.insert(text)
        self.text_send(text)
        self.window.run_command('deviot_send_serial_monitor')

        if(self.output_console):
            self.window.run_command('deviot_show_console')

    def on_cancel(self):

        history.reset_index()