diff --git a/uiterm/textbox.go b/uiterm/textbox.go index a7d0d4d..5f97043 100644 --- a/uiterm/textbox.go +++ b/uiterm/textbox.go @@ -7,6 +7,8 @@ import ( "github.com/nsf/termbox-go" ) +const maxTextboxLen = 2000 + type Textbox struct { Text string Fg, Bg Attribute @@ -71,8 +73,10 @@ func (t *Textbox) uiKeyEvent(mod Modifier, key Key) { t.Text = "" redraw = true case KeySpace: - t.Text = t.Text + " " - redraw = true + if len(t.Text) < maxTextboxLen { + t.Text = t.Text + " " + redraw = true + } case KeyBackspace: case KeyBackspace2: if len(t.Text) > 0 { @@ -88,6 +92,9 @@ func (t *Textbox) uiKeyEvent(mod Modifier, key Key) { } func (t *Textbox) uiCharacterEvent(chr rune) { + if len(t.Text) >= maxTextboxLen { + return + } t.Text = t.Text + string(chr) t.uiDraw() }