فهرست منبع

View: add reopen last closed tab

Yuxiao Mao 5 ماه پیش
والد
کامیت
3127b638e3
3فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 1 0
      bin/defaultProps.json
  2. 8 0
      hide/Ide.hx
  3. 2 0
      hide/ui/View.hx

+ 1 - 0
bin/defaultProps.json

@@ -51,6 +51,7 @@
 	"key.view.fullScreen" : "F11",
 	"key.view.refresh" : "F5",
 	"key.view.refreshApp" : "Ctrl-F5",
+	"key.view.reopenLastClosedTab" : "Ctrl-Shift-T",
 
 	// File tree
 	"filetree.excludes": [

+ 8 - 0
hide/Ide.hx

@@ -34,6 +34,7 @@ class Ide extends hide.tools.IdeData {
 	var fullscreen : Bool;
 	var updates : Array<Void->Void> = [];
 	var views : Array<hide.ui.View<Dynamic>> = [];
+	var lastClosedTabStates : Array<Dynamic> = [];
 
 	var renderers : Array<h3d.mat.MaterialSetup>;
 	var subView : { component : String, state : Dynamic, events : {} };
@@ -1588,6 +1589,13 @@ class Ide extends hide.tools.IdeData {
 			target.addChild(config, index);
 	}
 
+	public function reopenLastClosedTab() {
+		var state = lastClosedTabStates.pop();
+		if( state != null && state.componentName != null ) {
+			open(state.componentName, state);
+		}
+	}
+
 	public function globalMessage(element: Element, timeoutSeconds : Float = 5.0) {
 		var body = new Element('body');
 		var messages = body.find("#message-container");

+ 2 - 0
hide/ui/View.hx

@@ -69,6 +69,7 @@ class View<T> extends hide.comp.Component {
 			keys = new Keys(null);
 			#if js
 			keys.register("view.fullScreen", function() fullScreen = !fullScreen);
+			keys.register("view.reopenLastClosedTab", function() ide.reopenLastClosedTab());
 			#end
 		}
 		return keys;
@@ -300,6 +301,7 @@ class View<T> extends hide.comp.Component {
 		}
 		element = null;
 		containerView.__view = null;
+		@:privateAccess ide.lastClosedTabStates.push(state);
 	}
 
 	function buildTabMenu() : Array<hide.comp.ContextMenu.MenuItem> {