How to use the radian.session.RadianMode 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
session = ModalPromptSession(
        message=message,
        color_depth=ColorDepth.default(term=os.environ.get("TERM")),
        style=style_from_pygments_cls(get_style_by_name(settings.color_scheme)),
        editing_mode="VI" if settings.editing_mode in ["vim", "vi"] else "EMACS",
        history=history,
        enable_history_search=True,
        history_search_no_duplicates=settings.history_search_no_duplicates,
        search_ignore_case=settings.history_search_ignore_case,
        enable_suspend=True,
        tempfile_suffix=".R",
        input=CustomInput(sys.stdin),
        output=output,
        inputhook=get_inputhook(),
        mode_class=RadianMode
    )

    apply_settings(session, settings)

    def browse_activator(session):
        message = session.prompt_text
        if BROWSE_PATTERN.match(message):
            session.browse_level = BROWSE_PATTERN.match(message).group(1)
            return True
        else:
            return False

    def browse_on_pre_accept(session):
        if session.default_buffer.text.strip() in [
                "n", "s", "f", "c", "cont", "Q", "where", "help"]:
            session.add_history = False
github randy3k / radian / radian / session.py View on Github external
session = ModalPromptSession(
        message=message,
        color_depth=ColorDepth.default(term=os.environ.get("TERM")),
        style=style_from_pygments_cls(get_style_by_name(settings.color_scheme)),
        editing_mode="VI" if settings.editing_mode in ["vim", "vi"] else "EMACS",
        history=history,
        enable_history_search=True,
        history_search_no_duplicates=settings.history_search_no_duplicates,
        search_ignore_case=settings.history_search_ignore_case,
        enable_suspend=True,
        tempfile_suffix=".R",
        input=CustomInput(sys.stdin),
        output=output,
        inputhook=get_inputhook(),
        mode_class=RadianMode
    )

    apply_settings(session, settings)

    def browse_activator(session):
        message = session.prompt_text
        if BROWSE_PATTERN.match(message):
            session.browse_level = BROWSE_PATTERN.match(message).group(1)
            return True
        else:
            return False

    def browse_on_pre_accept(session):
        if session.default_buffer.text.strip() in [
                "n", "s", "f", "c", "cont", "Q", "where", "help"]:
            session.add_history = False
github randy3k / radian / radian / session.py View on Github external
def __init__(
            self,
            name,
            activator=None,
            on_post_accept=None,
            insert_new_line=False,
            **kwargs):
        self.activator = activator
        self.on_post_accept = on_post_accept
        self.insert_new_line = insert_new_line
        super(RadianMode, self).__init__(name, **kwargs)
github randy3k / radian / radian / session.py View on Github external
def __init__(
            self,
            name,
            activator=None,
            on_post_accept=None,
            insert_new_line=False,
            **kwargs):
        self.activator = activator
        self.on_post_accept = on_post_accept
        self.insert_new_line = insert_new_line
        super(RadianMode, self).__init__(name, **kwargs)