From d611f7f264bae580b3b9bb2ebec67bcbebfb0dfd Mon Sep 17 00:00:00 2001 From: Gabor Pihaj Date: Sat, 6 Jul 2024 16:01:59 +0100 Subject: [PATCH] Create type constructor functions for editor::Action --- helix-term/src/commands/engine/steel.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index 5f0834efe..e18b87e68 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -692,6 +692,12 @@ fn load_configuration_api(engine: &mut Engine, generate_sources: bool) { fn load_editor_api(engine: &mut Engine, generate_sources: bool) { let mut module = BuiltInModule::new("helix/core/editor"); + // Types + module.register_fn("Action::Load", || Action::Load); + module.register_fn("Action::Replace", || Action::Replace); + module.register_fn("Action::HorizontalSplit", || Action::HorizontalSplit); + module.register_fn("Action::VerticalSplit", || Action::VerticalSplit); + // Arity 0 module.register_fn("editor-focus", cx_current_focus); module.register_fn("editor-mode", cx_get_mode); @@ -730,6 +736,22 @@ fn load_editor_api(engine: &mut Engine, generate_sources: bool) { let mut builtin_editor_command_module = "(require-builtin helix/core/editor as helix.)".to_string(); + let mut template_function_type_constructor = |name: &str| { + builtin_editor_command_module.push_str(&format!( + r#" +(provide {}) +(define ({}) + (helix.{})) +"#, + name, name, name + )); + }; + + template_function_type_constructor("Action::Load"); + template_function_type_constructor("Action::Replace"); + template_function_type_constructor("Action::HorizontalSplit"); + template_function_type_constructor("Action::VerticalSplit"); + let mut template_function_arity_0 = |name: &str| { builtin_editor_command_module.push_str(&format!( r#"