- //no scrolling necessary if the length of the text to scroll is too short
- if (strlen(buf) - colorchanges <= sd->show) {
+ //(r)trim any incoming strings. some functions might return data with extra spaces on the end...
+ int k;
+ int len;
+ int junk=0;
+ len=strlen(buf);
+ for
+ (k=len-1;k>=0&&buf[k]==' ';k--)
+ {
+ buf[k]='\0';
+ }
+//count left padding but don't trim it because it's potentially needed for scrolling... (i commented this out because probably the only spaces on the front of the string
+//will be ours that we added above, should be more efficient to just keep track of those. but maybe this will be useful some day so i've left it here.
+// k=0;
+// while (buf[k]==' ') {
+// k++;
+// junk++;
+// }
+
+ //no scrolling necessary if the length of the text to scroll is shorter than the requested space from the conf
+ //if (strlen(buf) - colorchanges <= sd->show) {
+ if (strlen(buf) - junk - sd->junk - colorchanges <= sd->show) {
+ //ok we can really trim the left spaces now since we aren't scrolling it...
+ while ( buf[0] != '\0' && strchr ( &buf[0], ' ' ) != NULL ) {
+ memmove( &buf[0], &buf[1], strlen(buf) );
+ }