Permalink
Browse files

proper ctrl+backspace support

  • Loading branch information...
jacob1 committed May 9, 2017
1 parent abf6050 commit 0f40db4ef9cc3d4472c3063e0a4e4cf76b2f3684
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/gui/interface/Textbox.cpp
@@ -358,7 +358,12 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
else if (backingText.length() && cursor < (int)backingText.length())
{
if (ctrl)
backingText.erase(cursor, backingText.length()-cursor);
{
size_t stopChar;
stopChar = backingText.find_first_not_of(" .,!?\n", cursor);
stopChar = backingText.find_first_of(" .,!?\n", stopChar);
backingText.erase(cursor, stopChar-cursor);
}
else
backingText.erase(cursor, 1);
changed = true;
@@ -380,8 +385,14 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
if (ctrl)
{
backingText.erase(0, cursor);
cursor = 0;
size_t stopChar;
stopChar = backingText.substr(0, cursor).find_last_not_of(" .,!?\n");
if (stopChar == backingText.npos)
stopChar = -1;
else
stopChar = backingText.substr(0, stopChar).find_last_of(" .,!?\n");
backingText.erase(stopChar+1, cursor-(stopChar+1));
cursor = stopChar+1;
}
else
{

0 comments on commit 0f40db4

Please sign in to comment.