-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: b329cb990e5d7ca1af4e685614697e1d45955b04:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit b329cb990e5d7ca1af4e685614697e1d45955b04
Author: Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
Date:   Mon Jan 28 10:54:54 2008 +0000

    Replace scrollbar {up,dn}Button macros with methods.

diff --git a/src/command.C b/src/command.C

index 02048b5c09a576b638ec46a8500aa7e06a15a28c..

index ..fd8d8b3f4e71e8f60231c71f19a9bf4a06737cb5 100644

--- a/src/command.C
+++ b/src/command.C
@@ -1968,15 +1968,9 @@ rxvt_term::button_press (XButtonEvent &ev)
            * arrow buttons - send up/down
            * click on scrollbar - send pageup/down
            */
-          if ((scrollBar.style == R_SB_NEXT
-               && scrollbarnext_upButton (ev.y))
-              || (scrollBar.style == R_SB_RXVT
-                  && scrollbarrxvt_upButton (ev.y)))
+          if (scrollBar.upButton (ev.y))
             tt_printf ("\033[A");
-          else if ((scrollBar.style == R_SB_NEXT
-                    && scrollbarnext_dnButton (ev.y))
-                   || (scrollBar.style == R_SB_RXVT
-                       && scrollbarrxvt_dnButton (ev.y)))
+          else if (scrollBar.dnButton (ev.y))
             tt_printf ("\033[B");
           else
             switch (ev.button)
@@ -1998,20 +1992,10 @@ rxvt_term::button_press (XButtonEvent &ev)
         {
           char upordown = 0;

-          if (scrollBar.style == R_SB_NEXT)
-            {
-              if (scrollbarnext_upButton (ev.y))
-                upordown = -1;	/* up */
-              else if (scrollbarnext_dnButton (ev.y))
-                upordown = 1;	/* down */
-            }
-          else if (scrollBar.style == R_SB_RXVT)
-            {
-              if (scrollbarrxvt_upButton (ev.y))
-                upordown = -1;	/* up */
-              else if (scrollbarrxvt_dnButton (ev.y))
-                upordown = 1;	/* down */
-            }
+          if (scrollBar.upButton (ev.y))
+            upordown = -1; /* up */
+          else if (scrollBar.dnButton (ev.y))
+            upordown = 1;  /* down */

           if (upordown)
             {
diff --git a/src/scrollbar.h b/src/scrollbar.h

index e23dd323ff20c0477a6ec3a516ba23a99bffb1f1..

index ..2e70f8b2bef82c199fb023805bed1885205c18b0 100644

--- a/src/scrollbar.h
+++ b/src/scrollbar.h
@@ -5,6 +5,11 @@

 struct rxvt_term;

+#define R_SB_NEXT               1
+#define R_SB_XTERM              2
+#define R_SB_PLAIN              4
+#define R_SB_RXVT               8
+
 struct scrollBar_t {
   char            state;        /* scrollbar state                          */
   char            init;         /* scrollbar has been initialised           */
@@ -28,6 +33,23 @@ struct scrollBar_t {
   void setMotion() { state = 'm'; }
   void setUp()     { state = 'U'; }
   void setDn()     { state = 'D'; }
+
+  bool upButton (int y)
+  {
+    if (style == R_SB_NEXT)
+      return y > end && y <= end + width + 1;
+    if (style == R_SB_RXVT)
+      return y < beg;
+    return false;
+  }
+  bool dnButton (int y)
+  {
+    if (style == R_SB_NEXT)
+      return y > end + width + 1;
+    if (style == R_SB_RXVT)
+      return y > end;
+    return false;
+  }
 };

 #define scrollbar_TotalWidth()  (scrollBar.width + scrollBar.shadow * 2)
@@ -36,13 +58,7 @@ struct scrollBar_t {
 #define scrollbar_isDn()        (scrollBar.state == 'D')
 #define scrollbar_isUpDn()      (scrollbar_isUp () || scrollbar_isDn ())

-#define scrollbarnext_dnval()   (scrollBar.end + (scrollBar.width + 1))
-#define scrollbarnext_upButton(y)       ((y) > scrollBar.end \
-                                         && (y) <= scrollbarnext_dnval ())
-#define scrollbarnext_dnButton(y)       ((y) > scrollbarnext_dnval())
 #define SCROLLNEXT_MINHEIGHT    SB_THUMB_MIN_HEIGHT
-#define scrollbarrxvt_upButton(y)       ((y) < scrollBar.beg)
-#define scrollbarrxvt_dnButton(y)       ((y) > scrollBar.end)
 #define SCROLLRXVT_MINHEIGHT    10

 #define scrollbar_minheight()   (scrollBar.style == R_SB_NEXT        \
@@ -58,11 +74,6 @@ struct scrollBar_t {
 #define R_SB_ALIGN_TOP          1
 #define R_SB_ALIGN_BOTTOM       2

-#define R_SB_NEXT               1
-#define R_SB_XTERM              2
-#define R_SB_PLAIN              4
-#define R_SB_RXVT               8
-
 #define SB_WIDTH_NEXT           19
 #define SB_WIDTH_XTERM          15
 #define SB_WIDTH_PLAIN          7

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 09:17:35 2024