… | |
… | |
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" |
… | |
… | |
111 | #ifndef HAVE_XPOINTER |
112 | #ifndef HAVE_XPOINTER |
112 | typedef char *XPointer; |
113 | typedef char *XPointer; |
113 | #endif |
114 | #endif |
114 | |
115 | |
115 | #include <termios.h> |
116 | #include <termios.h> |
116 | typedef struct termios ttymode_t; |
|
|
117 | |
117 | |
118 | #include "background.h" |
118 | #include "background.h" |
119 | |
119 | |
120 | #ifndef STDIN_FILENO |
120 | #ifndef STDIN_FILENO |
121 | # define STDIN_FILENO 0 |
121 | # define STDIN_FILENO 0 |
… | |
… | |
280 | #define scrollBar_esc 30 |
280 | #define scrollBar_esc 30 |
281 | |
281 | |
282 | #if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR) |
282 | #if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR) |
283 | # define HAVE_SCROLLBARS 1 |
283 | # define HAVE_SCROLLBARS 1 |
284 | #endif |
284 | #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 | |
285 | |
365 | enum { |
286 | enum { |
366 | NO_REFRESH = 0, /* Window not visible at all! */ |
287 | NO_REFRESH = 0, /* Window not visible at all! */ |
367 | FAST_REFRESH = 1, /* Fully exposed window */ |
288 | FAST_REFRESH = 1, /* Fully exposed window */ |
368 | SLOW_REFRESH = 2, /* Partially exposed window */ |
289 | SLOW_REFRESH = 2, /* Partially exposed window */ |
… | |
… | |
737 | #if ENABLE_STYLES |
658 | #if ENABLE_STYLES |
738 | # define FONTSET(style) fontset[GET_STYLE (style)] |
659 | # define FONTSET(style) fontset[GET_STYLE (style)] |
739 | #else |
660 | #else |
740 | # define FONTSET(style) fontset[0] |
661 | # define FONTSET(style) fontset[0] |
741 | #endif |
662 | #endif |
742 | |
|
|
743 | #ifdef HAVE_SCROLLBARS |
|
|
744 | # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2) |
|
|
745 | #else |
|
|
746 | # define scrollbar_TotalWidth() (0) |
|
|
747 | #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 | |
663 | |
773 | typedef callback<void (const char *)> log_callback; |
664 | typedef callback<void (const char *)> log_callback; |
774 | typedef callback<int (int)> getfd_callback; |
665 | typedef callback<int (int)> getfd_callback; |
775 | |
666 | |
776 | /****************************************************************************/ |
667 | /****************************************************************************/ |
… | |
… | |
1029 | Opt_count |
920 | Opt_count |
1030 | }; |
921 | }; |
1031 | |
922 | |
1032 | /* ------------------------------------------------------------------------- */ |
923 | /* ------------------------------------------------------------------------- */ |
1033 | |
924 | |
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 | |
|
|
1052 | struct rxvt_vars : TermWin_t { |
925 | struct rxvt_vars : TermWin_t { |
1053 | scrollBar_t scrollBar; |
926 | scrollBar_t scrollBar; |
1054 | uint8_t options[(Opt_count + 7) >> 3]; |
927 | uint8_t options[(Opt_count + 7) >> 3]; |
1055 | XSizeHints szHint; |
928 | XSizeHints szHint; |
1056 | rxvt_color *pix_colors; |
929 | rxvt_color *pix_colors; |
1057 | rxvt_color *pix_colors_focused; |
|
|
1058 | #ifdef OFF_FOCUS_FADING |
|
|
1059 | rxvt_color *pix_colors_unfocused; |
|
|
1060 | #endif |
|
|
1061 | Cursor TermWin_cursor; /* cursor for vt window */ |
930 | Cursor TermWin_cursor; /* cursor for vt window */ |
1062 | int sb_shadow; /* scrollbar shadow width */ |
|
|
1063 | int numlock_state; |
931 | int numlock_state; |
1064 | line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf |
932 | line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf |
1065 | line_t *drawn_buf; // text on screen |
933 | line_t *drawn_buf; // text on screen |
1066 | line_t *swap_buf; // lines for swap buffer |
934 | line_t *swap_buf; // lines for swap buffer |
1067 | char *tabs; /* per location: 1 == tab-stop */ |
935 | char *tabs; /* per location: 1 == tab-stop */ |
1068 | screen_t screen; |
936 | screen_t screen; |
1069 | screen_t swap; |
937 | screen_t swap; |
1070 | selection_t selection; |
938 | selection_t selection; |
|
|
939 | rxvt_color pix_colors_focused[TOTAL_COLORS]; |
|
|
940 | #ifdef OFF_FOCUS_FADING |
|
|
941 | rxvt_color pix_colors_unfocused[TOTAL_COLORS]; |
|
|
942 | #endif |
1071 | }; |
943 | }; |
1072 | |
944 | |
1073 | struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { |
945 | struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { |
1074 | |
946 | |
1075 | // special markers with magic addresses |
947 | // special markers with magic addresses |
… | |
… | |
1104 | |
976 | |
1105 | unsigned char refresh_type, |
977 | unsigned char refresh_type, |
1106 | #ifdef META8_OPTION |
978 | #ifdef META8_OPTION |
1107 | meta_char, /* Alt-key prefix */ |
979 | meta_char, /* Alt-key prefix */ |
1108 | #endif |
980 | #endif |
1109 | scrollbar_align, |
|
|
1110 | selection_wait, |
981 | selection_wait, |
1111 | selection_type; |
982 | selection_type; |
1112 | /* ---------- */ |
983 | /* ---------- */ |
1113 | bool rvideo_state, rvideo_mode; |
984 | bool rvideo_state, rvideo_mode; |
1114 | #ifndef NO_BELL |
985 | #ifndef NO_BELL |
… | |
… | |
1132 | /* give proper Scroll behaviour */ |
1003 | /* give proper Scroll behaviour */ |
1133 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1004 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1134 | mouse_slip_wheel_speed, |
1005 | mouse_slip_wheel_speed, |
1135 | #endif |
1006 | #endif |
1136 | refresh_count, |
1007 | refresh_count, |
1137 | last_bot, /* scrollbar last bottom position */ |
|
|
1138 | last_top, /* scrollbar last top position */ |
|
|
1139 | last_state, /* scrollbar last state */ |
|
|
1140 | scrollbar_len, |
|
|
1141 | window_vt_x, |
1008 | window_vt_x, |
1142 | window_vt_y, |
1009 | window_vt_y, |
1143 | window_sb_x, |
1010 | window_sb_x, |
1144 | mouse_row, |
1011 | mouse_row, |
1145 | mouse_col, |
1012 | mouse_col, |
… | |
… | |
1187 | selection_request_time; |
1054 | selection_request_time; |
1188 | pid_t cmd_pid; /* process id of child */ |
1055 | pid_t cmd_pid; /* process id of child */ |
1189 | char * incr_buf; |
1056 | char * incr_buf; |
1190 | size_t incr_buf_size, incr_buf_fill; |
1057 | size_t incr_buf_size, incr_buf_fill; |
1191 | /* ---------- */ |
1058 | /* ---------- */ |
1192 | Cursor leftptr_cursor; |
|
|
1193 | /* ---------- */ |
|
|
1194 | struct mouse_event MEvent; |
1059 | struct mouse_event MEvent; |
1195 | XComposeStatus compose; |
1060 | XComposeStatus compose; |
1196 | ttymode_t tio; |
1061 | struct termios tio; |
1197 | row_col_t oldcursor; |
1062 | row_col_t oldcursor; |
1198 | #ifdef HAVE_BG_PIXMAP |
1063 | #ifdef HAVE_BG_PIXMAP |
1199 | bgPixmap_t bgPixmap; |
1064 | bgPixmap_t bgPixmap; |
1200 | #endif |
1065 | #endif |
1201 | #ifdef HAVE_AFTERIMAGE |
1066 | #ifdef HAVE_AFTERIMAGE |