Skip to content
Snippets Groups Projects
Commit d77a9540 authored by Wesley Wiser's avatar Wesley Wiser
Browse files

Add 'Repeat last command' ('.')

Fixes #29
parent 8a36ca75
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,7 @@ Editing:
( -> )
/ -> \
- ; : Go to prompt mode
- . : Repeat the previous command
# Insert
......
......@@ -220,6 +220,14 @@ impl Editor {
(Command(Normal), Char('~')) => {
self.invert_chars(n);
}
(Command(Normal), Char('.')) => {
if let Some(inst) = self.previous_instruction {
self.exec(inst);
} else {
self.status_bar.msg = "No previous command".into();
self.redraw_task = RedrawTask::StatusBar;
}
}
(Command(Normal), Char(c)) => {
self.status_bar.msg = format!("Unknown command: {}", c);
self.redraw_task = RedrawTask::StatusBar;
......@@ -249,5 +257,9 @@ impl Editor {
if mov {
self.redraw_task = RedrawTask::Cursor(bef, self.pos());
}
if !(self.cursor().mode == Command(Normal) && cmd.key == Char('.')) {
self.previous_instruction = Some(Inst(para, cmd));
}
}
}
......@@ -37,6 +37,8 @@ pub struct Editor {
pub key_state: KeyState,
/// Redraw
pub redraw_task: RedrawTask,
/// The previous instruction
pub previous_instruction: Option<Inst>,
}
impl Editor {
......@@ -59,6 +61,7 @@ impl Editor {
options: Options::new(),
key_state: KeyState::new(),
redraw_task: RedrawTask::None,
previous_instruction: None,
};
#[cfg(not(feature = "orbital"))]
......@@ -73,6 +76,7 @@ impl Editor {
options: Options::new(),
key_state: KeyState::new(),
redraw_task: RedrawTask::None,
previous_instruction: None,
};
if let Some(x) = args().skip(1).next() {
......
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