diff options
| author | Albert Cervin <albert@acervin.com> | 2023-01-23 23:56:38 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-01-23 23:56:38 +0100 |
| commit | 9a2b138a03e27d0f04101fe6ae3977d79518c513 (patch) | |
| tree | 113fe14c15e93872e0fe8b6d7a4e56ed3398b375 /src/command.c | |
| parent | 9eda570311ffd292d333f7687074403ff46cc838 (diff) | |
| download | dged-9a2b138a03e27d0f04101fe6ae3977d79518c513.tar.gz dged-9a2b138a03e27d0f04101fe6ae3977d79518c513.tar.xz dged-9a2b138a03e27d0f04101fe6ae3977d79518c513.zip | |
Add more tests and documentation
Both doxygen and man page
Diffstat (limited to 'src/command.c')
| -rw-r--r-- | src/command.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c index 93ede01..f8add1b 100644 --- a/src/command.c +++ b/src/command.c @@ -28,14 +28,14 @@ uint32_t hash_command_name(const char *name) { return hash; } -uint32_t register_command(struct commands *commands, struct command *command) { +uint32_t register_command(struct commands *commands, struct command command) { if (commands->ncommands == commands->capacity) { commands->capacity *= 2; commands->commands = realloc( commands->commands, sizeof(struct hashed_command) * commands->capacity); } - uint32_t hash = hash_command_name(command->name); + uint32_t hash = hash_command_name(command.name); commands->commands[commands->ncommands] = (struct hashed_command){.command = command, .hash = hash}; @@ -46,7 +46,7 @@ uint32_t register_command(struct commands *commands, struct command *command) { void register_commands(struct commands *command_list, struct command *commands, uint32_t ncommands) { for (uint32_t ci = 0; ci < ncommands; ++ci) { - register_command(command_list, &commands[ci]); + register_command(command_list, commands[ci]); } } @@ -60,7 +60,7 @@ struct command *lookup_command_by_hash(struct commands *commands, uint32_t hash) { for (uint32_t ci = 0; ci < commands->ncommands; ++ci) { if (commands->commands[ci].hash == hash) { - return commands->commands[ci].command; + return &commands->commands[ci].command; } } @@ -88,7 +88,7 @@ int32_t find_file(struct command_ctx ctx, int argc, const char *argv[]) { pth = argv[0]; ctx.active_window->buffer = buffers_add(ctx.buffers, buffer_from_file((char *)pth)); - minibuffer_echo_timeout(4, "buffer %s loaded", + minibuffer_echo_timeout(4, "buffer \"%s\" loaded", ctx.active_window->buffer->name); } else { minibuffer_prompt(ctx, "find file: "); |
