summaryrefslogtreecommitdiff
path: root/src/interface/Textbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interface/Textbox.cpp')
-rw-r--r--src/interface/Textbox.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index afb9fd3..bdad127 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -206,6 +206,29 @@ void Textbox::pasteIntoSelection()
*iter = '0';
}
}
+
+ int regionWidth = Size.X;
+ if(Appearance.icon)
+ regionWidth -= 13;
+ regionWidth -= Appearance.Margin.Left;
+ regionWidth -= Appearance.Margin.Right;
+
+ if(limit!=std::string::npos)
+ {
+ if(limit-backingText.length() > 0)
+ newText.substr(0, limit-backingText.length());
+ }
+ else if(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);
+
+ if(cIndex > 0)
+ newText = newText.substr(0, cIndex);
+ else
+ newText = "";
+ }
+
backingText.insert(cursor, newText);
cursor = cursor+newText.length();
ClearSelection();