1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-30 14:09:13 +00:00

$scroll fix for a text length <= length

This fixes $scroll to only scroll when the text length is greater than
the specified length; hopefully without breaking anything.

Signed-off-by: Brenden Matthews <brenden@diddyinc.com>
This commit is contained in:
Ben Kibbey 2010-01-01 14:51:46 -08:00 committed by Brenden Matthews
parent 6e6a1f59e8
commit 87e422c224

View File

@ -60,10 +60,16 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr
sd->step = 1; sd->step = 1;
} }
sd->text = malloc(strlen(arg + n1) + sd->show + 1); sd->text = malloc(strlen(arg + n1) + sd->show + 1);
if (strlen(arg) > sd->show) {
for(n2 = 0; (unsigned int) n2 < sd->show; n2++) { for(n2 = 0; (unsigned int) n2 < sd->show; n2++) {
sd->text[n2] = ' '; sd->text[n2] = ' ';
} }
sd->text[n2] = 0; sd->text[n2] = 0;
}
else
sd->text[0] = 0;
strcat(sd->text, arg + n1); strcat(sd->text, arg + n1);
sd->start = 0; sd->start = 0;
obj->sub = malloc(sizeof(struct text_object)); obj->sub = malloc(sizeof(struct text_object));
@ -142,7 +148,7 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
free(pwithcolors); free(pwithcolors);
//scroll //scroll
sd->start += sd->step; sd->start += sd->step;
if(buf[sd->start] == 0){ if(buf[sd->start] == 0 || sd->start > strlen(buf)){
sd->start = 0; sd->start = 0;
} }
} }