@@ -18,7 +18,7 @@ use crate::THEME;
18
18
#[ derive( Default , Debug , Clone ) ]
19
19
pub struct ChartConfigurationState {
20
20
pub input : Input ,
21
- pub selection : Option < Selection > ,
21
+ pub selection : Option < KagiSelection > ,
22
22
pub error_message : Option < String > ,
23
23
pub kagi_options : KagiOptions ,
24
24
pub cache_state : CacheState ,
@@ -27,7 +27,7 @@ pub struct ChartConfigurationState {
27
27
impl ChartConfigurationState {
28
28
pub fn add_char ( & mut self , c : char ) {
29
29
let input_field = match self . selection {
30
- Some ( Selection :: KagiReversalValue ) => & mut self . input . kagi_reversal_value ,
30
+ Some ( KagiSelection :: ReversalValue ) => & mut self . input . kagi_reversal_value ,
31
31
_ => return ,
32
32
} ;
33
33
@@ -41,7 +41,7 @@ impl ChartConfigurationState {
41
41
42
42
pub fn del_char ( & mut self ) {
43
43
let input_field = match self . selection {
44
- Some ( Selection :: KagiReversalValue ) => & mut self . input . kagi_reversal_value ,
44
+ Some ( KagiSelection :: ReversalValue ) => & mut self . input . kagi_reversal_value ,
45
45
_ => return ,
46
46
} ;
47
47
@@ -50,14 +50,14 @@ impl ChartConfigurationState {
50
50
51
51
fn get_tab_artifacts ( & mut self ) -> Option < ( & mut usize , usize ) > {
52
52
let tab_field = match self . selection {
53
- Some ( Selection :: KagiReversalType ) => & mut self . input . kagi_reversal_type ,
54
- Some ( Selection :: KagiPriceType ) => & mut self . input . kagi_price_type ,
53
+ Some ( KagiSelection :: ReversalType ) => & mut self . input . kagi_reversal_type ,
54
+ Some ( KagiSelection :: PriceType ) => & mut self . input . kagi_price_type ,
55
55
_ => return None ,
56
56
} ;
57
57
58
58
let mod_value = match self . selection {
59
- Some ( Selection :: KagiReversalType ) => 2 ,
60
- Some ( Selection :: KagiPriceType ) => 2 ,
59
+ Some ( KagiSelection :: ReversalType ) => 2 ,
60
+ Some ( KagiSelection :: PriceType ) => 2 ,
61
61
_ => 1 ,
62
62
} ;
63
63
Some ( ( tab_field, mod_value) )
@@ -155,21 +155,21 @@ impl ChartConfigurationState {
155
155
156
156
pub fn selection_up ( & mut self ) {
157
157
let new_selection = match self . selection {
158
- None => Selection :: KagiReversalValue ,
159
- Some ( Selection :: KagiReversalValue ) => Selection :: KagiReversalType ,
160
- Some ( Selection :: KagiReversalType ) => Selection :: KagiPriceType ,
161
- Some ( Selection :: KagiPriceType ) => Selection :: KagiReversalValue ,
158
+ None => KagiSelection :: ReversalValue ,
159
+ Some ( KagiSelection :: ReversalValue ) => KagiSelection :: ReversalType ,
160
+ Some ( KagiSelection :: ReversalType ) => KagiSelection :: PriceType ,
161
+ Some ( KagiSelection :: PriceType ) => KagiSelection :: ReversalValue ,
162
162
} ;
163
163
164
164
self . selection = Some ( new_selection) ;
165
165
}
166
166
167
167
pub fn selection_down ( & mut self ) {
168
168
let new_selection = match self . selection {
169
- None => Selection :: KagiPriceType ,
170
- Some ( Selection :: KagiPriceType ) => Selection :: KagiReversalType ,
171
- Some ( Selection :: KagiReversalType ) => Selection :: KagiReversalValue ,
172
- Some ( Selection :: KagiReversalValue ) => Selection :: KagiPriceType ,
169
+ None => KagiSelection :: PriceType ,
170
+ Some ( KagiSelection :: PriceType ) => KagiSelection :: ReversalType ,
171
+ Some ( KagiSelection :: ReversalType ) => KagiSelection :: ReversalValue ,
172
+ Some ( KagiSelection :: ReversalValue ) => KagiSelection :: PriceType ,
173
173
} ;
174
174
175
175
self . selection = Some ( new_selection) ;
@@ -213,7 +213,7 @@ impl ChartConfigurationState {
213
213
} )
214
214
. unwrap_or ( 0 ) ;
215
215
216
- self . selection = Some ( Selection :: KagiPriceType ) ;
216
+ self . selection = Some ( KagiSelection :: PriceType ) ;
217
217
self . input . kagi_reversal_value = format ! ( "{:.2}" , reversal_amount) ;
218
218
self . input . kagi_reversal_type = reversal_type;
219
219
self . input . kagi_price_type = price_type;
@@ -252,10 +252,10 @@ pub enum KagiReversalOption {
252
252
}
253
253
254
254
#[ derive( Debug , Clone , Copy , Hash , PartialEq , Eq ) ]
255
- pub enum Selection {
256
- KagiPriceType ,
257
- KagiReversalType ,
258
- KagiReversalValue ,
255
+ pub enum KagiSelection {
256
+ PriceType ,
257
+ ReversalType ,
258
+ ReversalValue ,
259
259
}
260
260
261
261
pub struct ChartConfigurationWidget {
@@ -358,7 +358,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
358
358
Spans :: default ( ) ,
359
359
Spans :: from( vec![
360
360
Span :: styled(
361
- if state. selection == Some ( Selection :: KagiPriceType ) {
361
+ if state. selection == Some ( KagiSelection :: PriceType ) {
362
362
"> "
363
363
} else {
364
364
" "
@@ -370,7 +370,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
370
370
Spans :: default ( ) ,
371
371
Spans :: from( vec![
372
372
Span :: styled(
373
- if state. selection == Some ( Selection :: KagiReversalType ) {
373
+ if state. selection == Some ( KagiSelection :: ReversalType ) {
374
374
"> "
375
375
} else {
376
376
" "
@@ -382,7 +382,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
382
382
Spans :: default ( ) ,
383
383
Spans :: from( vec![
384
384
Span :: styled(
385
- if state. selection == Some ( Selection :: KagiReversalValue ) {
385
+ if state. selection == Some ( KagiSelection :: ReversalValue ) {
386
386
"> "
387
387
} else {
388
388
" "
@@ -400,7 +400,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
400
400
"Close" ,
401
401
style( ) . fg( THEME . text_normal( ) ) . bg(
402
402
match ( state. selection, state. input. kagi_price_type) {
403
- ( Some ( Selection :: KagiPriceType ) , 0 ) => THEME . highlight_focused( ) ,
403
+ ( Some ( KagiSelection :: PriceType ) , 0 ) => THEME . highlight_focused( ) ,
404
404
( _, 0 ) => THEME . highlight_unfocused( ) ,
405
405
( _, _) => THEME . background( ) ,
406
406
} ,
@@ -411,7 +411,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
411
411
"High / Low" ,
412
412
style( ) . fg( THEME . text_normal( ) ) . bg(
413
413
match ( state. selection, state. input. kagi_price_type) {
414
- ( Some ( Selection :: KagiPriceType ) , 1 ) => THEME . highlight_focused( ) ,
414
+ ( Some ( KagiSelection :: PriceType ) , 1 ) => THEME . highlight_focused( ) ,
415
415
( _, 1 ) => THEME . highlight_unfocused( ) ,
416
416
( _, _) => THEME . background( ) ,
417
417
} ,
@@ -424,7 +424,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
424
424
"Pct" ,
425
425
style( ) . fg( THEME . text_normal( ) ) . bg(
426
426
match ( state. selection, state. input. kagi_reversal_type) {
427
- ( Some ( Selection :: KagiReversalType ) , 0 ) => THEME . highlight_focused( ) ,
427
+ ( Some ( KagiSelection :: ReversalType ) , 0 ) => THEME . highlight_focused( ) ,
428
428
( _, 0 ) => THEME . highlight_unfocused( ) ,
429
429
( _, _) => THEME . background( ) ,
430
430
} ,
@@ -435,7 +435,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
435
435
"Amount" ,
436
436
style( ) . fg( THEME . text_normal( ) ) . bg(
437
437
match ( state. selection, state. input. kagi_reversal_type) {
438
- ( Some ( Selection :: KagiReversalType ) , 1 ) => THEME . highlight_focused( ) ,
438
+ ( Some ( KagiSelection :: ReversalType ) , 1 ) => THEME . highlight_focused( ) ,
439
439
( _, 1 ) => THEME . highlight_unfocused( ) ,
440
440
( _, _) => THEME . background( ) ,
441
441
} ,
@@ -446,12 +446,12 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
446
446
Spans :: from( vec![ Span :: styled(
447
447
format!( "{: <22}" , & state. input. kagi_reversal_value) ,
448
448
style( )
449
- . fg( if state. selection == Some ( Selection :: KagiReversalValue ) {
449
+ . fg( if state. selection == Some ( KagiSelection :: ReversalValue ) {
450
450
THEME . text_secondary( )
451
451
} else {
452
452
THEME . text_normal( )
453
453
} )
454
- . bg( if state. selection == Some ( Selection :: KagiReversalValue ) {
454
+ . bg( if state. selection == Some ( KagiSelection :: ReversalValue ) {
455
455
THEME . highlight_unfocused( )
456
456
} else {
457
457
THEME . background( )
@@ -468,7 +468,7 @@ fn render_kagi_options(mut area: Rect, buf: &mut Buffer, state: &mut ChartConfig
468
468
. render ( layout[ 2 ] , buf) ;
469
469
470
470
// Set "cursor" color
471
- if matches ! ( state. selection, Some ( Selection :: KagiReversalValue ) ) {
471
+ if matches ! ( state. selection, Some ( KagiSelection :: ReversalValue ) ) {
472
472
let size = terminal:: size ( ) . unwrap_or ( ( 0 , 0 ) ) ;
473
473
474
474
let x = layout[ 2 ] . left ( ) as usize + state. input . kagi_reversal_value . len ( ) . min ( 20 ) ;
0 commit comments