diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-10-01 12:03:03 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-10-01 12:03:03 (GMT) |
| commit | c0c5717efec4d2436869e0643ab00431b35893a0 (patch) | |
| tree | 4a5a52a353e899ec6398caba7bb07a418fec97cc /src/interface/Textbox.cpp | |
| parent | 134a59609d5ae9b369683cadd603674fb19a94f0 (diff) | |
| download | powder-c0c5717efec4d2436869e0643ab00431b35893a0.zip powder-c0c5717efec4d2436869e0643ab00431b35893a0.tar.gz | |
Limit save description length
Diffstat (limited to 'src/interface/Textbox.cpp')
| -rw-r--r-- | src/interface/Textbox.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index bdad127..7b79974 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -215,10 +215,12 @@ void Textbox::pasteIntoSelection() if(limit!=std::string::npos) { - if(limit-backingText.length() > 0) - newText.substr(0, limit-backingText.length()); + if(limit-backingText.length() >= 0) + newText = newText.substr(0, limit-backingText.length()); + else + newText = ""; } - else if(Graphics::textwidth((char*)std::string(backingText+newText).c_str()) > regionWidth) + else if(!multiline && Graphics::textwidth((char*)std::string(backingText+newText).c_str()) > regionWidth) { int pLimit = regionWidth - Graphics::textwidth((char*)backingText.c_str()); int cIndex = Graphics::CharIndexAtPosition((char *)newText.c_str(), pLimit, 0); @@ -249,7 +251,10 @@ void Textbox::pasteIntoSelection() if(multiline) updateMultiline(); updateSelection(); - TextPosition(text); + if(multiline) + TextPosition(textLines); + else + TextPosition(text); if(cursor) { @@ -457,7 +462,10 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool if(multiline) updateMultiline(); updateSelection(); - TextPosition(text); + if(multiline) + TextPosition(textLines); + else + TextPosition(text); if(cursor) { |
