mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Merge pull request #2415 from Assumeru/unix-console
Unix console hotkeys
This commit is contained in:
commit
1a2f51ef6f
2 changed files with 40 additions and 1 deletions
|
@ -149,6 +149,7 @@
|
||||||
Feature #5036: Allow scripted faction leaving
|
Feature #5036: Allow scripted faction leaving
|
||||||
Feature #5046: Gamepad thumbstick cursor speed
|
Feature #5046: Gamepad thumbstick cursor speed
|
||||||
Feature #5051: Provide a separate textures for scrollbars
|
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 #4686: Upgrade media decoder to a more current FFmpeg API
|
||||||
Task #4695: Optimize Distant Terrain memory consumption
|
Task #4695: Optimize Distant Terrain memory consumption
|
||||||
Task #4789: Optimize cell transitions
|
Task #4789: Optimize cell transitions
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
#include <MyGUI_EditBox.h>
|
#include <MyGUI_EditBox.h>
|
||||||
|
#include <MyGUI_InputManager.h>
|
||||||
#include <MyGUI_LayerManager.h>
|
#include <MyGUI_LayerManager.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
@ -224,11 +225,48 @@ namespace MWGui
|
||||||
resetReference();
|
resetReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isWhitespace(char c)
|
||||||
|
{
|
||||||
|
return c == ' ' || c == '\t';
|
||||||
|
}
|
||||||
|
|
||||||
void Console::keyPress(MyGUI::Widget* _sender,
|
void Console::keyPress(MyGUI::Widget* _sender,
|
||||||
MyGUI::KeyCode key,
|
MyGUI::KeyCode key,
|
||||||
MyGUI::Char _char)
|
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<std::string> matches;
|
std::vector<std::string> matches;
|
||||||
listNames();
|
listNames();
|
||||||
|
|
Loading…
Reference in a new issue