diff --git a/CHANGELOG.md b/CHANGELOG.md index bf1f80705..c481994ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -149,6 +149,7 @@ Feature #5036: Allow scripted faction leaving Feature #5046: Gamepad thumbstick cursor speed Feature #5051: Provide a separate textures for scrollbars + Feature #5094: Unix like console hotkeys Task #4686: Upgrade media decoder to a more current FFmpeg API Task #4695: Optimize Distant Terrain memory consumption Task #4789: Optimize cell transitions diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 1633b92db..df4bdec5b 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -1,6 +1,7 @@ #include "console.hpp" #include +#include #include #include @@ -224,11 +225,48 @@ namespace MWGui resetReference(); } + bool isWhitespace(char c) + { + return c == ' ' || c == '\t'; + } + void Console::keyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char) { - if( key == MyGUI::KeyCode::Tab) + if(MyGUI::InputManager::getInstance().isControlPressed()) + { + if(key == MyGUI::KeyCode::W) + { + const auto& caption = mCommandLine->getCaption(); + if(caption.empty()) + return; + size_t max = mCommandLine->getTextCursor(); + while(max > 0 && (isWhitespace(caption[max - 1]) || caption[max - 1] == '>')) + max--; + while(max > 0 && !isWhitespace(caption[max - 1]) && caption[max - 1] != '>') + max--; + size_t length = mCommandLine->getTextCursor() - max; + if(length > 0) + { + std::string text = caption; + text.erase(max, length); + mCommandLine->setCaption(text); + mCommandLine->setTextCursor(max); + } + } + else if(key == MyGUI::KeyCode::U) + { + if(mCommandLine->getTextCursor() > 0) + { + std::string text = mCommandLine->getCaption(); + text.erase(0, mCommandLine->getTextCursor()); + mCommandLine->setCaption(text); + mCommandLine->setTextCursor(0); + } + } + } + else if(key == MyGUI::KeyCode::Tab) { std::vector matches; listNames();