@@ -21,6 +21,8 @@ pub struct EditorView {
2121 keymap: Keymaps,
2222}
2323
24+const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
25+
2426impl EditorView {
2527 pub fn new() -> Self {
2628 Self {
@@ -34,11 +36,10 @@ impl EditorView {
3436 surface: &mut Surface,
3537 theme: &Theme,
3638 ) {
37− const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
3839 let area = Rect::new(OFFSET, 0, viewport.width - OFFSET, viewport.height - 2); // - 2 for statusline and prompt
3940 self.render_buffer(view, area, surface, theme);
4041 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);
4243 }
4344
4445 // TODO: ideally not &mut View but highlights require it because of cursor cache
@@ -218,7 +219,7 @@ impl EditorView {
218219 };
219220 // statusline
220221 surface.set_style(
221− Rect::new(0, viewport.y, viewport.height, 1),
222+ Rect::new(0, viewport.y, viewport.width, 1),
222223 theme.get("ui.statusline"),
223224 );
224225 surface.set_string(1, viewport.y, mode, text_color());
@@ -306,6 +307,21 @@ impl Component for EditorView {
306307 }
307308
308309 // TODO: drop unwrap
309− // TODO: !!! self.render_cursor(cx.editor.view().unwrap(), None, viewport);
310+ }
311+
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"),
316+ // };
317+ let view = ctx.editor.view().unwrap();
318+ let cursor = view.doc.state.selection().cursor();
319+
320+ let mut pos = view
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;
325+ Some(pos)
310326 }
311327}