Esempio n. 1
0
def pye(*args, tab_size=4, undo=50):
    from pyb import USB_VCP
    USB_VCP().setinterrupt(-1)
    io_device = IO_DEVICE()
    ret = pye_edit(*args, tab_size=tab_size, undo=undo, io_device=io_device)
    io_device.deinit_tty()
    USB_VCP().setinterrupt(3)
    return ret
Esempio n. 2
0
def pye(*args, tab_size=4, undo=50):
    io_device = IO_DEVICE()
    ret = pye_edit(args, tab_size=tab_size, undo=undo, io_device=io_device)
    io_device.deinit_tty()
    return ret
Esempio n. 3
0
if "pye_edit" not in globals().keys():
    from pye import pye_edit, is_micropython

def pye(*args, tab_size=4, undo=500):
    io_device = IO_DEVICE(0)
    ret = pye_edit(*args, tab_size=tab_size, undo=undo, io_device=io_device)
    io_device.deinit_tty()
    return ret

if __name__ == "__main__":
    import stat
    fd_tty = 0
    if len(sys.argv) > 1:
        name = sys.argv[1:]
        io_device = IO_DEVICE(fd_tty)
        pye_edit(*name, undo=500, io_device=io_device)
    else:
        name = "."
        if not is_micropython:
            mode = os.fstat(0).st_mode
            if stat.S_ISFIFO(mode) or stat.S_ISREG(mode):
                name = sys.stdin.readlines()
                os.close(0) ## close and repopen /dev/tty
                fd_tty = os.open("/dev/tty", os.O_RDONLY) ## memorized, if new fd
                for i, l in enumerate(name):  ## strip and convert
                    name[i], tc = expandtabs(l.rstrip('\r\n\t '))
        io_device = IO_DEVICE(fd_tty)
        pye_edit(name, undo=500, io_device=io_device)

    io_device.deinit_tty()