def _(context): while True: if context.input_is_ready(): break try: process_events() except Exception: pass 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)) time.sleep(1.0 / 30)
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(): break try: if peek_event(): with session.app.input.detach(): with session.app.input.rare_mode(): process_events() else: polled_events() except Exception: pass time.sleep(1.0 / 30)
def apply_settings(session, settings): setoption("prompt", settings.prompt) if settings.auto_width: output_width = session.app.output.get_size().columns if output_width: setoption("width", output_width) # necessary on windows setoption("menu.graphics", False) if is_windows() and roption("crayon.enabled", None) is None: setoption("crayon.enabled", True) # enables completion of installed package names if rcopy(rcall(("utils", "rc.settings"), "ipck")) is None: rcall(("utils", "rc.settings"), ipck=True)
def load_settings(session): if roption("radian.editing_mode", "emacs") in ["vim", "vi"]: session.app.editing_mode = EditingMode.VI else: session.app.editing_mode = EditingMode.EMACS color_scheme = roption("radian.color_scheme", "native") session.style = style_from_pygments_cls(get_style_by_name(color_scheme)) session.auto_match = roption("radian.auto_match", False) session.auto_indentation = roption("radian.auto_indentation", True) session.tab_size = int(roption("radian.tab_size", 4)) session.complete_while_typing = roption("radian.complete_while_typing", True) session.completion_timeout = roption("radian.completion_timeout", 0.05) session.history_search_no_duplicates = roption( "radian.history_search_no_duplicates", False) session.insert_new_line = roption("radian.insert_new_line", True) session.indent_lines = roption("radian.indent_lines", True) prompt = roption("radian.prompt", None) if not prompt: sys_prompt = roption("prompt") if sys_prompt == "> ": prompt = PROMPT else: prompt = sys_prompt session.default_prompt = prompt setoption("prompt", prompt) shell_prompt = roption("radian.shell_prompt", SHELL_PROMPT) session.shell_prompt = shell_prompt browse_prompt = roption("radian.browse_prompt", BROWSE_PROMPT) session.browse_prompt = browse_prompt set_width_on_resize = roption("setWidthOnResize", True) session.auto_width = roption("radian.auto_width", set_width_on_resize) output_width = session.app.output.get_size().columns if output_width and session.auto_width: setoption("width", output_width) # necessary on windows setoption("menu.graphics", False) # enables completion of installed package names if rcopy(reval("rc.settings('ipck')")) is None: reval("rc.settings(ipck = TRUE)") # backup the updated settings session._backup_settings()
def apply_settings(session, settings): setoption("prompt", settings.prompt) if settings.auto_width: output_width = session.app.output.get_size().columns if output_width: setoption("width", output_width) # necessary on windows setoption("menu.graphics", False) def askpass(message): from prompt_toolkit import prompt return prompt(message, is_password=True) setoption("askpass", askpass) # enables completion of installed package names if rcopy(rcall(("utils", "rc.settings"), "ipck")) is None: rcall(("utils", "rc.settings"), ipck=True)
def session_initialize(session): if not sys.platform.startswith("win"): def reticulate_hook(*args): rcall(("base", "source"), os.path.join(os.path.dirname(__file__), "data", "patching_reticulate.R"), new_env()) set_hook(package_event("reticulate", "onLoad"), reticulate_hook) if not roption("radian.suppress_reticulate_message", False): def reticulate_message_hook(*args): if not roption("radian.suppress_reticulate_message", False): rcall("packageStartupMessage", RETICULATE_MESSAGE) set_hook(package_event("reticulate", "onLoad"), reticulate_message_hook) if roption("radian.enable_reticulate_prompt", True): def reticulate_prompt(*args): rcall(("base", "source"), os.path.join(os.path.dirname(__file__), "data", "register_reticulate.R"), new_env()) set_hook(package_event("reticulate", "onLoad"), reticulate_prompt) if roption("radian.editing_mode", "emacs") in ["vim", "vi"]: session.app.editing_mode = EditingMode.VI else: session.app.editing_mode = EditingMode.EMACS color_scheme = roption("radian.color_scheme", "native") session.style = style_from_pygments_cls(get_style_by_name(color_scheme)) session.auto_match = roption("radian.auto_match", False) session.auto_indentation = roption("radian.auto_indentation", True) session.tab_size = int(roption("radian.tab_size", 4)) session.complete_while_typing = roption("radian.complete_while_typing", True) session.completion_timeout = roption("radian.completion_timeout", 0.05) session.history_search_no_duplicates = roption( "radian.history_search_no_duplicates", False) session.insert_new_line = roption("radian.insert_new_line", True) session.indent_lines = roption("radian.indent_lines", True) prompt = roption("radian.prompt", None) if not prompt: sys_prompt = roption("prompt") if sys_prompt == "> ": prompt = PROMPT else: prompt = sys_prompt session.default_prompt = prompt setoption("prompt", prompt) shell_prompt = roption("radian.shell_prompt", SHELL_PROMPT) session.shell_prompt = shell_prompt browse_prompt = roption("radian.browse_prompt", BROWSE_PROMPT) session.browse_prompt = browse_prompt set_width_on_resize = roption("setWidthOnResize", True) session.auto_width = roption("radian.auto_width", set_width_on_resize) output_width = session.app.output.get_size().columns if output_width and session.auto_width: setoption("width", output_width) # necessary on windows setoption("menu.graphics", False) # enables completion of installed package names if rcopy(reval("rc.settings('ipck')")) is None: reval("rc.settings(ipck = TRUE)") # backup the updated settings session._backup_settings()
def enable_reticulate_prompt(): enable = "reticulate" in rcopy(reval("rownames(installed.packages())")) and \ roption("radian.enable_reticulate_prompt", True) if enable: setoption("radian.suppress_reticulate_message", True) return enable
def _(event): setoption("radian.suppress_reticulate_message", True) commit_text(event, "reticulate::repl_python()", False)