summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-01-30 10:50:31 +0100
committertomsmeding <tom.smeding@gmail.com>2016-01-30 10:50:31 +0100
commitfabeccb1a1b3f87793bbd70a6eee2165df53aa24 (patch)
treebe484e58988ca13585f8898a920ecab7afe35509
parent1d070eda0973a3b798bfec888a08798e86b3832f (diff)
support numerical input in graphical mode
-rw-r--r--volume.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/volume.cpp b/volume.cpp
index b5858e8..4ad5b03 100644
--- a/volume.cpp
+++ b/volume.cpp
@@ -74,6 +74,41 @@ int incvol(int &vol,int inc){
int interact(bool &m,int &vol){
char c=cin.get();
if(c=='q'||c=='Q'||c=='\n'||c=='\r')return 1;
+ if(c=='0')return incvol(vol,-100);
+ if(c>='0'&&c<='9'){
+ cout<<' '<<c;
+ int v=c-'0';
+ c=cin.get();
+ while(c!='\r'&&c!='\n'){
+ if(c==27)return 0;
+ if(c==8){
+ if(v){
+ v/=10;
+ displayslider(m,vol);
+ cout<<' '<<v<<flush;
+ } else {
+ cout<<'\x07'<<flush;
+ }
+ c=cin.get();
+ continue;
+ }
+ if(c<'0'||c>'9'){
+ cout<<'\x07';
+ c=cin.get();
+ continue;
+ }
+ if(10*v+c-'0'>100){
+ v=100;
+ displayslider(m,vol);
+ cout<<" 100\x07"<<flush;
+ } else {
+ v=10*v+c-'0';
+ cout<<c<<flush;
+ }
+ c=cin.get();
+ }
+ return incvol(vol,v-vol);
+ }
if(c=='l')return incvol(vol,5);
if(c=='h')return incvol(vol,-5);
if(c=='k')return incvol(vol,100);