首页 > 系统相关 >Linux 终端控件:实时时刻表

Linux 终端控件:实时时刻表

时间:2024-11-08 15:46:45浏览次数:1  
标签:时刻表 控件 const string color times int Linux return

为了看几点才能讨论所以设计的,因此这里面有一个自带的机房时间表,你直接跑就行

写得很 naive,因为没找到 Linux 有啥 API 接口

因此你需要在终端里跑

如果用 Vscode 推荐分一个终端挂着

否则可以单开一个终端然后置顶终端

各种部件和时刻详细信息都提供了快捷修改接口,设置项全都放在主函数上面(\(713\)-\(771\) 行)了,你可以按需求自行调整

效果图(?)

一个整体效果

#include<bits/stdc++.h>
using namespace std; 
#ifndef TOOL_H
#ifndef EXT_H
#define TOOL_H
namespace hdk{
	namespace tool{
		template<typename T>
		T floor_sqrt(T x,T l=1,T r=-1){
			if(r==-1) r=x;
			int ans=-1;
			while(l<=r){
				int mid=(l+r)/2;
				if(mid*mid<=x){
					l=mid+1;
					ans=mid;
				}
				else{
					r=mid-1;
				}
			}
			return ans;
		}
		template<typename T>
		void print(T x,bool first=true){
			if(x<0){
				putchar('-');
				print(-x,false);
				return;
			}
			if(x==0){
				if(first) putchar('0');
				return;
			}
			print(x/10,false);
			putchar((int)(x%10)+'0');
		}
		template<typename T>
		std::string to_string(T x){
			std::string res;bool f=false;
			if(x<0){
				f=true;
				x*=-1;
			}
			while(x){
				res.push_back((int)(x%10)+'0');
				x/=10;
			}
			reverse(res.begin(),res.end());
			if(f) res.push_back('-');
			if(res.empty()) res.push_back('0');
			return res;
		}
		long long to_number(std::string x){
			long long res=0;bool f=false;
			for(int i=0;i<=(int)x.length()-1;++i){
				if(x[i]=='-'){
					f=true;
				}
				else{
					res=res*10+x[i]-'0';
				}
			}
			return res*(f?-1:1);
		}
		template<typename T>
		std::string to_bit(T x){
			std::string ans;
			while(x){
				ans.push_back((x&1)+'0');
				x>>=1;
			}
			std::reverse(ans.begin(),ans.end());
			return ans;
		}
		std::string fixed_size(std::string x,int size,char fillchar='0'){
			std::string ans=x;
			std::reverse(ans.begin(),ans.end());
			while((int)ans.size()!=size) ans.push_back(fillchar);
			std::reverse(ans.begin(),ans.end());
			return ans;
		}
		bool copyfile(const char*in,const char *out){
			ifstream _fin(in);
			if(!_fin){
				cout<<"Error: File '"<<in<<"' not found"<<endl;
				return 0;
			}
			ofstream _fout(out);
			if(!_fout){
				cout<<"Error: File '"<<out<<"' not found"<<endl;
				return 0;
			}
			while(!_fin.eof()){
				char _a[1000001];_fin.getline(_a,1000000);
				_fout<<_a<<"\n";
			}
			return 1;
		}
		bool printfile(const char*in){
			ifstream _fin(in);
			if(!_fin){
				cout<<"Error: File '"<<in<<"' not found"<<endl;
				return 0;
			}
			cout<<"File '"<<in<<"'"<<endl;
			while(!_fin.eof()){
				char _a[1000001];_fin.getline(_a,1000000);
				cout<<_a<<"\n";
			}
			return 1;
		}
		bool fc(const char *file_A,const char *file_B,bool display=false,bool debug_mode=false){
			std::string a,b;
			if(display){printf("fc %s and %s\n",file_A,file_B);}
			bool eofA=false,eofB=false;std::ifstream f1,f2;f1.open(file_A);f2.open(file_B);
			if(!f1){
				cout<<"File '"<<file_A<<"' not found"<<endl;
				return true;
			}
			if(!f2){
				cout<<"File '"<<file_B<<"' not found"<<endl;
				return true;
			}
			while(1){
				if(f1.eof()){eofA=true;}
				else{f1>>a;}
				if(f2.eof()){eofB=true;}
				if(eofA and eofB){if(display) printf("File is equal.\n"); return false;}
				else if(eofA or eofB){if(display) printf("Length is not equal.\n");return true;}
				else{f2>>b;}
				if(debug_mode){printf("Compare: '%s' '%s'\n",a.c_str(),b.c_str());}
				if(a!=b){if(display){
				printf("Find Difference: \n");
				printf("%s: %s\n",file_A,a.c_str());
				printf("%s: %s\n",file_B,b.c_str());}
				return true;
				}
			}
		}
		bool fc(const std::string file_A,const std::string file_B,bool display=false,bool debug_mode=false){
			return fc(file_A.c_str(),file_B.c_str(),display,debug_mode);
		}
		const long long clocks_per_sec=CLOCKS_PER_SEC;
		#define time_s *clocks_per_sec
		#define time_ms *clocks_per_sec/1000.0
		class _time{
			private:
				long long last_clocks=-1;
				long long start_clocks=0;
			public:
				inline void sleep(long long clocks){
					int st=clock();
					while(clock()-st<=clocks);
				}
				inline long long record_time(){
					if(last_clocks==-1){
						last_clocks=clock();
						return 0;
					}
					else{
						int res=clock()-last_clocks;
						last_clocks=-1;
						return res;
					}
				}
				inline long long record_time(bool is_start){
					if(is_start){
						start_clocks=clock();
						return start_clocks;
					}
					else{
						return clock()-start_clocks;
					}
				}
		};
		string file_name(const string file){
			int pos=(int)file.length()-1;
			for(int i=(int)file.length()-1;i>=0;--i){
				if(file[i]=='.'){
					pos=i-1;break;
				}
			}
			string ans;
			for(int i=0;i<=pos;++i){
				ans.push_back(file[i]);
			}
			return ans;
		}
		int system(const string x){
			return std::system(x.c_str());
		}
		class bad_expression{};
		inline const pair<int,int> get_numeraic(const string &x,int start_pos){
			int res=0,f=1;
			for(int i=start_pos;i<=(int)x.length()-1;++i){
				if(x[i]=='-'){
					if(i==start_pos) f=-1;
					else throw bad_expression();
				}
				else if(x[i]==':'){
					return {res*f,i+1};
				}
				else if(isdigit(x[i])) res=res*10+x[i]-'0';
			}
			return {res*f,(int)x.length()};
		}
		inline const string substr(const string &x,int opt0=0,int opt1=0,int opt2=0){
			string ret="";
			if(opt0<0){
				opt0=(int)x.length()+opt0;
				if(opt0<0) throw bad_expression();
			}
			if(opt1<0){
				opt1=(int)x.length()+opt1;
				if(opt1<0) throw bad_expression();
			}
			if(opt2==0){
				for(int i=opt0;i<((opt1==0)?(int)x.length():opt1);++i){
					ret.push_back(x[i]);
				}
			}
			else if(opt2>0){
				for(int i=opt0;i<((opt1==0)?(int)x.length():opt1);i+=opt2){
					ret.push_back(x[i]);
				}
			}
			else{
				for(int i=((opt1==0)?(int)x.length():opt1)-1;i>=opt0;i+=opt2){
					ret.push_back(x[i]);
				}
			}
			return ret;
		}
		inline const string substr(const string &x,string expr=""){
			if(expr.empty()) return x;
			for(char&i:expr) if(i=='.' or i==';' or i==',' or i=='/' or i==' ') i=':';
			for(char i:expr) if(i!='-' and i!=':' and !isdigit(i)) throw bad_expression();
			vector<int>opt;
			int pos=0;
			while(pos<(int)expr.length()){
				if(expr[pos]==':'){
					opt.push_back(0);
					pos++;
				}
				else{
					auto rt=get_numeraic(expr,pos);
					opt.push_back(rt.first);
					pos=rt.second;
				}
			}
			if(expr.back()==':') opt.push_back(0);
			if(opt.size()>3ul) throw bad_expression();
			string ret="";
			if(opt[0]<0){
				opt[0]=(int)x.length()+opt[0];
				if(opt[0]<0) throw bad_expression();
			}
			if(opt[1]<0){
				opt[1]=(int)x.length()+opt[1];
				if(opt[1]<0) throw bad_expression();
			}
			if(opt.size()==1ul){
				for(int i=opt[0];i<(int)x.length();++i){
					ret.push_back(x[i]);
				}
				return ret;
			}
			if(opt.size()==2ul){
				for(int i=opt[0];i<((opt[1]==0)?(int)x.length():opt[1]);++i){
					ret.push_back(x[i]);
				}
				return ret;
			}
			if(opt.size()==3ul){
				if(opt[2]==0){
					for(int i=opt[0];i<((opt[1]==0)?(int)x.length():opt[1]);++i){
						ret.push_back(x[i]);
					}
				}
				else if(opt[2]>0){
					for(int i=opt[0];i<((opt[1]==0)?(int)x.length():opt[1]);i+=opt[2]){
						ret.push_back(x[i]);
					}
				}
				else{
					for(int i=((opt[1]==0)?(int)x.length():opt[1])-1;i>=opt[0];i+=opt[2]){
						ret.push_back(x[i]);
					}
				}
				return ret;
			}
			throw bad_expression();
			return "";
		}
		inline const string substr(const string &x,int start_pos,int length){
			return x.substr(start_pos,length);
		}
		class str_t{
			private:string str;
			public:str_t(const string &x){str=x;}
			inline const string operator[](string x){return substr(str,x);}
			inline const string operator[](const vector<int>&opt){return substr(str,opt[1],opt[2],opt[3]);}
			inline const string operator()(int opt1,int opt2,int opt3){return substr(str,opt1,opt2,opt3);}
			inline const string operator()(string x){return substr(str,x);}
			inline const string operator()(const vector<int>&opt){return substr(str,opt[1],opt[2],opt[3]);}
		};
		const string lowercase(const string&x){
			string res;
			for(char i:x){
				if(i>='A' and i<='Z') res.push_back(i-'A'+'a');
				else res.push_back(i);
			}
			return res;
		}
		const string uppercase(const string&x){
			string res;
			for(char i:x){
				if(i>='a' and i<='z') res.push_back(i-'a'+'A');
				else res.push_back(i);
			}
			return res;
		}
		template<typename return_value_type=unsigned long long,return_value_type numer=233,return_value_type mod=0>
		class string_hash{
			private:return_value_type get_hash(const string &x){
				return_value_type res=0;
				for(char i:x){
					if(mod==0) res=res*numer+i;
					else res=(1ll*res*numer%mod+i)%mod;
				}
				return res;
			}
			public:return_value_type operator()(const string &x){return get_hash(x);}
			return_value_type operator[](const string &x){return get_hash(x);}
		};
		string_hash<> strhash;
	}
}
#endif
#endif
#ifndef TIMES_H
#define TIMES_H
using namespace hdk::tool;
namespace hdk{
    char target_output[10001];
    struct times{
        typedef const std::string times_t;
        typedef const std::string format_t;
        times_t get_format(format_t x){
            time_t t=std::time(0);
            strftime(target_output,sizeof(target_output),x.c_str(),localtime(&t));
            return target_output;
        }
        times_t short_weekname(){return get_format("%a");}
        times_t weekname(){return get_format("%A");}
        times_t short_monthname(){return get_format("%b");}
        times_t monthname(){return get_format("%B");}
        times_t date_and_time(){return get_format("%c");}
        times_t date_of_month(){return get_format("%d");}
        times_t hours_24(){return get_format("%H");}
        times_t hours_12(){return get_format("%I");}
        times_t date_of_year(){return get_format("%j");}
        times_t month(){return get_format("%m");}
        times_t minute(){return get_format("%M");}
        times_t times_12(){return get_format("%p");}
        times_t second(){return get_format("%S");}
        times_t date_of_week(){return get_format("%w");}
        times_t week_of_year(){return get_format("%W");}
        times_t week_of_year_start_from_sunday(){return get_format("%U");}
        times_t date(){return get_format("%x");}
        times_t time(){return get_format("%X");}
        times_t short_year(){return get_format("%y");}
        times_t year(){return get_format("%Y");}
        times_t short_time_zone(){return get_format("%z");}
        times_t time_zone(){return get_format("%Z");}
    };
    struct hm_times_t{
        int hours,minute;
        hm_times_t(){}
        hm_times_t(int _h,int _m){hours=_h;minute=_m;}
        hm_times_t(const pair<int,int>hm){hours=hm.first;minute=hm.second;}
        hm_times_t(int _h){hours=_h;minute=0;}
    };
    int hours(long double x){
        return 60*x;
    }
    struct times_table{
        struct time_area{
            string name;
            hm_times_t start;
            hm_times_t end;
            time_area(const string a,const hm_times_t b,const hm_times_t c){
                name=a;
                start=b;
                end=c;
            }
            time_area(const string a,int b,int c,int d,int e){
                name=a;
                start=hm_times_t(b,c);
                end=hm_times_t(d,e);
            }
            bool in(const hm_times_t x){
                if(x.hours==start.hours and x.hours==end.hours){
                    return x.minute>=start.minute and x.minute<end.minute;
                }
                if(x.hours==start.hours){
                    return x.minute>=start.minute;
                }
                if(x.hours==end.hours){
                    return x.minute<end.minute;
                }
                return x.hours>start.hours and x.hours<end.hours;
            }
        };
        vector<time_area>v;
        times_table(const vector<time_area>&x){
            v=x;
        }
        const string operator[](const hm_times_t x){
            for(time_area i:v){
                if(i.in(x)){
                    return (string)"'"+i.name+"' ["+to_string(i.start.hours)+":"+fixed_size(to_string(i.start.minute),2,'0')+"-"+to_string(i.end.hours)+":"+fixed_size(to_string(i.end.minute),2,'0')+"]";
                }
            }
            return "No activity";
        }
    };
    int continued_time(const hm_times_t &a,const hm_times_t &b){
        return b.hours*60+b.minute-a.hours*60-a.minute;
    }
    struct ex_times_table{        
        struct ex_time_area{
            string name;
            hm_times_t start;
            hm_times_t end;
            int last_times;
            ex_time_area(const string a,const hm_times_t b,const hm_times_t c,int ls){
                name=a;
                start=b;
                end=c;
                last_times=ls;
            }
            ex_time_area(const string a,int b,int c,int d,int e,int ls){
                name=a;
                start=hm_times_t(b,c);
                end=hm_times_t(d,e);
                last_times=ls;
            }
            ex_time_area(const string a,const hm_times_t b,const hm_times_t c){
                name=a;
                start=b;
                end=c;
                last_times=continued_time(start,end);
            }
            ex_time_area(const string a,int b,int c,int d,int e){
                name=a;
                start=hm_times_t(b,c);
                end=hm_times_t(d,e);
                last_times=continued_time(start,end);
            }
            bool in(const hm_times_t x){
                if(x.hours==start.hours and x.hours==end.hours){
                    return x.minute>=start.minute and x.minute<end.minute;
                }
                if(x.hours==start.hours){
                    return x.minute>=start.minute;
                }
                if(x.hours==end.hours){
                    return x.minute<end.minute;
                }
                return x.hours>start.hours and x.hours<end.hours;
            }
        };
        vector<ex_time_area>v;
        ex_times_table(const vector<ex_time_area>&x){
            v=x;
        }
        pair<const string,pair<hm_times_t,int>> operator[](const hm_times_t x){
            for(ex_time_area i:v){
                if(i.in(x)){
                    return {(string)"'"+i.name+"' ["+to_string(i.start.hours)+":"+fixed_size(to_string(i.start.minute),2,'0')+"-"+to_string(i.end.hours)+":"+fixed_size(to_string(i.end.minute),2,'0')+"]",{i.start,i.last_times}};
                }
            }
            return {"No activity",{{0,0},1}};
        }
    };
}
#endif
#ifndef COLORLINUX_H
#if INT_MAX==RAND_MAX
#define COLORLINUX_H
class color{
    public:

