summaryrefslogtreecommitdiffstats
path: root/src/hci/mucurses
diff options
context:
space:
mode:
authorMichael Brown2006-12-20 04:41:55 +0100
committerMichael Brown2006-12-20 04:41:55 +0100
commitc66b99272f58a91806b9f52540d1f3135c532ec7 (patch)
tree69618fb9b753b5f5ee91390896b33142e8352b87 /src/hci/mucurses
parentSplit error-message table portions of errno.h out to gpxe/errortab.h (diff)
downloadipxe-c66b99272f58a91806b9f52540d1f3135c532ec7.tar.gz
ipxe-c66b99272f58a91806b9f52540d1f3135c532ec7.tar.xz
ipxe-c66b99272f58a91806b9f52540d1f3135c532ec7.zip
Fix (hopefully) the scrolling logic
Diffstat (limited to 'src/hci/mucurses')
-rw-r--r--src/hci/mucurses/widgets/editbox.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/hci/mucurses/widgets/editbox.c b/src/hci/mucurses/widgets/editbox.c
index ef65df3b..5c066fda 100644
--- a/src/hci/mucurses/widgets/editbox.c
+++ b/src/hci/mucurses/widgets/editbox.c
@@ -62,31 +62,31 @@ void init_editbox ( struct edit_box *box, char *buf, size_t len,
void draw_editbox ( struct edit_box *box ) {
size_t width = box->width;
char buf[ width + 1 ];
- size_t keep_len;
- signed int cursor_offset, underflow, overflow;
+ signed int cursor_offset, underflow, overflow, first;
size_t len;
/* Adjust starting offset so that cursor remains within box */
cursor_offset = ( box->string.cursor - box->first );
- keep_len = strlen ( box->string.buf );
- if ( keep_len > EDITBOX_MIN_CHARS )
- keep_len = EDITBOX_MIN_CHARS;
- underflow = ( keep_len - cursor_offset );
+ underflow = ( EDITBOX_MIN_CHARS - cursor_offset );
overflow = ( cursor_offset - ( width - 1 ) );
+ first = box->first;
if ( underflow > 0 ) {
- box->first -= underflow;
+ first -= underflow;
+ if ( first < 0 )
+ first = 0;
} else if ( overflow > 0 ) {
- box->first += overflow;
+ first += overflow;
}
- cursor_offset = ( box->string.cursor - box->first );
+ box->first = first;
+ cursor_offset = ( box->string.cursor - first );
/* Construct underscore-padded string portion */
memset ( buf, '_', width );
buf[width] = '\0';
- len = ( strlen ( box->string.buf ) - box->first );
+ len = ( strlen ( box->string.buf ) - first );
if ( len > width )
len = width;
- memcpy ( buf, ( box->string.buf + box->first ), len );
+ memcpy ( buf, ( box->string.buf + first ), len );
/* Print box content and move cursor */
if ( ! box->win )