Exemplo n.º 1
0
def newMessage():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		res = d.loop()
Exemplo n.º 2
0
def getPin():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		pin = ''
		while pin != '1234':
			d = DTextEntry(25, '', title='Enter Pin')
			pin = d.result()
Exemplo n.º 3
0
 def _init_screen(self):
     self.screen = Screen()
     self.screen.init_tty()
     self.screen.enable_mouse()
     self.screen.attr_color(C_WHITE, C_MAGENTA)
     self.screen.cls()
     self.screen.attr_reset()
     self.width, self.height = Screen.screen_size()
Exemplo n.º 4
0
    def __init__(self):
        self.screen_size = Screen.screen_size()
        self.e = DisasmViewer(1, 2, self.screen_size[0] - 2, self.screen_size[1] - 4)

        menu_file = WMenuBox([
            ("Save (Shift+s)", b"S"), ("Write disasm (Shift+w)", b"W"),
            ("Write function (Ctrl+w)", b"\x17"),
            ("Quit (q)", b"q")
        ])
        menu_goto = WMenuBox([
            ("Follow (Enter)", KEY_ENTER), ("Return (Esc)", KEY_ESC),
            ("Goto... (g)", b"g"), ("Search disasm... (/)", b"/"),
            ("Search next (Shift+/)", b"?"), ("Next undefined (Ctrl+u)", b"\x15"),
            ("Next non-function code (Ctrl+f)", b"\x06"),
        ])
        menu_edit = WMenuBox([
            ("Undefined (u)", b"u"), ("Code (c)", b"c"), ("Data (d)", b"d"),
            ("ASCII String (a)", b"a"), ("Filler (f)", b"f"), ("Make label (n)", b"n"),
            ("Mark function start (F)", b"F"), ("Add code to function", MENU_ADD_TO_FUNC),
            ("Number/Address (o)", b"o"), ("Hex/dec (h)", b"h"),
        ])
        menu_analysis = WMenuBox([
            ("Info (whereami) (i)", b"i"), ("Memory map (Shift+i)", b"I"),
            ("Run plugin...", MENU_PLUGIN),
            ("Preferences...", MENU_PREFS),
        ])
        menu_help = WMenuBox([
            ("Help (F1)", KEY_F1), ("About...", "about"),
        ])
        self.menu_bar = WMenuBar([
            ("File", menu_file), ("Goto", menu_goto), ("Edit", menu_edit),
            ("Analysis", menu_analysis), ("Help", menu_help)
        ])
        self.menu_bar.permanent = True
