Răsfoiți Sursa

now undo/redo supported

Dana Olson 10 ani în urmă
părinte
comite
380f12def2
1 a modificat fișierele cu 5 adăugiri și 8 ștergeri
  1. 5 8
      scene/gui/text_edit.cpp

+ 5 - 8
scene/gui/text_edit.cpp

@@ -3150,18 +3150,15 @@ void TextEdit::set_line(int line, String new_text)
 {
     if (line < 0 || line > text.size())
         return;
-    text.remove(line); // TODO: Make this Undo/Redoable....
-    insert_at(new_text, line);
-    //text.set(line, new_text);
+    _remove_text(line, 0, line, text[line].length());
+    _insert_text(line, 0, new_text);
 }
 
 void TextEdit::insert_at(const String &p_text, int at)
 {
-    cursor_set_column(0);
-    cursor_set_line(at);
-    _insert_text(at, 0, p_text+"\n");
-    //_insert_text_at_cursor(p_text);
-    //old: text.insert(at, p_text);
+	cursor_set_column(0);
+	cursor_set_line(at);
+	_insert_text(at, 0, p_text+"\n");
 }
 
 void TextEdit::set_show_line_numbers(bool p_show) {