summaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-12-15 18:17:29 (GMT)
committer jacob1 <jfu614@gmail.com>2012-12-15 18:17:29 (GMT)
commita172a9689783bed4d1fdfa8887f9f4be881b7076 (patch)
tree24d71ba0f0affbd5b8e4f5990486170febd918f5 /src/interface
parente0f8456531bcd77d0d6a93ccd5815c43ca0d548c (diff)
downloadpowder-a172a9689783bed4d1fdfa8887f9f4be881b7076.zip
powder-a172a9689783bed4d1fdfa8887f9f4be881b7076.tar.gz
make sure long amounts of text without spaces doesn't run over out of bounds
A character may be deleted to insert a new line, but when copying something like a url, the missing one is copied back in. I couldn't get inserting a newline between letters to work right
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/Label.cpp42
-rw-r--r--src/interface/Textbox.cpp2
2 files changed, 23 insertions, 21 deletions
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp
index 80387ce..5cd089c 100644
--- a/src/interface/Label.cpp
+++ b/src/interface/Label.cpp
@@ -96,23 +96,30 @@ void Label::updateMultiline()
lines++;
break;
default:
- if(pc == ' ')
- {
- wordStart = &rawText[charIndex-2];
- }
wordWidth += Graphics::CharWidth(c);
- if(lineWidth + wordWidth >= Size.X-(Appearance.Margin.Left+Appearance.Margin.Right))
- {
- if(wordStart && *wordStart)
- *wordStart = '\n';
- else if(!wordStart)
- rawText[charIndex-1] = '\n';
- lineWidth = wordWidth;
- wordWidth = 0;
- lines++;
- }
break;
}
+ if(pc == ' ')
+ {
+ wordStart = &rawText[charIndex-2];
+ }
+ if ((c != ' ' || pc == ' ') && lineWidth + wordWidth >= Size.X-(Appearance.Margin.Left+Appearance.Margin.Right))
+ {
+ if(wordStart && *wordStart)
+ {
+ *wordStart = '\n';
+ if (lineWidth != 0)
+ lineWidth = wordWidth;
+ }
+ else if(!wordStart)
+ {
+ rawText[charIndex-1] = '\n';
+ lineWidth = 0;
+ }
+ wordWidth = 0;
+ wordStart = 0;
+ lines++;
+ }
pc = c;
}
if(autoHeight)
@@ -201,12 +208,7 @@ void Label::OnMouseClick(int x, int y, unsigned button)
void Label::copySelection()
{
- std::string currentText;
-
- if(multiline)
- currentText = textLines;
- else
- currentText = text;
+ std::string currentText = text;
if(selectionIndex1 > selectionIndex0) {
clipboard_push_text((char*)currentText.substr(selectionIndex0, selectionIndex1-selectionIndex0).c_str());
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 383f07b..c82b6e4 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -447,7 +447,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
backingText.erase(backingText.begin());
}
if(cursor > backingText.length())
- cursor = backingText.length();
+ cursor = backingText.length();
if(changed)
{
if(masked)