mirror of
https://github.com/br0xen/termbox-util.git
synced 2024-11-23 05:53:14 +00:00
Some Tweaking
This commit is contained in:
parent
c581974cc0
commit
4b7d3032c8
@ -136,7 +136,7 @@ func (i *InputModal) Draw() {
|
|||||||
}
|
}
|
||||||
if i.text != "" {
|
if i.text != "" {
|
||||||
DrawStringAtPoint(i.text, i.x+1, next_y, i.fg, i.bg)
|
DrawStringAtPoint(i.text, i.x+1, next_y, i.fg, i.bg)
|
||||||
next_y += 2
|
next_y += 1
|
||||||
}
|
}
|
||||||
i.input.SetY(next_y)
|
i.input.SetY(next_y)
|
||||||
i.input.Draw()
|
i.input.Draw()
|
||||||
|
@ -49,10 +49,14 @@ func AlignText(txt string, width int, align TextAlignment) string {
|
|||||||
num_spaces := width - len(txt)
|
num_spaces := width - len(txt)
|
||||||
switch align {
|
switch align {
|
||||||
case ALIGN_CENTER:
|
case ALIGN_CENTER:
|
||||||
return fmt.Sprintf("%s%s%s",
|
if num_spaces/2 > 0 {
|
||||||
strings.Repeat(" ", num_spaces/2),
|
return fmt.Sprintf("%s%s%s",
|
||||||
txt, strings.Repeat(" ", num_spaces/2),
|
strings.Repeat(" ", num_spaces/2),
|
||||||
)
|
txt, strings.Repeat(" ", num_spaces/2),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return txt
|
||||||
|
}
|
||||||
case ALIGN_RIGHT:
|
case ALIGN_RIGHT:
|
||||||
return fmt.Sprintf("%s%s", strings.Repeat(" ", num_spaces), txt)
|
return fmt.Sprintf("%s%s", strings.Repeat(" ", num_spaces), txt)
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user