|
|
@ -254,6 +254,7 @@ impl Editor {
|
|
|
|
let mode = match view.state.mode() {
|
|
|
|
let mode = match view.state.mode() {
|
|
|
|
Mode::Insert => "INS",
|
|
|
|
Mode::Insert => "INS",
|
|
|
|
Mode::Normal => "NOR",
|
|
|
|
Mode::Normal => "NOR",
|
|
|
|
|
|
|
|
Mode::Goto => "GOTO",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
self.surface.set_style(
|
|
|
|
self.surface.set_style(
|
|
|
|
Rect::new(0, self.size.1 - 1, self.size.0, 1),
|
|
|
|
Rect::new(0, self.size.1 - 1, self.size.0, 1),
|
|
|
@ -278,6 +279,7 @@ impl Editor {
|
|
|
|
match view.state.mode() {
|
|
|
|
match view.state.mode() {
|
|
|
|
Mode::Insert => write!(stdout, "\x1B[6 q"),
|
|
|
|
Mode::Insert => write!(stdout, "\x1B[6 q"),
|
|
|
|
Mode::Normal => write!(stdout, "\x1B[2 q"),
|
|
|
|
Mode::Normal => write!(stdout, "\x1B[2 q"),
|
|
|
|
|
|
|
|
Mode::Goto => write!(stdout, "\x1B[2 q"),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// render the cursor
|
|
|
|
// render the cursor
|
|
|
@ -326,6 +328,7 @@ impl Editor {
|
|
|
|
}))) => {
|
|
|
|
}))) => {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Some(Ok(Event::Key(event))) => {
|
|
|
|
Some(Ok(Event::Key(event))) => {
|
|
|
|
if let Some(view) = &mut self.view {
|
|
|
|
if let Some(view) = &mut self.view {
|
|
|
|
match view.state.mode() {
|
|
|
|
match view.state.mode() {
|
|
|
@ -356,6 +359,19 @@ impl Editor {
|
|
|
|
// TODO: simplistic ensure cursor in view for now
|
|
|
|
// TODO: simplistic ensure cursor in view for now
|
|
|
|
view.ensure_cursor_in_view();
|
|
|
|
view.ensure_cursor_in_view();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Mode::Goto => {
|
|
|
|
|
|
|
|
// TODO: handle modes and sequences (`gg`)
|
|
|
|
|
|
|
|
let keys = vec![event];
|
|
|
|
|
|
|
|
if let Some(command) = keymap[&Mode::Goto].get(&keys) {
|
|
|
|
|
|
|
|
// TODO: handle count other than 1
|
|
|
|
|
|
|
|
command(view, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: simplistic ensure cursor in view for now
|
|
|
|
|
|
|
|
view.ensure_cursor_in_view();
|
|
|
|
|
|
|
|
|
|
|
|
self.render();
|
|
|
|
self.render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|