add Command module
This commit is contained in:
parent
89687100f3
commit
92a7dbe922
26
src/core/Command.cc
Normal file
26
src/core/Command.cc
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "Command.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const char * name;
|
||||||
|
uint32_t flags;
|
||||||
|
} Commands[] = {
|
||||||
|
{"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-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;
|
||||||
|
}
|
27
src/core/Command.h
Normal file
27
src/core/Command.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef COMMAND_H
|
||||||
|
#define COMMAND_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum : uint32_t
|
||||||
|
{
|
||||||
|
FOLLOWING_CHAR = 0x1u,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum : uint32_t
|
||||||
|
{
|
||||||
|
FORWARD_UP_TO_CHAR,
|
||||||
|
FORWARD_ON_TO_CHAR,
|
||||||
|
BACK_UP_TO_CHAR,
|
||||||
|
BACK_ON_TO_CHAR,
|
||||||
|
DELETE_LINE,
|
||||||
|
COMMAND_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t find_command_by_name(const char * name);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user