Просмотр исходного кода

Focus Hide when opening a file from remoteConsole

Allow opening .domkit files from remoteConsole
Leonardo Jeanteur 7 месяцев назад
Родитель
Сommit
5619806d49
4 измененных файлов с 23 добавлено и 3 удалено
  1. 6 0
      hide/Ide.hx
  2. 10 2
      hrt/impl/RemoteConsole.hx
  3. 4 0
      hrt/impl/RemoteTools.hx
  4. 3 1
      libs/nw/Window.hx

+ 6 - 0
hide/Ide.hx

@@ -309,6 +309,12 @@ class Ide extends hide.tools.IdeData {
 	function get_isFocused() {
 		return js.Browser.document.hasFocus();
 	}
+	public function focus() {
+		window.focus();
+	}
+	public function blur() {
+		window.blur();
+	}
 
 	function onWindowChange() {
 		if( hasReloaded )

+ 10 - 2
hrt/impl/RemoteConsole.hx

@@ -290,12 +290,20 @@ class RemoteConsoleConnection {
 			return;
 		if( args.cdbsheet != null ) {
 			var sheet = hide.Ide.inst.database.getSheet(args.cdbsheet);
-			hide.Ide.inst.open("hide.view.CdbTable", {}, function(view) {
+			hide.Ide.inst.open("hide.view.CdbTable", {}, null, function(view) {
+				hide.Ide.inst.focus();
 				Std.downcast(view,hide.view.CdbTable).goto(sheet,args.line,args.column);
 			});
 		} else {
 			hide.Ide.inst.showFileInResources(args.file);
-			hide.Ide.inst.openFile(args.file);
+			hide.Ide.inst.openFile(args.file, null, function(view) {
+				hide.Ide.inst.focus();
+				var domkit = Std.downcast(view, hide.view.Domkit);
+				if (domkit != null && args.line != null) {
+					@:privateAccess domkit.cssEditor.focus();
+					@:privateAccess domkit.cssEditor.editor.setPosition({column: args.column, lineNumber: args.line+1});
+				}
+			});
 		}
 	}
 #end

+ 4 - 0
hrt/impl/RemoteTools.hx

@@ -67,4 +67,8 @@ class RemoteTools {
 		rc?.sendCommand("open", { file : file });
 	}
 
+	public static function openDomkit( file : String, ?line : Int, ?column : Int ) {
+		rc?.sendCommand("open", { file : file, line : line, column : column });
+	}
+
 }

+ 3 - 1
libs/nw/Window.hx

@@ -27,7 +27,9 @@ extern class Window {
 	public function leaveFullscreen() : Void;
 	public function on( event : String, callb : Void -> Void ) : Void;
 
-	public function show( b : Bool ) : Void;
+	public function focus() : Void;
+	public function blur() : Void;
+	public function show( ?b : Bool ) : Void;
 
 	public function close( ?force : Bool ) : Void;