Commit 6e74c8f6 authored by Liam's avatar Liam Committed by GitHub

Merge pull request #5 from msehnout/master

Handling of Ctrl+a, Ctrl+u and Ctr+w
parents 102ce25e 03696cc4
......@@ -188,13 +188,16 @@ impl<'a, W: TermWrite + Write> Editor<'a, W> {
fn handle_ctrl_key(&mut self, c: char) -> io::Result<()> {
match c {
'l' => self.clear(),
'a' => self.move_cursor_to_start_of_line(),
'e' => self.move_cursor_to_end_of_line(),
'b' => self.move_cursor_left(1),
'f' => self.move_cursor_right(1),
'd' => self.delete_after_cursor(),
'p' => self.move_up(),
'n' => self.move_down(),
'u' => self.delete_all_before_cursor(),
'k' => self.delete_all_after_cursor(),
'w' => self.delete_word_before_cursor(true),
'x' => {
try!(self.undo());
Ok(())
......@@ -476,6 +479,13 @@ impl<'a, W: TermWrite + Write> Editor<'a, W> {
self.print_current_buffer(false)
}
/// Deletes every character preceding the cursor until the beggining of the line
pub fn delete_all_before_cursor(&mut self) -> io::Result<()> {
cur_buf_mut!(self).remove(0, self.cursor);
self.cursor = 0;
self.print_current_buffer(false)
}
/// Deletes every character after the cursor until the end of the line.
pub fn delete_all_after_cursor(&mut self) -> io::Result<()> {
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment