r306 - trunk

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat May 26 16:59:00 EDT 2007


Author: icculus
Date: 2007-05-26 16:59:00 -0400 (Sat, 26 May 2007)
New Revision: 306

Modified:
   trunk/gui_ncurses.c
Log:
ncurses UI: Put a percentage meter on the window if text can be scrolled.


Modified: trunk/gui_ncurses.c
===================================================================
--- trunk/gui_ncurses.c	2007-05-26 20:29:19 UTC (rev 305)
+++ trunk/gui_ncurses.c	2007-05-26 20:59:00 UTC (rev 306)
@@ -195,13 +195,24 @@
 static void drawText(MojoBox *mojobox)
 {
     int i;
+    const int tcount = mojobox->textlinecount;
     int pos = mojobox->textpos;
     int w, h;
     WINDOW *win = mojobox->textwin;
     getmaxyx(win, h, w);
+
     wclear(mojobox->textwin);  // !!! FIXME: flickers...
-    for (i = 0; (pos < mojobox->textlinecount) && (i < h); i++, pos++)
+    for (i = 0; (pos < tcount) && (i < h); i++, pos++)
         mvwaddstr(win, i, 0, mojobox->textlines[pos]);
+
+    if (tcount > h)
+    {
+        const int pct = (int) ((((double) pos) / ((double) tcount)) * 100.0);
+        win = mojobox->mainwin;
+        wattron(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD);
+        mvwprintw(win, h+1, w-5, "(%3d%%)", pct);
+        wattroff(win, COLOR_PAIR(MOJOCOLOR_BORDERTITLE) | A_BOLD);
+    } // if
 } // drawText
 
 




More information about the mojosetup-commits mailing list