From 4b7d3032c8c7bf50e0f6ab262ec9ae6195483415 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Tue, 12 May 2015 16:05:47 -0500 Subject: [PATCH] Some Tweaking --- termbox_inputmodal.go | 2 +- termbox_util.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/termbox_inputmodal.go b/termbox_inputmodal.go index 4928b5a..239b2a9 100644 --- a/termbox_inputmodal.go +++ b/termbox_inputmodal.go @@ -136,7 +136,7 @@ func (i *InputModal) Draw() { } if i.text != "" { 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.Draw() diff --git a/termbox_util.go b/termbox_util.go index 01b39d3..0041990 100644 --- a/termbox_util.go +++ b/termbox_util.go @@ -49,10 +49,14 @@ func AlignText(txt string, width int, align TextAlignment) string { num_spaces := width - len(txt) switch align { case ALIGN_CENTER: - return fmt.Sprintf("%s%s%s", - strings.Repeat(" ", num_spaces/2), - txt, strings.Repeat(" ", num_spaces/2), - ) + if num_spaces/2 > 0 { + return fmt.Sprintf("%s%s%s", + strings.Repeat(" ", num_spaces/2), + txt, strings.Repeat(" ", num_spaces/2), + ) + } else { + return txt + } case ALIGN_RIGHT: return fmt.Sprintf("%s%s", strings.Repeat(" ", num_spaces), txt) default: