Exemplo n.º 1
0
def run():
    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = Session()
            renderer = Rot13Renderer(output_transport.write)
            session.add_renderer(renderer)

            # Setup layout
            window = Window()
            session.add_window(window)
            pane = BashPane()
            window.add_pane(pane)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            input_transport, input_protocol = yield from loop.connect_read_pipe(
                                lambda:InputProtocol(session), sys.stdin)

            # Wait for everything to finish
            yield from pane.run()
Exemplo n.º 2
0
def run():
    finish_f = asyncio.Future()

    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = Session()
            renderer = PipeRenderer(output_transport.write)
            session.add_renderer(renderer)

            # Setup layout
            window = Window()
            session.add_window(window)
            pane1 = PythonPane()
            pane2 = PythonPane()
            window.add_pane(pane1)
            window.add_pane(pane2, vsplit=True)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            done = lambda: finish_f.set_result(None)
            yield from loop.connect_read_pipe(lambda:OurInputProtocol(session, done), sys.stdin)

            # Run panes
            asyncio.async(pane1.run())
            asyncio.async(pane2.run())

            # Wait for any key press to exit.
            yield from finish_f
Exemplo n.º 3
0
def run():
    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = PyMuxSession()
            renderer = PipeRenderer(output_transport.write)
            session.add_renderer(renderer)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            input_transport, input_protocol = yield from loop.connect_read_pipe(
                                lambda:PyMuxInputProtocol(session), sys.stdin)

            yield from session.run()
Exemplo n.º 4
0
def run():
    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(
        BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = PyMuxSession()
            renderer = PipeRenderer(output_transport.write)
            session.add_renderer(renderer)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            input_transport, input_protocol = yield from loop.connect_read_pipe(
                lambda: PyMuxInputProtocol(session), sys.stdin)

            yield from session.run()
Exemplo n.º 5
0
def run(filenames):
    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = Session()
            renderer = PipeRenderer(output_transport.write)
            session.add_renderer(renderer)

            # Setup layout
            window = Window()
            session.add_window(window)
            panes = []

            for filename in filenames:
                pane = TailPane(filename)
                window.add_pane(pane, vsplit=False)
                panes.append(pane)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            input_transport, input_protocol = yield from loop.connect_read_pipe(
                                lambda:OurInputProtocol(session), sys.stdin)

            @asyncio.coroutine
            def run_pane(p):
                yield from p.run()
                window.remove_pane(p)

            # Wait for everything to finish
            yield from asyncio.gather(* [ asyncio.async(run_pane(p)) for p in panes ])
Exemplo n.º 6
0
def run():
    # Output transport/protocol
    output_transport, output_protocol = yield from loop.connect_write_pipe(BaseProtocol, os.fdopen(0, 'wb'))

    with raw_mode(sys.stdin.fileno()):
        # Enter alternate screen buffer
        with alternate_screen(output_transport.write):
            # Create session and renderer
            session = Session()
            renderer = PipeRenderer(output_transport.write)
            session.add_renderer(renderer)

            # Setup layout
            window = Window()
            session.add_window(window)
            pane1 = BashPane()
            pane2 = BashPane()
            window.add_pane(pane1)
            window.add_pane(pane2, vsplit=True)

            # handle resize events
            call_on_sigwinch(session.update_size)

            # Input transport/protocol
            input_transport, input_protocol = yield from loop.connect_read_pipe(
                                lambda:OurInputProtocol(session), sys.stdin)

            @asyncio.coroutine
            def run_pane(p):
                yield from p.run()
                window.remove_pane(p)

            # Wait for everything to finish
            yield from asyncio.gather(
                    asyncio.async(run_pane(pane1)),
                    asyncio.async(run_pane(pane2))) # XXX: if we call pane1.run() twice. We get very weird errors!!!