giftcurs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[giFTcurs-devel] [PATCH] Scrollbar slider


From: Charles Levert
Subject: [giFTcurs-devel] [PATCH] Scrollbar slider
Date: Sat, 1 Jan 2005 15:43:27 -0500
User-agent: Mutt/1.4.1i

Changes:

        * A slider has been added to the scrollbar to accurately represent
          the displayed region.  A diamond is still used to represent the
          current content position.  In accordance with TODO.ms, a trough
          has not been added to the scrollbar; indeed, this would just be
          a visually encumbered waste of screen real estate.  Redundant
          code has been folded into a single draw_list_common() function.
          Use of the word "diamond" has been replaced with "scrollbar"
          in the code and configuration file to more accurately describe
          the nature of the object (that is no longer represented by a
          single diamond).



[ Edited with ude,
    the unified-format diff-output ("unidiff") editor,
    version 0.1 of 2004-11-03.  ]
--- src/screen.h.orig-0.6.2     2003-11-04 18:40:44 -0500
+++ src/screen.h        2005-01-01 06:05:44 -0500
@@ -41,7 +41,7 @@ enum colors {
        COLOR_HIT_BAD,
        COLOR_PROGRESS,
        COLOR_TOTAL_PROGRESS,
-       COLOR_DIAMOND,
+       COLOR_SCROLLBAR,
        COLOR_SELECTION,
        COLOR_BUTTON_BAR,
        COLOR_BUTTON_BAR_SEL,
@@ -110,6 +110,8 @@
 # define ACS_LTEE              ')'
 # undef ACS_DIAMOND
 # define ACS_DIAMOND   '*'
+# undef ACS_CKBOARD
+# define ACS_CKBOARD   ':'
 #endif
 
 /* translate default color from and to 255 <-> 8 */
--- src/screen.c.orig-0.6.2     2003-11-04 18:40:44 -0500
+++ src/screen.c        2005-01-01 06:13:08 -0500
@@ -82,7 +82,7 @@ } items[] = {
        {"hit-bad", N_("bad hits"), COLOR_RED, COLOR_BLACK},
        {"progress", N_("progress bar"), COLOR_BLUE, COLOR_GREEN},
        {"tot-progress", N_("total progress"), COLOR_BLUE, COLOR_GREEN},
-       {"diamond", N_("scroll indicator"), COLOR_GREEN, COLOR_BLACK},
+       {"scrollbar", N_("scroll indicator"), COLOR_GREEN, COLOR_BLACK},
        {"selection", N_("selection"), COLOR_YELLOW, COLOR_BLUE},
        {"buttonbar", N_("button bar"), COLOR_BLACK, COLOR_GREEN},
        {"buttonbar-sel", N_("button bar selection"), COLOR_BLACK, COLOR_CYAN},
@@ -117,6 +117,7 @@ void remap_linechars(void)
        ACS_RTEE = '(';
        ACS_LTEE = ')';
        ACS_DIAMOND = '*';
+       ACS_CKBOARD = ':';
 #endif
 }
 
--- src/ui_draw.c.orig-0.6.2    2003-11-16 11:15:36 -0500
+++ src/ui_draw.c       2005-01-01 14:09:06 -0500
@@ -177,7 +177,7 @@ static int scale(int x, int oldscale, in
        return (2 * x * (newscale - 1) / (oldscale - 1) + 1) / 2;
 }
 
-void draw_list_pretty(int x, int y, int w, int h, int draw_sel, list *snafu)
+static void draw_list_common(int x, int y, int w, int h, int draw_sel, list 
*snafu, int pretty)
 {
        int i;
 
@@ -188,46 +188,47 @@ void draw_list_pretty(int x, int y, int 
                return;
 
        for (i = snafu->start; i < snafu->start + h && i < snafu->num; i++) {
-               tree_node *node = snafu->entries[i];
-               char *s = node->pretty;
-
-               if (s == NULL)
-                       s = node->pretty = node->klass->pretty_line(node);
+               char *s;
+
+               if (pretty) {
+                       tree_node *node = snafu->entries[i];
+                       s = node->pretty;
+                       if (s == NULL)
+                               s = node->pretty = 
node->klass->pretty_line(node);
+               } else
+                       s = snafu->entries[i];
+
                draw_fmt_str(x, y - snafu->start + i, w, i == snafu->sel && 
draw_sel, s);
        }
 
        if (h > 1 && snafu->num > h) {
+               int isel, max;
+
+               i = (snafu->start <= 0)
+                       ? 0
+                       : scale(snafu->start, snafu->num, h);
+               max = snafu->start + h; /* temp */
+               isel = (snafu->sel < snafu->start || snafu->sel >= max)
+                       ? -1
+                       : scale(snafu->sel, snafu->num, h);
+               max = (max >= snafu->num)
+                       ? (h - 1)
+                       : scale(max - 1, snafu->num, h);
-               attrset(COLOR_PAIR(COLOR_DIAMOND));
-               mvaddch(y + scale(snafu->sel, snafu->num, h), x + w, 
ACS_DIAMOND);
+               attrset(COLOR_PAIR(COLOR_SCROLLBAR));
+               for (; i <= max; i++)
+                       mvaddch(y + i, x + w,
+                               i == isel ? ACS_DIAMOND : ACS_CKBOARD);
        }
 }
 
+void draw_list_pretty(int x, int y, int w, int h, int draw_sel, list *snafu)
+{
+       draw_list_common(x, y, w, h, draw_sel, snafu, 1);
+}
+
 void draw_list(int x, int y, int w, int h, int draw_sel, list *snafu)
 {
-       int i;
-
-       attrset(COLOR_PAIR(COLOR_STANDARD));
-       clear_area(x, y, w + 1, h);
-
-       if (snafu->num == 0)
-               return;
-
-       for (i = snafu->start; i < snafu->start + h && i < snafu->num; i++) {
-               char *s = snafu->entries[i];
-
-               draw_fmt_str(x, y - snafu->start + i, w, i == snafu->sel && 
draw_sel, s);
-       }
-
-       if (h > 1 && snafu->num > h) {
-               int off;
-
-               if (snafu->sel < 0)
-                       off = scale(snafu->start, snafu->num - h + 1, h);
-               else
-                       off = scale(snafu->sel, snafu->num, h);
-               attrset(COLOR_PAIR(COLOR_DIAMOND));
-               mvaddch(y + off, x + w, ACS_DIAMOND);
-       }
+       draw_list_common(x, y, w, h, draw_sel, snafu, 0);
 }
 
 #undef draw_button
--- giFTcurs.conf.5.orig-0.6.2  2004-01-01 11:12:53 -0500
+++ giFTcurs.conf.5     2005-01-01 06:14:24 -0500
@@ -264,7 +264,7 @@
 color hit\-bad red black
 color progress blue green
 color tot\-progress blue green
-color diamond green black
+color scrollbar green black
 set upload\-height 17       # height of upload box
 set scrolloff 3            # same as :set scrolloff=3 in vim
 set confirm\-cancel 5242880 # require shift when deleting > 5MB d/l




reply via email to

[Prev in Thread] Current Thread [Next in Thread]