diff --git a/display_bar.c b/display_bar.c index 42c7de7..87d3389 100644 --- a/display_bar.c +++ b/display_bar.c @@ -68,12 +68,15 @@ void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,con else buf[i] = '.'; } lock_scrolled(); + pos = scrolled - bar; + if (pos > MAX_TERMINAL_ROW) { + unlock_scrolled(); + return; + }//optimization. //if ioctl failed? what should i do... ioctl(STDIN_FILENO,TIOCGWINSZ,(char *)&wnd_size); if (wnd_size.ws_row < pos) return; - if (pos > MAX_TERMINAL_ROW) return;//optimization. - pos = scrolled - bar; - fprintf(stdout,"\x1b[%dA[%s]: %.2f%% %s bytes: %ld/%ld %d \x1b[%dB\r",pos,buf,cur_progress,filename,total,offset,pos,pos); + fprintf(stdout,"\x1b[%dA[%s]: %.2f%% %s bytes: %ld/%ld \x1b[%dB\r",pos,buf,cur_progress,filename,total,offset,pos); fflush(stdout); unlock_scrolled(); }