summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp12
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/commands.cpp12
-rw-r--r--src/commands.h5
-rw-r--r--src/gui/popups/popupmenu.cpp4
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h11
-rw-r--r--src/input/inputmanager.cpp16
-rw-r--r--src/input/inputmanager.h4
9 files changed, 47 insertions, 19 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index dbf3ab3d4..779d09dce 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -574,4 +574,16 @@ impHandler(execute)
return true;
}
+impHandler(enableHighlight)
+{
+ if (event.tab)
+ {
+ event.tab->setAllowHighlight(true);
+ if (chatWindow)
+ chatWindow->saveState();
+ return true;
+ }
+ return false;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 0a803e41c..d95050520 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -59,6 +59,7 @@ namespace Actions
decHandler(url);
decHandler(openUrl);
decHandler(execute);
+ decHandler(enableHighlight);
} // namespace Actions
#undef decHandler
diff --git a/src/commands.cpp b/src/commands.cpp
index 1f474bd3f..6c0abcd38 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -106,18 +106,6 @@ impHandler(hack)
return true;
}
-impHandler(enableHighlight)
-{
- if (event.tab)
- {
- event.tab->setAllowHighlight(true);
- if (chatWindow)
- chatWindow->saveState();
- return true;
- }
- return false;
-}
-
impHandler(disableHighlight)
{
if (event.tab)
diff --git a/src/commands.h b/src/commands.h
index 3875d4523..5cfbd55a1 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -52,7 +52,6 @@ struct CommandInfo final
namespace Commands
{
decHandler(hack);
- decHandler(enableHighlight);
decHandler(disableHighlight);
decHandler(dontRemoveName);
decHandler(removeName);
@@ -73,8 +72,7 @@ namespace Commands
enum
{
- COMMAND_ENABLEHIGHLIGHT = 0,
- COMMAND_DISABLEHIGHLIGHT,
+ COMMAND_DISABLEHIGHLIGHT = 0,
COMMAND_DONTREMOVENAME,
COMMAND_REMOVENAME,
COMMAND_DISABLEAWAY,
@@ -94,7 +92,6 @@ enum
static const CommandInfo commands[] =
{
- {"enablehighlight", &Commands::enableHighlight, -1, false},
{"disablehighlight", &Commands::disableHighlight, -1, false},
{"", &Commands::dontRemoveName, -1, false},
{"", &Commands::removeName, -1, false},
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 88316535c..69a4e096b 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1455,8 +1455,8 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "enable highlight" && mTab)
{
- if (commandHandler)
- commandHandler->invokeCommand(COMMAND_ENABLEHIGHLIGHT, mTab);
+ inputManager.executeChatCommand(InputAction::ENABLE_HIGHLIGHT,
+ std::string(), mTab);
}
else if (link == "disable highlight" && mTab)
{
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 48508b0fb..09f753117 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -408,6 +408,7 @@ namespace InputAction
OPEN_URL,
EXECUTE,
TEST_SDL_FONT,
+ ENABLE_HIGHLIGHT,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index e2d123b73..4a7f76c6b 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -3449,7 +3449,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
#else
"",
#endif
- false}
+ false},
+ {"keyEnableHightlight",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::enableHighlight,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "enablehighlight",
+ true}
};
#endif // INPUT_INPUTACTIONMAP_H
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 099e2b7fb..3a7f1be9c 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -752,6 +752,22 @@ bool InputManager::executeChatCommand(const std::string &cmd,
return false;
}
+bool InputManager::executeChatCommand(const int keyNum,
+ const std::string &args,
+ ChatTab *const tab)
+{
+ if (keyNum < 0 || keyNum >= InputAction::TOTAL)
+ return false;
+ ActionFuncPtr func = *(inputActionData[keyNum].action);
+ if (func)
+ {
+ InputEvent evt(args, tab, mMask);
+ func(evt);
+ return true;
+ }
+ return false;
+}
+
void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
KeyToIdMap &idMap,
KeyTimeMap &keyTimeMap,
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index 6bb4e65a2..b91af8882 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -123,6 +123,10 @@ class InputManager final
const std::string &args,
ChatTab *const tab);
+ bool executeChatCommand(const int keyNum,
+ const std::string &args,
+ ChatTab *const tab);
+
void addChatCommands(std::list<std::string> &arr);
protected: