#include #include #include #include #include #include using namespace std; int printusage(int,const char *const *argv,const char *message=NULL){ if(message)cout<=0))return 0; vol+=inc; if(vol<0)vol=0; if(vol>100)vol=100; return setvolume(vol); } int interact(bool &m,int &vol){ char c=cin.get(); if(c=='q'||c=='Q'||c=='\n'||c=='\r')return 1; if(c=='l')return incvol(vol,5); if(c=='h')return incvol(vol,-5); if(c=='m'){ m=!m; setmuted(m); return 0; } if(c!=27){ cout<<7<2)return printusage(argc,argv); if(argc==2){ if(argv[1][0]=='\0')return printusage(argc,argv,"Invalid volume format"); char *endp; const int vol=strtol(argv[1],&endp,10); if(*endp!='\0')return printusage(argc,argv,"Invalid volume format"); if(vol<0||vol>100)return printusage(argc,argv,"Volume argument not in range"); return setvolume(vol); } if(!isatty(1))return printusage(argc,argv,"Won't display slider if stdout is not a terminal"); initscreen(); atexit(endscreen); bool m=getmuted(); int vol=getvolume(); while(true){ displayslider(m,vol); if(interact(m,vol))break; } cout<