lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.3.dev4] Scrollbar support


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.3.dev4] Scrollbar support
Date: Sat, 7 Aug 1999 02:47:39 -0400 (EDT)

This patch makes it possible to compile lynx with -DUSE_SCROLLBAR
option.  Given this option, command-line options -scrollbar and
-scrollbar_arrow as well as corresponding LYNX_CFG options are enabled.

I did not add configure-support for USE_SCROLLBAR, I'm forced to ask
somebody to do it...

Enjoy,
Ilya

--- ./lynx.cfg~ Fri Aug  6 22:48:36 1999
+++ ./lynx.cfg  Fri Aug  6 23:36:46 1999
@@ -876,6 +876,23 @@ DEFAULT_INDEX_FILE:http://www.ncsa.uiuc.
 #
 #LYNX_SIG_FILE:.lynxsig
 
+# If SCROLLBAR is set TRUE, Lynx will show scrollbar on windows.  With
+# mouse enabled, the scrollbar strip outside the bar is clickable,
+# and scrolls the window by pages.
+# The appearence of the scrollbar can be changed from LYNX_LSS file:
+# define attributes scroll.bar, scroll.back
+# (for the bar, and for the strip along which the scrollbar moves).
+#SCROLLBAR:FALSE
+
+# If SCROLLBAR_ARROW is set TRUE, Lynx's scrollbar will have arrows
+# at the ends.  With mouse enabled, the arrows are clickable,
+# and scroll the window by 2 lines.
+# The appearence of the scrollbar arrows can be changed from LYNX_LSS file:
+# define attributes scroll.arrow, scroll.noarrow
+# (for enabled-arrows, and disabled arrows).  An arrow is "disabled"
+# if the bar is at this end of the strip.
+#SCROLLBAR_ARROW:TRUE
+
 # If USE_MOUSE is set TRUE, Lynx (when configured with ncurses) will allow
 # the user to click with button-1 on links to select them.
 #USE_MOUSE:FALSE
