[xiph-commits] r17665 - trunk/squishyball

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sat Nov 27 08:27:01 PST 2010


Author: xiphmont
Date: 2010-11-27 08:27:01 -0800 (Sat, 27 Nov 2010)
New Revision: 17665

Modified:
   trunk/squishyball/main.c
   trunk/squishyball/main.h
   trunk/squishyball/mincurses.c
   trunk/squishyball/mincurses.h
   trunk/squishyball/tty.c
Log:
add keymenu


Modified: trunk/squishyball/main.c
===================================================================
--- trunk/squishyball/main.c	2010-11-27 14:36:53 UTC (rev 17664)
+++ trunk/squishyball/main.c	2010-11-27 16:27:01 UTC (rev 17665)
@@ -2076,7 +2076,7 @@
   fragsamples=setup_windows(pcm,test_files);
 
   /* set up terminal */
-  atexit(min_remove_panel);
+  atexit(min_panel_remove);
   {
     double len=pcm[0]->size/((pcm[0]->bits+7)/8)/pcm[0]->ch/(double)pcm[0]->rate;
     panel_init(pcm, test_files, test_mode, start, end>0 ? end : len, len,
@@ -2261,6 +2261,7 @@
           end_pos=pcm[0]->size;
           break;
         case '?':
+          panel_toggle_keymap();
           break;
         }
 
@@ -2441,7 +2442,7 @@
   }
 
   /* tear down terminal */
-  min_remove_panel();
+  min_panel_remove();
 
   /* join */
   pthread_cond_signal(&state.play_cond);

Modified: trunk/squishyball/main.h
===================================================================
--- trunk/squishyball/main.h	2010-11-27 14:36:53 UTC (rev 17664)
+++ trunk/squishyball/main.h	2010-11-27 16:27:01 UTC (rev 17665)
@@ -49,5 +49,5 @@
 extern void panel_update_flip_mode(int mode);
 extern void panel_update_trials(char *trial_list);
 extern void panel_update_pause(int flag);
-
+extern void panel_toggle_keymap(void);
 #endif

Modified: trunk/squishyball/mincurses.c
===================================================================
--- trunk/squishyball/mincurses.c	2010-11-27 14:36:53 UTC (rev 17664)
+++ trunk/squishyball/mincurses.c	2010-11-27 16:27:01 UTC (rev 17665)
@@ -325,13 +325,6 @@
   if(column_address)min_putp(tparm(column_address,x));
 }
 
