瀏覽代碼

tools: reset ConsoleView's buffer when switching project

Fixes: #142
Daniele Bartolini 3 年之前
父節點
當前提交
4f7e60193a
共有 2 個文件被更改,包括 12 次插入0 次删除
  1. 1 0
      tools/level_editor/level_editor.vala
  2. 11 0
      tools/widgets/console_view.vala

+ 1 - 0
tools/level_editor/level_editor.vala

@@ -1960,6 +1960,7 @@ public class LevelEditorApplication : Gtk.Application
 
 
 			this.show_panel("main_vbox", Gtk.StackTransitionType.NONE);
 			this.show_panel("main_vbox", Gtk.StackTransitionType.NONE);
 			_user.add_or_touch_recent_project(source_dir, source_dir);
 			_user.add_or_touch_recent_project(source_dir, source_dir);
+			_console_view.reset();
 			restart_backend.begin(source_dir, LEVEL_NONE);
 			restart_backend.begin(source_dir, LEVEL_NONE);
 		}
 		}
 	}
 	}

+ 11 - 0
tools/widgets/console_view.vala

@@ -155,6 +155,17 @@ public class ConsoleView : Gtk.Box
 		_console_view_valid = true;
 		_console_view_valid = true;
 	}
 	}
 
 
+	public void reset()
+	{
+		Gtk.TextIter start;
+		Gtk.TextIter end;
+
+		Gtk.TextBuffer buffer = _text_view.buffer;
+		buffer.get_start_iter(out start);
+		buffer.get_end_iter(out end);
+		buffer.@delete(ref start, ref end);
+	}
+
 	private void on_entry_activated()
 	private void on_entry_activated()
 	{
 	{
 		string text = _entry.text;
 		string text = _entry.text;