mudgangster

Log | Files | Refs

commit e2e974c201e4d12a2c4f903207d6cc714668911c
parent 00b4d515a6204c571a3bc808b02b836b8a39c002
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat,  8 Sep 2018 12:08:55 +0300

Textbox fix

Diffstat:
src/textbox.cc | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/textbox.cc b/src/textbox.cc @@ -34,6 +34,7 @@ static void unpack_style( uint8_t style, int * fg, int * bg, int * bold ) { void textbox_init( TextBox * tb, size_t scrollback ) { // TODO: this is kinda crap + *tb = { }; tb->lines = ( TextBox::Line * ) calloc( sizeof( TextBox::Line ), scrollback ); tb->num_lines = 1; tb->max_lines = scrollback; @@ -69,7 +70,8 @@ void textbox_newline( TextBox * tb ) { } tb->head++; - tb->scroll_offset = min( tb->scroll_offset + 1, tb->num_lines - 1 ); + if( tb->scroll_offset > 0 ) + tb->scroll_offset = min( tb->scroll_offset + 1, tb->num_lines - 1 ); tb->dirty = true; TextBox::Line * line = &tb->lines[ ( tb->head + tb->num_lines ) % tb->max_lines ];