1+ using EtcdTerminal ;
12using System . Text ;
23using Spectre . Console ;
34
4- namespace EtcdTerminal . Console . Engine ;
5+ namespace EtcdTerminal . App . Engine ;
56
67public static class Prompt
78{
@@ -34,25 +35,25 @@ public static class Prompt
3435
3536 while ( true )
3637 {
37- var key = System . Console . ReadKey ( true ) ;
38+ var key = Console . ReadKey ( true ) ;
3839
3940 switch ( key . Key )
4041 {
4142 case ConsoleKey . Escape :
42- System . Console . WriteLine ( ) ;
43+ Console . WriteLine ( ) ;
4344 return null ;
4445 case ConsoleKey . Enter :
45- System . Console . WriteLine ( "n" ) ;
46+ Console . WriteLine ( "n" ) ;
4647 return false ;
4748 default :
4849 if ( key . KeyChar is 'y' or 'Y' )
4950 {
50- System . Console . WriteLine ( "y" ) ;
51+ Console . WriteLine ( "y" ) ;
5152 return true ;
5253 }
5354 if ( key . KeyChar is 'n' or 'N' )
5455 {
55- System . Console . WriteLine ( "n" ) ;
56+ Console . WriteLine ( "n" ) ;
5657 return false ;
5758 }
5859 break ;
@@ -66,44 +67,44 @@ public static class Prompt
6667 {
6768 var input = new StringBuilder ( prefill ?? "" ) ;
6869 var cursor = input . Length ;
69- var startCol = System . Console . CursorLeft ;
70+ var startCol = Console . CursorLeft ;
7071
7172 if ( ! string . IsNullOrEmpty ( prefill ) )
72- System . Console . Write ( prefill ) ;
73+ Console . Write ( prefill ) ;
7374
7475 while ( true )
7576 {
76- var key = System . Console . ReadKey ( true ) ;
77+ var key = Console . ReadKey ( true ) ;
7778
7879 switch ( key . Key )
7980 {
8081 case ConsoleKey . Escape :
8182 ClearInput ( startCol ) ;
82- System . Console . WriteLine ( ) ;
83+ Console . WriteLine ( ) ;
8384 return null ;
8485 case ConsoleKey . Enter :
85- System . Console . WriteLine ( ) ;
86+ Console . WriteLine ( ) ;
8687 return input . ToString ( ) ;
8788 case ConsoleKey . LeftArrow :
8889 if ( cursor > 0 )
8990 {
9091 cursor -- ;
91- System . Console . CursorLeft -- ;
92+ Console . CursorLeft -- ;
9293 }
9394 break ;
9495 case ConsoleKey . RightArrow :
9596 if ( cursor < input . Length )
9697 {
97- System . Console . Write ( input [ cursor ] ) ;
98+ Console . Write ( input [ cursor ] ) ;
9899 cursor ++ ;
99100 }
100101 break ;
101102 case ConsoleKey . Home :
102- System . Console . CursorLeft = startCol ;
103+ Console . CursorLeft = startCol ;
103104 cursor = 0 ;
104105 break ;
105106 case ConsoleKey . End :
106- System . Console . CursorLeft = startCol + input . Length ;
107+ Console . CursorLeft = startCol + input . Length ;
107108 cursor = input . Length ;
108109 break ;
109110 case ConsoleKey . Backspace :
@@ -135,18 +136,18 @@ public static class Prompt
135136
136137 private static void ClearInput ( int startCol )
137138 {
138- var endCol = System . Console . CursorLeft ;
139+ var endCol = Console . CursorLeft ;
139140
140- System . Console . CursorLeft = startCol ;
141- System . Console . Write ( new string ( ' ' , Math . Max ( 0 , endCol - startCol + 1 ) ) ) ;
142- System . Console . CursorLeft = startCol ;
141+ Console . CursorLeft = startCol ;
142+ Console . Write ( new string ( ' ' , Math . Max ( 0 , endCol - startCol + 1 ) ) ) ;
143+ Console . CursorLeft = startCol ;
143144 }
144145
145146 private static void RedrawInput ( int startCol , string text , int cursorPos )
146147 {
147- System . Console . CursorLeft = startCol ;
148- System . Console . Write ( text + ' ' ) ;
149- System . Console . CursorLeft = startCol + cursorPos ;
148+ Console . CursorLeft = startCol ;
149+ Console . Write ( text + ' ' ) ;
150+ Console . CursorLeft = startCol + cursorPos ;
150151 }
151152
152153 private static string ? ReadSecret ( )
@@ -155,28 +156,28 @@ private static void RedrawInput(int startCol, string text, int cursorPos)
155156
156157 while ( true )
157158 {
158- var key = System . Console . ReadKey ( true ) ;
159+ var key = Console . ReadKey ( true ) ;
159160
160161 switch ( key . Key )
161162 {
162163 case ConsoleKey . Escape :
163- System . Console . WriteLine ( ) ;
164+ Console . WriteLine ( ) ;
164165 return null ;
165166 case ConsoleKey . Enter :
166- System . Console . WriteLine ( ) ;
167+ Console . WriteLine ( ) ;
167168 return input . ToString ( ) ;
168169 case ConsoleKey . Backspace :
169170 if ( input . Length > 0 )
170171 {
171172 input . Length -- ;
172- System . Console . Write ( "\b \b " ) ;
173+ Console . Write ( "\b \b " ) ;
173174 }
174175 break ;
175176 default :
176177 if ( ! char . IsControl ( key . KeyChar ) )
177178 {
178179 input . Append ( key . KeyChar ) ;
179- System . Console . Write ( '*' ) ;
180+ Console . Write ( '*' ) ;
180181 }
181182 break ;
182183 }
0 commit comments