@@ -47,8 +47,7 @@ pub fn render(state: &mut State, frame: &mut Frame) {
47
47
frame. area ( ) ,
48
48
) ;
49
49
50
- let rects = Layout :: vertical ( [ Constraint :: Percentage ( 100 ) , Constraint :: Min ( 3 ) ] )
51
- . margin ( 1 )
50
+ let rects = Layout :: vertical ( [ Constraint :: Percentage ( 100 ) , Constraint :: Min ( 1 ) ] )
52
51
. split ( frame. area ( ) ) ;
53
52
render_key_bindings ( frame, rects[ 1 ] ) ;
54
53
@@ -93,13 +92,6 @@ fn render_key_bindings(frame: &mut Frame, rect: Rect) {
93
92
. collect :: < Vec < Span > > ( ) ,
94
93
)
95
94
. alignment ( Alignment :: Center ) ,
96
- )
97
- . block (
98
- Block :: bordered ( )
99
- . title_bottom ( Line :: from ( format ! ( "|{}|" , env!( "CARGO_PKG_VERSION" ) ) ) )
100
- . title_alignment ( Alignment :: Right )
101
- . border_type ( BorderType :: Rounded )
102
- . border_style ( Style :: default ( ) . fg ( Color :: Rgb ( 100 , 100 , 100 ) ) ) ,
103
95
) ,
104
96
rect,
105
97
) ;
@@ -115,46 +107,39 @@ fn render_list(state: &mut State, frame: &mut Frame, rect: Rect) {
115
107
rect,
116
108
) ;
117
109
if !state. configs . is_empty ( ) {
118
- let item_count = ( ( rect. height - 2 ) / 3 ) as usize ;
110
+ let rect =
111
+ Layout :: vertical ( [ Constraint :: Min ( 1 ) , Constraint :: Percentage ( 100 ) ] )
112
+ . split ( rect) [ 1 ] ;
113
+ let borders_line = 2 ;
114
+ let item_count = ( rect. height - borders_line) as usize ;
119
115
let start_offset = ( state. selected_index + 1 ) . saturating_sub ( item_count) ;
120
- let rects = Layout :: vertical ( [ Constraint :: Min ( 2 ) ] . repeat ( item_count) )
121
- . margin ( 1 )
122
- . split ( rect) ;
116
+ let rects =
117
+ Layout :: vertical ( [ Constraint :: Length ( 1 ) ] . repeat ( item_count) ) . split ( rect) ;
123
118
for ( i, config) in state
124
119
. configs
125
120
. iter_mut ( )
126
121
. skip ( start_offset)
127
122
. take ( item_count)
128
123
. enumerate ( )
129
124
{
130
- config. area = rects[ i] ;
131
- frame. render_widget (
132
- Block :: bordered ( )
133
- . border_type ( BorderType :: Rounded )
134
- . border_style ( {
135
- let mut style = Style :: new ( ) . fg ( Color :: Rgb ( 100 , 100 , 100 ) ) ;
136
- if config. is_hovered {
137
- style = style. yellow ( )
138
- } else if state. selected_index == i + start_offset {
139
- style = style. yellow ( ) ;
140
- }
141
- style
142
- } ) ,
143
- rects[ i] ,
144
- ) ;
125
+ let mut style = Style :: new ( ) ;
126
+ if config. is_hovered {
127
+ style = style. yellow ( )
128
+ } else if state. selected_index == i + start_offset {
129
+ style = style. yellow ( ) ;
130
+ }
145
131
let item = Layout :: horizontal ( [
146
132
Constraint :: Min ( 1 ) ,
147
133
Constraint :: Percentage ( 100 ) ,
148
134
] )
149
- . margin ( 1 )
150
135
. split ( rects[ i] ) ;
151
-
136
+ config . area = rects [ i ] ;
152
137
frame. render_widget (
153
- Paragraph :: new ( Line :: from ( config. file . clone ( ) ) ) ,
138
+ Paragraph :: new ( Line :: from ( config. file . clone ( ) ) . style ( style ) ) ,
154
139
item[ 1 ] ,
155
140
) ;
156
141
}
157
- if state. configs . len ( ) * 3 > rect. height as usize - 2 {
142
+ if state. configs . len ( ) > rect. height as usize - 2 {
158
143
frame. render_stateful_widget (
159
144
Scrollbar :: new ( ScrollbarOrientation :: VerticalRight )
160
145
. begin_symbol ( Some ( "↑" ) )
@@ -232,7 +217,11 @@ fn render_changelog(state: &mut State, frame: &mut Frame, rect: Rect) {
232
217
. left_aligned ( ) ,
233
218
)
234
219
. border_type ( BorderType :: Rounded )
235
- . border_style ( Style :: default ( ) . fg ( Color :: Rgb ( 100 , 100 , 100 ) ) ) ,
220
+ . border_style ( Style :: default ( ) . fg ( Color :: Rgb ( 100 , 100 , 100 ) ) )
221
+ . title_bottom (
222
+ Line :: from ( format ! ( "|{}|" , env!( "CARGO_PKG_VERSION" ) ) )
223
+ . right_aligned ( ) ,
224
+ ) ,
236
225
rect,
237
226
) ;
238
227
if let Some ( component) = & mut state. markdown . component {
0 commit comments