• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Virtual machine Management Terminal User Interface


Commit MetaInfo

Révision403648a254f1b0d2672393cb2d6d661702481cbd (tree)
l'heure2022-07-16 21:48:33
AuteurKoine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Message de Log

Implement One-Line String & Password Input mode.

Change Summary

Modification

--- a/src/hvisor.h
+++ b/src/hvisor.h
@@ -32,7 +32,7 @@
3232
3333 #define HVISOR_MAXLEN_NAME 64
3434 #define HVISOR_SSH_MAXLEN_USER 64
35-#define HVISOR_SSH_MAXLEN_PASSWORD 64
35+#define HVISOR_SSH_MAXLEN_PASSWORD PASS_MAX
3636 #define HVISOR_MAXLEN_HOSTFQDN VMTUI_MAXLEN_HOSTFQDN
3737 #define HVISOR_CMD_BUFFER 65536
3838
--- a/src/tuicmd.c
+++ b/src/tuicmd.c
@@ -36,6 +36,27 @@ int
3636 TuiCmd_Update(
3737 void )
3838 {
39+ int i_mode;
40+ int i_len;
41+ char *pstr_input;
42+ char str_pass[ HVISOR_SSH_MAXLEN_PASSWORD ];
43+
44+ werase( gp_cmd_win );
45+
46+ i_mode = TuiKey_GetMode();
47+ if( TUIKEY_MODE_INPUTSTR == i_mode ) {
48+ pstr_input = TuiKey_GetInputStringAndPasswd( NULL );
49+ mvwprintw( gp_cmd_win, 0, 0, "Input String => %s", pstr_input );
50+ }
51+ else if( TUIKEY_MODE_INPUTPASSWD == i_mode ) {
52+ pstr_input = TuiKey_GetInputStringAndPasswd( &i_len );
53+ str_pass[ i_len-- ] = '\0';
54+ for( ; 0 <= i_len; i_len-- ) { str_pass[ i_len ] = '*'; }
55+ mvwprintw( gp_cmd_win, 0, 0, "Input Password => %s", str_pass );
56+ }
57+ if( TUIKEY_MODE_VMLIST == i_mode ) {
58+ mvwaddstr( gp_cmd_win, 0, 0, "Command Line" );
59+ }
3960
4061 touchwin( gp_cmd_win );
4162 wnoutrefresh( gp_cmd_win );
@@ -50,8 +71,6 @@ int
5071 void )
5172 {
5273
53- mvwaddstr( gp_cmd_win, 0, 0, "Command Line" );
54-
5574 TuiCmd_Update();
5675
5776 return 0x00;
--- a/src/tuikey.c
+++ b/src/tuikey.c
@@ -97,6 +97,138 @@ int
9797 /* ===========================================================================*/
9898 VMTUI_TUIKEY_EXTERN
9999 int
100+ TuiKey_GetMode(
101+ void )
102+{
103+ return gi_keymode;
104+}
105+
106+/* ===========================================================================*/
107+VMTUI_TUIKEY_EXTERN
108+char *
109+ TuiKey_GetInputStringAndPasswd(
110+ int *pi_len )
111+{
112+ if(( TUIKEY_MODE_INPUTSTR != gi_keymode ) && ( TUIKEY_MODE_INPUTPASSWD != gi_keymode )) {
113+ return NULL;
114+ }
115+
116+ if( NULL != pi_len ) { *pi_len = gi_inputlen; }
117+
118+ return gstr_input;
119+}
120+
121+/* ===========================================================================*/
122+VMTUI_TUIKEY_EXTERN
123+int
124+ TuiKey_ChangeMode(
125+ int i_mode )
126+{
127+ if(( TUIKEY_MODE_INPUTSTR == i_mode ) || ( TUIKEY_MODE_INPUTPASSWD == i_mode )) {
128+ gi_keymode = i_mode;
129+ gi_inputlen = 0;
130+ gi_input = 0;
131+ }
132+ else {
133+ gi_keymode = TUIKEY_MODE_VMLIST;
134+ }
135+
136+ return 0x00;
137+}
138+
139+
140+/* ===========================================================================*/
141+int
142+ TuiKey_Dispatch_Mode_InputStr(
143+ int i_key )
144+{
145+ int i_ret = 0x00;
146+
147+ if( isprint( i_key ) ) {
148+ if( gi_inputlen < sizeof(gstr_input) - 1) {
149+ gstr_input[gi_inputlen++] = (char)i_key;
150+ gstr_input[gi_inputlen] = '\0';
151+ }
152+ }
153+ else if(( KEY_ENTER == i_key) || ( 10 == i_key )) {
154+ TuiKey_ChangeMode( TUIKEY_MODE_VMLIST );
155+ }
156+ // KEY_ESC
157+ else if( 27 == i_key ) {
158+ TuiKey_ChangeMode( TUIKEY_MODE_VMLIST );
159+ }
160+ else if( KEY_BACKSPACE == i_key ) {
161+ if( 0 < gi_inputlen ) {
162+ gstr_input[--gi_inputlen] = '\0';
163+ }
164+ }
165+
166+ return i_ret;
167+}
168+
169+/* ===========================================================================*/
170+int
171+ TuiKey_Dispatch_VmList(
172+ int i_key )
173+{
174+ int i_ret = 0x00;
175+
176+ switch( i_key ) {
177+ case 'q':
178+ i_ret = 0x01;
179+ break;
180+
181+ case 'h':
182+ TuiKey_ChangeInfoWindow( -1 );
183+ TuiSys_Draw();
184+ break;
185+
186+ case 'l':
187+ TuiKey_ChangeInfoWindow( +1 );
188+ TuiSys_Draw();
189+ break;
190+
191+ case 'j':
192+ TuiVmList_DownCursor();
193+ TuiKey_ChangeInfoWindow( 0 );
194+ TuiSys_Draw();
195+ break;
196+
197+ case 'k':
198+ TuiVmList_UpCursor();
199+ TuiKey_ChangeInfoWindow( 0 );
200+ TuiSys_Draw();
201+ break;
202+
203+ case 't':
204+ TuiKey_TestCode();
205+ //TuiSys_Draw();
206+ refresh();
207+ break;
208+
209+ case 'i':
210+ gi_keymode = TUIKEY_MODE_INPUTSTR;
211+ refresh();
212+ break;
213+ case 'p':
214+ gi_keymode = TUIKEY_MODE_INPUTPASSWD;
215+ refresh();
216+ break;
217+ /*
218+ case ERR:
219+ break;
220+ */
221+ default:
222+ HvCmd_Update_All();
223+ break;
224+ }
225+
226+ return i_ret;
227+}
228+
229+/* ===========================================================================*/
230+VMTUI_TUIKEY_EXTERN
231+int
100232 TuiKey_Dispatch(
101233 void )
102234 {
@@ -108,41 +240,15 @@ int
108240 do {
109241 i_key = wgetch( gp_cmd_win );
110242
111- /*
112- if( ERR == i_key ) {
113- break;
114- }
115- */
116-
117- switch( i_key ) {
118- case 'q':
119- i_exit = 0x01;
120- break;
121- case 'h':
122- TuiKey_ChangeInfoWindow( -1 );
123- TuiSys_Draw();
243+ switch( gi_keymode ) {
244+ case TUIKEY_MODE_VMLIST:
245+ i_exit = TuiKey_Dispatch_VmList( i_key );
124246 break;
125- case 'l':
126- TuiKey_ChangeInfoWindow( +1 );
127- TuiSys_Draw();
128- break;
129- case 'j':
130- TuiVmList_DownCursor();
131- TuiKey_ChangeInfoWindow( 0 );
132- TuiSys_Draw();
133- break;
134- case 'k':
135- TuiVmList_UpCursor();
136- TuiKey_ChangeInfoWindow( 0 );
137- TuiSys_Draw();
138- break;
139- case 't':
140- TuiKey_TestCode();
141- //TuiSys_Draw();
142- refresh();
247+ case TUIKEY_MODE_INPUTSTR:
248+ case TUIKEY_MODE_INPUTPASSWD:
249+ i_exit = TuiKey_Dispatch_Mode_InputStr( i_key );
143250 break;
144251 default:
145- HvCmd_Update_All();
146252 break;
147253 }
148254
@@ -165,6 +271,10 @@ int
165271
166272 curs_set(0);
167273
274+ gi_keymode = TUIKEY_MODE_VMLIST;
275+ gi_inputlen = 0;
276+ gi_input = 0;
277+
168278 return 0x00;
169279 }
170280
--- a/src/tuikey.h
+++ b/src/tuikey.h
@@ -35,10 +35,23 @@
3535 #else
3636 #define VMTUI_TUIKEY_EXTERN extern
3737 #endif
38+VMTUI_TUIKEY_EXTERN int TuiKey_GetMode( void );
39+VMTUI_TUIKEY_EXTERN char *TuiKey_GetInputStringAndPasswd( int *pi_len );
40+VMTUI_TUIKEY_EXTERN int TuiKey_ChangeMode( int i_mode );
3841 VMTUI_TUIKEY_EXTERN int TuiKey_Dispatch( void );
3942 VMTUI_TUIKEY_EXTERN int TuiKey_Init( void );
4043 VMTUI_TUIKEY_EXTERN int TuiKey_Term( void );
4144
45+#define TUIKEY_MODE_VMLIST 0x00
46+#define TUIKEY_MODE_INPUTSTR 0x01
47+#define TUIKEY_MODE_INPUTPASSWD 0x02
48+
49+#ifdef VMTUI_SRC_TUIKEY
50+static int gi_keymode;
51+static int gi_inputlen;
52+static int gi_input;
53+static char gstr_input[512];
54+#endif
4255
4356 #endif
4457
--- a/src/vmtui.h
+++ b/src/vmtui.h
@@ -48,6 +48,7 @@
4848 #include<signal.h>
4949 #include<termios.h>
5050 #include<grp.h>
51+#include<limits.h>
5152 #include<sys/socket.h>
5253 #include<sys/select.h>
5354 #include<sys/types.h>