浏览代码

home button like & whitespace

jonyrock 11 年之前
父节点
当前提交
89568b9017
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      scene/gui/text_edit.cpp

+ 15 - 2
scene/gui/text_edit.cpp

@@ -1349,8 +1349,21 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
 
 					if (k.mod.shift)
 						_pre_shift_selection();
-
-					cursor_set_column(0);
+					
+					// compute whitespace symbols seq length
+					int current_line_whitespace_len = 0;
+					while(current_line_whitespace_len < text[cursor.line].length()) {
+						CharType c = text[cursor.line][current_line_whitespace_len];
+						if(c != '\t' && c != ' ')
+							break;
+						current_line_whitespace_len++;
+					}
+					
+					if(cursor_get_column() == current_line_whitespace_len)
+						cursor_set_column(0);
+					else
+						cursor_set_column(current_line_whitespace_len);
+					
 					if (k.mod.command)
 						cursor_set_line(0);