@@ -26,7 +26,7 @@ public class SeImGuiConsole
2626 /// <summary>
2727 /// Input of Console
2828 /// </summary>
29- public string ConsoleInput = "" ;
29+ private string ConsoleInput = "" ;
3030
3131 /// <summary>
3232 /// Add Text to Console
@@ -61,36 +61,39 @@ public void Display(Window window)
6161
6262 if ( ImGui . InputText ( "Input" , ref ConsoleInput , 100 , ImGuiInputTextFlags . EnterReturnsTrue ) )
6363 {
64- if ( ConsoleInput . Length > 0 )
65- {
66- AddText ( "> " + ConsoleInput ) ;
67-
68- var command = ConsoleInput . Split ( " " ) ;
69- var commandName = command [ 0 ] ;
70- var commandArgs = Array . Empty < string > ( ) ;
71- if ( command . Length > 1 )
72- commandArgs = command [ 1 ..] ;
73-
74- var found = false ;
75- foreach ( var commandObject in Commands )
76- {
77- if ( commandObject . Command == commandName )
78- {
79- commandObject . Process ( commandArgs , this , window ) ;
80- found = true ;
81- break ;
82- }
83- }
84-
85- if ( ! found )
86- AddText ( "Unknown command." ) ;
87- }
64+ if ( ConsoleInput . Length > 0 )
65+ ProcessCommand ( window ) ;
8866
8967 ConsoleInput = "" ;
9068 ImGui . SetKeyboardFocusHere ( - 1 ) ;
9169 }
9270
9371 ImGui . End ( ) ;
9472 }
73+
74+ private void ProcessCommand ( Window window )
75+ {
76+ AddText ( "> " + ConsoleInput ) ;
77+
78+ var command = ConsoleInput . Split ( " " ) ;
79+ var commandName = command [ 0 ] ;
80+ var commandArgs = Array . Empty < string > ( ) ;
81+ if ( command . Length > 1 )
82+ commandArgs = command [ 1 ..] ;
83+
84+ var found = false ;
85+ foreach ( var commandObject in Commands )
86+ {
87+ if ( commandObject . Command == commandName )
88+ {
89+ commandObject . Process ( commandArgs , this , window ) ;
90+ found = true ;
91+ break ;
92+ }
93+ }
94+
95+ if ( ! found )
96+ AddText ( "Unknown command." ) ;
97+ }
9598 }
9699}
0 commit comments