* 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)
{
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)
{
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 */
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)
#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 \
#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