    const string NONE=                 "\e[0m";
    const string BLACK=                "\e[0;30m";
    const string L_BLACK=              "\e[1;30m";
    const string RED=                  "\e[0;31m";
    const string L_RED=                "\e[1;31m";
    const string GREEN=                "\e[0;32m";
    const string L_GREEN=              "\e[1;32m";
    const string BROWN=                "\e[0;33m";
    const string YELLOW=               "\e[1;33m";
    const string BLUE=                 "\e[0;34m";
    const string L_BLUE=               "\e[1;34m";
    const string PURPLE=               "\e[0;35m";
    const string L_PURPLE=             "\e[1;35m";
    const string CYAN=                 "\e[0;36m";
    const string L_CYAN=               "\e[1;36m";
    const string GRAY=                 "\e[0;37m";
    const string WHITE=                "\e[1;37m";

    const string BOLD=                 "\e[1m";
    const string UNDERLINE=            "\e[4m";
    const string BLINK=                "\e[5m";
    const string REVERSE=              "\e[7m";
    const string HIDE=                 "\e[8m";
    const string CLEAR=                "\e[2J";
}color;
class color_t{
    private:string x;
    public:
    color_t operator =(const std::string y){x=y;return *this;};
    color_t(const std::string y){x=y;}
    color_t operator +(const color_t&A)const{
        color_t ans=*this;ans.x=ans.x+";"+A.x;
        return ans;
    }
    const std::string operator()()const{return x;}
};
class __const_color_t{
    private:string x;
    public:
    __const_color_t operator =(const string y){x=y;return *this;};
    __const_color_t(const string y){x=y;}
    const string operator()()const{return x;}
};
class __color{
    public:
    const __const_color_t START=(string)"\e[";
    const __const_color_t NONE=(string)"\e[0m";

