diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index a427d27..7f2beaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,17 +141,24 @@ fn edit(file: &OsStr) -> Result<(), Box<dyn Error>> { Key::Left => { state.cursor_col = std::cmp::min(state.cursor_col, state.line_cols); if state.cursor_col == 0 { - continue; + state.cursor_row -= 1; + let _ = state.repaint_line_full(); + state.cursor_col = state.line_cols; + state.line_offset = state.buf.line(state.cursor_row).len(); + let _ = write!(stdout(), "\x1b[{}G", state.cursor_col+1); + } else { + state.cursor_col -= 1; + let _ = state.repaint_line_full(); } - state.cursor_col -= 1; - let _ = state.repaint_line_full(); let _ = stdout().flush(); } Key::Right => { if state.cursor_col >= state.line_cols { - continue; + state.cursor_row += 1; + state.cursor_col = 0; + } else { + state.cursor_col += 1; } - state.cursor_col += 1; let _ = state.repaint_line_full(); let _ = stdout().flush(); } |
