summaryrefslogtreecommitdiff
path: root/macro.c
diff options
context:
space:
mode:
Diffstat (limited to 'macro.c')
-rw-r--r--macro.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/macro.c b/macro.c
index 14ec016..19ebcd8 100644
--- a/macro.c
+++ b/macro.c
@@ -27,15 +27,16 @@ void macro_stop_recording(Ted *ted) {
ted->recording_macro = NULL;
}
-void macro_add(Ted *ted, Command command, CommandArgument argument) {
+void macro_add(Ted *ted, Command command, const CommandArgument *argument) {
if (!ted->recording_macro) return;
if (command == CMD_MACRO_EXECUTE || command == CMD_MACRO_RECORD || command == CMD_MACRO_STOP)
return;
- if (argument.string)
- argument.string = str_dup(argument.string);
+ CommandArgument arg = *argument;
+ if (arg.string)
+ arg.string = str_dup(arg.string);
Action action = {
.command = command,
- .argument = argument
+ .argument = arg
};
arr_add(ted->recording_macro->actions, action);
}
@@ -49,10 +50,9 @@ void macro_execute(Ted *ted, u32 index) {
}
ted->executing_macro = true;
- CommandContext context = {0};
- context.from_macro = true;
+ const CommandContext context = {.running_macro = true};
arr_foreach_ptr(macro->actions, Action, act) {
- command_execute_ex(ted, act->command, act->argument, context);
+ command_execute_ex(ted, act->command, &act->argument, &context);
}
ted->executing_macro = false;
}