1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-10 02:41:32 +00:00

Don't replace tags when dealing with console input

This commit is contained in:
Evil Eye 2023-07-29 17:07:37 +02:00
parent 81deb3796b
commit c47489ef6e

View file

@ -277,7 +277,7 @@ namespace MWGui
{ {
if (key == MyGUI::KeyCode::W) if (key == MyGUI::KeyCode::W)
{ {
const auto& caption = mCommandLine->getCaption(); auto caption = mCommandLine->getOnlyText();
if (caption.empty()) if (caption.empty())
return; return;
size_t max = mCommandLine->getTextCursor(); size_t max = mCommandLine->getTextCursor();
@ -288,9 +288,8 @@ namespace MWGui
size_t length = mCommandLine->getTextCursor() - max; size_t length = mCommandLine->getTextCursor() - max;
if (length > 0) if (length > 0)
{ {
auto text = caption; caption.erase(max, length);
text.erase(max, length); mCommandLine->setOnlyText(caption);
mCommandLine->setCaption(text);
mCommandLine->setTextCursor(max); mCommandLine->setTextCursor(max);
} }
} }
@ -298,9 +297,9 @@ namespace MWGui
{ {
if (mCommandLine->getTextCursor() > 0) if (mCommandLine->getTextCursor() > 0)
{ {
auto text = mCommandLine->getCaption(); auto text = mCommandLine->getOnlyText();
text.erase(0, mCommandLine->getTextCursor()); text.erase(0, mCommandLine->getTextCursor());
mCommandLine->setCaption(text); mCommandLine->setOnlyText(text);
mCommandLine->setTextCursor(0); mCommandLine->setTextCursor(0);
} }
} }
@ -309,9 +308,9 @@ namespace MWGui
{ {
std::vector<std::string> matches; std::vector<std::string> matches;
listNames(); listNames();
std::string oldCaption = mCommandLine->getCaption(); std::string oldCaption = mCommandLine->getOnlyText();
std::string newCaption = complete(mCommandLine->getOnlyText(), matches); std::string newCaption = complete(mCommandLine->getOnlyText(), matches);
mCommandLine->setCaption(newCaption); mCommandLine->setOnlyText(newCaption);
// List candidates if repeatedly pressing tab // List candidates if repeatedly pressing tab
if (oldCaption == newCaption && !matches.empty()) if (oldCaption == newCaption && !matches.empty())
@ -342,7 +341,7 @@ namespace MWGui
if (mCurrent != mCommandHistory.begin()) if (mCurrent != mCommandHistory.begin())
{ {
--mCurrent; --mCurrent;
mCommandLine->setCaption(*mCurrent); mCommandLine->setOnlyText(*mCurrent);
} }
} }
else if (key == MyGUI::KeyCode::ArrowDown) else if (key == MyGUI::KeyCode::ArrowDown)
@ -352,10 +351,10 @@ namespace MWGui
++mCurrent; ++mCurrent;
if (mCurrent != mCommandHistory.end()) if (mCurrent != mCommandHistory.end())
mCommandLine->setCaption(*mCurrent); mCommandLine->setOnlyText(*mCurrent);
else else
// Restore the edit string // Restore the edit string
mCommandLine->setCaption(mEditString); mCommandLine->setOnlyText(mEditString);
} }
} }
} }