• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Virtual machine Management Terminal User Interface


Commit MetaInfo

修訂b0c6d0e1a367fca204f3c23405a25dc08d9f5f9c (tree)
時間2022-05-04 13:23:29
作者Koine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Log Message

[Implement] show HVisor Status
[Implement] show Guest Status Color

Change Summary

差異

--- a/src/tuisys.c
+++ b/src/tuisys.c
@@ -84,8 +84,12 @@ int
8484
8585 if( has_colors() ) {
8686 start_color();
87+ // init_pair( 0, COLOR_WHITE, COLOR_BLACK ); // VMList Guest
8788 init_pair( 1, COLOR_WHITE, COLOR_BLACK ); // VMList Guest
88- init_pair( 2, COLOR_GREEN, COLOR_BLACK ); // VMList HVisor
89+ init_pair( 2, COLOR_GREEN, COLOR_BLACK ); // VMList HVisor (Running)
90+ init_pair( 3, COLOR_CYAN, COLOR_BLACK ); // VMList Guest (Running)
91+ init_pair( 4, COLOR_YELLOW, COLOR_BLACK ); // VMList Guest (Others)
92+ init_pair( 5, COLOR_RED, COLOR_BLACK ); // VMList HVisor (Not Running)
8993 init_pair( 10, COLOR_YELLOW, COLOR_BLUE ); // VmTui Title Line
9094 init_pair( 11, COLOR_WHITE, COLOR_BLUE ); // Guest Info Title Line
9195 init_pair( 12, COLOR_GREEN, COLOR_BLUE ); // HVisor Info Title Line
--- a/src/tuivmlist.c
+++ b/src/tuivmlist.c
@@ -162,11 +162,12 @@ int
162162 int i_now;
163163 int i_end;
164164 int i_line = 0;
165+ int i_attr;
165166 HVisor *p_hvisor;
166167 Guest *p_guest;
167168 VmList_Item *p_item;
168169 char str_fmt[32];
169- char str_gstat[8];
170+ char str_stat[16];
170171
171172 i_err = TuiVmList_CreateList();
172173
@@ -189,18 +190,28 @@ int
189190
190191 if( GUEST_ID_NONE == p_item->i_guest ) {
191192 // HVisor ---
193+ p_hvisor = HVisor_Ref( p_item->i_hvisor );
194+
195+ if( HVISOR_STATUS_CONNECTED & p_hvisor->dw_status ) {
196+ strncpy( str_stat, "* ONLINE", 15 );
197+ i_attr = COLOR_PAIR(2); // Green-Black
198+ }
199+ else {
200+ strncpy( str_stat, "X NotConnect", 15 );
201+ i_attr = COLOR_PAIR(5); // Red-Black
202+ }
203+
192204 if( gi_line_now == i_line )
193- { wattrset( gp_vmlist_win, COLOR_PAIR(2) | A_BOLD | A_REVERSE ); }
205+ { wattrset( gp_vmlist_win, i_attr | A_BOLD | A_REVERSE ); }
194206 else
195- { wattrset( gp_vmlist_win, COLOR_PAIR(2) | A_BOLD ); }
207+ { wattrset( gp_vmlist_win, i_attr | A_BOLD ); }
196208
197- p_hvisor = HVisor_Ref( p_item->i_hvisor );
198209
199- // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(8)
210+ // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(10)
200211 // ConnectType: "Local", "SSH(vmbhyve)
201- snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-8s",
202- (COLS - 2 - 16 - 8 - 2 - 2) , (COLS - 2 - 16 - 8 - 2 - 2) );
203- mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_hvisor->str_name, "contype", "state" );
212+ snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-14s",
213+ (COLS - 2 - 16 - 14 - 2 - 2) , (COLS - 2 - 16 - 14 - 2 - 2) );
214+ mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_hvisor->str_name, "contype", str_stat );
204215
205216 HVisor_Release( p_hvisor );
206217
@@ -208,35 +219,41 @@ int
208219 }
209220 else {
210221 // Guest ---
211- if( gi_line_now == i_line )
212- { wattrset( gp_vmlist_win, COLOR_PAIR(0) | A_REVERSE ); }
213- else
214- { wattrset( gp_vmlist_win, COLOR_PAIR(0) ); }
215-
216222 p_guest = Guest_Ref( p_item->i_guest );
217223
218224 switch( p_guest->dw_status ) {
219225 case GUEST_STATUS_STOP:
220- strncpy( str_gstat, "Stop", 7 );
226+ strncpy( str_stat, " Stop", 15 );
227+ i_attr = COLOR_PAIR(1); // White-Black
221228 break;
222229 case GUEST_STATUS_RUN:
223- strncpy( str_gstat, "RUN", 7 );
230+ strncpy( str_stat, "* RUN", 15 );
231+ i_attr = COLOR_PAIR(3); // Cyan-Black
224232 break;
225233 case GUEST_STATUS_WAIT:
226- strncpy( str_gstat, "Wait", 7 );
234+ strncpy( str_stat, "- Wait", 15 );
235+ i_attr = COLOR_PAIR(4); // Yellow-Black
227236 break;
228237 case GUEST_STATUS_UNKNOWN:
229- strncpy( str_gstat, "UNKNOWN", 7 );
238+ strncpy( str_stat, "? UNKNOWN", 15 );
239+ i_attr = COLOR_PAIR(4); // Yellow-Black
230240 break;
231241 default:
232- strncpy( str_gstat, "BUG!!", 7 );
242+ strncpy( str_stat, "! BUG!!", 15 );
243+ i_attr = COLOR_PAIR(4); // Yellow-Black
233244 break;
234245 }
235246
247+ if( gi_line_now == i_line )
248+ { wattrset( gp_vmlist_win, i_attr | A_REVERSE ); }
249+ else
250+ { wattrset( gp_vmlist_win, i_attr ); }
236251
237- snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-8s",
238- (COLS - 4 - 16 - 8 - 2 - 2) , (COLS - 4 - 16 - 8 - 2 - 2) );
239- mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_guest->str_vmname, "type", str_gstat );
252+ // Indent(2) + HyperName&fqdn(48+) + ConnectType(16) + State(10)
253+ // ConnectType: "Local", "SSH(vmbhyve)
254+ snprintf( str_fmt, 32, " %%-%d.%ds %%-16s %%-14s",
255+ (COLS - 4 - 16 - 14 - 2 - 2) , (COLS - 4 - 16 - 14 - 2 - 2) );
256+ mvwprintw( gp_vmlist_win, i_line, 1, str_fmt, p_guest->str_vmname, "type", str_stat );
240257
241258 Guest_Release( p_guest );
242259