Exemplo n.º 5
0
def servStatus():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		d.add(1, 3, WLabel("SWIFT services:"))
		d.add(1, 5, WLabel("Messaging service:  "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 6, WLabel("Processing service: "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 7, WLabel("Debug service:      "+bcolors.WARNING+"[ OK ]" + bcolors.ENDC))
		d.add(1, 8, WLabel("Input service:      "+bcolors.OKGREEN+"[ OK ]" + bcolors.ENDC))
		d.add(1, 11, WLabel("Processing Directory: "+os.popen("du -sh /root/Downloads/swift/processing").read()))	
		d.add(1, 12, WLabel("Failure Directory: "+os.popen("du -sh /root/Downloads/swift/failed").read()))
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		mainMenu()
Exemplo n.º 6
0
def failMessage():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		msgs = os.listdir('failed')
		msgs.append('Main Menu')
		rb = WRadioButton(msgs)
		d.add(1,3,rb)
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		choice = rb.choice
		if msgs[choice] == 'Main Menu':
			mainMenu()
		else:
			displayMessage('failed/'+msgs[choice],'fail')
Exemplo n.º 7
0
def displayMessage(msg,type):
	with Context():
		Screen.cls()
		Screen.attr_reset()
		file_data = open(msg,'r').readlines()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		d.add(1, 2, WLabel(bcolors.OKGREEN+"[+] Viewing " + msg+bcolors.ENDC))
		i = 4
		for item in file_data:
			item.strip('\r\n')
			d.add(1,i,WLabel(item))
			i+=1
		b = WButton(8, "OK")
		d.add(10,20,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		if type == 'proc':
			procMessage()
		if type == 'fail':
			failMessage()
Exemplo n.º 8
0
def test_dialog():
    global test_data

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    test_data.dialog_w = DialogNew(1, 1, 70, 20, title="RR-DUINO TEST SETUP")

    test_data.dialog_w.add(
        1, 1, WFrame(58, 3, "Device setup address " + str(address)))

    test_data.dialog_w.add(2, 2, "Status:")
    test_data.device_status = WLabel("Unknown state", 22)
    test_data.dialog_w.add(10, 2, test_data.device_status)

    test_data.dialog_w.add(1, 4, WFrame(25, 9, "Test setup"))
    test_data.dialog_w.add(2, 5, "Subaddress:")
    test_data.subadd_entry = WTextEntry(5, "0")
    test_data.dialog_w.add(14, 5, test_data.subadd_entry)
    test_data.io = WRadioButton(["sensor", "turnout"])
    test_data.dialog_w.add(2, 7, test_data.io)
    test_data.value = WRadioButton(["OFF", "ON"])
    test_data.dialog_w.add(2, 9, test_data.value)
    test_read_button = WButton(10, "Read")
    test_read_button.on("click", test_read_clicked)
    test_data.dialog_w.add(2, 11, test_read_button)
    test_write_button = WButton(10, "Write")
    test_write_button.on("click", test_write_clicked)
    test_data.dialog_w.add(13, 11, test_write_button)

    test_data.dialog_w.loop()
    next_dialog = None
Exemplo n.º 9
0
    def draw_line(v_pos, y, current_h_kind):
        Screen.goto(left, y)
        h_stop = 0

        border_chars = CHARS[current_h_kind]
        Screen.wr(CHARS[2 * left_kind + current_h_kind][4 * v_pos + P_FIRST])
        x = left + 1
        while True:
            next_h_stop = (
                w - 1,
                right_kind) if h_stop >= len(h_stops) else h_stops[h_stop]
            next_x = left + next_h_stop[0]
            Screen.wr(border_chars[4 * v_pos + P_NONE] * (next_x - x))
            x = next_x
            if h_stop >= len(h_stops):
                break
            else:
                next_h_stop_v_kind = next_h_stop[1]
                Screen.wr(CHARS[2 * next_h_stop_v_kind +
                                current_h_kind][4 * v_pos + P_STOP])
                x = x + 1
                h_stop = h_stop + 1
        Screen.wr(CHARS[2 * right_kind + current_h_kind][4 * v_pos + P_LAST])
Exemplo n.º 10
0
def mainMenu():
	with Context():
		Screen.cls()
		Screen.attr_reset()
		d = Dialog(5, 1, 50, 12)
		d.add(1, 1, WLabel("SWIFT Debug Interface"))
		rb = WRadioButton(['View Processing Messages','View Failed Messages','Status','Exit'])
		d.add(1, 3, rb)
		b = WButton(8, "OK")
		d.add(10,16,b)
		b.finish_dialog = ACTION_OK
		res = d.loop()
		choice = rb.choice
		if choice not in [0,1,2,3]:
			res = d.loop()
		elif choice == 0:
			procMessage()
		elif choice == 1:
			failMessage()
		elif choice == 2:
			servStatus()
		elif choice == 3:
			os.system('clear')
			os.system('pkill '+str(os.getpid()))
Exemplo n.º 11
0
def loading_project():
    with Context():
        rows, columns = os.popen('stty size', 'r').read().split()
        Screen.attr_color(C_WHITE, C_RED)
        Screen.cls()
        Screen.attr_reset()
        d = Dialog(0, 0, int(columns), int(rows))
        d.add(1, 1, "Loading Project")
        choice = WListBox(16, int(rows) - 5, ["choice%d" % i for i in range(100)])
        d.add(1, 3, choice)
        b = WButton(8, "Choose")
        d.add(1, int(rows) - 2, b)
        b.finish_dialog = ACTION_OK
        res = d.loop()
Exemplo n.º 12
0
def sensor_dialog():
    global sensor_data

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    sensor_data.dialog_w = DialogNew(1,
                                     1,
                                     70,
                                     20,
                                     title="RR-DUINO SENSOR SETUP")

    sensor_data.dialog_w.add(
        1, 1, WFrame(58, 3, "Device setup address " + str(address)))

    sensor_data.dialog_w.add(2, 2, "Status:")
    sensor_data.device_status = WLabel("Unknown state", 22)
    sensor_data.dialog_w.add(10, 2, sensor_data.device_status)
    sensor_data.eeprom_status = WLabel("Not loaded / Not storing", 25)
    set_eeprom_status(sensor_data.eeprom_status)
    sensor_data.dialog_w.add(32, 2, sensor_data.eeprom_status)

    sensor_data.dialog_w.add(1, 4, WFrame(25, 8, "New sensor"))
    sensor_data.dialog_w.add(2, 5, "Subaddress:")
    sensor_data.subadd_entry = WTextEntry(5, "0")
    sensor_data.dialog_w.add(14, 5, sensor_data.subadd_entry)
    sensor_data.dialog_w.add(2, 6, "Pin:")
    sensor_data.pin_entry = WTextEntry(5, "0")
    sensor_data.dialog_w.add(14, 6, sensor_data.pin_entry)
    sensor_data.io = WRadioButton(["input", "input with pull-up", "output"])
    sensor_data.dialog_w.add(2, 7, sensor_data.io)
    sensor_commit_button = WButton(15, "Commit sensor")
    sensor_commit_button.on("click", sensor_commit_clicked)
    sensor_data.dialog_w.add(5, 10, sensor_commit_button)

    sensor_data.device_status.t, sensor_data.sensors_list = load_sensors()

    sensor_data.list_wg = WListBox(28, 6, sensor_data.sensors_list)
    sensor_data.dialog_w.add(26, 4, WFrame(30, 8, "Sensors"))
    sensor_data.dialog_w.add(27, 5, sensor_data.list_wg)
    button = WButton(28, "Delete sensor")
    button.on("click", sensor_delete_clicked)
    sensor_data.dialog_w.add(27, 12, button)

    sensor_data.dialog_w.loop()
    next_dialog = None
Exemplo n.º 13
0
def restore_dialog():
    global restore_data

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    restore_data.dialog_w = DialogNew(1,
                                      1,
                                      70,
                                      20,
                                      title="RR-DUINO NODE RESTORE")

    restore_data.dialog_w.add(
        1, 1, WFrame(58, 4, "Device setup address " + str(address)))

    restore_data.dialog_w.add(2, 2, "Status:")
    if main_data.status is None:
        s = "Unknown state"
    else:
        s = main_data.status
    restore_data.device_status = WLabel(s, 22)
    restore_data.dialog_w.add(10, 2, restore_data.device_status)
    restore_data.dialog_w.add(2, 3, "EEPROM Status:")
    restore_data.eeprom_status = WLabel(eeprom_status_str(), 22)
    restore_data.dialog_w.add(16, 3, restore_data.eeprom_status)

    restore_data.dialog_w.add(1, 5, WFrame(68, 16, "Restore"))
    restore_data.dialog_w.add(2, 6, "Restore file:")
    restore_data.file_entry = WTextEntry(53, "")
    restore_data.dialog_w.add(15, 6, restore_data.file_entry)
    restore_load_button = WButton(66, "Load restore file")
    restore_load_button.on("click", restore_load_clicked)
    restore_data.dialog_w.add(2, 8, restore_load_button)
    restore_node_button = WButton(66, "Restore selected node")
    restore_node_button.on("click", restore_node_clicked)
    restore_data.dialog_w.add(2, 19, restore_node_button)
    restore_data.warning = WLabel(
        "File name not set                                               ")
    restore_data.dialog_w.add(2, 7, restore_data.warning)
    restore_data.list_wg = WListBox(64, 7, [])
    restore_data.dialog_w.add(2, 10, WFrame(66, 9, "Nodes"))
    restore_data.dialog_w.add(3, 11, restore_data.list_wg)
    restore_data.dialog_w.loop()
    next_dialog = None
Exemplo n.º 14
0
def backup_dialog():
    global backup_data

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    backup_data.dialog_w = DialogNew(1,
                                     1,
                                     70,
                                     20,
                                     title="RR-DUINO NODE BACKUP")

    backup_data.dialog_w.add(
        1, 1, WFrame(58, 4, "Device setup address " + str(address)))

    backup_data.dialog_w.add(2, 2, "Status:")
    if main_data.status is None:
        s = "Unknown state"
    else:
        s = main_data.status
    backup_data.device_status = WLabel(s, 22)
    backup_data.dialog_w.add(10, 2, backup_data.device_status)
    backup_data.dialog_w.add(2, 3, "EEPROM Status:")
    backup_data.eeprom_status = WLabel(eeprom_status_str(), 22)
    backup_data.dialog_w.add(16, 3, backup_data.eeprom_status)

    backup_data.dialog_w.add(1, 5, WFrame(68, 7, "Backup"))
    backup_data.dialog_w.add(2, 6, "Backup file:")
    backup_data.file_entry = WTextEntry(54, "")
    backup_data.dialog_w.add(14, 6, backup_data.file_entry)
    backup_data.dialog_w.add(2, 7, "Node name:")
    backup_data.name_entry = WTextEntry(54, "")
    backup_data.dialog_w.add(14, 7, backup_data.name_entry)
    backup_write_button = WButton(66, "Write to file")
    backup_write_button.on("click", backup_write_clicked)
    backup_data.dialog_w.add(2, 9, backup_write_button)
    backup_data.warning = WLabel(
        "File name not set                                               ")
    backup_data.dialog_w.add(2, 10, backup_data.warning)

    backup_data.dialog_w.loop()
    next_dialog = None
Exemplo n.º 15
0
def run(delegate):
    import os
    DEVEL = int(os.environ.get("DEVEL", "0"))
    s = Screen()
    try:
        cursor_position_save()
        if not DEVEL:
            s.init_tty()
        s.cursor(False)
        screen_alt()
        s.cls()
        s.attr_reset()

        return delegate()
    finally:
        s.attr_reset()
        s.cls()
        s.goto(0, 0)
        s.cursor(True)
        if not DEVEL:
            s.deinit_tty()
        screen_regular()
        cursor_position_restore()
Exemplo n.º 16
0
def screen_regular():
    Screen.wr(b"\x1b[?47l")
Exemplo n.º 17
0
def with_alt_screen(f):
    try:
        cursor_position_save()
        screen_alt()
        # Screen.init_tty()

        Screen.cls()
        Screen.attr_reset()
        Screen.cursor(False)

        f()
    finally:
        Screen.attr_reset()
        Screen.cls()
        Screen.goto(0, 0)
        Screen.cursor(True)

        # Screen.deinit_tty()
        screen_regular()
        cursor_position_restore()
Exemplo n.º 18
0
def scroll_down():
    Screen.wr(b"\x1b[1T")
Exemplo n.º 19
0
def scroll_up():
    Screen.wr(b"\x1b[1S")
Exemplo n.º 20
0
def scroll_region(top_row: int, bottom_row: int):
    Screen.wr(bytes(f"\x1b[{top_row + 1};{bottom_row + 1}r", 'utf-8'))
Exemplo n.º 21
0
from picotui.screen import Screen
from picotui.widgets import Dialog, WAutoComplete

s = Screen()

s.init_tty()
s.cls()


w, h = s.screen_size()
d = Dialog(0, 0, w, h)

d.add(1, 1, WAutoComplete(10, 'a', ['pajo', 'majo']))


d.loop()
s.deinit_tty()
Exemplo n.º 22
0
def screen_alt():
    Screen.wr(b"\x1b[?47h")
Exemplo n.º 23
0
def cursor_position_restore():
    Screen.wr(b"\x1b8")
Exemplo n.º 24
0
    else:
        if ENTRYPOINTS:
            show_addr = ENTRYPOINTS[0][1]
        else:
            show_addr = engine.ADDRESS_SPACE.min_addr()

    t = time.time()
    #_model = engine.render()
    _model = engine.render_partial_around(show_addr, 0, HEIGHT * 2)
    print("Rendering time: %fs" % (time.time() - t))
    #print(_model.lines())
    #sys.exit()

    engine.ADDRESS_SPACE.is_loading = False
    engine.ADDRESS_SPACE.changed = False
    Screen.init_tty()
    try:
        Screen.cls()
        Screen.enable_mouse()
        main_screen = MainScreen()
        APP.main_screen = main_screen
        APP.is_ui = True
        main_screen.e.set_model(_model)
        main_screen.e.addr_stack = addr_stack
        main_screen.e.goto_addr(show_addr)
        Screen.set_screen_redraw(main_screen.redraw)
        main_screen.redraw()
        main_screen.e.show_status("Press F1 for help, F9 for menus")
        main_screen.loop()
    except:
        log.exception("Unhandled exception")
Exemplo n.º 25
0
import termios
#
# This example shows how to change the items of a ListBox widget
# when the current selection of a DropDown widget changes.
#
from picotui.screen import Screen
from picotui.widgets import *
from picotui.defs import *


if __name__ == "__main__":

    s = Screen()

    # Set the list of all available DropDown choices
    choices = ["Green1", "Green2", "Green3", "Red1", "Red2", "Red3", "Yellow1", "Yellow2", "Yellow3"]

    try:
        s.init_tty()
        s.enable_mouse()
        s.attr_color(C_WHITE, C_BLUE)
        s.cls()
        s.attr_reset()
        d = Dialog(5, 5, 20, 12)

        # DropDown and ListBox widgets
        d.add(1, 1, "Dropdown:")
        w_dropdown = WDropDown(10, ["All", "Red", "Green", "Yellow"])
        d.add(11, 1, w_dropdown)

        d.add(1, 3, "List:")
Exemplo n.º 26
0
 def set_colors(self, *c):
     if len(c) == 2:
         self.attr_color(*c)
     else:
         Screen.wr(ansi_foreground_escape_code(c[0], c[1], c[2]))
         Screen.wr(ansi_background_escape_code(c[3], c[4], c[5]))
Exemplo n.º 27
0
def cursor_move(where, n):
    Screen.wr(b"\x1b[" + bytes(n) + where)
Exemplo n.º 28
0
    else:
        if ENTRYPOINTS:
            show_addr = ENTRYPOINTS[0][1]
        else:
            show_addr = engine.ADDRESS_SPACE.min_addr()

    t = time.time()
    #_model = engine.render()
    _model = engine.render_partial_around(show_addr, 0, HEIGHT * 2)
    print("Rendering time: %fs" % (time.time() - t))
    #print(_model.lines())
    #sys.exit()

    engine.ADDRESS_SPACE.is_loading = False
    engine.ADDRESS_SPACE.changed = False
    Screen.init_tty()
    try:
        Screen.cls()
        Screen.enable_mouse()
        main_screen = MainScreen()
        APP.main_screen = main_screen
        APP.is_ui = True
        main_screen.e.set_model(_model)
        main_screen.e.addr_stack = addr_stack
        main_screen.e.goto_addr(show_addr)
        Screen.set_screen_redraw(main_screen.redraw)
        main_screen.redraw()
        main_screen.e.show_status("Press F1 for help, F9 for menus")
        main_screen.loop()
    except:
        log.exception("Unhandled exception")
Exemplo n.º 29
0
    _status  = [WCheckbox(x, choice=f) for x,f in zip(_choices,O_FLAGS)] 
    with Context(cls=True):
        _width  = 4 + max( [len(x) for x in _choices] )
        _height = 1 + len(_choices)
        d = Dialog( 0, 0, _width, _height )
        # add multiple checkbox
        for i,x in enumerate(_status):
            d.add(1, i+1, x)
        # add OK butthon
        b = WButton(_width-4, "OK")
        d.add(1+int((_width-b.w)/2), _height, b)
        b.finish_dialog = ACTION_OK
        # rendering
        res = d.loop()
        pass
    Screen.cls() #cleanup the screen
    Screen.goto(0, 0) #cleanup the screen

    CHOICES = dict()
    if res==ACTION_OK:
        for x in _status:
            _key = x.t.split()[1]
            CHOICES[_key] = x.choice
        # print(res, [x.choice for x in _status])
    else:
        exit()
    pass

#=====================================================#
with Halo(text='Generate viewsettings.xml file.') as sh:
    if CHOICES['GEN_VIEW']:
Exemplo n.º 30
0
from picotui.context import Context
from picotui.screen import Screen
from picotui.widgets import *
from picotui.defs import *

with Context():

    Screen.attr_color(C_WHITE, C_BLUE)
    Screen.cls()
    Screen.attr_reset()
    d = Dialog(5, 5, 50, 12)

    # Can add a raw string to dialog, will be converted to WLabel
    d.add(1, 1, "Label:")
    d.add(11, 1, WLabel("it's me!"))

    d.add(1, 2, "Entry:")
    d.add(11, 2, WTextEntry(4, "foo"))

    d.add(1, 3, "Dropdown:")
    d.add(11, 3, WDropDown(10, ["Red", "Green", "Yellow"]))

    d.add(1, 4, "Combo:")
    d.add(11, 4, WComboBox(8, "fo", ["foo", "foobar", "bar", "long string"]))

    d.add(1, 5, "Auto complete:")
    d.add(15, 5, WAutoComplete(8, "fo",
                               ["foo", "foobar", "bar", "car", "dar"]))

    d.add(1, 6, "Password:"******""))
Exemplo n.º 31
0
def cursor_position_save():
    Screen.wr(b"\x1b7")