    const color_t EMPTY=(string)"";
    
    const color_t HIGHLIGHT=(string)"1";
    const color_t VAGUE=(string)"2";
    const color_t ITALIC=(string)"3";
    const color_t UNDERLINE=(string)"4";
    const color_t TWINKLE=(string)"5";
    const color_t FAST_TWINKLE=(string)"6";
    const color_t REVERSE_COLOR=(string)"7";
    const color_t HIDE=(string)"8";

    struct{
        const color_t BLACK=(string)"30";
        const color_t RED=(string)"31";
        const color_t GREEN=(string)"32";
        const color_t YELLOW=(string)"33";
        const color_t BLUE=(string)"34";
        const color_t PERPLE=(string)"35";
        const color_t CRAY=(string)"36";
        const color_t WHITE=(string)"37";
    }FRONTCOLOR;

    struct{
        const color_t BLACK=(string)"40";
        const color_t RED=(string)"41";
        const color_t GREEN=(string)"42";
        const color_t YELLOW=(string)"43";
        const color_t BLUE=(string)"44";
        const color_t PERPLE=(string)"45";
        const color_t CRAY=(string)"46";
        const color_t WHITE=(string)"47";
    }BACKGROUND;
};
typedef __color __color_t;
__color_t __color_info;
#define color_print(x) printf("%s",((string)""+(x)+color.NONE).c_str())
#define printc(x,info) printf("%s",(__color_info.START()+(x)()+"m"+info+__color_info.NONE()).c_str())
#endif
#endif
#ifndef LINUX_HPP
#define LINUX_HPP
#if INT_MAX==RAND_MAX
bool linux_copyfile(const char*in,const char *out){
    ifstream _fin(in);
    if(!_fin){
        printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Error");
        cout<<": File ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.ITALIC,in);
        cout<<" not found"<<endl;
        return 0;
    }
    ofstream _fout(out);
    if(!_fout){
        printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Error");
        cout<<": File ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.ITALIC,out);
        cout<<" not found"<<endl;
        return 0;
    }
    while(!_fin.eof()){
        char _a[1000001];_fin.getline(_a,1000000);
        _fout<<_a<<"\n";
    }
    return 1;
}
bool linux_printfile(const char*in){
    ifstream _fin(in);
    if(!_fin){
        printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Error");
        cout<<": File ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.ITALIC,in);
        cout<<" not found"<<endl;
        return 0;
    }
    cout<<"File ";
    printc(__color_info.FRONTCOLOR.CRAY+__color_info.UNDERLINE+__color_info.ITALIC,in);
    cout<<endl;
    while(!_fin.eof()){
        char _a[1000001];_fin.getline(_a,1000000);
        cout<<_a<<"\n";
    }
    return 1;
}
bool linux_fc(const char *file_A,const char *file_B,bool display=true,bool debug_mode=false){
    std::string a,b;
    if(display){
        printc(__color_info.FRONTCOLOR.PERPLE,"fc");
        cout<<' ';
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.UNDERLINE+__color_info.ITALIC,file_A);
        cout<<" and ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.UNDERLINE+__color_info.ITALIC,file_B);
        cout<<endl;
    }
    bool eofA=false,eofB=false;std::ifstream f1,f2;f1.open(file_A);f2.open(file_B);
    if(!f1){
        printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Error");
        cout<<": File ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.ITALIC,file_A);
        cout<<" not found"<<endl;
        return true;
    }
    if(!f2){
        printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Error");
        cout<<": File ";
        printc(__color_info.FRONTCOLOR.CRAY+__color_info.ITALIC,file_B);
        cout<<" not found"<<endl;
        return true;
    }
    while(1){
        if(f1.eof()){eofA=true;}
        else{f1>>a;}
        if(f2.eof()){eofB=true;}
        else{f2>>b;}
        if(eofA and eofB){
            if(display){
                printc(__color_info.FRONTCOLOR.GREEN+__color_info.HIGHLIGHT,"Accept");
                cout<<": File is equal.";
                cout<<endl;
                return false;
            }
        }
        else if(eofA or eofB){
            if((eofA and (b[0]=='\n' or b[0]==' ' or b[0]==0)) or (eofB and (a[0]=='\n' or a[0]==' ' or a[0]==0))){
                if(display){
                    printc(__color_info.FRONTCOLOR.GREEN+__color_info.HIGHLIGHT,"Accept");
                    cout<<": File is equal.";
                    cout<<endl;
                }
                return false;
            }
            if(display){
                printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Find Difference");
                printf(" Length is not equal.\n");
                return true;
            }
        }
        if(debug_mode){
            printc(__color_info.FRONTCOLOR.PERPLE,"Compare");
            printf(": '%s' '%s'\n",a.c_str(),b.c_str());
        }
        if(a!=b){
            if(display){
                printc(__color_info.FRONTCOLOR.RED+__color_info.HIGHLIGHT,"Find Difference");
                cout<<endl;
                printc(__color_info.FRONTCOLOR.CRAY+__color_info.UNDERLINE+__color_info.ITALIC,file_A);
                printf(": %s\n",a.c_str());
                printc(__color_info.FRONTCOLOR.CRAY+__color_info.UNDERLINE+__color_info.ITALIC,file_B);
                printf(": %s\n",b.c_str());
            }
            return true;
        }
    }
}
bool linux_fc(const std::string file_A,const std::string file_B,bool display=true,bool debug_mode=false){
    return linux_fc(file_A.c_str(),file_B.c_str(),display,debug_mode);
}
void scroll_line(int size,double nowpercent,const color_t finished_color,const color_t unfinished_color){
    int finished=size*nowpercent;
    for(int i=1;i<=finished;++i){
        printc(finished_color,' ');
    }
    for(int i=finished+1;i<=size;++i){
        printc(unfinished_color,' ');
    }
}
#endif
#endif
using namespace hdk;

