@@ -2,6 +2,7 @@ package choose_files
22
33import (
44 "fmt"
5+ "math"
56 "os"
67 "path/filepath"
78 "strings"
@@ -173,6 +174,29 @@ func (h *Handler) draw_list_of_results(matches []*ResultItem, y, height int) int
173174 return num_cols
174175}
175176
177+ func (h * Handler ) draw_num_of_matches (num_shown , y int ) {
178+ m := ""
179+ switch h .state .num_of_matches_at_last_render {
180+ case 0 :
181+ m = " no matches "
182+ default :
183+ m = fmt .Sprintf (" %d of %d matches " , num_shown , h .state .num_of_matches_at_last_render )
184+ }
185+ w := int (math .Ceil (float64 (wcswidth .Stringwidth (m )) / 2.0 ))
186+ h .lp .MoveCursorTo (h .screen_size .width - w - 2 , y )
187+ st := loop.SizedText {Subscale_denominator : 2 , Subscale_numerator : 1 , Vertical_alignment : 2 , Width : 1 }
188+ graphemes := wcswidth .SplitIntoGraphemes (m )
189+ for len (graphemes ) > 0 {
190+ s := ""
191+ for w := 0 ; w < 2 && len (graphemes ) > 0 ; {
192+ w += wcswidth .Stringwidth (graphemes [0 ])
193+ s += graphemes [0 ]
194+ graphemes = graphemes [1 :]
195+ }
196+ h .lp .DrawSizedText (s , st )
197+ }
198+ }
199+
176200func (h * Handler ) draw_results (y , bottom_margin int , matches []* ResultItem , in_progress bool ) (height int ) {
177201 height = h .screen_size .height - y - bottom_margin
178202 h .lp .MoveCursorTo (1 , 1 + y )
@@ -190,16 +214,7 @@ func (h *Handler) draw_results(y, bottom_margin int, matches []*ResultItem, in_p
190214 num_cols = h .draw_list_of_results (matches , y , h .state .num_of_slots_per_column_at_last_render )
191215 }
192216 h .state .num_of_matches_at_last_render = len (matches )
193- m := ""
194- switch h .state .num_of_matches_at_last_render {
195- case 0 :
196- m = " no matches "
197- default :
198- m = fmt .Sprintf (" %d of %d matches " , h .state .num_of_slots_per_column_at_last_render * num_cols , h .state .num_of_matches_at_last_render )
199- }
200- w := wcswidth .Stringwidth (m )
201- h .lp .MoveCursorTo (h .screen_size .width - w - 2 , y + height - 2 )
202- h .lp .PrintStyled ("dim" , m )
217+ h .draw_num_of_matches (h .state .num_of_slots_per_column_at_last_render * num_cols , y + height - 2 )
203218 return
204219}
205220
0 commit comments