diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2003-08-31 17:55:46 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2003-08-31 17:55:46 +0000 |
commit | 19eab8b8e47590be0c3122a09a29a27a31620bd3 (patch) | |
tree | f75abef44b0f70973592b7edb66a319f92a1d7b2 /contrib/libreadline/kill.c | |
parent | fb21882ffc08f0f36202a6492bc4628bd832ac18 (diff) | |
download | src-19eab8b8e47590be0c3122a09a29a27a31620bd3.tar.gz src-19eab8b8e47590be0c3122a09a29a27a31620bd3.zip |
Virgin import of GNU Readline 4.3
Notes
Notes:
svn path=/vendor/libreadline/dist/; revision=119610
Diffstat (limited to 'contrib/libreadline/kill.c')
-rw-r--r-- | contrib/libreadline/kill.c | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/contrib/libreadline/kill.c b/contrib/libreadline/kill.c index 3ced8fbc9a93..a616b920d903 100644 --- a/contrib/libreadline/kill.c +++ b/contrib/libreadline/kill.c @@ -70,6 +70,11 @@ static int rl_kill_index; /* How many slots we have in the kill ring. */ static int rl_kill_ring_length; +static int _rl_copy_to_kill_ring PARAMS((char *, int)); +static int region_kill_internal PARAMS((int)); +static int _rl_copy_word_as_kill PARAMS((int, int)); +static int rl_yank_nth_arg_internal PARAMS((int, int, int)); + /* How to say that you only want to save a certain amount of kill material. */ int @@ -129,7 +134,7 @@ _rl_copy_to_kill_ring (text, append) if (_rl_last_command_was_kill && rl_editing_mode != vi_mode) { old = rl_kill_ring[slot]; - new = xmalloc (1 + strlen (old) + strlen (text)); + new = (char *)xmalloc (1 + strlen (old) + strlen (text)); if (append) { @@ -196,18 +201,21 @@ int rl_kill_word (count, key) int count, key; { - int orig_point = rl_point; + int orig_point; if (count < 0) return (rl_backward_kill_word (-count, key)); else { + orig_point = rl_point; rl_forward_word (count, key); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -217,16 +225,20 @@ int rl_backward_kill_word (count, ignore) int count, ignore; { - int orig_point = rl_point; + int orig_point; if (count < 0) return (rl_kill_word (-count, ignore)); else { + orig_point = rl_point; rl_backward_word (count, ignore); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); + + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -237,16 +249,19 @@ int rl_kill_line (direction, ignore) int direction, ignore; { - int orig_point = rl_point; + int orig_point; if (direction < 0) return (rl_backward_kill_line (1, ignore)); else { + orig_point = rl_point; rl_end_of_line (1, ignore); if (orig_point != rl_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -257,7 +272,7 @@ int rl_backward_kill_line (direction, ignore) int direction, ignore; { - int orig_point = rl_point; + int orig_point; if (direction < 0) return (rl_kill_line (1, ignore)); @@ -267,8 +282,12 @@ rl_backward_kill_line (direction, ignore) rl_ding (); else { + orig_point = rl_point; rl_beg_of_line (1, ignore); - rl_kill_text (orig_point, rl_point); + if (rl_point != orig_point) + rl_kill_text (orig_point, rl_point); + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } } return 0; @@ -282,6 +301,7 @@ rl_kill_full_line (count, ignore) rl_begin_undo_group (); rl_point = 0; rl_kill_text (rl_point, rl_end); + rl_mark = 0; rl_end_undo_group (); return 0; } @@ -316,6 +336,8 @@ rl_unix_word_rubout (count, key) } rl_kill_text (orig_point, rl_point); + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -336,6 +358,8 @@ rl_unix_line_discard (count, key) { rl_kill_text (rl_point, 0); rl_point = 0; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -348,17 +372,14 @@ region_kill_internal (delete) { char *text; - if (rl_mark == rl_point) + if (rl_mark != rl_point) { - _rl_last_command_was_kill++; - return 0; + text = rl_copy_text (rl_point, rl_mark); + if (delete) + rl_delete_text (rl_point, rl_mark); + _rl_copy_to_kill_ring (text, rl_point < rl_mark); } - text = rl_copy_text (rl_point, rl_mark); - if (delete) - rl_delete_text (rl_point, rl_mark); - _rl_copy_to_kill_ring (text, rl_point < rl_mark); - _rl_last_command_was_kill++; return 0; } @@ -525,6 +546,8 @@ rl_yank_nth_arg_internal (count, ignore, history_skip) rl_begin_undo_group (); + _rl_set_mark_at_pos (rl_point); + #if defined (VI_MODE) /* Vi mode always inserts a space before yanking the argument, and it inserts it right *after* rl_point. */ @@ -612,12 +635,13 @@ rl_paste_from_clipboard (count, key) if (ptr) { len = ptr - data; - ptr = xmalloc (len + 1); + ptr = (char *)xmalloc (len + 1); ptr[len] = '\0'; strncpy (ptr, data, len); } else ptr = data; + _rl_set_mark_at_pos (rl_point); rl_insert_text (ptr); if (ptr != data) free (ptr); |