map editor scroll

This commit is contained in:
2026-06-23 21:59:40 -05:00
parent cca56a6153
commit 8637c0a52a
2 changed files with 47 additions and 21 deletions
+3 -3
View File
@@ -300,7 +300,7 @@ impl EditorState {
/// board (right-click handling). No-op when the click is off the board. When draw
/// mode is on and the cursor lands on a new cell, stamps the current thing there.
pub(crate) fn set_cursor_at_screen(&mut self, sx: u16, sy: u16) {
let cell = screen_to_board(self.last_board_area, &self.board(), sx, sy);
let cell = screen_to_board(self.last_board_area, &self.board(), sx, sy, self.cursor);
if let Some((bx, by)) = cell {
let target = (bx as i32, by as i32);
let moved = target != self.cursor;
@@ -417,12 +417,12 @@ pub(crate) fn draw_editor(frame: &mut Frame, ed: &mut EditorState, ui: &mut Ui)
}
let inner = block.inner(board_area);
frame.render_widget(block, board_area);
frame.render_widget(BoardWidget::new(&board), inner);
frame.render_widget(BoardWidget::new(&board).with_focus(ed.cursor.0, ed.cursor.1), inner);
// Overlay the cursor during its visible phase (a light-gray solid block).
if ed.blink_on {
let (cx, cy) = (ed.cursor.0 as usize, ed.cursor.1 as usize);
if let Some((sx, sy)) = board_to_screen(inner, &board, cx, cy)
if let Some((sx, sy)) = board_to_screen(inner, &board, cx, cy, (ed.cursor.0, ed.cursor.1))
&& let Some(cell) = frame.buffer_mut().cell_mut((sx, sy))
{
cell.set_char(CURSOR_CHAR)