HW12/display_bar.h

40 lines
1.0 KiB
C
Raw Normal View History

2020-12-08 02:59:11 +09:00
#include<stdio.h>
#include<time.h>
#include<stdbool.h>
2020-12-14 19:19:49 +09:00
#include<stddef.h>
2020-12-08 02:59:11 +09:00
#ifndef _DISPLAY_BAR_H_
#define _DISPLAY_BAR_H_
2020-12-14 19:19:49 +09:00
//declare for raw operation
2020-12-08 02:59:11 +09:00
typedef unsigned raw_progress_bar_t;
void lock_scrolled();
void unlock_scrolled();
void add_scrolled_unlocked(unsigned int i);
raw_progress_bar_t create_raw_progress_bar();
void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,const char * filename);
2020-12-14 19:19:49 +09:00
//you should call before using progrees bar.
void ready_progress_bar();
//quit progress bar system.
void quit_progress_bar();
//same as isatty
2020-12-08 02:59:11 +09:00
bool isatty_file(FILE * file);
2020-12-14 19:19:49 +09:00
//
2020-12-08 02:59:11 +09:00
void myd_perror(const char * msg);
2020-12-14 19:19:49 +09:00
int myd_vfprintf(int line,FILE * f,const char * msg,va_list arg);
2020-12-08 02:59:11 +09:00
typedef struct {
raw_progress_bar_t bar;
//millisecond unit
int update_rate;
struct timespec last_update;
} progress_bar_t;
2020-12-09 00:14:42 +09:00
//update rate is millsecond unit
2020-12-08 02:59:11 +09:00
void init_progress_bar(progress_bar_t * bar,int update_rate);
void DisplayProgressBar(progress_bar_t * bar,size_t offset,size_t total,const char * filename, bool sync);
#endif