CLI Widget
This commit is contained in:
@@ -112,7 +112,7 @@ func (w *AbsoluteLayout) Draw(screen tcell.Screen) {
|
|||||||
a = w.defAnchor
|
a = w.defAnchor
|
||||||
}
|
}
|
||||||
midX := (w.x + (w.x + w.w)) / 2
|
midX := (w.x + (w.x + w.w)) / 2
|
||||||
midY := (w.y + (w.y + w.h)) / 2
|
// midY := (w.y + (w.y + w.h)) / 2
|
||||||
switch a {
|
switch a {
|
||||||
case AnchorTL:
|
case AnchorTL:
|
||||||
w.widgets[i].SetPos(p.Add(Coord{X: w.x, Y: w.y}))
|
w.widgets[i].SetPos(p.Add(Coord{X: w.x, Y: w.y}))
|
||||||
|
|||||||
7
cli.go
7
cli.go
@@ -62,6 +62,7 @@ func NewCli(id string, s tcell.Style) *Cli {
|
|||||||
|
|
||||||
func (w *Cli) Init(id string, s tcell.Style) {
|
func (w *Cli) Init(id string, s tcell.Style) {
|
||||||
w.id, w.style = id, s
|
w.id, w.style = id, s
|
||||||
|
w.visible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Cli) Id() string { return w.id }
|
func (w *Cli) Id() string { return w.id }
|
||||||
@@ -179,7 +180,7 @@ func (w *Cli) Draw(screen tcell.Screen) {
|
|||||||
}
|
}
|
||||||
dStyle := w.style
|
dStyle := w.style
|
||||||
if !w.active {
|
if !w.active {
|
||||||
w.style = dStyle.Dim(true)
|
dStyle = dStyle.Dim(true)
|
||||||
}
|
}
|
||||||
h.Border(w.x, w.y, w.x+w.w-1, w.y+w.h, h.BRD_SIMPLE, dStyle, screen)
|
h.Border(w.x, w.y, w.x+w.w-1, w.y+w.h, h.BRD_SIMPLE, dStyle, screen)
|
||||||
x, y := w.x+1, w.y+1+w.h-3
|
x, y := w.x+1, w.y+1+w.h-3
|
||||||
@@ -189,7 +190,7 @@ func (w *Cli) Draw(screen tcell.Screen) {
|
|||||||
if len(line) > w.w-2 {
|
if len(line) > w.w-2 {
|
||||||
line = line[:w.w-2]
|
line = line[:w.w-2]
|
||||||
}
|
}
|
||||||
h.DrawText(x, y, line, dStyle, screen)
|
h.DrawText(x, y, h.PadR(line, w.w), dStyle, screen)
|
||||||
y--
|
y--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +209,7 @@ func (w *Cli) Draw(screen tcell.Screen) {
|
|||||||
x += len(pre)
|
x += len(pre)
|
||||||
h.DrawText(x, y, cursor, dStyle.Reverse(w.active), screen)
|
h.DrawText(x, y, cursor, dStyle.Reverse(w.active), screen)
|
||||||
x += 1
|
x += 1
|
||||||
h.DrawText(x, y, post, dStyle, screen)
|
h.DrawText(x, y, h.PadR(post, w.w-x), dStyle, screen)
|
||||||
// x += len(post) - 1
|
// x += len(post) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user