Skip to content

Commit

Permalink
proper ctrl+backspace support
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed May 9, 2017
1 parent abf6050 commit 0f40db4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/gui/interface/Textbox.cpp
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down

0 comments on commit 0f40db4

Please sign in to comment.