@@ -21,6 +21,8 @@ pub struct EditorView {
21 keymap: Keymaps,
21 keymap: Keymaps,
24+const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
24impl EditorView {
26impl EditorView {
25 pub fn new() -> Self {
27 pub fn new() -> Self {
@@ -34,11 +36,10 @@ impl EditorView {
34 surface: &mut Surface,
36 surface: &mut Surface,
35 theme: &Theme,
37 theme: &Theme,
37− const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
38 let area = Rect::new(OFFSET, 0, viewport.width - OFFSET, viewport.height - 2); // - 2 for statusline and prompt
39 let area = Rect::new(OFFSET, 0, viewport.width - OFFSET, viewport.height - 2); // - 2 for statusline and prompt
39 self.render_buffer(view, area, surface, theme);
40 self.render_buffer(view, area, surface, theme);
40 let area = Rect::new(0, viewport.height - 2, viewport.width, 1);
41 let area = Rect::new(0, viewport.height - 2, viewport.width, 1);
41− self.render_statusline(view, viewport, surface, theme);
42+ self.render_statusline(view, area, surface, theme);
44 // TODO: ideally not &mut View but highlights require it because of cursor cache
45 // TODO: ideally not &mut View but highlights require it because of cursor cache
@@ -218,7 +219,7 @@ impl EditorView {
219 // statusline
220 // statusline
220 surface.set_style(
221 surface.set_style(
221− Rect::new(0, viewport.y, viewport.height, 1),
222+ Rect::new(0, viewport.y, viewport.width, 1),
222 theme.get("ui.statusline"),
223 theme.get("ui.statusline"),
224 surface.set_string(1, viewport.y, mode, text_color());
225 surface.set_string(1, viewport.y, mode, text_color());
@@ -306,6 +307,21 @@ impl Component for EditorView {
308 // TODO: drop unwrap
309 // TODO: drop unwrap
312+ fn cursor_position(&self, area: Rect, ctx: &mut Context) -> Option<Position> {
313+ // match view.doc.mode() {
314+ // Mode::Insert => write!(stdout, "\x1B[6 q"),
315+ // mode => write!(stdout, "\x1B[2 q"),
309− // TODO: !!! self.render_cursor(cx.editor.view().unwrap(), None, viewport);
317+ let view = ctx.editor.view().unwrap();
318+ let cursor = view.doc.state.selection().cursor();
321+ .screen_coords_at_pos(&view.doc.text().slice(..), cursor)
322+ .expect("Cursor is out of bounds.");
323+ pos.col += area.x as usize + OFFSET as usize;
324+ pos.row += area.y as usize;