diff options
| author | tslil <tslil@posteo.de> | 2025-10-31 12:19:33 +0000 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2025-10-31 13:04:41 +0000 |
| commit | 00e03d8fb65119e736dae4db8335e1ac67aac23e (patch) | |
| tree | e468d08301bbdc31820920705f342415100ef799 /rprt-engine/src/selection_functions/function_end.rs | |
| parent | f7c23142e8c73732fe3f75d03dc36e905f28715b (diff) | |
Rework character and end implementations
Diffstat (limited to 'rprt-engine/src/selection_functions/function_end.rs')
| -rw-r--r-- | rprt-engine/src/selection_functions/function_end.rs | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/rprt-engine/src/selection_functions/function_end.rs b/rprt-engine/src/selection_functions/function_end.rs index 47cff79..3f18fd3 100644 --- a/rprt-engine/src/selection_functions/function_end.rs +++ b/rprt-engine/src/selection_functions/function_end.rs @@ -4,14 +4,43 @@ use crate::selection_functions::types::{get_buffer, SFArguments, SFError, SFResu use crate::state::EditorState; selection_function! { - name: end_sequential, + name: end, niladic: |es: &EditorState| { let buf = get_buffer(es, es.current_buffer_id)?; Ok(Selection::Position { buffer_id: es.current_buffer_id, - pos: buf.max_pos() + pos: buf.max_pos(), }) }, + monadic_rank0: |_, buffer_id, pos | Ok(Selection::Position { buffer_id, pos }), + monadic_rank1: |_, buffer_id, int | Ok(Selection::Position { buffer_id, pos: int.end }) +} + +selection_function! { + name: reverse_end, + niladic: |es: &EditorState| { + Ok(Selection::Position { + buffer_id: es.current_buffer_id, + pos: 0, + }) + }, + monadic_rank0: |_, buffer_id, pos | Ok(Selection::Position { buffer_id, pos }), + monadic_rank1: |_, buffer_id, int | Ok(Selection::Position { buffer_id, pos: int.start }) +} + +selection_function! { + name: sequential_end, + niladic: |_| Err(SFError::NoNiladicForm(";$").into()), + monadic_rank0: |_, buffer_id, pos| Ok(Selection::Position { buffer_id, pos }), + monadic_rank1: |es, buffer_id, _| { + let buf = get_buffer(es, buffer_id)?; + Ok(Selection::Position { buffer_id, pos: buf.max_pos() }) + } +} + +selection_function! { + name: sequential_reverse_end, + niladic: |_| Err(SFError::NoNiladicForm(";'$").into()), monadic_rank0: |_, buffer_id, pos| { Ok(Selection::Position { buffer_id, pos }) }, @@ -24,14 +53,15 @@ selection_function! { } selection_function! { - name: end_structural, - niladic: |es: &EditorState| { - let buf = get_buffer(es, es.current_buffer_id)?; + name: reverse_sequential_end, + niladic: |_| Err(SFError::NoNiladicForm("';$").into()), + monadic_rank0: |_, buffer_id, pos| { + Ok(Selection::Position { buffer_id, pos }) + }, + monadic_rank1: |_, buffer_id, interval| { Ok(Selection::Position { - buffer_id: es.current_buffer_id, - pos: buf.max_pos(), + buffer_id, + pos: interval.end, }) - }, - monadic_rank0: |_, buffer_id, pos | Ok(Selection::Position { buffer_id, pos }), - monadic_rank1: |_, buffer_id, int | Ok(Selection::Position { buffer_id, pos: int.end }) + } } |
