@@ -18,6 +18,7 @@ pub fn render_ui(
1818 // Resolve Global Defaults from Env
1919 let default_border_color = Color :: Rgb ( 176 , 176 , 176 ) ;
2020 let default_fps_color = Color :: Yellow ;
21+ let default_caps_color = Color :: Rgb ( 222 , 133 , 212 ) ;
2122 let global_border_color = match env. get ( "border_color" ) {
2223 Some ( Value :: RGB ( r, g, b) ) => Color :: Rgb ( * r, * g, * b) ,
2324 _ => default_border_color,
@@ -34,11 +35,37 @@ pub fn render_ui(
3435 _ => global_border_color,
3536 } ;
3637
37- let fps_color= match env. get ( "fps_color" ) {
38+ let show_kps = match env. get ( "show_kps" ) {
39+ Some ( Value :: Number ( n) ) => {
40+ if * n == 0 {
41+ false
42+ } else {
43+ true
44+ }
45+ }
46+ _ => true ,
47+ } ;
48+
49+ let show_caps = match env. get ( "show_caps" ) {
50+ Some ( Value :: Number ( n) ) => {
51+ if * n == 0 {
52+ false
53+ } else {
54+ true
55+ }
56+ }
57+ _ => true ,
58+ } ;
59+
60+ let fps_color = match env. get ( "fps_color" ) {
3861 Some ( Value :: RGB ( r, g, b) ) => Color :: Rgb ( * r, * g, * b) ,
3962 _ => default_fps_color,
4063 } ;
4164
65+ let caps_color = match env. get ( "caps_color" ) {
66+ Some ( Value :: RGB ( r, g, b) ) => Color :: Rgb ( * r, * g, * b) ,
67+ _ => default_caps_color,
68+ } ;
4269
4370 // Render Outer Container
4471 let outer_block = Block :: default ( )
@@ -56,16 +83,34 @@ pub fn render_ui(
5683 . constraints ( [ Constraint :: Length ( 1 ) , Constraint :: Min ( 0 ) ] )
5784 . split ( inner_area) ;
5885
86+ let status_bar = TuiLayout :: default ( )
87+ . direction ( Direction :: Horizontal )
88+ . constraints ( [ Constraint :: Min ( 0 ) , Constraint :: Length ( 10 ) ] )
89+ . split ( chunks[ 0 ] ) ;
90+
91+ let mut status_spans = Vec :: new ( ) ;
92+
93+ let caps_text = if show_caps { "CAPS" } else { "" } ;
94+ if pressed_keys. contains ( & rdev:: Key :: CapsLock ) {
95+ status_spans. push ( Span :: styled (
96+ caps_text,
97+ Style :: default ( ) . fg ( caps_color) . add_modifier ( Modifier :: BOLD ) ,
98+ ) ) ;
99+ }
100+
101+ // Render Status
102+ f. render_widget (
103+ Paragraph :: new ( Line :: from ( status_spans) ) . alignment ( Alignment :: Right ) ,
104+ status_bar[ 0 ] ,
105+ ) ;
106+
59107 // Render KPS
108+ let kps_text = if show_kps { format ! ( "KPS: {}" , kps) } else { String :: new ( ) } ;
60109 f. render_widget (
61- Paragraph :: new ( format ! ( "KPS: {} " , kps ) )
110+ Paragraph :: new ( kps_text )
62111 . alignment ( Alignment :: Right )
63- . style (
64- Style :: default ( )
65- . fg ( fps_color)
66- . add_modifier ( Modifier :: BOLD ) ,
67- ) ,
68- chunks[ 0 ] ,
112+ . style ( Style :: default ( ) . fg ( fps_color) . add_modifier ( Modifier :: BOLD ) ) ,
113+ status_bar[ 1 ] ,
69114 ) ;
70115
71116 // Render Keyboard Rows
@@ -171,8 +216,3 @@ fn get_highlight(l: usize, env: &Env) -> Color {
171216 } ,
172217 }
173218}
174-
175-
176-
177-
178-
0 commit comments