lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.3.dev10] Scrollbar doubleclick support


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.3.dev10] Scrollbar doubleclick support
Date: Wed, 20 Oct 1999 03:34:30 -0400 (EDT)

Somehow my patch of August 10 was not applied.  Here I repeat it
(updated for 2.8.3.dev10).  As I wrote it in August, the patch also
gives "more precise" position to scrollbar, and simplifies the logic.

Enjoy,
Ilya

--- ./src/GridText.c-presb      Wed Sep 29 06:40:38 1999
+++ ./src/GridText.c    Wed Oct 20 03:25:10 1999
@@ -1258,63 +1258,45 @@ PRIVATE void display_scrollbar ARGS1(
     int i;
     int h = display_lines - 2 * (LYsb_arrow!=0); /* Height of the scrollbar */
     int off = (LYsb_arrow != 0);                /* Start of the scrollbar */
-    int top_skip, bot_skip, sh;
+    int top_skip, bot_skip, sh, shown;
 
     LYsb_begin = LYsb_end = -1;
     if (!LYsb || !text || h <= 2
        || (text->Lines + 1) <= display_lines)
        return;
 
+    if (text->top_of_screen >= text->Lines + 1 - display_lines) {
+       /* Only part of the screen shows actual text */
+       shown = text->Lines + 1 - text->top_of_screen;
+
+       if (shown <= 0)
+           shown = 1;
+    } else
+       shown = display_lines;
     /* Each cell of scrollbar represents text->Lines/h lines of text. */
     /* Always smaller than h */
-    sh = (display_lines*h + text->Lines/2)/(text->Lines + 1);
+    sh = (shown*h + text->Lines/2)/(text->Lines + 1);
     if (sh <= 0)
        sh = 1;
-    if (sh >= h)
-       sh = h - 1;
+    if (sh >= h - 1)
+       sh = h - 2;             /* Position at ends indicates BEG and END */
 
-    /* Always non-zero if not top, which is text->top_of_screen != 0 . */
-    top_skip = (text->top_of_screen * h + text->Lines)/(text->Lines + 1);
-    if (top_skip >= h)
-       top_skip = h - 1;
-
-    /* End happens when
-       (text->Lines + 1 - (text->top_of_screen + display_lines - 1))
-       is either 0 or 1. */
-    bot_skip =
-       (text->Lines + 1 - (text->top_of_screen + display_lines - 1) - 1);
-    if (bot_skip < 0)
-       bot_skip = 0;
-    bot_skip = (bot_skip * h + text->Lines)/(text->Lines + 1);
-
-    /* Now make sure the height is always sh unless top_skip==bot_skip==1  */
-    if (top_skip + bot_skip + sh != h && !(top_skip == 1 && bot_skip == 1)) {
-       /* One which is smaller takes precedence. */
-       if (top_skip < bot_skip) {
-           int t = h - top_skip - sh;
-
-           if (t < top_skip)
-               bot_skip = top_skip;
-           else
-               bot_skip = t;
-       } else {
-           int t = h - bot_skip - sh;
-
-           if (t < bot_skip)
-               top_skip = bot_skip;
-           else
-               top_skip = t;
-       }
-    }
-    /* Ensure the bar is visible if h >= 3 */
-    if (top_skip + bot_skip >= h)
-       bot_skip = h - top_skip;
-    if (top_skip + bot_skip == h && h >= 3) {
-       if (bot_skip > 1)
-           bot_skip--;
-       else
-           top_skip--;
+    if (text->top_of_screen == 0)
+       top_skip = 0;
+    else if (text->Lines - (text->top_of_screen + display_lines - 1) <= 0)
+       top_skip = h - sh;
+    else {
+       /* text->top_of_screen between 1 and text->Lines - display_lines
+          corresponds to top_skip between 1 and h - sh - 1 */
+       /* Use rounding to get as many positions into top_skip==h - sh - 1
+          as into top_skip == 1:
+          1--->1, text->Lines - display_lines + 1--->h - sh. */
+       top_skip = 1 + 
+           1. * (h - sh - 1) * text->top_of_screen
+               /(text->Lines - display_lines + 1);
     }
+    bot_skip = h - sh - top_skip;
+
     LYsb_begin = top_skip;
     LYsb_end = h - bot_skip;
 
--- ./src/LYStrings.c-presb     Wed Sep 29 06:40:38 1999
+++ ./src/LYStrings.c   Wed Oct 20 03:20:52 1999
@@ -315,6 +315,17 @@ PRIVATE int set_clicked_link ARGS4(
            return INSERT_KEY;
        if (y >= h)
            return REMOVE_KEY;
+#ifdef DISP_PARTIAL                    /* Newline is not defined otherwise */
+       if (clicks >= 2) {
+           double frac = (1. * y)/(h - 1);
+           int l = HText_getNumOfLines() + 1;  /* NOL() off by one? */
+
+           l -= display_lines;
+           if (l > 0)
+               Newline = frac * l + 1 + 0.5;
+           return LYReverseKeymap(LYK_DO_NOTHING);
+       }
+#endif
        if (y < LYsb_begin)
            return PGUP;
        if (y >= LYsb_end)

reply via email to

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