/*
//----- SETTING -----
*/
    const int flush_time=1;
        //屏幕刷新频率
    const bool show_nowtime=true;
        //显示当前时间
    const bool show_remain_times_line=true;
        //是否显示最后一行
    const bool show_scl=true;
        //是否显示进度条
    const bool show_percent=true;
        //是否显示当前百分比
    const bool show_remain_times=true;
        //是否显示剩余时间
    const int scl_size=20;
        //进度条大小
    const color_t scl_color=__color_info.BACKGROUND.GREEN;
        //进度条颜色
    const color_t scl_color2=__color_info.EMPTY;
        //进度条(未到达区域)颜色
    const times::format_t time_format="default";
        //时间显示格式
    ex_times_table day(
        {
            {"晚休",      0, 0,  6, 0},
            {"早操",      6, 0,  6,15},
            {"早读",      6,15,  7, 0},
            {"早饭",      7, 0,  7,25},
            {"上午第一节", 7,25,  8,25},
            {"讨论",      8,25,  8,45},
            {"上午第二节", 8,45,  9,45},
            {"讨论",      9,45, 10, 5},
            {"上午第三节",10, 5, 11, 5},
            {"讨论",     11, 5, 11,25},
            {"上午第四节",11,25, 12,15},
            {"午休",     12,15, 14, 0},
            {"下午第一节",14, 0, 14,50},
            {"讨论",     14,50, 15,10},
            {"下午第二节",15,10, 16,10},
            {"讨论",     16,10, 16,30},
            {"下午第三节",16,30, 17,30},
            {"讨论",     17,30, 17,45},
            {"下午第四节",17,45, 18,20},
            {"晚饭",     18,20, 18,35},
            {"讨论",     18,35, 18,55},
            {"晚间第一节",18,55, 20,10},
            {"讨论",     20,10, 20,30},
            {"晚间第二节",20,30, 21,40},
            {"晚休",     21,40, 24,00}
        }
        //时间表
        //支持调整与修改项目
    );
    static_assert(flush_time>0);
    static_assert(scl_size>0);
