@@ -26,7 +26,7 @@ pub struct TuiUi {
26
26
version : String ,
27
27
enhanced_graphics : bool ,
28
28
show_logs : bool ,
29
- clients_idx : usize ,
29
+ client_idx : usize ,
30
30
clients : usize ,
31
31
charts_tab_idx : usize ,
32
32
graph_data : Vec < ( f64 , f64 ) > ,
@@ -48,7 +48,7 @@ impl TuiUi {
48
48
version,
49
49
enhanced_graphics,
50
50
show_logs : true ,
51
- clients_idx : 1 ,
51
+ client_idx : 0 ,
52
52
..TuiUi :: default ( )
53
53
}
54
54
}
@@ -67,29 +67,15 @@ impl TuiUi {
67
67
}
68
68
}
69
69
70
- //pub fn on_up(&mut self) {}
71
-
72
- //pub fn on_down(&mut self) {}
73
-
74
70
pub fn on_right ( & mut self ) {
75
- if self . clients != 0 {
76
- // clients_idx never 0
77
- if self . clients - 1 != 0 {
78
- // except for when it is ;)
79
- self . clients_idx = 1 + self . clients_idx % ( self . clients - 1 ) ;
80
- }
71
+ if self . clients > 0 && self . client_idx < self . clients - 1 {
72
+ self . client_idx += 1 ;
81
73
}
82
74
}
83
75
84
76
pub fn on_left ( & mut self ) {
85
- if self . clients != 0 {
86
- // clients_idx never 0
87
- if self . clients_idx == 1 {
88
- self . clients_idx = self . clients - 1 ;
89
- } else if self . clients - 1 != 0 {
90
- // don't wanna be dividing by 0
91
- self . clients_idx = 1 + ( self . clients_idx - 2 ) % ( self . clients - 1 ) ;
92
- }
77
+ if self . client_idx > 0 {
78
+ self . client_idx -= 1 ;
93
79
}
94
80
}
95
81
@@ -248,7 +234,7 @@ impl TuiUi {
248
234
fn draw_client_ui ( & mut self , f : & mut Frame , app : & Arc < RwLock < TuiContext > > , area : Rect ) {
249
235
let client_block = Block :: default ( )
250
236
. title ( Span :: styled (
251
- format ! ( "client #{} (l/r arrows to switch)" , self . clients_idx ) ,
237
+ format ! ( "client #{} (←/→ arrows to switch)" , self . client_idx ) ,
252
238
Style :: default ( )
253
239
. fg ( Color :: LightCyan )
254
240
. add_modifier ( Modifier :: BOLD ) ,
@@ -431,16 +417,16 @@ impl TuiUi {
431
417
let empty_geometry: ItemGeometry = ItemGeometry :: new ( ) ;
432
418
let item_geometry: & ItemGeometry = if is_overall {
433
419
& tui_context. total_item_geometry
434
- } else if self . clients < 2 {
420
+ } else if self . clients == 0 {
435
421
& empty_geometry
436
422
} else {
437
423
let clients = & tui_context. clients ;
438
- let client = clients. get ( & self . clients_idx ) ;
424
+ let client = clients. get ( & self . client_idx ) ;
439
425
let client = client. as_ref ( ) ;
440
426
if let Some ( client) = client {
441
427
& client. item_geometry
442
428
} else {
443
- log:: warn!( "Client {} was `None`. Race condition?" , & self . clients_idx ) ;
429
+ log:: warn!( "Client {} was `None`. Race condition?" , & self . client_idx ) ;
444
430
& empty_geometry
445
431
}
446
432
} ;
@@ -508,41 +494,41 @@ impl TuiUi {
508
494
let empty_timing: ProcessTiming = ProcessTiming :: new ( ) ;
509
495
let tup: ( Duration , & ProcessTiming ) = if is_overall {
510
496
( tui_context. start_time , & tui_context. total_process_timing )
511
- } else if self . clients < 2 {
497
+ } else if self . clients == 0 {
512
498
( current_time ( ) , & empty_timing)
513
499
} else {
514
500
let clients = & tui_context. clients ;
515
- let client = clients. get ( & self . clients_idx ) ;
501
+ let client = clients. get ( & self . client_idx ) ;
516
502
let client = client. as_ref ( ) ;
517
503
if let Some ( client) = client {
518
504
(
519
505
client. process_timing . client_start_time ,
520
506
& client. process_timing ,
521
507
)
522
508
} else {
523
- log:: warn!( "Client {} was `None`. Race condition?" , & self . clients_idx ) ;
509
+ log:: warn!( "Client {} was `None`. Race condition?" , & self . client_idx ) ;
524
510
( current_time ( ) , & empty_timing)
525
511
}
526
512
} ;
527
513
let items = vec ! [
528
514
Row :: new( vec![
529
- Cell :: from( Span :: raw( "run time" ) ) ,
515
+ Cell :: from( Span :: raw( "global run time" ) ) ,
530
516
Cell :: from( Span :: raw( format_duration_hms( & ( current_time( ) - tup. 0 ) ) ) ) ,
531
517
] ) ,
532
518
Row :: new( vec![
533
- Cell :: from( Span :: raw( "exec speed" ) ) ,
519
+ Cell :: from( Span :: raw( "global exec speed" ) ) ,
534
520
Cell :: from( Span :: raw( & tup. 1 . exec_speed) ) ,
535
521
] ) ,
536
522
Row :: new( vec![
537
- Cell :: from( Span :: raw( "total execs" ) ) ,
523
+ Cell :: from( Span :: raw( "global total execs" ) ) ,
538
524
Cell :: from( Span :: raw( format_big_number( tup. 1 . total_execs) ) ) ,
539
525
] ) ,
540
526
Row :: new( vec![
541
- Cell :: from( Span :: raw( "last new entry" ) ) ,
527
+ Cell :: from( Span :: raw( "global last new entry" ) ) ,
542
528
Cell :: from( Span :: raw( format_duration_hms( & ( tup. 1 . last_new_entry) ) ) ) ,
543
529
] ) ,
544
530
Row :: new( vec![
545
- Cell :: from( Span :: raw( "last solution" ) ) ,
531
+ Cell :: from( Span :: raw( "global last solution" ) ) ,
546
532
Cell :: from( Span :: raw( format_duration_hms( & ( tup. 1 . last_saved_solution) ) ) ) ,
547
533
] ) ,
548
534
] ;
@@ -642,7 +628,7 @@ impl TuiUi {
642
628
Cell :: from( Span :: raw( format!(
643
629
"{}" ,
644
630
app. clients
645
- . get( & self . clients_idx )
631
+ . get( & self . client_idx )
646
632
. map_or( 0 , |x| x. cycles_done)
647
633
) ) ) ,
648
634
] ) ,
@@ -651,7 +637,7 @@ impl TuiUi {
651
637
Cell :: from( Span :: raw( format!(
652
638
"{}" ,
653
639
app. clients
654
- . get( & self . clients_idx )
640
+ . get( & self . client_idx )
655
641
. map_or( 0 , |x| x. objectives)
656
642
) ) ) ,
657
643
] ) ,
@@ -686,22 +672,22 @@ impl TuiUi {
686
672
Row :: new( vec![
687
673
Cell :: from( Span :: raw( "corpus count" ) ) ,
688
674
Cell :: from( Span :: raw( format_big_number(
689
- app. clients. get( & self . clients_idx ) . map_or( 0 , |x| x. corpus) ,
675
+ app. clients. get( & self . client_idx ) . map_or( 0 , |x| x. corpus) ,
690
676
) ) ) ,
691
677
] ) ,
692
678
Row :: new( vec![
693
679
Cell :: from( Span :: raw( "total execs" ) ) ,
694
680
Cell :: from( Span :: raw( format_big_number(
695
681
app. clients
696
- . get( & self . clients_idx )
682
+ . get( & self . client_idx )
697
683
. map_or( 0 , |x| x. executions) ,
698
684
) ) ) ,
699
685
] ) ,
700
686
Row :: new( vec![
701
687
Cell :: from( Span :: raw( "map density" ) ) ,
702
688
Cell :: from( Span :: raw(
703
689
app. clients
704
- . get( & self . clients_idx )
690
+ . get( & self . client_idx )
705
691
. map_or( "0%" . to_string( ) , |x| x. map_density. to_string( ) ) ,
706
692
) ) ,
707
693
] ) ,
@@ -734,7 +720,7 @@ impl TuiUi {
734
720
let mut items = vec ! [ ] ;
735
721
{
736
722
let ctx = app. read ( ) . unwrap ( ) ;
737
- if let Some ( client) = ctx. introspection . get ( & self . clients_idx ) {
723
+ if let Some ( client) = ctx. introspection . get ( & self . client_idx ) {
738
724
items. push ( Row :: new ( vec ! [
739
725
Cell :: from( Span :: raw( "scheduler" ) ) ,
740
726
Cell :: from( Span :: raw( format!( "{:.2}%" , client. scheduler * 100.0 ) ) ) ,
0 commit comments