From 37982493c266d9912dd2192b510a31b0f44d5d29 Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Mon, 18 Aug 2003 05:27:13 +0000 Subject: [PATCH] Smarter jumpscroll. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3931 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-player.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index bbb157a94f..3344a7478a 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c @@ -626,12 +626,27 @@ static void scroll_thread(void) int jumping_scroll=s->jump_scroll; update = true; if (s->jump_scroll) { - s->offset+=s->jump_scroll_steps; + + /* Find new position to start jump scroll by + * finding last white space within + * jump_scroll_steps */ + int i; + o = s->offset = s->offset + s->jump_scroll_steps; + for (i = 0; i < s->jump_scroll_steps; i++, o--) { + if (o < s->textlen && + ((0x20 <= s->text[o] && s->text[o] <= 0x2f) || s->text[o] == '_')) + { + s->offset = o; + break; + } + } + s->scroll_start_tick = current_tick + jump_scroll_delay; /* Eat space */ while (s->offset < s->textlen && - s->text[s->offset] == ' ') { + ((0x20 <= s->text[s->offset] && s->text[s->offset] <= 0x2f) || + s->text[s->offset] == '_')) { s->offset++; } if (s->offset >= s->textlen) { @@ -667,7 +682,7 @@ static void scroll_thread(void) o=s->offset; while (i<11) { buffer[i++]=s->text[o++]; - if (o==s->textlen) + if (o==s->textlen /* || (jump_scroll && buffer[i-1] == ' ') */) break; } o=0;