29 lines
650 B
C++
29 lines
650 B
C++
#include "Command.h"
|
|
#include <string.h>
|
|
|
|
static const struct
|
|
{
|
|
const char * name;
|
|
uint32_t flags;
|
|
} Commands[] = {
|
|
{"nop", 0u},
|
|
{"forward-up-to-char", Command::FOLLOWING_CHAR},
|
|
{"forward-on-to-char", Command::FOLLOWING_CHAR},
|
|
{"back-up-to-char", Command::FOLLOWING_CHAR},
|
|
{"back-on-to-char", Command::FOLLOWING_CHAR},
|
|
{"delete", Command::RANGE},
|
|
{"delete-line", 0u},
|
|
};
|
|
|
|
uint32_t Command::find_command_by_name(const char * name)
|
|
{
|
|
for (uint32_t i = 0u; i < COMMAND_COUNT; i++)
|
|
{
|
|
if (strcmp(Commands[i].name, name) == 0u)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return COMMAND_COUNT;
|
|
}
|