@@ -10,7 +10,7 @@ import (
1010 "github.com/chriskim06/kubectl-topui/internal/config"
1111 "github.com/chriskim06/kubectl-topui/internal/metrics"
1212 "github.com/chriskim06/kubectl-topui/internal/ui/list"
13- "github.com/muesli/reflow/truncate "
13+ "github.com/chriskim06/kubectl-topui/internal/ui/utils "
1414)
1515
1616type listItem string
@@ -33,12 +33,12 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, item list.Ite
3333 line = ""
3434 } else {
3535 line = line [m .GetOffset ():]
36- line = truncate . StringWithTail (line , uint ( m .Width ()), "…" )
36+ line = utils . Truncate (line , m .Width ())
3737 }
3838 if index == m .Index () {
39- fmt .Fprintf (w , adaptive .Copy ().Background (lipgloss .Color ("245" )).Bold (true ).Render (line ))
39+ fmt .Fprintf (w , utils . Adaptive .Copy ().Background (lipgloss .Color ("245" )).Bold (true ).Render (line ))
4040 } else {
41- fmt .Fprintf (w , adaptive .Copy ().Render (line ))
41+ fmt .Fprintf (w , utils . Adaptive .Copy ().Render (line ))
4242 }
4343}
4444
@@ -62,7 +62,7 @@ func NewList(resource metrics.Resource, conf config.Colors) *List {
6262 conf : conf ,
6363 content : itemList ,
6464 focused : true ,
65- style : border .Copy ().Padding (0 , 1 ),
65+ style : utils . Border .Copy ().Padding (0 , 1 ),
6666 }
6767}
6868
@@ -76,7 +76,7 @@ func (l *List) Update(msg tea.Msg) (List, tea.Cmd) {
7676 case tea.KeyMsg :
7777 l .content , cmd = l .content .Update (msg )
7878 case tickMsg :
79- header , items := tabStrings (msg .m , l .resource )
79+ header , items := utils . TabStrings (msg .m , l .resource )
8080 listItems := []list.Item {}
8181 for _ , item := range items {
8282 listItems = append (listItems , listItem (item ))
@@ -89,9 +89,9 @@ func (l *List) Update(msg tea.Msg) (List, tea.Cmd) {
8989
9090func (l List ) View () string {
9191 if l .focused {
92- l .style .BorderForeground (toColor (string (l .conf .Selected )))
92+ l .style .BorderForeground (utils . ToColor (string (l .conf .Selected )))
9393 } else {
94- l .style .BorderForeground (adaptive .Copy ().GetForeground ())
94+ l .style .BorderForeground (utils . Adaptive .Copy ().GetForeground ())
9595 }
9696 return l .style .Render (l .content .View ())
9797}
0 commit comments