… | |
… | |
76 | |
76 | |
77 | #include "encoding.h" |
77 | #include "encoding.h" |
78 | #include "rxvtutil.h" |
78 | #include "rxvtutil.h" |
79 | #include "rxvtfont.h" |
79 | #include "rxvtfont.h" |
80 | #include "rxvttoolkit.h" |
80 | #include "rxvttoolkit.h" |
|
|
81 | #include "scrollbar.h" |
81 | #include "ev_cpp.h" |
82 | #include "ev_cpp.h" |
82 | #include "salloc.h" |
83 | #include "salloc.h" |
83 | #include "libptytty.h" |
84 | #include "libptytty.h" |
84 | |
85 | |
85 | #include "rxvtperl.h" |
86 | #include "rxvtperl.h" |
… | |
… | |
280 | #define scrollBar_esc 30 |
281 | #define scrollBar_esc 30 |
281 | |
282 | |
282 | #if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR) |
283 | #if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR) |
283 | # define HAVE_SCROLLBARS 1 |
284 | # define HAVE_SCROLLBARS 1 |
284 | #endif |
285 | #endif |
285 | |
|
|
286 | #define R_SB_ALIGN_CENTRE 0 |
|
|
287 | #define R_SB_ALIGN_TOP 1 |
|
|
288 | #define R_SB_ALIGN_BOTTOM 2 |
|
|
289 | |
|
|
290 | #define R_SB_NEXT 1 |
|
|
291 | #define R_SB_XTERM 2 |
|
|
292 | #define R_SB_PLAIN 4 |
|
|
293 | #define R_SB_RXVT 8 |
|
|
294 | |
|
|
295 | #define SB_WIDTH_NEXT 19 |
|
|
296 | #define SB_WIDTH_XTERM 15 |
|
|
297 | #define SB_WIDTH_PLAIN 7 |
|
|
298 | #ifndef SB_WIDTH_RXVT |
|
|
299 | # define SB_WIDTH_RXVT 10 |
|
|
300 | #endif |
|
|
301 | |
|
|
302 | /* |
|
|
303 | * NeXT scrollbar defines |
|
|
304 | */ |
|
|
305 | #define SB_PADDING 1 |
|
|
306 | #define SB_BORDER_WIDTH 1 |
|
|
307 | #define SB_BEVEL_WIDTH_UPPER_LEFT 1 |
|
|
308 | #define SB_BEVEL_WIDTH_LOWER_RIGHT 2 |
|
|
309 | #define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH) |
|
|
310 | #define SB_MARGIN_SPACE (SB_PADDING * 2) |
|
|
311 | #define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH) |
|
|
312 | #define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH) |
|
|
313 | #define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING) |
|
|
314 | #define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) |
|
|
315 | #define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) |
|
|
316 | #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) |
|
|
317 | #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) |
|
|
318 | #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) |
|
|
319 | /* |
|
|
320 | * +-------------+ |
|
|
321 | * | | <---< SB_PADDING |
|
|
322 | * | ::::::::::: | |
|
|
323 | * | ::::::::::: | |
|
|
324 | * ''''''''''''''''' |
|
|
325 | * ,,,,,,,,,,,,,,,,, |
|
|
326 | * | ::::::::::: | |
|
|
327 | * | ::::::::::: | |
|
|
328 | * | +---------------< SB_BEVEL_WIDTH_UPPER_LEFT |
|
|
329 | * | | :::::::: | |
|
|
330 | * | V :::: vv-------< SB_BEVEL_WIDTH_LOWER_RIGHT |
|
|
331 | * | +---------+ | |
|
|
332 | * | | ......%%| | |
|
|
333 | * | | ......%%| | |
|
|
334 | * | | .. ()..%%| | |
|
|
335 | * | | ......%%| | |
|
|
336 | * | | %%%%%%%%| | |
|
|
337 | * | +---------+ | <......................... |
|
|
338 | * | | <---< SB_PADDING : |
|
|
339 | * | +---------+ | <-+.......... :---< SB_BUTTON_TOTAL_HEIGHT |
|
|
340 | * | | ......%%| | | : : |
|
|
341 | * | | ../\..%%| | |---< SB_BUTTON_HEIGHT : |
|
|
342 | * | | %%%%%%%%| | | : : |
|
|
343 | * | +---------+ | <-+ : : |
|
|
344 | * | | : : |
|
|
345 | * | +---------+ | <-+ :---< SB_BUTTON_BOTH_HEIGHT |
|
|
346 | * | | ......%%| | | : : |
|
|
347 | * | | ..\/..%%| | | : : |
|
|
348 | * | | %%%%%%%%| | |---< SB_BUTTON_SINGLE_HEIGHT |
|
|
349 | * | +---------+ | | : : |
|
|
350 | * | | | : : |
|
|
351 | * +-------------+ <-+.........:............: |
|
|
352 | * ^^|_________| : |
|
|
353 | * || | : |
|
|
354 | * || +---< SB_BUTTON_WIDTH |
|
|
355 | * || : |
|
|
356 | * |+------< SB_PADDING |
|
|
357 | * |: : |
|
|
358 | * +----< SB_BORDER_WIDTH |
|
|
359 | * : : |
|
|
360 | * :............: |
|
|
361 | * | |
|
|
362 | * +---< SB_WIDTH_NEXT |
|
|
363 | */ |
|
|
364 | |
286 | |
365 | enum { |
287 | enum { |
366 | NO_REFRESH = 0, /* Window not visible at all! */ |
288 | NO_REFRESH = 0, /* Window not visible at all! */ |
367 | FAST_REFRESH = 1, /* Fully exposed window */ |
289 | FAST_REFRESH = 1, /* Fully exposed window */ |
368 | SLOW_REFRESH = 2, /* Partially exposed window */ |
290 | SLOW_REFRESH = 2, /* Partially exposed window */ |
… | |
… | |
743 | #ifdef HAVE_SCROLLBARS |
665 | #ifdef HAVE_SCROLLBARS |
744 | # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2) |
666 | # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2) |
745 | #else |
667 | #else |
746 | # define scrollbar_TotalWidth() (0) |
668 | # define scrollbar_TotalWidth() (0) |
747 | #endif |
669 | #endif |
748 | #define scrollbar_isMotion() (scrollBar.state == 'm') |
|
|
749 | #define scrollbar_isUp() (scrollBar.state == 'U') |
|
|
750 | #define scrollbar_isDn() (scrollBar.state == 'D') |
|
|
751 | #define scrollbar_isUpDn() isupper (scrollBar.state) |
|
|
752 | #define isScrollbarWindow(w) (scrollBar.state && (w) == scrollBar.win) |
|
|
753 | |
|
|
754 | #define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1)) |
|
|
755 | #define scrollbarnext_upButton(y) ((y) > scrollBar.end \ |
|
|
756 | && (y) <= scrollbarnext_dnval ()) |
|
|
757 | #define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval()) |
|
|
758 | #define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT |
|
|
759 | #define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg) |
|
|
760 | #define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end) |
|
|
761 | #define SCROLLRXVT_MINHEIGHT 10 |
|
|
762 | #define SCROLLXTERM_MINHEIGHT 10 |
|
|
763 | |
|
|
764 | #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ |
|
|
765 | ? SCROLLNEXT_MINHEIGHT \ |
|
|
766 | : SCROLLRXVT_MINHEIGHT) |
|
|
767 | #define scrollbar_above_slider(y) ((y) < scrollBar.top) |
|
|
768 | #define scrollbar_below_slider(y) ((y) > scrollBar.bot) |
|
|
769 | #define scrollbar_position(y) ((y) - scrollBar.beg) |
|
|
770 | #define scrollbar_size() (scrollBar.end - scrollBar.beg \ |
|
|
771 | - scrollbar_minheight ()) |
|
|
772 | |
670 | |
773 | typedef callback<void (const char *)> log_callback; |
671 | typedef callback<void (const char *)> log_callback; |
774 | typedef callback<int (int)> getfd_callback; |
672 | typedef callback<int (int)> getfd_callback; |
775 | |
673 | |
776 | /****************************************************************************/ |
674 | /****************************************************************************/ |
… | |
… | |
1028 | # undef def |
926 | # undef def |
1029 | Opt_count |
927 | Opt_count |
1030 | }; |
928 | }; |
1031 | |
929 | |
1032 | /* ------------------------------------------------------------------------- */ |
930 | /* ------------------------------------------------------------------------- */ |
1033 | |
|
|
1034 | typedef struct { |
|
|
1035 | char state; /* scrollbar state */ |
|
|
1036 | char init; /* scrollbar has been initialised */ |
|
|
1037 | unsigned int beg; /* slider sub-window begin height */ |
|
|
1038 | unsigned int end; /* slider sub-window end height */ |
|
|
1039 | unsigned int top; /* slider top position */ |
|
|
1040 | unsigned int bot; /* slider bottom position */ |
|
|
1041 | unsigned int style; /* style: rxvt, xterm, next */ |
|
|
1042 | unsigned int width; /* scrollbar width */ |
|
|
1043 | Window win; |
|
|
1044 | int (rxvt_term::*update)(int, int, int, int); |
|
|
1045 | |
|
|
1046 | void setIdle() { state = 1 ; } |
|
|
1047 | void setMotion() { state = 'm'; } |
|
|
1048 | void setUp() { state = 'U'; } |
|
|
1049 | void setDn() { state = 'D'; } |
|
|
1050 | } scrollBar_t; |
|
|
1051 | |
931 | |
1052 | struct rxvt_vars : TermWin_t { |
932 | struct rxvt_vars : TermWin_t { |
1053 | scrollBar_t scrollBar; |
933 | scrollBar_t scrollBar; |
1054 | uint8_t options[(Opt_count + 7) >> 3]; |
934 | uint8_t options[(Opt_count + 7) >> 3]; |
1055 | XSizeHints szHint; |
935 | XSizeHints szHint; |