int rl_vi_insert_beg (int count, int key) { rl_beg_of_line (1, key); rl_vi_insertion_mode (1, key); return (0); }
int rl_back_to_indent (int ignore1, int ignore2) { rl_beg_of_line (ignore1, ignore2); while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) rl_point++; return (0); }
int rl_vi_arg_digit (int count, int c) { if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg) return (rl_beg_of_line (1, c)); else return (rl_digit_argument (count, c)); }
int rl_vi_back_to_indent(int count, int key) { rl_beg_of_line (1, key); while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) rl_point++; return (0); }
/* Turn the current line into a comment in shell history. A K*rn shell style function. */ int rl_vi_comment (int count, int key) { rl_beg_of_line (0, 0); if (rl_vi_comment_begin != (char *)NULL) rl_insert_text (rl_vi_comment_begin); else rl_insert_text (VI_COMMENT_BEGIN_DEFAULT); /* Default. */ rl_redisplay (); rl_newline (1, '\n'); return (0); }
int rl_vi_subst (int count, int key) { rl_begin_undo_group (); if (uppercase_p (key)) { rl_beg_of_line (1, key); rl_kill_line (1, key); } else rl_delete_text (rl_point, rl_point+count); rl_end_undo_group (); _rl_vi_set_last (key, count, rl_arg_sign); rl_begin_undo_group (); _rl_vi_doing_insert = 1; rl_vi_insertion_mode (1, key); return (0); }
int rl_vi_domove (int key, int *nextkey) { int c, save; int old_end; rl_mark = rl_point; c = rl_read_key (); *nextkey = c; if (!member (c, vi_motion)) { if (digit_p (c)) { save = rl_numeric_arg; rl_numeric_arg = digit_value (c); rl_digit_loop1 (); rl_numeric_arg *= save; c = rl_read_key (); /* real command */ *nextkey = c; } else if (key == c && (key == 'd' || key == 'y' || key == 'c')) { rl_mark = rl_end; rl_beg_of_line (1, c); _rl_vi_last_motion = c; return (0); } else return (-1); } _rl_vi_last_motion = c; /* Append a blank character temporarily so that the motion routines work right at the end of the line. */ old_end = rl_end; rl_line_buffer[rl_end++] = ' '; rl_line_buffer[rl_end] = '\0'; _rl_dispatch (c, _rl_keymap); /* Remove the blank that we added. */ rl_end = old_end; rl_line_buffer[rl_end] = '\0'; if (rl_point > rl_end) rl_point = rl_end; /* No change in position means the command failed. */ if (rl_mark == rl_point) return (-1); /* rl_vi_f[wW]ord () leaves the cursor on the first character of the next word. If we are not at the end of the line, and we are on a non-whitespace character, move back one (presumably to whitespace). */ if ((to_upper (c) == 'W') && rl_point < rl_end && rl_point > rl_mark && !whitespace (rl_line_buffer[rl_point])) rl_point--; /* If cw or cW, back up to the end of a word, so the behaviour of ce or cE is the actual result. Brute-force, no subtlety. */ if (key == 'c' && rl_point >= rl_mark && (to_upper (c) == 'W')) { /* Don't move farther back than where we started. */ while (rl_point > rl_mark && whitespace (rl_line_buffer[rl_point])) rl_point--; /* Posix.2 says that if cw or cW moves the cursor towards the end of the line, the character under the cursor should be deleted. */ if (rl_point == rl_mark) rl_point++; else { /* Move past the end of the word so that the kill doesn't remove the last letter of the previous word. Only do this if we are not at the end of the line. */ if (rl_point >= 0 && rl_point < (rl_end - 1) && !whitespace (rl_line_buffer[rl_point])) rl_point++; } } if (rl_mark < rl_point) exchange (rl_point, rl_mark); return (0); }