@@ -214,7 +214,8 @@ impl<'out, 'prompt> State<'out, 'prompt> {
214
214
let mut info = try!( self . term . get_console_screen_buffer_info ( ) ) ;
215
215
info. dwCursorPosition . X = 0 ;
216
216
info. dwCursorPosition . Y -= self . cursor . row as i16 ;
217
- try!( self . term . set_console_cursor_position ( info. dwCursorPosition ) ) ;
217
+ try!( self . term
218
+ . set_console_cursor_position ( info. dwCursorPosition ) ) ;
218
219
let mut _count = 0 ;
219
220
try!( self . term
220
221
. fill_console_output_character ( ( info. dwSize . X * ( self . old_rows as i16 + 1 ) ) as u32 ,
@@ -230,7 +231,8 @@ impl<'out, 'prompt> State<'out, 'prompt> {
230
231
let mut info = try!( self . term . get_console_screen_buffer_info ( ) ) ;
231
232
info. dwCursorPosition . X = cursor. col as i16 ;
232
233
info. dwCursorPosition . Y -= ( end_pos. row - cursor. row ) as i16 ;
233
- try!( self . term . set_console_cursor_position ( info. dwCursorPosition ) ) ;
234
+ try!( self . term
235
+ . set_console_cursor_position ( info. dwCursorPosition ) ) ;
234
236
235
237
self . cursor = cursor;
236
238
self . old_rows = end_pos. row ;
@@ -838,9 +840,6 @@ fn reverse_incremental_search<R: RawReader>(rdr: &mut R,
838
840
Ok ( Some ( cmd) )
839
841
}
840
842
841
- static KILL_RING_NAME : & ' static str = "kill_ring" ;
842
- static UNDOS_NAME : & ' static str = "undos" ;
843
-
844
843
/// Handles reading and editting the readline buffer.
845
844
/// It will also handle special inputs in an appropriate fashion
846
845
/// (e.g., C-c will exit readline)
@@ -860,7 +859,10 @@ fn readline_edit<C: Completer>(prompt: &str,
860
859
prompt,
861
860
editor. history . len ( ) ,
862
861
editor. custom_bindings . clone ( ) ) ;
863
- s. line . bind ( UNDOS_NAME , s. changes . clone ( ) ) ;
862
+
863
+ s. line . bind ( s. changes . clone ( ) ) ;
864
+ s. line . bind ( editor. kill_ring . clone ( ) ) ;
865
+
864
866
try!( s. refresh_line ( ) ) ;
865
867
866
868
let mut rdr = try!( s. term . create_reader ( & editor. config ) ) ;
@@ -945,15 +947,15 @@ fn readline_edit<C: Completer>(prompt: &str,
945
947
}
946
948
Cmd :: Kill ( Movement :: EndOfLine ) => {
947
949
// Kill the text from point to the end of the line.
948
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
950
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
949
951
try!( edit_kill_line ( & mut s) ) ;
950
- s . line . unbind ( KILL_RING_NAME ) ;
952
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
951
953
}
952
954
Cmd :: Kill ( Movement :: WholeLine ) => {
953
955
try!( edit_move_home ( & mut s) ) ;
954
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
956
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
955
957
try!( edit_kill_line ( & mut s) ) ;
956
- s . line . unbind ( KILL_RING_NAME ) ;
958
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
957
959
}
958
960
Cmd :: ClearScreen => {
959
961
// Clear the screen leaving the current line at the top of the screen.
@@ -974,9 +976,9 @@ fn readline_edit<C: Completer>(prompt: &str,
974
976
}
975
977
Cmd :: Kill ( Movement :: BeginningOfLine ) => {
976
978
// Kill backward from point to the beginning of the line.
977
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
979
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
978
980
try!( edit_discard_line ( & mut s) ) ;
979
- s . line . unbind ( KILL_RING_NAME ) ;
981
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
980
982
}
981
983
#[ cfg( unix) ]
982
984
Cmd :: QuotedInsert => {
@@ -1003,9 +1005,9 @@ fn readline_edit<C: Completer>(prompt: &str,
1003
1005
}
1004
1006
Cmd :: Kill ( Movement :: BackwardWord ( n, word_def) ) => {
1005
1007
// kill one word backward (until start of word)
1006
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
1008
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
1007
1009
try!( edit_delete_prev_word ( & mut s, word_def, n) ) ;
1008
- s . line . unbind ( KILL_RING_NAME ) ;
1010
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
1009
1011
}
1010
1012
Cmd :: BeginningOfHistory => {
1011
1013
// move to first entry in history
@@ -1025,9 +1027,9 @@ fn readline_edit<C: Completer>(prompt: &str,
1025
1027
}
1026
1028
Cmd :: Kill ( Movement :: ForwardWord ( n, at, word_def) ) => {
1027
1029
// kill one word forward (until start/end of word)
1028
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
1030
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
1029
1031
try!( edit_delete_word ( & mut s, at, word_def, n) ) ;
1030
- s . line . unbind ( KILL_RING_NAME ) ;
1032
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
1031
1033
}
1032
1034
Cmd :: Move ( Movement :: ForwardWord ( n, at, word_def) ) => {
1033
1035
// move forwards one word
@@ -1053,16 +1055,14 @@ fn readline_edit<C: Completer>(prompt: &str,
1053
1055
}
1054
1056
Cmd :: Move ( Movement :: ViCharSearch ( n, cs) ) => try!( edit_move_to ( & mut s, cs, n) ) ,
1055
1057
Cmd :: Kill ( Movement :: ViCharSearch ( n, cs) ) => {
1056
- s . line . bind ( KILL_RING_NAME , editor. kill_ring . clone ( ) ) ;
1058
+ editor. kill_ring . borrow_mut ( ) . start_killing ( ) ;
1057
1059
try!( edit_delete_to ( & mut s, cs, n) ) ;
1058
- s . line . unbind ( KILL_RING_NAME ) ;
1060
+ editor . kill_ring . borrow_mut ( ) . stop_killing ( ) ;
1059
1061
}
1060
1062
Cmd :: Undo => {
1061
- s. line . unbind ( UNDOS_NAME ) ;
1062
1063
if s. changes . borrow_mut ( ) . undo ( & mut s. line ) {
1063
1064
try!( s. refresh_line ( ) ) ;
1064
1065
}
1065
- s. line . bind ( UNDOS_NAME , s. changes . clone ( ) ) ;
1066
1066
}
1067
1067
Cmd :: Interrupt => {
1068
1068
return Err ( error:: ReadlineError :: Interrupted ) ;
0 commit comments