Skip to content
Snippets Groups Projects
Commit b527512b authored by Daan Planken's avatar Daan Planken
Browse files

Implement 'I', 'A' and 'c' commands.

Also fixes a bug where pressing 'L' would put
the cursor beyond the last character of the line.
parent 5034fdcd
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,14 @@ impl Editor {
mode: InsertMode::Insert,
}));
}
(Command(Normal), Char('I')) => {
self.cursor_mut().x = 0;
self.cursor_mut().mode =
Mode::Primitive(PrimitiveMode::Insert(InsertOptions {
mode: InsertMode::Insert,
}));
}
(Command(Normal), Char('a')) => {
let pos = self.right(1, false);
......@@ -57,7 +65,15 @@ impl Editor {
Mode::Primitive(PrimitiveMode::Insert(InsertOptions {
mode: InsertMode::Insert,
}));
}
(Command(Normal), Char('A')) => {
let pos = (self.buffers.current_buffer()[self.y()].len(), self.y());
//let pos = self.right(1, false);
self.goto(pos);
self.cursor_mut().mode =
Mode::Primitive(PrimitiveMode::Insert(InsertOptions {
mode: InsertMode::Insert,
}));
}
(Command(Normal), Char('o')) => {
let y = self.y();
......@@ -118,7 +134,7 @@ impl Editor {
self.goto(bounded);
}
(Command(Normal), Char('L')) => {
let ln_end = (self.buffers.current_buffer()[self.y()].len(), self.y());
let ln_end = (self.buffers.current_buffer()[self.y()].len() - 1, self.y());
self.goto(ln_end);
mov = true;
}
......@@ -149,6 +165,16 @@ impl Editor {
self.remove_rb(m);
}
}
(Command(Normal), Char('c')) => {
let ins = self.get_inst();
if let Some(m) = self.to_motion_unbounded(ins) {
self.remove_rb(m);
self.cursor_mut().mode =
Mode::Primitive(PrimitiveMode::Insert(InsertOptions {
mode: InsertMode::Insert,
}));
}
}
(Command(Normal), Char('G')) => {
let last = self.buffers.current_buffer().len() - 1;
self.goto((0, last));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment