فهرست منبع

Text editor tweaks

Ivan Safrin 13 سال پیش
والد
کامیت
edd323094b
2فایلهای تغییر یافته به همراه12 افزوده شده و 8 حذف شده
  1. 1 1
      IDE/Contents/Source/PolycodeTextEditor.cpp
  2. 11 7
      Modules/Contents/UI/Source/PolyUITextInput.cpp

+ 1 - 1
IDE/Contents/Source/PolycodeTextEditor.cpp

@@ -10,7 +10,7 @@
  
  
  The above copyright notice and this permission notice shall be included in
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  all copies or substantial portions of the Software.
- 
+	
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

+ 11 - 7
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -155,9 +155,8 @@ void UITextInput::setSelection(int lineStart, int lineEnd, int colStart, int col
 	} else {
 	} else {
 		selectionCaretPosition = colStart;
 		selectionCaretPosition = colStart;
 	}
 	}
-
 	
 	
-//	Logger::log("SET lineStart:%d lineEnd:%d colStart:%d colEnd:%d\n", lineStart, lineEnd, colStart, colEnd);
+	//printf("SET lineStart:%d lineEnd:%d colStart:%d colEnd:%d\n", lineStart, lineEnd, colStart, colEnd);
 	
 	
 	if(lineStart > lineEnd) {
 	if(lineStart > lineEnd) {
 		int tmp = lineStart;
 		int tmp = lineStart;
@@ -177,14 +176,17 @@ void UITextInput::setSelection(int lineStart, int lineEnd, int colStart, int col
 	
 	
 	clearSelection();
 	clearSelection();
 	
 	
+
+	
 	if(lineStart > lines.size()-1)
 	if(lineStart > lines.size()-1)
 		return;	
 		return;	
-	
+
 	ScreenLabel *topLine = lines[lineStart];	
 	ScreenLabel *topLine = lines[lineStart];	
 	
 	
-	if(colStart+1 > topLine->getText().length())
-		return;
-	
+	if(colStart+1 > topLine->getText().length()) {
+		colStart = topLine->getText().length();
+	}
+		
 	Number fColEnd  = colEnd;
 	Number fColEnd  = colEnd;
 	
 	
 	if(colEnd > topLine->getText().length() || lineStart != lineEnd)
 	if(colEnd > topLine->getText().length() || lineStart != lineEnd)
@@ -208,6 +210,8 @@ void UITextInput::setSelection(int lineStart, int lineEnd, int colStart, int col
 		ScreenLabel *bottomLine = lines[lineEnd];	
 		ScreenLabel *bottomLine = lines[lineEnd];	
 		selectorRectBottom->visible = true;		
 		selectorRectBottom->visible = true;		
 		Number bottomSize = bottomLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), bottomLine->getText().substr(0,colEnd), fontSize) - 4; 
 		Number bottomSize = bottomLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), bottomLine->getText().substr(0,colEnd), fontSize) - 4; 
+		if(bottomSize < 0)
+			bottomSize = this->width-padding;
 		Number bottomHeight = lineHeight+lineSpacing;
 		Number bottomHeight = lineHeight+lineSpacing;
 		selectorRectBottom->setScale(bottomSize, bottomHeight);
 		selectorRectBottom->setScale(bottomSize, bottomHeight);
 		selectorRectBottom->setPosition(padding + (bottomSize/2.0) + 1, padding + (lineEnd * (lineHeight+lineSpacing)) + (bottomHeight/2.0));
 		selectorRectBottom->setPosition(padding + (bottomSize/2.0) + 1, padding + (lineEnd * (lineHeight+lineSpacing)) + (bottomHeight/2.0));
@@ -411,7 +415,7 @@ void UITextInput::dragSelectionTo(Number x, Number y) {
 	int lineOffset = y  / (lineHeight+lineSpacing);
 	int lineOffset = y  / (lineHeight+lineSpacing);
 	if(lineOffset > lines.size()-1)
 	if(lineOffset > lines.size()-1)
 		lineOffset = lines.size()-1;
 		lineOffset = lines.size()-1;
-
+	
 	ScreenLabel *selectToLine = lines[lineOffset];
 	ScreenLabel *selectToLine = lines[lineOffset];
 	
 	
 	int len = selectToLine->getText().length();
 	int len = selectToLine->getText().length();