--- ./src/LYStrings.c~  Sat Jul 17 19:35:14 1999
+++ ./src/LYStrings.c   Fri Aug  6 22:20:14 1999
@@ -305,6 +305,22 @@ PRIVATE int set_clicked_link ARGS4(
        if (x < left) c = LTARROW;
        else if (x > right) c = '\b';
        else c = PGUP;
+#ifdef USE_SCROLLBAR
+    } else if (x == LYcols - 1 && LYsb && LYsb_begin >= 0) {
+       int h = display_lines - 2*(LYsb_arrow != 0);
+
+       mouse_link = -2;
+       y -= 1 + (LYsb_arrow != 0);
+       if (y < 0)
+           return INSERT_KEY;
+       if (y >= h)
+           return REMOVE_KEY;
+       if (y < LYsb_begin)
+           return PGUP;
+       if (y >= LYsb_end)
+           return PGDOWN;
+       mouse_link = -1;                /* No action in edit fields */
+#endif
     } else {
        int mouse_err = 4, /* subjctv-dist better than this for approx stuff */
            cur_err;
@@ -1832,6 +1848,10 @@ re_read:
                    if (c == PGDOWN)
                        c = END_KEY;
                    else if (c == PGUP)
+                       c = HOME;
+                   else if (c == REMOVE_KEY)
+                       c = END_KEY;
+                   else if (c == INSERT_KEY)
                        c = HOME;
                    else if (c == RTARROW)
                        c = END_KEY;
--- ./src/GridText.c~   Wed Jul 14 09:25:26 1999
+++ ./src/GridText.c    Fri Aug  6 22:22:58 1999
@@ -138,6 +138,13 @@ PUBLIC int LYCacheSource = SOURCE_CACHE_
 PUBLIC BOOLEAN from_source_cache = FALSE;  /* mutable */
 #endif
 
+#ifdef USE_SCROLLBAR
+PUBLIC int LYsb = FALSE;
+PUBLIC int LYsb_arrow = TRUE;
+PUBLIC int LYsb_begin = -1;
+PUBLIC int LYsb_end = -1;
+#endif
+
 #if defined(USE_COLOR_STYLE)
 #define MAX_STYLES_ON_LINE 64
 
@@ -1212,6 +1219,137 @@ PRIVATE void display_title ARGS1(
     return;
 }
 
+/*     Output the scrollbar
+**     ---------------------
+*/
+PRIVATE void display_scrollbar ARGS1(
+       HText *,        text)
+{
+#ifdef USE_SCROLLBAR
+    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, last, sh;
+
+    LYsb_begin = LYsb_end = -1;
+    if (!LYsb || !text || h <= 2
+       || (text->Lines + 1) <= display_lines)
+       return;
+
+    /* 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);
+    if (sh <= 0)
+       sh = 1;
+    if (sh >= h)
+       sh = h - 1;
+
+    /* 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--;
+    }
+    LYsb_begin = top_skip;
+    LYsb_end = h - bot_skip;
+
+    if (LYsb_arrow) {
+#ifdef USE_COLOR_STYLE
+       int s = top_skip ? s_sb_aa : s_sb_naa;
+
+       if (last_colorattr_ptr > 0) {
+           LynxChangeStyle(s, STACK_ON, 0);
+       } else {
+           LynxChangeStyle(s, ABS_ON, 0);
+       }
+#endif /* USE_COLOR_STYLE */
+       move(1, LYcols - 1);
+       addch(ACS_UARROW);
+#ifdef USE_COLOR_STYLE
+       LynxChangeStyle(s, STACK_OFF, 0);
+#endif /* USE_COLOR_STYLE */
+    }
+#ifdef USE_COLOR_STYLE
+    if (last_colorattr_ptr > 0) {
+       LynxChangeStyle(s_sb_bg, STACK_ON, 0);
+    } else {
+       LynxChangeStyle(s_sb_bg, ABS_ON, 0);
+    }
+#endif /* USE_COLOR_STYLE */
+
+    for (i=1; i <= h; i++) {
+#ifdef USE_COLOR_STYLE
+       if (i-1 <= top_skip && i > top_skip)
+           LynxChangeStyle(s_sb_bar, STACK_ON, 0);
+       if (i-1 <= h - bot_skip && i > h - bot_skip)
+           LynxChangeStyle(s_sb_bar, STACK_OFF, 0);
+#endif /* USE_COLOR_STYLE */
+       move(i + off, LYcols - 1);
+       if (i > top_skip && i <= h - bot_skip)
+           addch(ACS_BLOCK);
+       else
+           addch(ACS_CKBOARD);
+    }
+#ifdef USE_COLOR_STYLE
+    LynxChangeStyle(s_sb_bg, STACK_OFF, 0);
+#endif /* USE_COLOR_STYLE */
+
+    if (LYsb_arrow) {
+#ifdef USE_COLOR_STYLE
+       int s = bot_skip ? s_sb_aa : s_sb_naa;
+
+       if (last_colorattr_ptr > 0) {
+           LynxChangeStyle(s, STACK_ON, 0);
+       } else {
+           LynxChangeStyle(s, ABS_ON, 0);
+       }
+#endif /* USE_COLOR_STYLE */
+       move(h + 2, LYcols - 1);
+       addch(ACS_DARROW);
+#ifdef USE_COLOR_STYLE
+       LynxChangeStyle(s, STACK_OFF, 0);
+#endif /* USE_COLOR_STYLE */
+    }
+    return;
+#endif /* USE_SCROLLBAR */
+}
+
 /*     Output a page
 **     -------------
 */
@@ -1784,6 +1922,7 @@ PRIVATE void display_page ARGS3(
         */
        addstr("\n     Document is empty");
     }
+    display_scrollbar(text);
 
 #ifdef DISP_PARTIAL
     if (display_partial && display_flag &&
--- ./src/LYGlobalDefs.h~       Wed Jul 14 09:25:26 1999
+++ ./src/LYGlobalDefs.h        Thu Aug  5 11:33:48 1999
@@ -435,4 +435,11 @@ extern void cygwin_conv_to_full_posix_pa
 extern int setmode(int handle, int amode);
 #endif
 
+#ifdef USE_SCROLLBAR
+extern int LYsb;
+extern int LYsb_arrow;
+extern int LYsb_begin;
+extern int LYsb_end;
+#endif
+
 #endif /* LYGLOBALDEFS_H */
--- ./src/LYMain.c~     Wed Jul 14 09:25:26 1999
+++ ./src/LYMain.c      Thu Aug  5 01:07:32 1999
@@ -3235,6 +3235,16 @@ with the PREV_DOC command or from the Hi
       "rlogin",                UNSET_ARG,              &rlogin_ok,
       "disable rlogins"
    ),
