How to use the radian.io.CustomOutput.from_pty function in radian

To help you get started, we’ve selected a few radian examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github randy3k / radian / radian / session.py View on Github external
if options.no_history:
        history = ModalInMemoryHistory()
    elif not options.global_history and os.path.exists(local_history_file):
        history = ModalFileHistory(os.path.abspath(local_history_file))
    else:
        history_file = os.path.join(os.path.expanduser(global_history_file))
        history_file = os.path.expandvars(history_file)
        history_file_dir = os.path.dirname(history_file)
        if not os.path.exists(history_file_dir):
            os.makedirs(history_file_dir, 0o700)
        history = ModalFileHistory(history_file)

    if is_windows():
        output = None
    else:
        output = CustomOutput.from_pty(sys.stdout, term=get_term_environment_variable())

    def get_inputhook():
        # make testing more robust
        if "RADIAN_NO_INPUTHOOK" in os.environ:
            return None

        terminal_width = [None]

        def _(context):
            output_width = session.app.output.get_size().columns
            if output_width and terminal_width[0] != output_width:
                terminal_width[0] = output_width
                setoption("width", max(terminal_width[0], 20))

            while True:
                if context.input_is_ready():
github randy3k / radian / radian / session.py View on Github external
def create_radian_prompt_session(options, settings):

    history_file = ".radian_history"
    if options.no_history:
        history = ModalInMemoryHistory()
    elif not options.global_history and os.path.exists(history_file):
        history = ModalFileHistory(os.path.abspath(history_file))
    else:
        history = ModalFileHistory(os.path.join(os.path.expanduser("~"), history_file))

    if is_windows():
        output = None
    else:
        output = CustomOutput.from_pty(sys.stdout, term=get_term_environment_variable())

    def get_inputhook():
        # make testing more robust
        if "CIRCLECI" in os.environ or "GITHUB_REPOSITORY" in os.environ:
            return None

        terminal_width = [None]

        def _(context):
            output_width = session.app.output.get_size().columns
            if output_width and terminal_width[0] != output_width:
                terminal_width[0] = output_width
                setoption("width", max(terminal_width[0], 20))

            while True:
                if context.input_is_ready():