fix display bar bug

This commit is contained in:
ubuntu201711081 2020-12-08 04:55:21 +00:00
parent 80f3226421
commit 5183083888

View File

@ -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();
}