diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-03-27 07:09:17 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-03-27 07:09:17 -0700 |
| commit | 3f3d62639b3160bd9ea7dc2c5ec6a53b3e9e11bc (patch) | |
| tree | 969b36fa8e1be549dc05ace71b1c6ff2dfbc7971 | |
| parent | a15c23a885a8ff53e9bcd20c96b8a3813a08e19e (diff) | |
implement the 0 and $ commands
Force-Push: yes Change-Id: I0a056ed4e021124f05e56c893d47c3b3dc5f3cd7
| -rw-r--r-- | src/main.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 5929295..f21096f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -245,6 +245,48 @@ impl Ivy { }).await?; }, + '0' => { + self.handle_movement(async |ivy: &mut Ivy| { + let window = ivy.window.write().await; + + let mut column = window.cursor_column.write().await; + *column = 0; + + /* For this one, the neutral column changes regardless of + * whether the column does. + */ + *window.cursor_neutral_column.write().await = *column; + + Ok(()) + }).await?; + }, + + '$' => { + self.handle_movement(async |ivy: &mut Ivy| { + let buffer = ivy.buffer.read().await; + let window = ivy.window.write().await; + + let row = *window.cursor_row.read().await; + if let Some(span) = buffer.line_span(row).await { + let width = span.end - span.start; + + let mut column = window.cursor_column.write().await; + if width > 0 { + *column = width - 1; + } else { + *column = 0; + } + + /* For this one, the neutral column changes regardless of + * whether the column does. + */ + *window.cursor_neutral_column.write().await = *column; + } + + Ok(()) + }).await?; + }, + _ => { return Ok(()); }, |