/* * Actually initialize readline. */ value caml_initialize_readline(value unit) { CAMLparam1(unit); /* Setup the default command table */ commands = NULL; /* Tell the completer about our command completion engine */ rl_attempted_completion_function = (RL_CPP_TYPE *)command_completion; /* Set horizontal scroll mode; other modes screw up display */ rl_variable_bind("horizontal-scroll-mode", "on"); /* Disable the bell */ rl_variable_bind("bell-style", "none"); CAMLreturn(Val_unit); }
void init_readline(char *UNUSED(prompt)) { DPRINTF1(DEBUG_READLINE, "Initialising readline version %x", rl_readline_version); rl_add_defun("rlwrap-accept-line", my_accept_line,-1); rl_add_defun("rlwrap-accept-line-and-forget", my_accept_line_and_forget,-1); rl_add_defun("rlwrap-call-editor", munge_line_in_editor, -1); rl_add_defun("rlwrap-direct-keypress", direct_keypress, -1); rl_add_defun("rlwrap-hotkey", handle_hotkey, -1); rl_add_defun("rlwrap-hotkey-ignore-history", handle_hotkey_ignore_history, -1); /* only useful while debugging */ rl_add_defun("rlwrap-dump-all-keybindings", dump_all_keybindings,-1); rl_add_defun("rlwrap-debug-ad-hoc", debug_ad_hoc, -1); /* the old rlwrap bindable function names with underscores are deprecated: */ rl_add_defun("rlwrap_accept_line_and_forget", please_update_alaf,-1); rl_add_defun("rlwrap_call_editor", please_update_ce,-1); rl_variable_bind("blink-matching-paren","on"); /* Shouldn't this be on by default? */ bindkey('\n', my_accept_line, "emacs-standard; vi-insert; vi-command"); bindkey('\r', my_accept_line, "emacs-standard; vi-insert; vi-command"); bindkey(15, my_accept_line_and_forget, "emacs-standard; vi-insert; vi-command"); /* ascii #15 (Control-O) is unused in readline's emacs and vi keymaps */ if (multiline_separator) bindkey(30, munge_line_in_editor, "emacs-standard;vi-insert;vi-command"); /* CTRL-^: unused in vi-insert-mode, hardly used in emacs (doubles arrow-up) */ /* rl_variable_bind("gnah","gnerp"); It is not possible to create new readline variables (only functions) */ rl_catch_signals = 0; rl_initialize(); /* This has to happen *before* we set rl_redisplay_function, otherwise readline will not bother to call tgetent(), will be agnostic about terminal capabilities and hence not be able to honour e.g. a set horizontal-scroll-mode off in .inputrc */ using_history(); rl_redisplay_function = my_redisplay; rl_completion_entry_function = (rl_compentry_func_t *) & my_completion_function; rl_catch_signals = FALSE; rl_catch_sigwinch = FALSE; saved_rl_state.input_buffer = mysavestring(pre_given ? pre_given : ""); /* Even though the pre-given input won't be displayed before the first cooking takes place, we still want it to be accepted when the user presses ENTER before that (e.g. because she already knows the pre-given input and wants to accept that) */ saved_rl_state.point = strlen(saved_rl_state.input_buffer); saved_rl_state.raw_prompt = mysavestring(""); saved_rl_state.cooked_prompt = NULL; }
// Set everything up void gnu_readline_init() { using_history(); rl_bind_key(')', gnu_readline_paren_bounce); rl_bind_key(']', gnu_readline_paren_bounce); #if 0 rl_bind_keyseq("[D", highlight_paren); #endif rl_completion_entry_function = &gnu_readline_tab_complete; rl_variable_bind("rl_catch_signals", 0); rl_clear_signals(); rl_set_signals(); rl_completer_quote_characters = "\""; }
void init_readline(char *prompt) { DPRINTF1(DEBUG_READLINE, "Initialising readline version %x", rl_readline_version); rl_add_defun("rlwrap-accept-line", my_accept_line,-1); rl_add_defun("rlwrap-accept-line-and-forget", my_accept_line_and_forget,-1); rl_add_defun("rlwrap-dump-all-keybindings", dump_all_keybindings,-1); rl_add_defun("rlwrap-call-editor", munge_line_in_editor, -1); /* rlwrap bindable function names with underscores are deprecated: */ rl_add_defun("rlwrap_accept_line_and_forget", please_update_alaf,-1); rl_add_defun("rlwrap_call_editor", please_update_ce,-1); rl_variable_bind("blink-matching-paren","on"); /* Shouldn't this be on by default? */ bindkey('\n', my_accept_line, "emacs-standard; vi-insert; vi-command"); bindkey('\r', my_accept_line, "emacs-standard; vi-insert; vi-command"); bindkey(15, my_accept_line_and_forget, "emacs-standard; vi-insert; vi-command"); /* ascii #15 (Control-O) is unused in readline's emacs and vi keymaps */ if (multiline_separator) bindkey(30, munge_line_in_editor, "emacs-standard;vi-insert;vi-command"); /* CTRL-^: unused in vi-insert-mode, hardly used in emacs (doubles arrow-up) */ if (debug) bindkey(7, dump_all_keybindings,"emacs-standard; vi-insert; vi-move; vi-command" /* "emacs-ctlx; emacs-meta" */); /* CTRL-G */ /* rl_variable_bind("gnah","gnerp"); It is not possible to create new readline variables (only functions) */ rl_catch_signals = 0; rl_initialize(); /* This has to happen *before* we set rl_redisplay_function, otherwise readline will not bother to call tgetent(), will be agnostic about terminal capabilities and hence not be able to honour e.g. a set horizontal-scroll-mode off in .inputrc */ using_history(); rl_redisplay_function = my_redisplay; rl_completion_entry_function = (rl_compentry_func_t *) & my_completion_function; rl_catch_signals = FALSE; rl_catch_sigwinch = FALSE; saved_rl_state.input_buffer = mysavestring(""); saved_rl_state.raw_prompt = mysavestring(""); saved_rl_state.cooked_prompt = NULL; }
static void rtty_prep() { // readline static QByteArray progname; QFileInfo fileinfo = QCoreApplication::applicationFilePath(); progname = fileinfo.baseName().toLocal8Bit(); rl_readline_name = progname.data(); rl_getc_function = rtty_getchar; rl_attempted_completion_function = rtty_complete; rl_completer_quote_characters = "\"'"; rl_completion_append_character = '\0'; #ifdef RL_READLINE_VERSION # if RL_READLINE_VERSION > 0x402 rl_set_paren_blink_timeout(250000); rl_bind_key (')', rl_insert_close); rl_bind_key (']', rl_insert_close); rl_bind_key ('}', rl_insert_close); rl_variable_bind("comment-begin","-- "); # endif #endif rl_initialize(); // history rtty_history = ".luahistory"; const char *home = getenv("HOME"); const char *luaHistory = getenv("LUA_HISTORY"); const char *luaHistSize = getenv("LUA_HISTSIZE"); int histSize = 1000; if (luaHistory && luaHistory[0]) rtty_history = luaHistory; else if (home && home[0]) rtty_history = QByteArray(home) + "/" + rtty_history; if (luaHistSize && luaHistSize[0]) histSize = strtol(luaHistSize, 0, 10); using_history(); stifle_history(qBound(25,histSize,250000)); read_history(rtty_history.constData()); // done rtty_inited = true; }
void octave_rl_enable_paren_matching (int val) { rl_variable_bind ("blink-matching-paren", val ? "1" : "0"); }
/* Createing and Destroying a librline context. {{{*/ struct rline* rline_initialize (int slavefd, command_cb *command, completion_cb *completion, char *TERM) { struct rline *rline = (struct rline*)malloc (sizeof(struct rline)); if (!rline) return NULL; /* Initialize each member variable */ rline->input = NULL; rline->output = NULL; rline->input = fdopen (slavefd, "r"); if (!rline->input) { rline_shutdown (rline); return NULL; } rline->output = fdopen (slavefd, "w"); if (!rline->output) { rline_shutdown (rline); return NULL; } rline->tab_completion = completion; rline->rline_rl_last_func = NULL; rline->rline_rl_completion_query_items = rl_completion_query_items; rl_readline_name = "cgdb"; rl_instream = rline->input; rl_outstream = rline->output; /* Tell readline not to put the initial prompt */ rl_already_prompted = 1; /* Tell readline not to catch signals */ rl_catch_signals = 0; rl_catch_sigwinch = 0; /* Tell readline what the prompt is if it needs to put it back */ rl_callback_handler_install("(gdb) ", command); rl_bind_key ('\t', completion); /* Set the terminal type to dumb so the output of readline can be * understood by tgdb */ if (rl_reset_terminal (TERM) == -1) { rline_shutdown (rline); return NULL; } /* For some reason, readline can not deprep the terminal. * However, it doesn't matter because no other application is working on * the terminal besides readline */ rl_deprep_term_function = custom_deprep_term_function; /* These variables are here to make sure readline doesn't * attempt to query the user to determine if it wants more input. */ rl_completion_query_items = -1; rl_variable_bind ("page-completions", "0"); rl_completer_word_break_characters = " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-"; rl_completer_quote_characters = "'"; return rline; }
static void setup_readline(readlinestate *mod_state) { #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); #endif #ifdef __APPLE__ /* the libedit readline emulation resets key bindings etc * when calling rl_initialize. So call it upfront */ if (using_libedit_emulation) rl_initialize(); /* Detect if libedit's readline emulation uses 0-based * indexing or 1-based indexing. */ add_history("1"); if (history_get(1) == NULL) { libedit_history_start = 0; } else { libedit_history_start = 1; } clear_history(); #endif /* __APPLE__ */ using_history(); rl_readline_name = "python"; /* Force rebind of TAB to insert-tab */ rl_bind_key('\t', rl_insert); /* Bind both ESC-TAB and ESC-ESC to the completion function */ rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap); rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap); #ifdef HAVE_RL_RESIZE_TERMINAL /* Set up signal handler for window resize */ sigwinch_ohandler = PyOS_setsig(SIGWINCH, readline_sigwinch_handler); #endif /* Set our hook functions */ rl_startup_hook = on_startup_hook; #ifdef HAVE_RL_PRE_INPUT_HOOK rl_pre_input_hook = on_pre_input_hook; #endif /* Set our completion function */ rl_attempted_completion_function = flex_complete; /* Set Python word break characters */ completer_word_break_characters = rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ mod_state->begidx = PyLong_FromLong(0L); mod_state->endidx = PyLong_FromLong(0L); #ifdef __APPLE__ if (!using_libedit_emulation) #endif { if (!isatty(STDOUT_FILENO)) { /* Issue #19884: stdout is not a terminal. Disable meta modifier keys to not write the ANSI sequence "\033[1034h" into stdout. On terminals supporting 8 bit characters like TERM=xterm-256color (which is now the default Fedora since Fedora 18), the meta key is used to enable support of 8 bit characters (ANSI sequence "\033[1034h"). With libedit, this call makes readline() crash. */ rl_variable_bind ("enable-meta-key", "off"); } } /* Initialize (allows .inputrc to override) * * XXX: A bug in the readline-2.2 library causes a memory leak * inside this function. Nothing we can do about it. */ #ifdef __APPLE__ if (using_libedit_emulation) rl_read_init_file(NULL); else #endif /* __APPLE__ */ rl_initialize(); RESTORE_LOCALE(saved_locale) }
static int _inp_rl_startup_hook(void) { rl_bind_keyseq("\\e1", _inp_rl_win_1_handler); rl_bind_keyseq("\\e2", _inp_rl_win_2_handler); rl_bind_keyseq("\\e3", _inp_rl_win_3_handler); rl_bind_keyseq("\\e4", _inp_rl_win_4_handler); rl_bind_keyseq("\\e5", _inp_rl_win_5_handler); rl_bind_keyseq("\\e6", _inp_rl_win_6_handler); rl_bind_keyseq("\\e7", _inp_rl_win_7_handler); rl_bind_keyseq("\\e8", _inp_rl_win_8_handler); rl_bind_keyseq("\\e9", _inp_rl_win_9_handler); rl_bind_keyseq("\\e0", _inp_rl_win_0_handler); rl_bind_keyseq("\\eOP", _inp_rl_win_1_handler); rl_bind_keyseq("\\eOQ", _inp_rl_win_2_handler); rl_bind_keyseq("\\eOR", _inp_rl_win_3_handler); rl_bind_keyseq("\\eOS", _inp_rl_win_4_handler); rl_bind_keyseq("\\e[15~", _inp_rl_win_5_handler); rl_bind_keyseq("\\e[17~", _inp_rl_win_6_handler); rl_bind_keyseq("\\e[18~", _inp_rl_win_7_handler); rl_bind_keyseq("\\e[19~", _inp_rl_win_8_handler); rl_bind_keyseq("\\e[20~", _inp_rl_win_9_handler); rl_bind_keyseq("\\e[21~", _inp_rl_win_0_handler); rl_bind_keyseq("\\e[1;9D", _inp_rl_win_prev_handler); rl_bind_keyseq("\\e[1;3D", _inp_rl_win_prev_handler); rl_bind_keyseq("\\e\\e[D", _inp_rl_win_prev_handler); rl_bind_keyseq("\\e[1;9C", _inp_rl_win_next_handler); rl_bind_keyseq("\\e[1;3C", _inp_rl_win_next_handler); rl_bind_keyseq("\\e\\e[C", _inp_rl_win_next_handler); rl_bind_keyseq("\\e\\e[5~", _inp_rl_subwin_pageup_handler); rl_bind_keyseq("\\e[5;3~", _inp_rl_subwin_pageup_handler); rl_bind_keyseq("\\e\\eOy", _inp_rl_subwin_pageup_handler); rl_bind_keyseq("\\e\\e[6~", _inp_rl_subwin_pagedown_handler); rl_bind_keyseq("\\e[6;3~", _inp_rl_subwin_pagedown_handler); rl_bind_keyseq("\\e\\eOs", _inp_rl_subwin_pagedown_handler); rl_bind_keyseq("\\e[5~", _inp_rl_win_pageup_handler); rl_bind_keyseq("\\eOy", _inp_rl_win_pageup_handler); rl_bind_keyseq("\\e[6~", _inp_rl_win_pagedown_handler); rl_bind_keyseq("\\eOs", _inp_rl_win_pagedown_handler); rl_bind_key('\t', _inp_rl_tab_handler); // unbind unwanted mappings rl_bind_keyseq("\\e=", NULL); // disable readline completion rl_variable_bind("disable-completion", "on"); // check for and load ~/.config/profanity/inputrc char *inputrc = prefs_get_inputrc(); if (inputrc) { rl_read_init_file(inputrc); free(inputrc); } return 0; }