-static void insert_lines(int n){
-  int i;
-  for(i=0;i<n-1;i++)
-    min_putstr("\r\n");
-  cursor_line_offset=n-1;
-}
-
 static void setup_term_customize(void){
   if (cur_term != 0) {
     term = cur_term->Nttyb;
@@ -354,8 +347,8 @@
 }
 
 extern void _nc_init_acs(void);
-int min_init_panel(int pl){
-  int ret = OK;
+int min_panel_init(int pl){
+  int i,ret = OK;
   if(!initted){
 
     if(isatty(STDOUT_FILENO))
@@ -386,14 +379,58 @@
     minc_init_keytry();
 
     panel_lines=pl;
-    insert_lines(panel_lines);
+    for(i=0;i<pl-1;i++)
+      min_putstr("\r\n");
+    cursor_line_offset=pl-1;
     initted=1;
     min_flush();
   }
   return ret;
 }
 
-void min_remove_panel(){
+int min_panel_expand(int l,int bottomp){
+  int i,ret=0;
+  if(bottomp){
+    min_mvcur(0,panel_lines);
+    for(i=0;i<l-1;i++)
+      ret|=min_putstr("\n\r");
+    panel_lines+=l;
+    cursor_line_offset=panel_lines-1;
+  }else{
+    min_mvcur(0,0);
+    if(parm_insert_line){
+      ret|=min_putp(tparm(parm_insert_line,l));
+    }else
+      ret=1;
+    panel_lines+=l;
+    cursor_line_offset=0;
+  }
+  return ret;
+}
+
+int min_panel_contract(int l,int bottomp){
+  int ret=0;
+  if(l>0){
+    if(l>panel_lines)l=panel_lines;
+    if(bottomp){
+      min_mvcur(0,panel_lines-l);
+      if(parm_delete_line){
+        ret|=min_putp(tparm(parm_delete_line,l));
+      }else
+        ret=1;
+    }else{
+      min_mvcur(0,0);
+      if(parm_delete_line){
+        ret|=min_putp(tparm(parm_delete_line,l));
+      }else
+        ret=1;
+    }
+    panel_lines-=l;
+  }
+  return ret;
+}
+
+void min_panel_remove(){
   if(initted){
     if(parm_delete_line){
       min_mvcur(0,0);

Modified: trunk/squishyball/mincurses.h
===================================================================
--- trunk/squishyball/mincurses.h	2010-11-27 14:36:53 UTC (rev 17664)
+++ trunk/squishyball/mincurses.h	2010-11-27 16:27:01 UTC (rev 17665)
@@ -32,8 +32,10 @@
 extern int min_write(const char *str,int len);
 extern int min_putstr(const char *str);
 extern void min_mvcur(int x, int y);
-extern int min_init_panel(int pl);
-extern void min_remove_panel(void);
+extern int min_panel_init(int pl);
+extern void min_panel_remove(void);
+extern int min_panel_expand(int l,int bottomp);
+extern int min_panel_contract(int l,int bottomp);
 extern int min_hidecur(void);
 extern int min_showcur(void);
 extern int min_clreol(void);

Modified: trunk/squishyball/tty.c
===================================================================
--- trunk/squishyball/tty.c	2010-11-27 14:36:53 UTC (rev 17664)
+++ trunk/squishyball/tty.c	2010-11-27 16:27:01 UTC (rev 17665)
@@ -296,7 +296,7 @@
 
 void panel_init(pcm_t **pcm, int test_files, int test_mode, double start, double end, double size,
                 int flip_mode,int repeat_mode,int trials,char *trial_list){
-  if(min_init_panel(test_mode==3 ? test_files+6:7)){
+  if(min_panel_init(test_mode==3 ? test_files+6:7)){
     fprintf(stderr,"Unable to initialize terminal\n");
     exit(101);
   }
@@ -552,3 +552,81 @@
     min_unset();
   }
 }
+
+static void min_putstrb(char *s){
+  min_bold(1);
+  min_putstr(s);
+  min_bold(0);
+}
+
+static int p_keymap=0;
+void panel_toggle_keymap(){
+  int l=18;
+  int o=1;
+  p_keymap = !p_keymap;
+  if(p_keymap){
+    timerow+=l;
+    playrow+=l;
+    toprow+=l;
+    boxrow+=l;
+    fliprow+=l;
+    min_panel_expand(l,0);
+    min_fg(COLOR_CYAN);
+    min_mvcur(0,o++);
+    min_putstrb("     a b x     ");
+    min_putstr(": Switch playback between A, B [and X] samples");
+    min_mvcur(0,o++);
+    min_putstrb("      A B      ");
+    min_putstr(": Choose A or B sample for A/B[/X] trial result");
+    min_mvcur(0,o++);
+    min_putstrb("    1 2 3...   ");
+    min_putstr(": Switch between first, second, etc samples");
+    min_mvcur(0,o++);
+    min_putstrb("     ! @ #     ");
+    min_putstr(": Choose sample 1, 2, or 3 for X/X/Y trial result");
+    min_mvcur(0,o++);
+    min_putstrb("  <ins> <del>  ");
+    min_putstr(": Undo/redo last trial result selection");
+    min_mvcur(0,o++);
+    min_putstrb("    <enter>    ");
+    min_putstr(": Choose current sample for this trial");
+    min_mvcur(0,o++);
+    min_putstrb("     <- ->     ");
+    min_putstr(": Seek back/forward two seconds, +shift for 10 seconds");
+    min_mvcur(0,o++);
+    min_putstrb("   <up/down>   ");
+    min_putstr(": Select sample from list (casual mode)");
+    min_mvcur(0,o++);
+    min_putstrb("    <space>    ");
+    min_putstr(": Pause/resume playback");
+    min_mvcur(0,o++);
+    min_putstrb("   <backspc>   ");
+    min_putstr(": Reset playback to start point");
+    min_mvcur(0,o++);
+    min_putstrb("      e E      ");
+    min_putstr(": set/reset end playback loop point");
+    min_mvcur(0,o++);
+    min_putstrb("       f       ");
+    min_putstr(": Toggle through beep-/mark-/seamless-flip modes");
+    min_mvcur(0,o++);
+    min_putstrb("       r       ");
+    min_putstr(": Toggle through restart-after/every/no-restart");
+    min_mvcur(0,o++);
+    min_putstrb("      s S      ");
+    min_putstr(": set/reset start playback loop point");
+    min_mvcur(0,o++);
+    min_putstrb("       ?       ");
+    min_putstr(": Print this keymap");
+    min_mvcur(0,o++);
+    min_putstrb("      ^-c      ");
+    min_putstr(": Quit");
+    min_unset();
+  }else{
+    min_panel_contract(l,0);
+    timerow-=l;
+    playrow-=l;
+    toprow-=l;
+    boxrow-=l;
+    fliprow-=l;
+  }
+}



More information about the commits mailing list