Add DefaultCommandMap module to define the default command map.
This commit is contained in:
parent
4df3f620f1
commit
25806993f9
@ -13,8 +13,12 @@ public:
|
|||||||
FORWARD_ON_TO_CHAR,
|
FORWARD_ON_TO_CHAR,
|
||||||
BACK_UP_TO_CHAR,
|
BACK_UP_TO_CHAR,
|
||||||
BACK_ON_TO_CHAR,
|
BACK_ON_TO_CHAR,
|
||||||
DELETE,
|
DELETE_MOTION,
|
||||||
DELETE_LINE,
|
DELETE_LINE,
|
||||||
|
DELETE_CHAR,
|
||||||
|
DELETE_CHAR_BACK,
|
||||||
|
CHANGE_MOTION,
|
||||||
|
CHANGE_LINE,
|
||||||
COMMAND_COUNT,
|
COMMAND_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
26
src/core/DefaultCommandMap.cc
Normal file
26
src/core/DefaultCommandMap.cc
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "DefaultCommandMap.h"
|
||||||
|
|
||||||
|
std::shared_ptr<CommandMap> g_DefaultCommandMap;
|
||||||
|
|
||||||
|
void DefaultCommandMap::build()
|
||||||
|
{
|
||||||
|
g_DefaultCommandMap = std::make_shared<CommandMap>();
|
||||||
|
CommandMap * dcm = &*g_DefaultCommandMap;
|
||||||
|
auto motion_map = std::make_shared<CommandMap>();
|
||||||
|
|
||||||
|
motion_map->add("t", Command::Motion::FORWARD_UP_TO_CHAR, nullptr, true);
|
||||||
|
motion_map->add("f", Command::Motion::FORWARD_ON_TO_CHAR, nullptr, true);
|
||||||
|
motion_map->add("T", Command::Motion::BACK_UP_TO_CHAR, nullptr, true);
|
||||||
|
motion_map->add("F", Command::Motion::BACK_ON_TO_CHAR, nullptr, true);
|
||||||
|
|
||||||
|
dcm->add("t", Command::FORWARD_UP_TO_CHAR, nullptr, true);
|
||||||
|
dcm->add("f", Command::FORWARD_ON_TO_CHAR, nullptr, true);
|
||||||
|
dcm->add("T", Command::BACK_UP_TO_CHAR, nullptr, true);
|
||||||
|
dcm->add("F", Command::BACK_ON_TO_CHAR, nullptr, true);
|
||||||
|
dcm->add("d", Command::DELETE_MOTION, motion_map, false);
|
||||||
|
dcm->add("dd", Command::DELETE_LINE, nullptr, false);
|
||||||
|
dcm->add("x", Command::DELETE_CHAR, nullptr, false);
|
||||||
|
dcm->add("X", Command::DELETE_CHAR_BACK, nullptr, false);
|
||||||
|
dcm->add("c", Command::CHANGE_MOTION, motion_map, false);
|
||||||
|
dcm->add("cc", Command::CHANGE_LINE, nullptr, false);
|
||||||
|
}
|
19
src/core/DefaultCommandMap.h
Normal file
19
src/core/DefaultCommandMap.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef DEFAULTCOMMANDMAP_H
|
||||||
|
#define DEFAULTCOMMANDMAP_H
|
||||||
|
|
||||||
|
#include "CommandMap.h"
|
||||||
|
|
||||||
|
extern std::shared_ptr<CommandMap> g_DefaultCommandMap;
|
||||||
|
|
||||||
|
class DefaultCommandMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void build();
|
||||||
|
|
||||||
|
static std::shared_ptr<CommandMap> get()
|
||||||
|
{
|
||||||
|
return g_DefaultCommandMap;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -3,6 +3,7 @@
|
|||||||
#include "Runtime.h"
|
#include "Runtime.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
#include "DefaultCommandMap.h"
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
@ -12,6 +13,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Runtime::init(System::executable_path().c_str(), APPNAME);
|
Runtime::init(System::executable_path().c_str(), APPNAME);
|
||||||
|
DefaultCommandMap::build();
|
||||||
|
|
||||||
const char * filename = nullptr;
|
const char * filename = nullptr;
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user