Skip to content

Commit

Permalink
Extract MetaCol
Browse files Browse the repository at this point in the history
  • Loading branch information
stokito committed Dec 11, 2020
1 parent cdcb8b6 commit 9545dfb
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions cwidgets/compact/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,28 @@ import (
ui "github.com/gizak/termui"
)

type NameCol struct {
// Column that shows container's meta property i.e. name, id, image tc.
type MetaCol struct {
*TextCol
metaName string
}

func (w *MetaCol) SetMeta(m models.Meta) {
w.setText(m.Get(w.metaName))
}

func NewNameCol() CompactCol {
c := &NameCol{NewTextCol("NAME")}
c := &MetaCol{NewTextCol("NAME"), "name"}
c.fWidth = 30
return c
}

func (w *NameCol) SetMeta(m models.Meta) {
w.setText(m.Get("name"))
}

type CIDCol struct {
*TextCol
}

func NewCIDCol() CompactCol {
c := &CIDCol{NewTextCol("CID")}
c := &MetaCol{NewTextCol("CID"), "id"}
c.fWidth = 12
return c
}

func (w *CIDCol) SetMeta(m models.Meta) {
w.setText(m.Get("id"))
}

type NetCol struct {
*TextCol
}
Expand Down

0 comments on commit 9545dfb

Please sign in to comment.