/* Handle C-u style numeric args, as well as M--, and M-digits. */ static int rl_digit_loop (void) { int c, r; while (1) { if (_rl_arg_overflow ()) return 1; c = _rl_arg_getchar (); if (c < 0) { _rl_abort_internal (); return -1; } r = _rl_arg_dispatch (_rl_argcxt, c); if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)) break; } return r; }
/* Stop defining a keyboard macro. A numeric argument says to execute the macro right now, that many times, counting the definition as the first time. */ int rl_end_kbd_macro (int count, int ignore) { if (RL_ISSTATE (RL_STATE_MACRODEF) == 0) { _rl_abort_internal (); return 1; } current_macro_index -= rl_key_sequence_length; current_macro[current_macro_index] = '\0'; RL_UNSETSTATE(RL_STATE_MACRODEF); return (rl_call_last_kbd_macro (--count, 0)); }
/* The user must press "y" or "n". Non-zero return means "y" pressed. Comes from readline/complete.c */ static int get_y_or_n(void) { int c; for (;;) { c = rl_read_key(); if ((c == 'y') || (c == 'Y') || (c == ' ')) return (1); if ((c == 'n') || (c == 'N') || (c == RUBOUT)) return (0); if (c == ABORT_CHAR) _rl_abort_internal(); beep(); } }
/* Execute the most recently defined keyboard macro. COUNT says how many times to execute it. */ int rl_call_last_kbd_macro (int count, int ignore) { if (current_macro == 0) _rl_abort_internal (); if (RL_ISSTATE (RL_STATE_MACRODEF)) { rl_ding (); /* no recursive macros */ current_macro[--current_macro_index] = '\0'; /* erase this char */ return 0; } while (count--) _rl_with_macro_input (savestring (current_macro)); return 0; }
/* The user must press "y" or "n". Non-zero return means "y" pressed. Comes from readline/complete.c */ static int get_y_or_n (void) { extern int _rl_abort_internal (); int c; for (;;) { c = rl_read_key (); if (c == 'y' || c == 'Y' || c == ' ') return (1); if (c == 'n' || c == 'N' || c == RUBOUT) return (0); if (c == ABORT_CHAR) _rl_abort_internal (); beep (); } }
/* Set up to read subsequent input from STRING. STRING is free ()'ed when we are done with it. */ void _rl_with_macro_input (char *string) { if (macro_level > MAX_MACRO_LEVEL) { _rl_errmsg ("maximum macro execution nesting level exceeded"); _rl_abort_internal (); return; } #if 0 if (rl_executing_macro) /* XXX - later */ #endif _rl_push_executing_macro (); rl_executing_macro = string; executing_macro_index = 0; RL_SETSTATE(RL_STATE_MACROINPUT); }
/* Begin defining a keyboard macro. Keystrokes are recorded as they are executed. End the definition with rl_end_kbd_macro (). If a numeric argument was explicitly typed, then append this definition to the end of the existing macro, and start by re-executing the existing macro. */ int rl_start_kbd_macro (int ignore1, int ignore2) { if (RL_ISSTATE (RL_STATE_MACRODEF)) { _rl_abort_internal (); return 1; } if (rl_explicit_arg) { if (current_macro) _rl_with_macro_input (savestring (current_macro)); } else current_macro_index = 0; RL_SETSTATE(RL_STATE_MACRODEF); return 0; }
int rl_abort (int count, int key) { return (_rl_abort_internal ()); }