/*
//-------------------
*/

int main(){
    times a;
    while(1){
        int st=time(0);
        while(time(0)-st!=flush_time);
        #if RAND_MAX==INT_MAX
        system("clear");
        #else
        system("cls");
        #endif
        hm_times_t now((int)to_number(a.hours_24()),(int)to_number(a.minute()));
        if(show_nowtime){
            if(time_format=="default") cout<<"Time: "<<a.date()<<" "<<a.weekname()<<" "<<a.hours_24()<<":"<<a.minute()<<":"<<a.second()<<endl;
            else cout<<a.get_format(time_format)<<endl;
        }
        auto x=day[{(int)to_number(a.hours_24()),(int)to_number(a.minute())}];
        cout<<"Now "<<x.first<<endl;
        if(show_remain_times_line){
            if(show_percent) printf("%.0f%% ",continued_time(x.second.first,now)*100.0/x.second.second);
            if(show_scl) scroll_line(scl_size,continued_time(x.second.first,now)*1.0/x.second.second,scl_color,scl_color2);
            if(show_remain_times) cout<<" remain: "<<x.second.second-continued_time(x.second.first,now)<<" min"<<endl;
        }
    }
}

标签:时刻表,控件,const,string,color,times,int,Linux,return
From: https://www.cnblogs.com/HaneDaCafe/p/18535225

