1
0
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:
Brian Buller 2015-05-12 16:05:47 -05:00
parent c581974cc0
commit 4b7d3032c8
2 changed files with 9 additions and 5 deletions

View File

@ -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()

View File

@ -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:
if num_spaces/2 > 0 {
return fmt.Sprintf("%s%s%s", return fmt.Sprintf("%s%s%s",
strings.Repeat(" ", num_spaces/2), strings.Repeat(" ", num_spaces/2),
txt, 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: