예제 #1
0
 def get_style():
     ctx = context.get()
     if ctx.app.layout.current_buffer is buffer:
         cls = style.TEXTBOX_FOCUSED
     else:
         cls = style.TEXTBOX
     return f"class:{cls}"
예제 #2
0
def main(path, command, process_and_exit, horizontal, manual, focus):
    if len(path) > 1:
        raise click.ClickException("Only one path argument is supported")

    if process_and_exit and manual:
        raise click.ClickException("--manual with --process-and-exit makes no sense")

    ctx = context.get()

    path = path[0] if path else None
    if path or not sys.stdin.isatty():
        if path:
            with open(path) as f:
                text = f.read()
        else:
            text = sys.stdin.read()
            sys.stdin.close()
            sys.stdin = open(2)
        ctx.input_buffer.text = text

    ctx.live = not manual
    ctx.box_veritcal_orientation = not horizontal
    ctx.cmd_buffer.text = command

    if process_and_exit:
        ctx.non_interactive = True
        process_one()
    else:
        ctx.app = create_app(focus)
        with patch_stdout():
            ctx.app.run()

    if ctx.print_output_on_exit or ctx.non_interactive:
        print(ctx.output_buffer.text)
예제 #3
0
 def __init__(self):
     self.ctx = context.get()
     self.process_ctx = context.get_process()
     self.ctx.process_fn = self.process_key
     self.lexer_threshold = 10000
     self.input_lexer = ToggledLexer(inputs.registry, take_last=False)
     self.output_lexer = ToggledLexer(outputs.registry, take_last=True)
예제 #4
0
def copy_output_to_clipboard(_):
    ctx = context.get()
    ctx.app.clipboard.set_text(ctx.output_buffer.text)
    ctx.copied_to_clipboard = True

    def off():
        ctx.copied_to_clipboard = False

    ctx.app.loop.call_later(0.1, off)
예제 #5
0
def run1(_):
    ctx = context.get()
    ctx.process_fn("run")
예제 #6
0
def toggle_live(_):
    ctx = context.get()
    ctx.live = not ctx.live
예제 #7
0
def toggle_help(_):
    ctx = context.get()
    ctx.display_help = not ctx.display_help
예제 #8
0
def exit_and_print_output(_):
    ctx = context.get()
    ctx.print_output_on_exit = True
    ctx.app.exit()
예제 #9
0
def change_boxes_orientation(_):
    ctx = context.get()
    ctx.box_veritcal_orientation = not ctx.box_veritcal_orientation