@@ -1,5 +1,5 @@
1use clap::ArgMatches as Args;
1use clap::ArgMatches as Args;
2−use helix_core::{indent::TAB_WIDTH, state::Mode, syntax::HighlightEvent, Range, State};
2+use helix_core::{indent::TAB_WIDTH, state::Mode, syntax::HighlightEvent, Position, Range, State};
3use helix_view::{commands, keymap, View};
3use helix_view::{commands, keymap, View};
@@ -242,6 +242,7 @@ impl Editor {
242 Mode::Insert => "INS",
242 Mode::Insert => "INS",
243 Mode::Normal => "NOR",
243 Mode::Normal => "NOR",
244 Mode::Goto => "GOTO",
244 Mode::Goto => "GOTO",
245+ Mode::Command => ":",
246 self.surface.set_style(
247 self.surface.set_style(
247 Rect::new(0, self.size.1 - 1, self.size.0, 1),
248 Rect::new(0, self.size.1 - 1, self.size.0, 1),
@@ -251,35 +252,45 @@ impl Editor {
251 let text_color = Style::default().fg(Color::Rgb(219, 191, 239)); // lilac
252 let text_color = Style::default().fg(Color::Rgb(219, 191, 239)); // lilac
252 self.surface
253 self.surface
253 .set_string(1, self.size.1 - 1, mode, text_color);
254 .set_string(1, self.size.1 - 1, mode, text_color);
254− if let Some(path) = view.state.path() {
256− .set_string(6, self.size.1 - 1, path.to_string_lossy(), text_color);
261− .draw(self.cache.diff(&self.surface).into_iter());
263− std::mem::swap(&mut self.surface, &mut self.cache);
265 // set cursor shape
256 // set cursor shape
266 match view.state.mode() {
257 match view.state.mode() {
267 Mode::Insert => write!(stdout, "\x1B[6 q"),
258 Mode::Insert => write!(stdout, "\x1B[6 q"),
268 Mode::Normal => write!(stdout, "\x1B[2 q"),
259 Mode::Normal => write!(stdout, "\x1B[2 q"),
269 Mode::Goto => write!(stdout, "\x1B[2 q"),
260 Mode::Goto => write!(stdout, "\x1B[2 q"),
261+ Mode::Command => write!(stdout, "\x1B[2 q"),
272 // render the cursor
264 // render the cursor
273− let pos = view.state.selection().cursor();
265+ let mut pos: Position;
266+ if view.state.mode() == Mode::Command {
267+ pos = Position::new(self.size.0 as usize, 2);
269+ if let Some(path) = view.state.path() {
270+ self.surface.set_string(
273+ path.to_string_lossy(),
275− let pos = view
278+ let cursor = view.state.selection().cursor();
276− .screen_coords_at_pos(&view.state.doc().slice(..), pos)
277− .expect("Cursor is out of bounds.");
279− execute!(
280+ pos = view
280− stdout,
281+ .screen_coords_at_pos(&view.state.doc().slice(..), cursor)
282+ .expect("Cursor is out of bounds.");
283+ pos.col += viewport.x as usize;
284+ pos.row += viewport.y as usize;
289+ .draw(self.cache.diff(&self.surface).into_iter());
291+ std::mem::swap(&mut self.surface, &mut self.cache);
281− cursor::MoveTo(pos.col as u16 + viewport.x, pos.row as u16 + viewport.y,)
293+ execute!(stdout, cursor::MoveTo(pos.col as u16, pos.row as u16));
284 None => (),
295 None => (),
@@ -357,6 +368,16 @@ impl Editor {
357 // TODO: simplistic ensure cursor in view for now
368 // TODO: simplistic ensure cursor in view for now
358 view.ensure_cursor_in_view();
369 view.ensure_cursor_in_view();
375+ // TODO: handle modes and sequences (`gg`)
376+ let keys = vec![event];
377+ if let Some(command) = keymap[&Mode::Goto].get(&keys) {
378+ // TODO: handle count other than 1
360 self.render();
381 self.render();