From 5183083888288dc453f6a0c248e5b0164d6b3734 Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Tue, 8 Dec 2020 04:55:21 +0000 Subject: [PATCH] fix display bar bug --- display_bar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(); }