mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 09:18:08 +02:00
...
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"kitty/tools/tui/loop"
|
"kitty/tools/tui/loop"
|
||||||
"kitty/tools/tui/readline"
|
"kitty/tools/tui/readline"
|
||||||
"kitty/tools/utils"
|
"kitty/tools/utils"
|
||||||
|
"kitty/tools/wcswidth"
|
||||||
|
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
)
|
)
|
||||||
@@ -61,8 +62,29 @@ func (h *handler) draw_search_bar() {
|
|||||||
|
|
||||||
const SEPARATOR = "║"
|
const SEPARATOR = "║"
|
||||||
|
|
||||||
func (h *handler) draw_family_summary() (err error) {
|
func center_string(x string, width int) string {
|
||||||
// TODO: Implement me
|
l := wcswidth.Stringwidth(x)
|
||||||
|
spaces := int(float64(width-l) / 2)
|
||||||
|
return strings.Repeat(" ", utils.Max(0, spaces)) + x
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *handler) draw_family_summary(start_x int, sz loop.ScreenSize) (err error) {
|
||||||
|
family := h.family_list.CurrentFamily()
|
||||||
|
if family == "" || int(sz.WidthCells) < start_x+2 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
lines := []string{
|
||||||
|
h.lp.SprintStyled("fg=green bold", center_string(family, int(sz.WidthCells)-start_x)),
|
||||||
|
"",
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, line := range lines {
|
||||||
|
if i >= int(sz.HeightCells)-1 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
h.lp.MoveCursorTo(start_x+1, i+1)
|
||||||
|
h.lp.QueueWriteString(line)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +115,7 @@ func (h *handler) draw_listing_screen() (err error) {
|
|||||||
h.lp.Println(SEPARATOR)
|
h.lp.Println(SEPARATOR)
|
||||||
}
|
}
|
||||||
if h.family_list.Len() > 0 {
|
if h.family_list.Len() > 0 {
|
||||||
if err = h.draw_family_summary(); err != nil {
|
if err = h.draw_family_summary(mw+2, sz); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user