2
0
Эх сурвалжийг харах

Add console completion after '/'

Leonardo Jeanteur 3 жил өмнө
parent
commit
4b5dbf0338
1 өөрчлөгдсөн 9 нэмэгдсэн , 2 устгасан
  1. 9 2
      h2d/Console.hx

+ 9 - 2
h2d/Console.hx

@@ -259,7 +259,7 @@ class Console #if !macro extends h2d.Object #end {
 		}
 		for( cmdName in all ) {
 			var c = commands.get(cmdName);
-			var str = "/" + cmdName;
+			var str = String.fromCharCode(shortKeyChar) + cmdName;
 			for( a in aliases.keys() )
 				if( aliases.get(a) == cmdName )
 					str += "|" + a;
@@ -311,6 +311,11 @@ class Console #if !macro extends h2d.Object #end {
 	}
 
 	function getCommandSuggestion(cmd : String) : String {
+		var hadShortKey = false;
+		if (cmd.charCodeAt(0) == shortKeyChar) {
+			hadShortKey = true;
+			cmd = cmd.substr(1);
+		}
 		if (cmd == "") {
 			return "";
 		}
@@ -325,6 +330,8 @@ class Console #if !macro extends h2d.Object #end {
 			}
 		}
 
+		if (hadShortKey && closestCommand != "")
+			closestCommand = String.fromCharCode(shortKeyChar) + closestCommand;
 		return closestCommand;
 	}
 
@@ -391,7 +398,7 @@ class Console #if !macro extends h2d.Object #end {
 
 	function handleCommand( command : String ) {
 		command = StringTools.trim(command);
-		if( command.charCodeAt(0) == "/".code ) command = command.substr(1);
+		if( command.charCodeAt(0) == shortKeyChar ) command = command.substr(1);
 		if( command == "" ) {
 			hide();
 			return;