minimenu; 'b' now works in select menu (in addition to enter); pressing keyboard...
[pandora-libraries.git] / minimenu / mmui.c
index 7d2815f..7a2e21d 100644 (file)
@@ -74,8 +74,10 @@ mm_appref_t *ui_selected = NULL;
 unsigned char ui_category = 0;          // current category
 unsigned char ui_catshift = 0;          // how many cats are offscreen to the left
 
-extern mm_category_t g_categories [ MAX_CATS ];
+extern mm_category_t *g_categories;
 extern unsigned char g_categorycount;
+extern mm_category_t _categories_invis [ MAX_CATS ];
+extern unsigned char _categories_inviscount;
 
 static SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore
 static int ui_selected_index ( void );
@@ -425,104 +427,108 @@ void ui_render ( void ) {
     unsigned int maxtab = ( screen_width / tab_width ) < g_categorycount ? ( screen_width / tab_width ) + ui_catshift : g_categorycount + ui_catshift;
     unsigned int maxtabspot = ( screen_width / tab_width );
 
-    // draw tabs with categories
-    for ( col = ui_catshift;
-         col < maxtab;
-         col++ )
-    {
+    if ( g_categorycount > 0 ) {
 
-      SDL_Surface *s;
+      // draw tabs with categories
+      for ( col = ui_catshift;
+           col < maxtab;
+           col++ )
+      {
 
-      // if this is the first (leftmost) tab, we use different artwork
-      // than if the other tabs (so skinner can link lines up nicely.)
-      if ( col == ui_catshift ) {
-       // leftmost tab, special case
+       SDL_Surface *s;
 
-       if ( col == ui_category ) {
-         s = g_imagecache [ IMG_TAB_SEL_L ].i;
-       } else {
-         s = g_imagecache [ IMG_TAB_UNSEL_L ].i;
-       }
+       // if this is the first (leftmost) tab, we use different artwork
+       // than if the other tabs (so skinner can link lines up nicely.)
+       if ( col == ui_catshift ) {
+         // leftmost tab, special case
 
-      } else if ( col == maxtab - 1 ) {
-       // rightmost tab, special case
+         if ( col == ui_category ) {
+           s = g_imagecache [ IMG_TAB_SEL_L ].i;
+         } else {
+           s = g_imagecache [ IMG_TAB_UNSEL_L ].i;
+         }
 
-       if ( col == ui_category ) {
-         s = g_imagecache [ IMG_TAB_SEL_R ].i;
-       } else {
-         s = g_imagecache [ IMG_TAB_UNSEL_R ].i;
-       }
+       } else if ( col == maxtab - 1 ) {
+         // rightmost tab, special case
 
-      } else {
-       // normal (not leftmost) tab
+         if ( col == ui_category ) {
+           s = g_imagecache [ IMG_TAB_SEL_R ].i;
+         } else {
+           s = g_imagecache [ IMG_TAB_UNSEL_R ].i;
+         }
 
-       if ( col == ui_category ) {
-         s = g_imagecache [ IMG_TAB_SEL ].i;
        } else {
-         s = g_imagecache [ IMG_TAB_UNSEL ].i;
-       }
+         // normal (not leftmost) tab
 
-      } // first col, or not first col?
+         if ( col == ui_category ) {
+           s = g_imagecache [ IMG_TAB_SEL ].i;
+         } else {
+           s = g_imagecache [ IMG_TAB_UNSEL ].i;
+         }
 
-      // draw tab
-      src.x = 0;
-      src.y = 0;
+       } // first col, or not first col?
+
+       // draw tab
+       src.x = 0;
+       src.y = 0;
 #if 0
-      src.w = tab_width;
-      if ( col == ui_category ) {
-       src.h = tab_selheight;
-      } else {
-       src.h = tab_height;
-      }
+       src.w = tab_width;
+       if ( col == ui_category ) {
+         src.h = tab_selheight;
+       } else {
+         src.h = tab_height;
+       }
 #else
-      src.w = s -> w;
-      src.h = s -> h;
+       src.w = s -> w;
+       src.h = s -> h;
 #endif
-      dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
-      dest -> y = tab_offset_y;
+       dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
+       dest -> y = tab_offset_y;
 
-      // store touch info
-      ui_register_tab ( col, dest -> x, dest -> y, tab_width, tab_height );
+       // store touch info
+       ui_register_tab ( col, dest -> x, dest -> y, tab_width, tab_height );
 
-      if ( render_jobs_b & R_TABS ) {
-       //pnd_log ( pndn_debug, "tab %u at %ux%u\n", col, dest.x, dest.y );
-       SDL_BlitSurface ( s, &src, sdl_realscreen, dest );
-       dest++;
+       if ( render_jobs_b & R_TABS ) {
+         //pnd_log ( pndn_debug, "tab %u at %ux%u\n", col, dest.x, dest.y );
+         SDL_BlitSurface ( s, &src, sdl_realscreen, dest );
+         dest++;
 
-       // draw tab line
-       if ( col == ui_category ) {
-         // no line for selected tab
-       } else {
-         if ( col - ui_catshift == 0 ) {
-           s = g_imagecache [ IMG_TAB_LINEL ].i;
-         } else if ( col - ui_catshift == maxtabspot - 1 ) {
-           s = g_imagecache [ IMG_TAB_LINER ].i;
+         // draw tab line
+         if ( col == ui_category ) {
+           // no line for selected tab
          } else {
-           s = g_imagecache [ IMG_TAB_LINE ].i;
+           if ( col - ui_catshift == 0 ) {
+             s = g_imagecache [ IMG_TAB_LINEL ].i;
+           } else if ( col - ui_catshift == maxtabspot - 1 ) {
+             s = g_imagecache [ IMG_TAB_LINER ].i;
+           } else {
+             s = g_imagecache [ IMG_TAB_LINE ].i;
+           }
+           dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
+           dest -> y = tab_offset_y + tab_height;
+           SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
+           dest++;
          }
-         dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
-         dest -> y = tab_offset_y + tab_height;
-         SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
+
+         // draw text
+         SDL_Surface *rtext;
+         SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
+         rtext = TTF_RenderText_Blended ( g_tab_font, g_categories [ col ].catname, tmpfontcolor );
+         src.x = 0;
+         src.y = 0;
+         src.w = rtext -> w < text_width ? rtext -> w : text_width;
+         src.h = rtext -> h;
+         dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width ) + text_offset_x;
+         dest -> y = tab_offset_y + text_offset_y;
+         SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
+         SDL_FreeSurface ( rtext );
          dest++;
-       }
 
-       // draw text
-       SDL_Surface *rtext;
-       SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
-       rtext = TTF_RenderText_Blended ( g_tab_font, g_categories [ col ].catname, tmpfontcolor );
-       src.x = 0;
-       src.y = 0;
-       src.w = rtext -> w < text_width ? rtext -> w : text_width;
-       src.h = rtext -> h;
-       dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width ) + text_offset_x;
-       dest -> y = tab_offset_y + text_offset_y;
-       SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
-       SDL_FreeSurface ( rtext );
-       dest++;
+       } // r_tabs
 
-      } // r_tabs
+      } // for
 
-    } // for
+    } // if we got categories
 
     if ( render_jobs_b & R_TABS ) {
 
@@ -1189,13 +1195,13 @@ void ui_process_input ( unsigned char block_p ) {
       } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) {
        ui_push_exec();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_z || event.key.keysym.sym == SDLK_RSHIFT ) {
+      } else if ( event.key.keysym.sym == SDLK_RSHIFT ) {
        ui_push_ltrigger();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) {
+      } else if ( event.key.keysym.sym == SDLK_RCTRL ) {
        ui_push_rtrigger();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_y || event.key.keysym.sym == SDLK_PAGEUP ) {
+      } else if ( event.key.keysym.sym == SDLK_PAGEUP ) {
        // info
        if ( ui_selected ) {
          ui_show_info ( pnd_run_script, ui_selected -> ref );
@@ -1208,23 +1214,22 @@ void ui_process_input ( unsigned char block_p ) {
 
       } else if ( event.key.keysym.sym == SDLK_LCTRL /*LALT*/ ) { // select button
        char *opts [ 20 ] = {
-         "Return to Minimenu",
+         "Reveal hidden category",
          "Shutdown Pandora",
-         "Rescan for Applications",
+         "Rescan for applications",
          "Cache previews to SD now",
-         "Run xfce4 from Minimenu",
          "Run a terminal/console",
-         "Exit and run xfce4",
-         "Exit and run pmenu",
+         "Run another GUI (xfce, etc)",
          "Quit (<- beware)",
          "Select a Minimenu skin",
          "About Minimenu"
        };
-       int sel = ui_modal_single_menu ( opts, 11, "Minimenu", "Enter to select; other to return." );
+       int sel = ui_modal_single_menu ( opts, 9, "Minimenu", "Enter to select; other to return." );
 
        char buffer [ 100 ];
        if ( sel == 0 ) {
          // do nothing
+         ui_revealscreen();
        } else if ( sel == 1 ) {
          // shutdown
          sprintf ( buffer, "sudo poweroff" );
@@ -1235,12 +1240,6 @@ void ui_process_input ( unsigned char block_p ) {
          applications_free();
          pnd_log ( pndn_debug, "Rescanning applications\n" );
          applications_scan();
-         // reset view
-         ui_selected = NULL;
-         ui_rows_scrolled_down = 0;
-         // set back to first tab, to be safe
-         ui_category = 0;
-         ui_catshift = 0;
        } else if ( sel == 3 ) {
          // cache preview to SD now
          extern pnd_box_handle g_active_apps;
@@ -1265,11 +1264,6 @@ void ui_process_input ( unsigned char block_p ) {
          } // while
 
        } else if ( sel == 4 ) {
-         // run xfce
-         char buffer [ PATH_MAX ];
-         sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/bin/startxfce4" );
-         emit_and_quit ( buffer );
-       } else if ( sel == 5 ) {
          // run terminal
          char *argv[5];
          argv [ 0 ] = pnd_conf_get_as_char ( g_conf, "utility.terminal" );
@@ -1279,41 +1273,61 @@ void ui_process_input ( unsigned char block_p ) {
            ui_forkexec ( argv );
          }
 
-       } else if ( sel == 6 ) {
-         // set env to xfce
-         sprintf ( buffer, "echo startxfce4 > /tmp/gui.load" );
-         system ( buffer );
-         emit_and_quit ( buffer );
-         //sprintf ( buffer, "sudo poweroff" );
-         //system ( buffer );
-         exit ( 0 );
-       } else if ( sel == 7 ) {
-         // set env to pmenu
-         sprintf ( buffer, "echo pmenu > /tmp/gui.load" );
-         system ( buffer );
+       } else if ( sel == 5 ) {
+         char buffer [ PATH_MAX ];
+         sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/pandora/scripts/op_switchgui.sh" );
          emit_and_quit ( buffer );
-         //sprintf ( buffer, "sudo poweroff" );
-         //system ( buffer );
-         exit ( 0 );
-       } else if ( sel == 8 ) {
+       } else if ( sel == 6 ) {
          emit_and_quit ( MM_QUIT );
-       } else if ( sel == 9 ) {
+       } else if ( sel == 7 ) {
          // select skin
          if ( ui_pick_skin() ) {
            emit_and_quit ( MM_RESTART );
          }
-       } else if ( sel == 10 ) {
+       } else if ( sel == 8 ) {
          // about
+         char buffer [ PATH_MAX ];
+         sprintf ( buffer, "%s/about.txt", g_skinpath );
+         ui_aboutscreen ( buffer );
        }
 
        ui_event++;
        render_mask |= CHANGED_EVERYTHING;
-      }
+
+      } else {
+       // unknown SDLK_ keycode?
+
+       // many SDLK_keycodes map to ASCII ("a" is ascii(a)), so try to jump to a filename of that name, in this category?
+       // and if already there, try to jump to next, maybe?
+       // future: look for sequence typing? ie: user types 'm' then 'a', look for 'ma*' instead of 'm' then 'a' matching
+       if ( isalpha ( event.key.keysym.sym ) && g_categories [ ui_category ].refcount > 0 ) {
+         mm_appref_t *app = g_categories [ ui_category ].refs;
+
+         // walk the category, looking for a first-char match
+         while ( app ) {
+           if ( app -> ref -> title_en && toupper ( app -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) ) {
+             break;
+           }
+           app = app -> next;
+         }
+
+         // found something, or no?
+         if ( app ) {
+           // looks like we found a potential match; try switching it to visible selection
+           ui_selected = app;
+           ui_set_selected ( ui_selected );
+         }
+
+       } // SDLK_alphanumeric?
+
+      } // SDLK_....
 
       // extras
+#if 0
       if ( event.key.keysym.sym == SDLK_q ) {
        emit_and_quit ( MM_QUIT );
       }
+#endif
 
       break;
 #endif
@@ -1629,6 +1643,10 @@ void ui_push_ltrigger ( void ) {
   unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
   unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
 
+  if ( g_categorycount == 0 ) {
+    return;
+  }
+
   if ( ui_category > 0 ) {
     ui_category--;
     category_fs_restock ( &(g_categories [ ui_category ]) );
@@ -1664,6 +1682,10 @@ void ui_push_ltrigger ( void ) {
 void ui_push_rtrigger ( void ) {
   unsigned char oldcat = ui_category;
 
+  if ( g_categorycount == 0 ) {
+    return;
+  }
+
   unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
   unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
 
@@ -1947,6 +1969,8 @@ int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *f
   SDL_Rect *dest = rects;
   SDL_Rect src;
   SDL_Surface *rtext;
+  unsigned char max_visible = pnd_conf_get_as_int_d ( g_conf, "detailtext.max_visible" , 11 );
+  unsigned char first_visible = 0;
 
   bzero ( rects, sizeof(SDL_Rect) * 40 );
 
@@ -2021,7 +2045,7 @@ int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *f
     }
 
     // show options
-    for ( i = 0; i < argc; i++ ) {
+    for ( i = first_visible; i < first_visible + max_visible && i < argc; i++ ) {
 
       // show options
       if ( sel == i ) {
@@ -2030,7 +2054,7 @@ int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *f
        rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], tmpfontcolor );
       }
       dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
-      dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 40 + ( 20 * ( i + 1 ) );
+      dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 40 + ( 20 * ( i + 1 - first_visible ) );
       SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
       SDL_FreeSurface ( rtext );
       dest++;
@@ -2051,17 +2075,31 @@ int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *f
        if ( event.key.keysym.sym == SDLK_UP ) {
          if ( sel ) {
            sel--;
+
+           if ( sel < first_visible ) {
+             first_visible--;
+           }
+
          }
        } else if ( event.key.keysym.sym == SDLK_DOWN ) {
+
          if ( sel < argc - 1 ) {
            sel++;
+
+           // ensure visibility
+           if ( sel >= first_visible + max_visible ) {
+             first_visible++;
+           }
+
          }
 
-       } else if ( event.key.keysym.sym == SDLK_RETURN ) {
+       } else if ( event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_END ) { // return, or "B"
          return ( sel );
 
+#if 0
        } else if ( event.key.keysym.sym == SDLK_q ) {
          exit ( 0 );
+#endif
 
        } else {
          return ( -1 ); // nada
@@ -2323,6 +2361,42 @@ void ui_post_scan ( void ) {
 
   } // deferred icon load
 
+  // reset view
+  ui_selected = NULL;
+  ui_rows_scrolled_down = 0;
+  // set back to first tab, to be safe
+  ui_category = 0;
+  ui_catshift = 0;
+
+  // do we have a preferred category to jump to?
+  char *dc = pnd_conf_get_as_char ( g_conf, "categories.default_cat" );
+  if ( dc ) {
+
+    // attempt to find default cat; if we do find it, select it; otherwise
+    // default behaviour will pick first cat (ie: usually All)
+    unsigned int i;
+    for ( i = 0; i < g_categorycount; i++ ) {
+      if ( strcasecmp ( g_categories [ i ].catname, dc ) == 0 ) {
+       ui_category = i;
+       // ensure visibility
+       unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
+       unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
+       if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
+         ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
+       }
+       break;
+      }
+    }
+
+    if ( i == g_categorycount ) {
+      pnd_log ( pndn_warning, "  User defined default category '%s' but not found, so using default behaviour\n", dc );
+    }
+
+  } // default cat
+
+  // redraw all
+  render_mask |= CHANGED_EVERYTHING;
+
   return;
 }
 
@@ -2442,3 +2516,290 @@ unsigned char ui_pick_skin ( void ) {
 
   return ( 0 );
 }
+
+void ui_aboutscreen ( char *textpath ) {
+#define PIXELW 7
+#define PIXELH 7
+#define MARGINW 3
+#define MARGINH 3
+#define SCRW 800
+#define SCRH 480
+#define ROWS SCRH / ( PIXELH + MARGINH )
+#define COLS SCRW / ( PIXELW + MARGINW )
+
+  unsigned char pixelboard [ ROWS * COLS ]; // pixel heat
+  bzero ( pixelboard, ROWS * COLS );
+
+  SDL_Surface *rtext;
+  SDL_Rect r;
+
+  SDL_Color rtextc = { 200, 200, 200, 100 };
+
+  // pixel scroller
+  char *textloop [ 500 ];
+  unsigned int textmax = 0;
+  bzero ( textloop, 500 * sizeof(char*) );
+
+  // cursor scroller
+  char cbuffer [ 50000 ];
+  bzero ( cbuffer, 50000 );
+  unsigned int crevealed = 0;
+
+  FILE *f = fopen ( textpath, "r" );
+
+  if ( ! f ) {
+    pnd_log ( pndn_error, "ERROR: Couldn't open about text: %s\n", textpath );
+    return;
+  }
+
+  char textbuf [ 100 ];
+  while ( fgets ( textbuf, 100, f ) ) {
+
+    // add to full buffer
+    strncat ( cbuffer, textbuf, 50000 );
+
+    // chomp
+    if ( strchr ( textbuf, '\n' ) ) {
+      * strchr ( textbuf, '\n' ) = '\0';
+    }
+
+    // add to pixel loop
+    if ( 1||textbuf [ 0 ] ) {
+      textloop [ textmax ] = strdup ( textbuf );
+      textmax++;
+    }
+
+  } // while fgets
+
+  fclose ( f );
+
+  unsigned int textiter = 0;
+  while ( textiter < textmax ) {
+    char *text = textloop [ textiter ];
+
+    rtext = NULL;
+    if ( text [ 0 ] ) {
+      // render to surface
+      rtext = TTF_RenderText_Blended ( g_grid_font, text, rtextc );
+
+      // render font to pixelboard
+      unsigned int px, py;
+      unsigned char *ph;
+      unsigned int *pixels = rtext -> pixels;
+      unsigned char cr, cg, cb, ca;
+      for ( py = 0; py < rtext -> h; py ++ ) {
+       for ( px = 0; px < ( rtext -> w > COLS ? COLS : rtext -> w ); px++ ) {
+
+         SDL_GetRGBA ( pixels [ ( py * rtext -> pitch / 4 ) + px ],
+                       rtext -> format, &cr, &cg, &cb, &ca );
+
+         if ( ca != 0 ) {
+
+           ph = pixelboard + ( /*y offset */ 30 * COLS ) + ( py * COLS ) + px /* / 2 */;
+
+           if ( *ph < 100 ) {
+             *ph = 100;
+           }
+
+           ca /= 5;
+           if ( *ph + ca < 250 ) {
+             *ph += ca;
+           }
+
+         } // got a pixel?
+
+       } // x
+      } // y
+
+    } // got text?
+
+    unsigned int runcount = 10;
+    while ( runcount-- ) {
+
+      // clear display
+      SDL_FillRect( sdl_realscreen, NULL /* whole */, 0 );
+
+      // render pixelboard
+      unsigned int x, y;
+      unsigned int c;
+      for ( y = 0; y < ROWS; y++ ) {
+       for ( x = 0; x < COLS; x++ ) {
+
+         if ( 1||pixelboard [ ( y * COLS ) + x ] ) {
+
+           // position
+           r.x = x * ( PIXELW + MARGINW );
+           r.y = y * ( PIXELH + MARGINH );
+           r.w = PIXELW;
+           r.h = PIXELH;
+           // heat -> colour
+           c = SDL_MapRGB ( sdl_realscreen -> format, 100 /* r */, 0 /* g */, pixelboard [ ( y * COLS ) + x ] );
+           // render
+           SDL_FillRect( sdl_realscreen, &r /* whole */, c );
+
+         }
+
+       } // x
+      } // y
+
+      // cool pixels
+      unsigned char *pc = pixelboard;
+      for ( y = 0; y < ROWS; y++ ) {
+       for ( x = 0; x < COLS; x++ ) {
+
+         if ( *pc > 10 ) {
+           (*pc) -= 3;
+         }
+
+         pc++;
+       } // x
+      } // y
+
+      // slide pixels upwards
+      memmove ( pixelboard, pixelboard + COLS, ( COLS * ROWS ) - COLS );
+
+      // render actual readable text
+      {
+
+       // display up to cursor
+       SDL_Rect dest;
+       unsigned int cdraw = 0;
+       SDL_Surface *cs;
+       char ctb [ 2 ];
+
+       if ( crevealed > 200 ) {
+         cdraw = crevealed - 200;
+       }
+
+       dest.x = 400;
+       dest.y = 20;
+
+       for ( ; cdraw < crevealed; cdraw++ ) {
+         ctb [ 0 ] = cbuffer [ cdraw ];
+         ctb [ 1 ] = '\0';
+         // move over or down
+         if ( cbuffer [ cdraw ] == '\n' ) {
+           // EOL
+           dest.x = 400;
+           dest.y += 14;
+
+           if ( dest.y > 450 ) {
+             dest.y = 450;
+           }
+
+         } else {
+           // draw the char
+           cs = TTF_RenderText_Blended ( g_tab_font, ctb, rtextc );
+           if ( cs ) {
+             SDL_BlitSurface ( cs, NULL /* all */, sdl_realscreen, &dest );
+             SDL_FreeSurface ( cs );
+             // over
+             dest.x += cs -> w;
+           }
+         }
+
+       }
+
+       dest.w = 10;
+       dest.h = 20;
+       SDL_FillRect ( sdl_realscreen, &dest /* whole */, 220 );
+
+       // increment cursor to next character
+       if ( cbuffer [ crevealed ] != '\0' ) {
+         crevealed++;
+       }
+
+      } // draw cursor text
+
+      // reveal
+      //
+      SDL_UpdateRect ( sdl_realscreen, 0, 0, 0, 0 ); // whole screen
+
+      usleep ( 50000 );
+
+      // any button? if so, about
+      {
+       SDL_PumpEvents();
+
+       SDL_Event e;
+
+       if ( SDL_PeepEvents ( &e, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_KEYUP) ) > 0 ) {
+         return;
+       }
+
+      }
+
+    } // while cooling
+
+    if ( rtext ) {
+      SDL_FreeSurface ( rtext );
+    }
+
+    textiter++;
+  } // while more text
+
+  // free up
+  unsigned int i;
+  for ( i = 0; i < textmax; i++ ) {
+    if ( textloop [ i ] ) {
+      free ( textloop [ i ] );
+      textloop [ i ] = 0;
+    }
+  }
+
+  return;
+}
+
+void ui_revealscreen ( void ) {
+  char *labels [ 500 ];
+  unsigned int labelmax = 0;
+  unsigned int i;
+
+  if ( ! _categories_inviscount ) {
+    return; // nothing to do
+  }
+
+  for ( i = 0; i < _categories_inviscount; i++ ) {
+    labels [ labelmax++ ] = _categories_invis [ i ].catname;
+  }
+
+  int sel = ui_modal_single_menu ( labels, labelmax, "Temporary Category Reveal",
+                                  "Enter to select; other to return." );
+
+  if ( sel >= 0 ) {
+
+    if ( category_query ( _categories_invis [ sel ].catname ) ) {
+      // already present
+      return;
+    }
+
+    // fix up category name, if its been hacked
+    if ( strchr ( _categories_invis [ sel ].catname, '.' ) ) {
+      char *t = _categories_invis [ sel ].catname;
+      _categories_invis [ sel ].catname = strdup ( strchr ( _categories_invis [ sel ].catname, '.' ) + 1 );
+      free ( t );
+    }
+    // copy invisi-cat into live-cat
+    memmove ( &(g_categories [ g_categorycount ]), &(_categories_invis [ sel ]), sizeof(mm_category_t) );
+    g_categorycount++;
+    // move subsequent invisi-cats up, so the selected invisi-cat is nolonger existing in invisi-list at
+    // all (avoid double-free() later)
+    memmove ( &(_categories_invis [ sel ]), &(_categories_invis [ sel + 1 ]), sizeof(mm_category_t) * ( _categories_inviscount - sel - 1 ) );
+    _categories_inviscount--;
+
+    // switch to the new category
+    ui_category = g_categorycount - 1;
+
+    // ensure visibility
+    unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
+    unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
+    if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
+      ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
+    }
+
+    // redraw tabs
+    render_mask |= CHANGED_CATEGORY;
+  }
+
+  return;
+}