@@ -45,14 +45,20 @@ impl DrawableComponent for SelectBranchComponent {
45
45
// Render a scrolllist of branches inside a box
46
46
47
47
if self . visible {
48
- const SIZE : ( u16 , u16 ) = ( 50 , 20 ) ;
49
- let scroll_threshold = SIZE . 1 / 3 ;
48
+ const PERCENT_SIZE : ( u16 , u16 ) = ( 60 , 25 ) ;
49
+ const MIN_SIZE : ( u16 , u16 ) = ( 50 , 20 ) ;
50
+
51
+ let area = ui:: centered_rect (
52
+ PERCENT_SIZE . 0 ,
53
+ PERCENT_SIZE . 1 ,
54
+ f. size ( ) ,
55
+ ) ;
56
+ let area = ui:: rect_min ( MIN_SIZE . 0 , MIN_SIZE . 1 , area) ;
57
+
58
+ let scroll_threshold = area. height / 3 ;
50
59
let scroll =
51
60
self . selection . saturating_sub ( scroll_threshold) ;
52
61
53
- let area =
54
- ui:: centered_rect_absolute ( SIZE . 0 , SIZE . 1 , f. size ( ) ) ;
55
-
56
62
f. render_widget ( Clear , area) ;
57
63
f. render_widget (
58
64
Block :: default ( )
@@ -275,15 +281,17 @@ impl SelectBranchComponent {
275
281
theme : & SharedTheme ,
276
282
width_available : u16 ,
277
283
) -> Result < Text > {
278
- const BRANCH_NAME_LENGTH : usize = 15 ;
279
284
const COMMIT_HASH_LENGTH : usize = 8 ;
280
285
const IS_HEAD_STAR_LENGTH : usize = 3 ; // "* "
281
286
const THREE_DOTS_LENGTH : usize = 3 ; // "..."
282
287
288
+ // branch name = 30% of area size
289
+ let branch_name_length: usize =
290
+ width_available as usize * 30 / 100 ;
283
291
// commit message takes up the remaining width
284
292
let commit_message_length: usize = ( width_available as usize )
285
293
. saturating_sub ( COMMIT_HASH_LENGTH )
286
- . saturating_sub ( BRANCH_NAME_LENGTH )
294
+ . saturating_sub ( branch_name_length )
287
295
. saturating_sub ( IS_HEAD_STAR_LENGTH )
288
296
. saturating_sub ( THREE_DOTS_LENGTH ) ;
289
297
let mut txt = Vec :: new ( ) ;
@@ -301,9 +309,9 @@ impl SelectBranchComponent {
301
309
}
302
310
303
311
let mut branch_name = displaybranch. name . clone ( ) ;
304
- if branch_name. len ( ) > BRANCH_NAME_LENGTH {
312
+ if branch_name. len ( ) > branch_name_length {
305
313
branch_name. truncate (
306
- BRANCH_NAME_LENGTH
314
+ branch_name_length
307
315
. saturating_sub ( THREE_DOTS_LENGTH ) ,
308
316
) ;
309
317
branch_name += "..." ;
@@ -322,7 +330,7 @@ impl SelectBranchComponent {
322
330
format!(
323
331
">{:w$} " ,
324
332
branch_name,
325
- w = BRANCH_NAME_LENGTH
333
+ w = branch_name_length
326
334
) ,
327
335
theme. commit_author( true ) ,
328
336
) ,
@@ -348,7 +356,7 @@ impl SelectBranchComponent {
348
356
format!(
349
357
" {:w$} " ,
350
358
branch_name,
351
- w = BRANCH_NAME_LENGTH
359
+ w = branch_name_length
352
360
) ,
353
361
theme. commit_author( false ) ,
354
362
) ,
0 commit comments