相关文章

  • 云服务器Linux部署war、jar包,并在nginx配置域名
    一,打包Jar包        一个Springboot项目默认打包jar包,无需修改配置,点击右侧Maven-Lifecycle-package打包即可注意:需要先检查pom.xml文件,可能此时打包完的jar包会出现        nomainmanifestattribute,intest-0.0.1-SNAPSHOT.jar        xx......
  • 【linux】Linux虚拟网络中的网络接口介绍
    原创信息技术圈IntroductiontoLinuxinterfacesforvirtualnetworkingLinux拥有丰富的虚拟网络功能,这些功能为托管虚拟机、容器以及云环境提供了基础。在这篇文章中,我将简要介绍所有常用虚拟网络接口类型。本文不涉及代码分析,仅对Linux上的接口及其使用进行简要介绍。......
  • linux新增物理卷,扩容逻辑分区,出现WARNING: xfs signature detected on /dev/vdb at of
    linux新增物理卷出现WARNING:xfssignaturedetectedon/dev/vdbatoffset0.Wipeit?[y/n]:标识这个/dev/vdb磁盘已经从0位置被标记为xfs类型的文件系统报错解释:这条信息表示在设备/dev/vdb上检测到了XFS文件系统的签名。通常情况下,这可能意味着分区/dev/vdb已被......
  • Linux分区出现 Device for PV wwoBYr-XnZx-Oa4D-71JE-essF-5qPe-Zu8Cvw not found or
    linux分区,出现这种情况,磁盘创建或分配出现了异常WARNING:DeviceforPVwwoBYr-XnZx-Oa4D-71JE-essF-5qPe-Zu8Cvwnotfoundorrejectedbyafilter.Couldn'tfinddevicewithuuidwwoBYr-XnZx-Oa4D-71JE-essF-5qPe-Zu8Cvw.PV/dev/vda2VGcentoslvm2[<39.0......
  • 在Linux中如何添加新的硬盘
    准备工作检查系统环境在开始Linux磁盘分区之前,检查系统环境是一个关键步骤。Linux提供了两种常用的方法来查看现有的磁盘信息:fdisk-l:这个命令用于显示磁盘的分区表,提供详细的分区信息。lsblk:这个命令以树状结构展示系统中的块设备,包括磁盘和分区,同时显示挂载点信息。......
  • Linux命令行压力测试工具:基准测试与性能优化
    文章目录Linux命令行压力测试工具:基准测试与性能优化Linux安装模拟CPU压力基本用法:高负载模拟:常见选项解析:模拟CPU满负荷模拟I/O瓶颈随机读测试:顺序写测试:初始化与清理操作:模拟大流量网络压力客户端测试命令:服务端命令:模拟端口禁用与防火墙配置查看当前规则:禁用出口端......
  • 【命令操作】Linux三剑客之sed详解 _ 统信 _ 麒麟 _ 方德
    原文链接:【命令操作】Linux三剑客之sed详解|统信|麒麟|方德Hello,大家好啊!今天带来一篇关于Linux三剑客之sed命令详解的文章。sed是一款功能强大的流编辑器,它可以在命令行中快速处理文本,支持替换、插入、删除等操作,特别适合用于处理大型文件或批量文本处理任务。本文......
  • linux_1
    静态库:以lib开头,文件名通常:libxxx.a;静态库在编译时,会链接(拷贝一份)放到可执行程序;因为要被复制到可执行文件,所以代码体积会增大。它不会共享。若库被更新了程序需要重新编译。共享库:文件名通常libxx.so;在需要这个库时程序需要回到共享库区执行库中的代码。库更......
  • WPF StatusBar控件 这一块也能放一些东西
    WPFStatusBar控件这一块也能放一些东西  StatusBar控件一般在窗口的底部。用于显示有关应用程序当前状态的各种信息,如光标位置、字数、任务进度等。<Windowx:Class="WpfApp14.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"......
  • Linux基础 -- (1)
    声明:本文的学习内容来源于B站up主“泷羽sec”的公开分享,所有内容仅限于网络安全技术的交流学习,不涉及任何侵犯版权或其他侵权意图。如有任何侵权问题,请联系本人,我将立即删除相关内容。本文旨在帮助网络安全爱好者提升自身安全技能,并严格遵守国家法律法规。任何人利用本文......