Skip to content

Commit bb79a27

Browse files
committed
Render match
1 parent 1ab1e10 commit bb79a27

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

kittens/choose_files/results.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,25 @@ func (h *Handler) draw_no_matches_message(in_progress bool) {
5454

5555
}
5656

57+
const matching_position_style = "fg=green"
58+
5759
func (h *Handler) draw_matching_result(r ResultItem) {
60+
icon := icon_for(r.abspath, r.dir_entry)
61+
h.lp.MoveCursorHorizontally(1)
62+
p, s, _ := strings.Cut(h.lp.SprintStyled(matching_position_style, " "), " ")
63+
h.lp.QueueWriteString(p)
64+
h.lp.DrawSizedText(icon, loop.SizedText{Scale: 2})
65+
h.lp.QueueWriteString(s)
66+
text := r.text
67+
available_width := (h.screen_size.width - 6) / 2
68+
if wcswidth.Stringwidth(text) > available_width {
69+
text = wcswidth.TruncateToVisualLength(text, available_width-2) + "…"
70+
}
71+
h.render_match_with_positions(text, len(r.text), r.positions, 2)
5872
}
5973

6074
func (h *Handler) render_match_with_positions(text string, stop_at int, positions []int, scale int) {
61-
prefix, suffix, _ := strings.Cut(h.lp.SprintStyled("fg=green", " "), " ")
75+
prefix, suffix, _ := strings.Cut(h.lp.SprintStyled(matching_position_style, " "), " ")
6276
write_chunk := func(text string, emphasize bool) {
6377
if text == "" {
6478
return

0 commit comments

Comments
 (0)