From 05801b92652f3fc21063a8aab516633769c9ba55 Mon Sep 17 00:00:00 2001 From: Dana Olson Date: Sun, 7 Dec 2014 01:07:00 -0500 Subject: apply patch #882 from dcubix --- scene/gui/text_edit.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scene/gui/text_edit.cpp') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index b95d27139..3f0dc22ab 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3150,12 +3150,18 @@ void TextEdit::set_line(int line, String new_text) { if (line < 0 || line > text.size()) return; - text.set(line, new_text); + text.remove(line); // TODO: Make this Undo/Redoable.... + insert_at(new_text, line); + //text.set(line, new_text); } void TextEdit::insert_at(const String &p_text, int at) { - text.insert(at, p_text); + 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); } void TextEdit::set_show_line_numbers(bool p_show) { -- cgit v1.2.3-70-g09d2 From 380f12def25e4031756354907e8d5abe5466b864 Mon Sep 17 00:00:00 2001 From: Dana Olson Date: Sun, 7 Dec 2014 02:21:49 -0500 Subject: now undo/redo supported --- scene/gui/text_edit.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'scene/gui/text_edit.cpp') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3f0dc22ab..f1100c7c2 100644 --- a/scene/gui/text_edit.cpp +++ b/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) { -- cgit v1.2.3-70-g09d2