[xiph-commits] r17663 - trunk/squishyball

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sat Nov 27 05:11:25 PST 2010


Author: xiphmont
Date: 2010-11-27 05:11:25 -0800 (Sat, 27 Nov 2010)
New Revision: 17663

Modified:
   trunk/squishyball/main.c
   trunk/squishyball/main.h
   trunk/squishyball/mincurses.c
   trunk/squishyball/mincurses.h
   trunk/squishyball/tty.c
Log:
More ui hookup work



Modified: trunk/squishyball/main.c
===================================================================
--- trunk/squishyball/main.c	2010-11-26 16:29:22 UTC (rev 17662)
+++ trunk/squishyball/main.c	2010-11-27 13:11:25 UTC (rev 17663)
@@ -2265,9 +2265,11 @@
 
 
       /* update terminal */
+      {
+        double current = (double)current_pos/(pcm[0]->ch*(pcm[0]->bits+7)/8*pcm[0]->rate);
+        panel_update_current(current);
+      }
 
-
-
       if(state.fragment_size==0 && !state.exiting){
         /* fill audio output */
         off_t save_pos=current_pos;
@@ -2387,7 +2389,9 @@
     }
   }
 
-  /* done */
+  /* tear down terminal */
+  min_remove_panel();
+
   /* join */
   pthread_cond_signal(&state.play_cond);
   pthread_cancel(fd_handle);
@@ -2395,10 +2399,6 @@
   pthread_join(playback_handle,NULL);
   pthread_join(fd_handle,NULL);
 
-  /* tear down terminal */
-  min_remove_panel();
-
-
   for(i=0;i<test_files;i++)
     free_pcm(pcm[i]);
   return 0;

Modified: trunk/squishyball/main.h
===================================================================
--- trunk/squishyball/main.h	2010-11-26 16:29:22 UTC (rev 17662)
+++ trunk/squishyball/main.h	2010-11-27 13:11:25 UTC (rev 17663)
@@ -41,15 +41,13 @@
 extern char *make_time_string(double s,int pad);
 extern 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);
-extern void panel_update_playing(char c);
+extern void panel_update_playing(int n);
 extern void panel_update_start(double time);
 extern void panel_update_current(double time);
 extern void panel_update_end(double time);
 extern void panel_update_repeat_mode(int mode);
 extern void panel_update_flip_mode(int mode);
 extern void panel_update_trials(char *trial_list);
-extern void panel_update_sample(int n);
 extern void panel_update_pause(int flag);
 
-
 #endif

Modified: trunk/squishyball/mincurses.c
===================================================================
--- trunk/squishyball/mincurses.c	2010-11-26 16:29:22 UTC (rev 17662)
+++ trunk/squishyball/mincurses.c	2010-11-27 13:11:25 UTC (rev 17663)
@@ -399,6 +399,7 @@
       min_mvcur(0,0);
       min_putp(tparm(parm_delete_line,panel_lines));
     }
+    min_unset();
     min_showcur();
     min_flush();
     SET_TTY(outfd,&orig);
@@ -438,22 +439,7 @@
     return 1;
 }
 
-int min_gfxmode(void){
-  if(enter_alt_charset_mode){
-    min_putp(enter_alt_charset_mode);
-    return 0;
-  }else
-    return 1;
-}
-
-int min_textmode(void){
-  if(exit_alt_charset_mode){
-    min_putp(exit_alt_charset_mode);
-    return 0;
-  }else
-    return 1;
-}
-
+static int acs=0;
 static int fg=-1;
 static int bg=-1;
 static int bold=0;
@@ -473,124 +459,210 @@
   fg=-1;
   bg=-1;
   bold=0;
-  if(ul){
-    min_underline(0);
-    ul=0;
-  }
+  rev=0;
+  blink=0;
+  acs=0;
+  ul=0;
   return unset();
 }
 
