diff --git a/internal/editor/model.go b/internal/editor/model.go index 8eb7bed..63be138 100644 --- a/internal/editor/model.go +++ b/internal/editor/model.go @@ -210,6 +210,35 @@ func (m *Model) processInsertKey(key string) { } m.SetCursorX(x + len(tabs)) + case "up": + if y > 0 { + m.SetCursorY(y - 1) + m.ClampCursorX() + } + + case "down": + if y+1 < m.LineCount() { + m.SetCursorY(y + 1) + m.ClampCursorX() + } + + case "left": + if x > 0 { + m.SetCursorX(x - 1) + } else if y > 0 { + prevLine := m.Line(y - 1) + m.SetCursorX(len(prevLine)) + m.SetCursorY(y - 1) + } + + case "right": + if x < len(l) { + m.SetCursorX(x + 1) + } else if y+1 < m.LineCount() { + m.SetCursorX(0) + m.SetCursorY(y + 1) + } + // Regular character default: if x < len(l) {