aboutsummaryrefslogtreecommitdiff
path: root/rprt-engine/src/selection_functions/function_end.rs
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2025-10-31 11:29:08 +0000
committertslil <tslil@posteo.de>2025-10-31 11:55:36 +0000
commitf7c23142e8c73732fe3f75d03dc36e905f28715b (patch)
tree7dc1e0c6919cc9469f013b6015d4dc9356c7a9c9 /rprt-engine/src/selection_functions/function_end.rs
parentc16e21d82e3b398c572e48ccbf4ff896086425ef (diff)
Refactor selection functions into a module, one function per file
Diffstat (limited to 'rprt-engine/src/selection_functions/function_end.rs')
-rw-r--r--rprt-engine/src/selection_functions/function_end.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/rprt-engine/src/selection_functions/function_end.rs b/rprt-engine/src/selection_functions/function_end.rs
new file mode 100644
index 0000000..47cff79
--- /dev/null
+++ b/rprt-engine/src/selection_functions/function_end.rs
@@ -0,0 +1,37 @@
+use crate::selection::Selection;
+use crate::selection_function;
+use crate::selection_functions::types::{get_buffer, SFArguments, SFError, SFResult};
+use crate::state::EditorState;
+
+selection_function! {
+ name: end_sequential,
+ 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()
+ })
+ },
+ monadic_rank0: |_, buffer_id, pos| {
+ Ok(Selection::Position { buffer_id, pos })
+ },
+ monadic_rank1: |_, buffer_id, interval| {
+ Ok(Selection::Position {
+ buffer_id,
+ pos: interval.end,
+ })
+ }
+}
+
+selection_function! {
+ name: end_structural,
+ 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(),
+ })
+ },
+ monadic_rank0: |_, buffer_id, pos | Ok(Selection::Position { buffer_id, pos }),
+ monadic_rank1: |_, buffer_id, int | Ok(Selection::Position { buffer_id, pos: int.end })
+}