+#ifdef USE_SCROLLBAR
+   PARSE_SET(
+      "scrollbar",     TOGGLE_ARG,             &LYsb,
+      "toggles showing scrollbar (requires color styles)"
+   ),
+   PARSE_SET(
+      "scrollbar_arrow",       TOGGLE_ARG,     &LYsb_arrow,
+      "toggles showing arrows at ends of the scrollbar"
+   ),
+#endif
    PARSE_FUN(
       "selective",     FUNCTION_ARG,           selective_fun,
       "require .www_browsable files to browse directories"
--- ./src/LYReadCFG.c~  Wed Aug  4 18:17:30 1999
+++ ./src/LYReadCFG.c   Thu Aug  5 01:06:42 1999
@@ -1214,6 +1214,10 @@ static Config_Type Config_Table [] =
 #endif /* NO_RULES */
      PARSE_STR("save_space", CONF_STR, &lynx_save_space),
      PARSE_SET("scan_for_buried_news_refs", CONF_BOOL, 
&scan_for_buried_news_references),
+#ifdef USE_SCROLLBAR
+     PARSE_SET("scrollbar", CONF_BOOL, &LYsb),
+     PARSE_SET("scrollbar_arrow", CONF_BOOL, &LYsb_arrow),
+#endif
      PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, &LYSeekFragAREAinCur),
      PARSE_SET("seek_frag_map_in_cur", CONF_BOOL, &LYSeekFragMAPinCur),
      PARSE_SET("set_cookies", CONF_BOOL, &LYSetCookies),
--- ./src/LYStyle.c~    Sat Jul 17 17:46:54 1999
+++ ./src/LYStyle.c     Thu Aug  5 00:29:28 1999
@@ -64,6 +64,10 @@ static char *Mono_Strings[7] =
 PUBLIC int     s_alink  = NOSTYLE, s_a     = NOSTYLE, s_status = NOSTYLE,
                s_label  = NOSTYLE, s_value = NOSTYLE, s_high   = NOSTYLE,
                s_normal = NOSTYLE, s_alert = NOSTYLE, s_title  = NOSTYLE,
+#ifdef USE_SCROLLBAR
+               s_sb_bar = NOSTYLE, s_sb_bg = NOSTYLE,
+               s_sb_aa = NOSTYLE, s_sb_naa = NOSTYLE,
+#endif
                s_whereis= NOSTYLE;
 
 /* start somewhere safe */
@@ -355,6 +359,12 @@ PUBLIC void style_initialiseHashTable NO
        s_status = hash_code("status");
        s_alert  = hash_code("alert");
        s_title  = hash_code("title");
+#ifdef USE_SCROLLBAR
+       s_sb_bar  = hash_code("scroll.bar");
+       s_sb_bg  = hash_code("scroll.back");
+       s_sb_aa  = hash_code("scroll.arrow");
+       s_sb_naa  = hash_code("scroll.noarrow");
+#endif
 }
 
 /* because curses isn't started when we parse the config file, we
--- ./src/LYHash.h~     Thu May 20 05:48:10 1999
+++ ./src/LYHash.h      Thu Aug  5 00:28:30 1999
@@ -45,6 +45,9 @@ extern int hash_table[CSHASHSIZE]; /* 32
 extern int     s_alink, s_a, s_status,
                s_label, s_value, s_high,
                s_normal, s_alert, s_title,
+#ifdef USE_SCROLLBAR
+               s_sb_bar, s_sb_bg, s_sb_aa, s_sb_naa,
+#endif
                s_whereis;
 #define CACHEW 128
 #define CACHEH 64

reply via email to

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