+static int setfg(int c){
+  if(set_a_foreground){
+    fg=c;
+    min_putp(tparm(set_a_foreground,c));
+    return 0;
+  }
+  return 1;
+}
+
+static int setbg(int c){
+  if(set_a_background){
+    bg=c;
+    min_putp(tparm(set_a_background,c));
+    return 0;
+  }
+  return 1;
+}
+
+static int setbold(void){
+  if(enter_bold_mode){
+    min_putp(enter_bold_mode);
+    bold=1;
+    return 0;
+  }
+  return 1;
+}
+
+static int setblink(void){
+  if(enter_blink_mode){
+    min_putp(enter_blink_mode);
+    blink=1;
+    return 0;
+  }
+  return 1;
+}
+
+static int setunderline(void){
+  if(enter_underline_mode){
+    ul=1;
+    min_putp(enter_underline_mode);
+    return 0;
+  }
+  return 1;
+}
+
+static int setgfx(void){
+  if(enter_alt_charset_mode){
+    acs=1;
+    min_putp(enter_alt_charset_mode);
+    return 0;
+  }
+  return 1;
+}
+
+static int setreverse(void){
+  if(enter_reverse_mode){
+    min_putp(enter_reverse_mode);
+    rev=1;
+    return 0;
+  }
+  return 1;
+}
+
 static int reset(){
   int ret=0;
-  if(fg>=0)ret|=min_fg(fg);
-  if(bg>=0)ret|=min_bg(bg);
-  if(bold)ret|=min_bold(1);
-  if(blink)ret|=min_blink(1);
-  if(rev)ret|=min_reverse(1);
+  if(acs)ret|=setgfx();
+  if(fg>=0)ret|=setfg(fg);
+  if(bg>=0)ret|=setbg(bg);
+  if(bold)ret|=setbold();
+  if(blink)ret|=setblink();
+  if(rev)ret|=setreverse();
+  if(ul)ret|=setunderline();
   return ret;
 }
 
 int min_fg(int c){
   int ret=0;
-  if(c<0 && fg>=0){
-    fg=-1;
-    ret|=unset();
-    ret|=reset();
+  if(c<0){
+    if(fg>=0){
+      fg=-1;
+      ret|=unset();
+      ret|=reset();
+    }
   }else{
-    if(set_a_foreground){
-      fg=c;
-      min_putp(tparm(set_a_foreground,c));
-    }else
-      ret=1;
+    if(fg!=c)
+      ret=setfg(c);
   }
   return ret;
 }
 
 int min_bg(int c){
   int ret=0;
-  if(c<0 && bg>=0){
-    bg=-1;
-    ret|=unset();
-    ret|=reset();
+  if(c<0){
+    if(bg>=0){
+      bg=-1;
+      ret|=unset();
+      ret|=reset();
+    }
   }else{
-    if(set_a_background){
-      bg=c;
-      min_putp(tparm(set_a_background,c));
-    }else
-      ret=1;
+    if(bg!=c)
+      ret=setbg(c);
   }
   return ret;
 }
 
+int min_color(int f,int b){
+  int ret=0;
+  fg=-1;
+  bg=-1;
+  ret|=unset();
+  ret|=reset();
+  ret|=min_fg(f);
+  ret|=min_bg(b);
+  return ret;
+}
+
 int min_bold(int flag){
   int ret=0;
-  if(!flag && bold){
-    bold=0;
-    ret|=unset();
-    ret|=reset();
+  if(!flag){
+    if(bold){
+      bold=0;
+      ret|=unset();
+      ret|=reset();
+    }
   }else{
-    if(enter_bold_mode){
-      min_putp(enter_bold_mode);
-      bold=1;
-    }else
-      ret=1;
+    if(!bold)
+      ret=setbold();
   }
   return ret;
 }
 
-int min_color(int f,int b){
+int min_blink(int flag){
   int ret=0;
-  ret|=min_fg(f);
-  ret|=min_bg(b);
+  if(!flag){
+    if(blink){
+      blink=0;
+      ret|=unset();
+      ret|=reset();
+    }
+  }else{
+    if(!blink)
+      ret=setblink();
+  }
   return ret;
 }
 
-int min_blink(int flag){
+int min_underline(int flag){
   int ret=0;
-  if(!flag && blink){
-    blink=0;
-    ret|=unset();
-    ret|=reset();
+  if(!flag){
+    if(ul){
+      if(exit_underline_mode){
+        ul=0;
+        min_putp(exit_underline_mode);
+      }else{
+        ul=0;
+        ret|=unset();
+        ret|=reset();
+      }
+    }
   }else{
-    if(enter_blink_mode){
-      min_putp(enter_blink_mode);
-      blink=1;
-    }else
-      ret=1;
+    if(!ul)
+      ret=setunderline();
   }
   return ret;
 }
 
-int min_underline(int flag){
-  if(flag){
-    if(enter_underline_mode){
-      ul=1;
-      min_putp(enter_underline_mode);
-      return 0;
-    }else
-      return 1;
+int min_gfx(int flag){
+  int ret=0;
+  if(!flag){
+    if(acs){
+      if(exit_alt_charset_mode){
+        acs=0;
+        min_putp(exit_alt_charset_mode);
+      }else{
+        acs=0;
+        ret|=unset();
+        ret|=reset();
+      }
+    }
   }else{
-    if(exit_underline_mode){
-      ul=0;
-      min_putp(exit_underline_mode);
-      return 0;
-    }else
-      return 1;
+    if(!acs)
+      ret=setgfx();
   }
+  return ret;
 }
 
 int min_reverse(int flag){
   int ret=0;
-  if(!flag && rev){
-    rev=0;
-    ret|=unset();
-    ret|=reset();
+  if(!flag){
+    if(rev){
+      rev=0;
+      ret|=unset();
+      ret|=reset();
+    }
   }else{
-    if(enter_reverse_mode){
-      min_putp(enter_reverse_mode);
-      rev=1;
-    }else
-      ret=1;
+    if(!rev)
+      ret=setreverse();
   }
   return ret;
 }

Modified: trunk/squishyball/mincurses.h
===================================================================
--- trunk/squishyball/mincurses.h	2010-11-26 16:29:22 UTC (rev 17662)
+++ trunk/squishyball/mincurses.h	2010-11-27 13:11:25 UTC (rev 17663)
@@ -38,8 +38,6 @@
 extern int min_showcur(void);
 extern int min_clreol(void);
 extern int min_clrbol(void);
-extern int min_gfxmode(void);
-extern int min_textmode(void);
 
 extern int min_unset(void);
 extern int min_fg(int c);
@@ -49,4 +47,5 @@
 extern int min_blink(int flag);
 extern int min_underline(int flag);
 extern int min_reverse(int flag);
+extern int min_gfx(int flag);
 #endif

Modified: trunk/squishyball/tty.c
===================================================================
--- trunk/squishyball/tty.c	2010-11-26 16:29:22 UTC (rev 17662)
+++ trunk/squishyball/tty.c	2010-11-27 13:11:25 UTC (rev 17663)
@@ -34,22 +34,9 @@
 #include "main.h"
 #include "mincurses.h"
 
-/*
-
-- CASUAL COMPARISON MODE ------------------------------------- 2ch 24bit 44100 -
-
-PLAYING A           00:00:00.00 | 00:00:00.00 | 00:00:00.00          00:00:00.00
-OOOOOOOOOOOOOOOOOOOHHHHHHHHHHHHH|HHHHHHHHHHHHHHHHHHHHH00000000000000000000000000
-                                ^
-+------------------------------------------------- REPEAT AFTER - SILENT FLIP -+
-| 6/10 trials: ABABAA                                                          |
-+------------------------------------------------------------------------------+
-
-*/
-
-static int p_tm,p_ch,p_b,p_r,p_fm,p_rm,pcm_n,p_tr,p_tn,p_pau;
+static int p_tm,p_ch,p_b,p_r,p_fm,p_rm,pcm_n,p_tr,p_tn,p_pau,p_pl;
 static double p_st,p_cur,p_end,p_len;
-static char p_pl, *p_tl;
+static char *p_tl;
 static pcm_t **pcm_p;
 
 static char timebuffer[80];
@@ -85,147 +72,108 @@
     buf[i+pos]=s[i];
 }
 
-void panel_update_playing(char c){
-}
+static int timerow;
+static int playrow;
+static int toprow;
+static int boxrow;
+static int fliprow;
 
-void panel_update_start(double time){
-
-}
-void panel_update_current(double time){
-
-}
-void panel_update_end(double time){
-
-}
-
-void panel_update_repeat_mode(int mode){
-
-}
-
-void panel_update_flip_mode(int mode){
-
-}
-
-void panel_update_trials(char *trial_list){
-
-}
-
-void panel_update_sample(int n){
-
-}
-void panel_update_pause(int flag){
-
-}
-
-static void draw_topbar(void){
+static void draw_topbar(int row){
   char buf[columns+1];
-  char buf2[columns+1];
+  int i=0,j;
+  toprow=row;
 
-  fill(buf,ACS_HLINE,columns);
-  min_mvcur(0,1);
-  min_gfxmode();
-  min_putstr(buf);
-  min_textmode();
+  min_mvcur(0,row);
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
+  min_putchar(ACS_VLINE);
+  min_unset();
+  i++;
 
-  min_mvcur(1,1);
   switch(p_tm){
   case 0:
-    min_putstr(" A/B MODE ");
+    min_putstr(" A/B TEST MODE ");
+    i+=j=15;
     break;
   case 1:
-    min_putstr(" A/B/X MODE ");
+    i+=j=17;
+    min_putstr(" A/B/X TEST MODE ");
     break;
   case 2:
-    min_putstr(" X/X/Y MODE ");
+    i+=j=17;
+    min_putstr(" X/X/Y TEST MODE ");
     break;
   case 3:
+    i+=j=24;
     min_putstr(" CASUAL COMPARISON MODE ");
     break;
   }
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
+  min_putchar(ACS_VLINE);
+  min_unset();
+  i++;
 
-  sprintf(buf2," %dch %dbit %dHz ",p_ch,p_b,p_r);
+  sprintf(buf," %dch %dbit %dHz ",p_ch,p_b,p_r);
+  for(;i<columns-strlen(buf);i++)
+    min_putchar(' ');
+  min_putstr(buf);
 
-  min_mvcur(columns-strlen(buf2)-1,1);
-  min_putstr(buf2);
+  min_mvcur(0,row-1);
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
+  min_putchar(ACS_ULCORNER);
+  for(i=0;i<j;i++)
+    min_putchar(ACS_HLINE);
+  min_putchar(ACS_URCORNER);
+
+  min_mvcur(0,row+1);
+  min_putchar(ACS_VLINE);
+  min_fg(COLOR_CYAN);
+  for(i=0;i<j;i++)
+    min_putchar(ACS_HLINE);
+  min_putchar(ACS_LLCORNER);
+  min_unset();
 }
 
-static void draw_timebar(void){
-  int pre = rint(p_st/p_len*columns);
-  int post = rint((p_len-p_end)/p_len*columns);
-  int cur = rint(p_cur/(p_len-1)*columns);
+static void draw_timebar(int row){
   char buf[columns+1];
-  int i;
+  timerow=row;
 
-  /* first line: spacing */
-  min_mvcur(0,2);
-  fill(buf,' ',columns);
+  fill(buf,ACS_HLINE,columns);
+  min_mvcur(0,row);
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
   min_putstr(buf);
+  min_unset();
 
-  /* second line: timing */
-  min_mvcur(0,3);
-  if(p_pau){
-    min_blink(1);
-    min_putstr("PAUSED   ");
-    min_blink(0);
-  }else{
-    min_putstr("PLAYING ");
-    switch(p_tm){
-    case 0: /* AB */
-    case 1: /* ABX */
-      min_putchar(p_pl+'A');
-      break;
-    case 2: /* XXY*/
-    case 3: /* Casual */
-      min_putchar(p_pl+'1');
-      break;
-    }
-  }
-
-  for(i=9;i<columns/2-19;i++)
-    min_putchar(' ');
-
-  if(p_st<=0.f){
-    min_fg(COLOR_CYAN);
-    min_putstr("xx:xx:xx.xx");
-    min_fg(-1);
-  }else{
-    char *time=make_time_string(p_st,1);
-    min_putstr(time);
-  }
-  min_putstr(" | ");
+  min_mvcur(columns-12,row);
+  min_putchar(' ');
   {
-    char *time=make_time_string(p_cur,1);
-    min_putstr(time);
-  }
-  min_putstr(" | ");
-  if(p_end>=p_len){
-    min_fg(COLOR_CYAN);
-    min_putstr("xx:xx:xx.xx");
-    min_fg(-1);
-  }else{
-    char *time=make_time_string(p_end,1);
-    min_putstr(time);
-  }
-
-  for(i=columns/2+20;i<columns-11;i++)
-    min_putchar(' ');
-  {
     char *time=make_time_string(p_len,1);
     min_putstr(time);
   }
+}
 
-  /* third line: indicator */
+static void draw_playbar(int row){
+  int pre = rint(p_st/p_len*columns);
+  int post = rint((p_len-p_end)/p_len*columns);
+  int cur = rint(p_cur/(p_len-1)*columns);
+  int i;
+  playrow=row;
+
   i=0;
-  min_mvcur(0,4);
+  min_mvcur(0,row);
+  min_gfx(1);
+  min_color(COLOR_YELLOW,COLOR_CYAN);
+  min_bold(1);
   if(pre>0){
-    min_bg(COLOR_CYAN);
     while(i<pre){
       min_putchar(' ');
       i++;
     }
   }
-  min_color(COLOR_YELLOW,COLOR_BLACK);
-  min_bold(1);
+  min_bg(COLOR_BLACK);
   while(i<cur){
     min_putchar(' ');
     i++;
@@ -241,124 +189,57 @@
     min_putchar(' ');
     i++;
   }
-  min_bg(-1);
-
-  /* fourth line: spacing with indicator */
-  min_mvcur(0,5);
-  min_fg(COLOR_YELLOW);
-  min_bold(1);
-  i=0;
-  while(i<cur){
-    min_putchar(' ');
-    i++;
-  }
-  min_putchar(ACS_TTEE);
-  i++;
-  while(i<post){
-    min_putchar(' ');
-    i++;
-  }
   min_unset();
 }
 
-static void draw_trials_box(void){
+static void draw_trials_box(int row){
   char buf[columns+1];
+  boxrow=row;
+  fliprow=row+2;
 
   /* top line of box */
   fill(buf,ACS_HLINE,columns);
   buf[0]=ACS_ULCORNER;
   buf[columns-1]=ACS_URCORNER;
-
-  switch(p_rm){
-  case 0:
-    break;
-  case 1:
-    print_into(buf,columns-31," RESTART AFTER ");
-    break;
-  case 2:
-    print_into(buf,columns-31," RESTART EVERY ");
-    break;
-  }
-  switch(p_fm){
-  case 1:
-    print_into(buf,columns-12," MARK FLIP ");
-    break;
-  case 2:
-    print_into(buf,columns-12," BEEP FLIP ");
-    break;
-  case 3:
-    print_into(buf,columns-14," SILENT FLIP ");
-    break;
-  }
-  min_mvcur(0,6);
+  min_mvcur(0,row);
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
   min_putstr(buf);
 
   /* trials line */
-  min_mvcur(0,7);
+  min_mvcur(0,row+1);
   min_putchar(ACS_VLINE);
-  {
-    int l = strlen(p_tl);
-    sprintf(buf," %d/%d trials: ",l,p_tn);
-    min_putstr(buf);
-
-    l+=strlen(buf);
-    if(l>columns-4){
-      min_putstr("...");
-      min_putstr(p_tl+l-columns-7);
-      min_putchar(' ');
-    }else{
-      int i;
-      min_putstr(p_tl);
-      for(i=strlen(buf)+strlen(p_tl);i<columns-2;i++)
-        min_putchar(' ');
-    }
-  }
+  min_mvcur(columns-1,row+1);
   min_putchar(ACS_VLINE);
 
-  min_mvcur(0,8);
+  min_mvcur(0,row+2);
   fill(buf,ACS_HLINE,columns);
   buf[0]=ACS_LLCORNER;
   buf[columns-1]=ACS_LRCORNER;
   min_putstr(buf);
+  min_unset();
 }
 
-static void draw_samples_box(void){
+static void draw_samples_box(int row){
   char buf[columns+1];
   int i;
+  boxrow=row;
+  fliprow=row+pcm_n+1;
 
   /* top line of box */
   fill(buf,ACS_HLINE,columns);
   buf[0]=ACS_ULCORNER;
   buf[columns-1]=ACS_URCORNER;
-
-  switch(p_rm){
-  case 0:
-    break;
-  case 1:
-    print_into(buf,columns-31," RESTART AFTER ");
-    break;
-  case 2:
-    print_into(buf,columns-31," RESTART EVERY ");
-    break;
-  }
-  switch(p_fm){
-  case 1:
-    print_into(buf,columns-12," MARK FLIP ");
-    break;
-  case 2:
-    print_into(buf,columns-12," BEEP FLIP ");
-    break;
-  case 3:
-    print_into(buf,columns-14," SILENT FLIP ");
-    break;
-  }
-  min_mvcur(0,6);
+  min_mvcur(0,row);
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
   min_putstr(buf);
 
   /* one line per sample, highlight the currently played sample */
   for(i=0;i<pcm_n;i++){
-    min_mvcur(0,7+i);
+    min_mvcur(0,row+i+1);
     min_putchar(ACS_VLINE);
+    min_unset();
     fill(buf,' ',columns-3);
     if(i==p_pl){
       min_putchar('>');
@@ -373,29 +254,46 @@
     min_putstr(buf);
     if(i==p_pl)
       min_bold(0);
+    min_gfx(1);
+    min_fg(COLOR_CYAN);
     min_putchar(ACS_VLINE);
   }
-  min_mvcur(0,7+pcm_n);
+  min_mvcur(0,row+pcm_n+1);
   fill(buf,ACS_HLINE,columns);
   buf[0]=ACS_LLCORNER;
   buf[columns-1]=ACS_LRCORNER;
   min_putstr(buf);
+  min_unset();
 }
 
 void panel_redraw_full(void){
-  draw_topbar();
-  draw_timebar();
+  int i=2;
 
-  if(p_tm==3)
-    draw_samples_box();
-  else
-    draw_trials_box();
+  if(p_tm==3){
+    draw_samples_box(i);
+    i+=pcm_n+2;
+  }else{
+    draw_trials_box(i);
+    i+=3;
+  }
+  draw_playbar(i++);
+  draw_timebar(i++);
+  draw_topbar(1);
+  panel_update_pause(p_pau);
+  panel_update_playing(p_pl);
+  panel_update_start(p_st);
+  panel_update_current(p_cur);
+  panel_update_end(p_end);
+  panel_update_repeat_mode(p_rm);
+  panel_update_flip_mode(p_fm);
+  if(p_tm!=3)
+    panel_update_trials(p_tl);
   min_flush();
 }
 
 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+8:9)){
+  if(min_init_panel(test_mode==3 ? test_files+6:7)){
     fprintf(stderr,"Unable to initialize terminal\n");
     exit(101);
   }
@@ -426,3 +324,222 @@
   min_hidecur();
   panel_redraw_full();
 }
+
+void panel_update_start(double time){
+  p_st=time;
+  min_mvcur(columns/2-21,timerow);
+  min_putchar(' ');
+  if(p_st<=0.f){
+    min_fg(COLOR_CYAN);
+    min_putstr("xx:xx:xx.xx");
+    min_fg(-1);
+  }else{
+    char *time=make_time_string(p_st,1);
+    min_putstr(time);
+  }
+  min_putchar(' ');
+  draw_playbar(playrow);
+  min_flush();
+}
+
+void panel_update_current(double time){
+  int was = rint(p_cur/(p_len-1)*columns);
+  int now = rint(time/(p_len-1)*columns);
+  p_cur=time;
+  min_mvcur(columns/2-7,timerow);
+  min_putchar(' ');
+  {
+    char *time=make_time_string(p_cur,1);
+    min_putstr(time);
+  }
+  min_putchar(' ');
+
+  if(was!=now){
+    int pre = rint(p_st/p_len*columns);
+    int post = rint((p_len-p_end)/p_len*columns);
+
+    min_bold(1);
+    min_gfx(1);
+
+    min_mvcur(was,playrow);
+    if(was<pre || (columns-was)<post){
+      min_color(COLOR_YELLOW,COLOR_CYAN);
+    }else{
+      min_color(COLOR_YELLOW,COLOR_BLACK);
+    }
+    min_putchar(' ');
+
+
+    min_mvcur(now,playrow);
+    if(now<pre || (columns-now)<post){
+      min_bg(COLOR_CYAN);
+    }else{
+      min_bg(COLOR_BLACK);
+    }
+    min_putchar(ACS_VLINE);
+  }
+  min_unset();
+  min_flush();
+}
+
+void panel_update_end(double time){
+  p_end=time;
+  min_mvcur(columns/2+7,timerow);
+  min_putchar(' ');
+  if(p_end>=p_len){
+    min_fg(COLOR_CYAN);
+    min_putstr("xx:xx:xx.xx");
+    min_fg(-1);
+  }else{
+    char *time=make_time_string(p_end,1);
+    min_putstr(time);
+  }
+  min_putchar(' ');
+  draw_playbar(playrow);
+  min_flush();
+}
+
+void panel_update_repeat_mode(int mode){
+  int i;
+  min_mvcur(columns-31,fliprow);
+  p_rm=mode;
+  switch(p_rm){
+  case 0:
+    min_fg(COLOR_CYAN);
+    min_gfx(1);
+    for(i=0;i<15;i++)
+      min_putchar(ACS_HLINE);
+    min_unset();
+    break;
+  case 1:
+    min_putstr(" RESTART AFTER ");
+    break;
+  case 2:
+    min_mvcur(columns-31,fliprow+2);
+    min_putstr(" RESTART EVERY ");
+    break;
+  }
+  min_flush();
+}
+
+void panel_update_flip_mode(int mode){
+  min_mvcur(columns-14,fliprow);
+  min_fg(COLOR_CYAN);
+  min_gfx(1);
+  min_putchar(ACS_HLINE);
+  min_putchar(ACS_HLINE);
+  min_unset();
+
+  p_fm=mode;
+  switch(p_fm){
+  case 1:
+    min_mvcur(columns-12,fliprow);
+    min_putstr(" MARK FLIP ");
+    break;
+  case 2:
+    min_mvcur(columns-12,fliprow);
+    min_putstr(" BEEP FLIP ");
+    break;
+  case 3:
+    min_mvcur(columns-14,fliprow);
+    min_putstr(" SILENT FLIP ");
+    break;
+  }
+  min_flush();
+}
+
+static int old_p_tl_len=-1;
+void panel_update_trials(char *trial_list){
+  char buf[columns+1];
+  int k,l = strlen(trial_list);
+  if(p_tl)free(p_tl);
+  p_tl=strdup(trial_list);
+  min_mvcur(1,boxrow+1);
+
+  sprintf(buf," %d/%d trials: ",l,p_tn);
+  min_putstr(buf);
+
+  l+=strlen(buf);
+  if(l>columns-4){
+    min_putstr("...");
+    min_putstr(p_tl+l-columns-7);
+    l+=strlen(p_tl+l-columns-7);
+  }else{
+    min_putstr(p_tl);
+    l+=strlen(p_tl);
+  }
+  {
+    k=l;
+    while(k++<old_p_tl_len)
+      min_putchar(' ');
+    old_p_tl_len=l;
+  }
+  min_flush();
+}
+
+void panel_update_playing(int n){
+  if(p_tm==3){
+    min_mvcur(1,boxrow+1+p_pl);
+    min_putchar(' ');
+    if(strlen(pcm_p[p_pl]->path)>columns-4)
+      min_putstr(pcm_p[p_pl]->path+strlen(pcm_p[p_pl]->path)-columns+4);
+    else
+      min_putstr(pcm_p[p_pl]->path);
+
+    min_mvcur(1,boxrow+1+n);
+    min_putchar('>');
+    min_bold(1);
+    if(strlen(pcm_p[n]->path)>columns-4)
+      min_putstr(pcm_p[n]->path+strlen(pcm_p[n]->path)-columns+4);
+    else
+      min_putstr(pcm_p[n]->path);
+    min_unset();
+  }
+
+  p_pl=n;
+  if(!p_pau){
+    min_mvcur(8,timerow);
+    switch(p_tm){
+    case 0: /* AB */
+    case 1: /* ABX */
+      min_putchar(p_pl+'A');
+      break;
+    case 2: /* XXY*/
+    case 3: /* Casual */
+      min_putchar(p_pl+'1');
+      break;
+    }
+  }
+  min_flush();
+}
+
+void panel_update_pause(int flag){
+  p_pau=flag;
+  min_mvcur(0,timerow);
+  if(p_pau){
+    min_blink(1);
+    min_putstr("PAUSED ");
+    min_blink(0);
+  }else{
+    min_putstr("PLAYING ");
+    switch(p_tm){
+    case 0: /* AB */
+    case 1: /* ABX */
+      min_putchar(p_pl+'A');
+      break;
+    case 2: /* XXY*/
+    case 3: /* Casual */
+      min_putchar(p_pl+'1');
+      break;
+    }
+  }
+  min_putchar(' ');
+
+  min_gfx(1);
+  min_fg(COLOR_CYAN);
+  min_putchar(ACS_HLINE);
+  min_putchar(ACS_HLINE);
+  min_putchar(ACS_HLINE);
+  min_unset();
+  min_flush();
+}



More information about the commits mailing list