本文整理汇总了C++中CKeySet::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ CKeySet::Parse方法的具体用法?C++ CKeySet::Parse怎么用?C++ CKeySet::Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKeySet
的用法示例。
在下文中一共展示了CKeySet::Parse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKeyBindings
int LuaUnsyncedRead::GetKeyBindings(lua_State* L)
{
const int args = lua_gettop(L); // number of arguments
if ((args != 1) || !lua_isstring(L, 1)) {
luaL_error(L, "Incorrect arguments to GetKeyBindings(\"keyset\")");
}
const string keysetStr = lua_tostring(L, 1);
CKeySet ks;
if (!ks.Parse(keysetStr)) {
return 0;
}
const CKeyBindings::ActionList& actions = keyBindings->GetActionList(ks);
lua_newtable(L);
for (int i = 0; i < (int)actions.size(); i++) {
const Action& action = actions[i];
lua_pushnumber(L, i + 1);
lua_newtable(L);
lua_pushstring(L, action.command.c_str());
lua_pushstring(L, action.extra.c_str());
lua_rawset(L, -3);
lua_rawset(L, -3);
}
lua_pushstring(L, "n");
lua_pushnumber(L, actions.size());
lua_rawset(L, -3);
return 1;
}
示例2: AddKeySymbol
bool CKeyBindings::AddKeySymbol(const string& keysym, const string& code)
{
CKeySet ks;
if (!ks.Parse(code)) {
LOG_L(L_WARNING, "AddKeySymbol: could not parse key: %s", code.c_str());
return false;
}
if (!keyCodes->AddKeySymbol(keysym, ks.Key())) {
LOG_L(L_WARNING, "AddKeySymbol: could not add: %s", keysym.c_str());
return false;
}
return true;
}
示例3: AddKeySymbol
bool CKeyBindings::AddKeySymbol(const string& keysym, const string& code)
{
CKeySet ks;
if (!ks.Parse(code)) {
logOutput.Print("AddKeySymbol: could not parse key: %s\n", code.c_str());
return false;
}
if (!keyCodes->AddKeySymbol(keysym, ks.Key())) {
logOutput.Print("AddKeySymbol: could not add: %s\n", keysym.c_str());
return false;
}
return true;
}
示例4: AddNamedKeySet
bool CKeyBindings::AddNamedKeySet(const string& name, const string& keystr)
{
CKeySet ks;
if (!ks.Parse(keystr)) {
printf("AddNamedKeySet: could not parse keyset: %s\n", keystr.c_str());
return false;
}
if ((ks.Key() < 0) || !CKeyCodes::IsValidLabel(name)) {
printf("AddNamedKeySet: bad custom keyset name: %s\n", name.c_str());
return false;
}
namedKeySets[name] = ks;
}
示例5: SetFakeMetaKey
bool CKeyBindings::SetFakeMetaKey(const string& keystr)
{
CKeySet ks;
if (StringToLower(keystr) == "none") {
fakeMetaKey = -1;
return true;
}
if (!ks.Parse(keystr)) {
LOG_L(L_WARNING, "SetFakeMetaKey: could not parse key: %s", keystr.c_str());
return false;
}
fakeMetaKey = ks.Key();
return true;
}
示例6: SetFakeMetaKey
bool CKeyBindings::SetFakeMetaKey(const string& keystr)
{
CKeySet ks;
if (StringToLower(keystr) == "none") {
fakeMetaKey = -1;
return true;
}
if (!ks.Parse(keystr)) {
logOutput.Print("SetFakeMetaKey: could not parse key: %s\n", keystr.c_str());
return false;
}
fakeMetaKey = ks.Key();
return true;
}
示例7: ParseKeySet
bool CKeyBindings::ParseKeySet(const string& keystr, CKeySet& ks) const
{
if (keystr[0] != NamedKeySetChar) {
return ks.Parse(keystr);
}
else {
const string keysetName = keystr.substr(1);
NamedKeySetMap::const_iterator it = namedKeySets.find(keysetName);
if (it != namedKeySets.end()) {
ks = it->second;
} else {
return false;
}
}
return true;
}
示例8: UnBindKeyset
bool CKeyBindings::UnBindKeyset(const std::string& keystr)
{
CKeySet ks;
if (!ks.Parse(keystr)) {
LOG_L(L_WARNING, "UnBindKeyset: could not parse key: %s", keystr.c_str());
return false;
}
bool success = false;
KeyMap::iterator it = bindings.find(ks);
if (it != bindings.end()) {
bindings.erase(it);
success = true;
}
return success;
}
示例9: UnBind
bool CKeyBindings::UnBind(const std::string& keystr, const std::string& command)
{
CKeySet ks;
if (!ks.Parse(keystr)) {
LOG_L(L_WARNING, "UnBind: could not parse key: %s", keystr.c_str());
return false;
}
bool success = false;
KeyMap::iterator it = bindings.find(ks);
if (it != bindings.end()) {
ActionList& al = it->second;
success = RemoveCommandFromList(al, command);
if (al.empty()) {
bindings.erase(it);
}
}
return success;
}
示例10: ParseSingleChain
static bool ParseSingleChain(const std::string& keystr, CKeyChain* kc)
{
kc->clear();
CKeySet ks;
// note: this will fail if keystr contains spaces
std::stringstream ss(keystr);
while (ss.good()) {
char kcstr[256];
ss.getline(kcstr, 256, ',');
std::string kstr(kcstr);
if (!ks.Parse(kstr, false))
return false;
kc->emplace_back(ks);
}
return true;
}