cleaning up

mine
derailed 2019-12-30 15:28:28 -07:00
parent a298ba0d9e
commit 86ccf9b18f
2 changed files with 44 additions and 2 deletions

View File

@ -14,6 +14,7 @@ func initKeys() {
initNumbKeys()
initStdKeys()
initShiftKeys()
initShiftNumKeys()
}
// Defines numeric keys for container actions
@ -164,7 +165,7 @@ func initStdKeys() {
tcell.KeyNames[tcell.Key(KeyZ)] = "z"
}
func initShiftKeys() {
func initShiftNumKeys() {
tcell.KeyNames[tcell.Key(KeyShift0)] = "Shift-0"
tcell.KeyNames[tcell.Key(KeyShift1)] = "Shift-1"
tcell.KeyNames[tcell.Key(KeyShift2)] = "Shift-2"
@ -175,7 +176,9 @@ func initShiftKeys() {
tcell.KeyNames[tcell.Key(KeyShift7)] = "Shift-7"
tcell.KeyNames[tcell.Key(KeyShift8)] = "Shift-8"
tcell.KeyNames[tcell.Key(KeyShift9)] = "Shift-9"
}
func initShiftKeys() {
tcell.KeyNames[tcell.Key(KeyShiftA)] = "Shift-A"
tcell.KeyNames[tcell.Key(KeyShiftB)] = "Shift-B"
tcell.KeyNames[tcell.Key(KeyShiftC)] = "Shift-C"

View File

@ -3,6 +3,8 @@ package ui
import (
"context"
"errors"
"fmt"
"strings"
"github.com/derailed/k9s/internal/config"
"github.com/derailed/k9s/internal/model"
@ -340,9 +342,46 @@ func (t *Table) ShowDeleted() {
// UpdateTitle refreshes the table title.
func (t *Table) UpdateTitle() {
t.SetTitle(t.styleTitle())
}
// UpdateTitle refreshes the table title.
func (t *Table) styleTitle() string {
ns := t.GetModel().GetNamespace()
if ns == render.AllNamespaces {
ns = render.NamespaceAll
}
t.SetTitle(styleTitle(t.GetRowCount(), ns, t.BaseTitle, t.Path, t.cmdBuff.String(), t.styles))
rc := t.GetRowCount()
if rc > 0 {
rc--
}
base, path := strings.Title(t.BaseTitle), t.Path
if ns == render.AllNamespaces {
ns = render.NamespaceAll
}
info := ns
if path != "" {
info = path
cns, n := render.Namespaced(path)
if cns == render.ClusterScope {
info = n
}
}
buff := t.SearchBuff().String()
var title string
if info == "" || info == render.ClusterScope {
title = SkinTitle(fmt.Sprintf(titleFmt, base, rc), t.styles.Frame())
} else {
title = SkinTitle(fmt.Sprintf(nsTitleFmt, base, info, rc), t.styles.Frame())
}
if buff == "" {
return title
}
if IsLabelSelector(buff) {
buff = TrimLabelSelector(buff)
}
return title + SkinTitle(fmt.Sprintf(SearchFmt, buff), t.styles.Frame())
}