summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/command.c b/command.c
index cce923d..c09e0fd 100644
--- a/command.c
+++ b/command.c
@@ -145,21 +145,32 @@ const char *command_to_str(Command c) {
}
void command_execute(Ted *ted, Command c, i64 argument) {
- CommandArgument arg = {
+ const CommandArgument arg = {
.number = argument,
.string = NULL,
};
- command_execute_ex(ted, c, arg, (CommandContext){0});
+ const CommandContext ctx = {0};
+ command_execute_ex(ted, c, &arg, &ctx);
}
-void command_execute_ex(Ted *ted, Command c, CommandArgument full_argument, CommandContext context) {
+void command_execute_string_argument(Ted *ted, Command c, const char *string) {
+ assert(string);
+ const CommandArgument arg = {
+ .number = 0,
+ .string = string,
+ };
+ const CommandContext ctx = {0};
+ command_execute_ex(ted, c, &arg, &ctx);
+}
+
+void command_execute_ex(Ted *ted, Command c, const CommandArgument *full_argument, const CommandContext *context) {
TextBuffer *buffer = ted->active_buffer;
Node *node = ted->active_node;
Settings *settings = ted_active_settings(ted);
if (ted->recording_macro)
macro_add(ted, c, full_argument);
- i64 argument = full_argument.number;
- const char *argument_str = full_argument.string;
+ i64 argument = full_argument->number;
+ const char *argument_str = full_argument->string;
/*
it's important that when we're playing back a macro,
we only execute commands specifically from the macro.
@@ -171,7 +182,7 @@ void command_execute_ex(Ted *ted, Command c, CommandArgument full_argument, Comm
find_next("apple") // (generated by find.c)
if we ran these commands as-is, we'd end up searching for "apple" twice!
*/
- if (ted->executing_macro && !context.from_macro)
+ if (ted->executing_macro && !context->running_macro)
return;
switch (c) {