@@ -262,9 +262,9 @@ fn draw_footer(frame: &mut Frame, area: Rect, app: &mut App) {
262
262
help. push ( ": Apply " . dim ( ) ) ;
263
263
}
264
264
help. push ( "o : Set Env " . dim ( ) ) ;
265
- help. push ( "Ctrl+N" . dim ( ) ) ;
266
- help. push ( format ! ( ": Attempts {}x " , app. best_of_n) . dim ( ) ) ;
267
265
if app. new_task . is_some ( ) {
266
+ help. push ( "Ctrl+N" . dim ( ) ) ;
267
+ help. push ( format ! ( ": Attempts {}x " , app. best_of_n) . dim ( ) ) ;
268
268
help. push ( "(editing new task) " . dim ( ) ) ;
269
269
} else {
270
270
help. push ( "n : New Task " . dim ( ) ) ;
@@ -1004,32 +1004,40 @@ pub fn draw_best_of_modal(frame: &mut Frame, area: Rect, app: &mut App) {
1004
1004
use ratatui:: widgets:: Wrap ;
1005
1005
1006
1006
let inner = overlay_outer ( area) ;
1007
+ const MAX_WIDTH : u16 = 40 ;
1008
+ const MIN_WIDTH : u16 = 20 ;
1009
+ const MAX_HEIGHT : u16 = 12 ;
1010
+ const MIN_HEIGHT : u16 = 6 ;
1011
+ let modal_width = inner. width . min ( MAX_WIDTH ) . max ( inner. width . min ( MIN_WIDTH ) ) ;
1012
+ let modal_height = inner
1013
+ . height
1014
+ . min ( MAX_HEIGHT )
1015
+ . max ( inner. height . min ( MIN_HEIGHT ) ) ;
1016
+ let modal_x = inner. x + ( inner. width . saturating_sub ( modal_width) ) / 2 ;
1017
+ let modal_y = inner. y + ( inner. height . saturating_sub ( modal_height) ) / 2 ;
1018
+ let modal_area = Rect :: new ( modal_x, modal_y, modal_width, modal_height) ;
1007
1019
let title = Line :: from ( vec ! [ "Parallel Attempts" . magenta( ) . bold( ) ] ) ;
1008
1020
let block = overlay_block ( ) . title ( title) ;
1009
1021
1010
- frame. render_widget ( Clear , inner ) ;
1011
- frame. render_widget ( block. clone ( ) , inner ) ;
1012
- let content = overlay_content ( inner ) ;
1022
+ frame. render_widget ( Clear , modal_area ) ;
1023
+ frame. render_widget ( block. clone ( ) , modal_area ) ;
1024
+ let content = overlay_content ( modal_area ) ;
1013
1025
1014
1026
let rows = Layout :: default ( )
1015
1027
. direction ( Direction :: Vertical )
1016
1028
. constraints ( [ Constraint :: Length ( 2 ) , Constraint :: Min ( 1 ) ] )
1017
1029
. split ( content) ;
1018
1030
1019
- let hint = Paragraph :: new ( Line :: from (
1020
- "Use ↑/↓ to choose, 1-4 jump; Enter confirm, Esc cancel"
1021
- . cyan ( )
1022
- . dim ( ) ,
1023
- ) )
1024
- . wrap ( Wrap { trim : true } ) ;
1031
+ let hint = Paragraph :: new ( Line :: from ( "Use ↑/↓ to choose, 1-4 jump" . cyan ( ) . dim ( ) ) )
1032
+ . wrap ( Wrap { trim : true } ) ;
1025
1033
frame. render_widget ( hint, rows[ 0 ] ) ;
1026
1034
1027
1035
let selected = app. best_of_modal . as_ref ( ) . map ( |m| m. selected ) . unwrap_or ( 0 ) ;
1028
1036
let options = [ 1usize , 2 , 3 , 4 ] ;
1029
1037
let mut items: Vec < ListItem > = Vec :: new ( ) ;
1030
1038
for & attempts in & options {
1031
- let mut spans : Vec < ratatui :: text :: Span > =
1032
- vec ! [ format!( "{attempts} attempt{}" , if attempts == 1 { "" } else { "s" } ) . into( ) ] ;
1039
+ let noun = if attempts == 1 { "attempt" } else { "attempts" } ;
1040
+ let mut spans : Vec < ratatui :: text :: Span > = vec ! [ format!( "{attempts} {noun:<8}" ) . into( ) ] ;
1033
1041
spans. push ( " " . into ( ) ) ;
1034
1042
spans. push ( format ! ( "{attempts}x parallel" ) . dim ( ) ) ;
1035
1043
if attempts == app. best_of_n {
0 commit comments