… | |
… | |
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 |
… | |
… | |
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 | |
285 | |
286 | #define R_SB_ALIGN_CENTRE 0 |
286 | #if !defined (RXVT_SCROLLBAR) && !defined (NEXT_SCROLLBAR) |
287 | #define R_SB_ALIGN_TOP 1 |
287 | # define NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 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 |
288 | #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 | |
289 | |
365 | enum { |
290 | enum { |
366 | NO_REFRESH = 0, /* Window not visible at all! */ |
291 | NO_REFRESH = 0, /* Window not visible at all! */ |
367 | FAST_REFRESH = 1, /* Fully exposed window */ |
292 | FAST_REFRESH = 1, /* Fully exposed window */ |
368 | SLOW_REFRESH = 2, /* Partially exposed window */ |
293 | SLOW_REFRESH = 2, /* Partially exposed window */ |
… | |
… | |
473 | XTerm_name = 0, |
398 | XTerm_name = 0, |
474 | XTerm_iconName = 1, |
399 | XTerm_iconName = 1, |
475 | XTerm_title = 2, |
400 | XTerm_title = 2, |
476 | XTerm_property = 3, // change X property |
401 | XTerm_property = 3, // change X property |
477 | XTerm_Color = 4, // change colors |
402 | XTerm_Color = 4, // change colors |
478 | XTerm_Color00 = 10, // not implemented, CLASH! |
403 | XTerm_Color00 = 10, // change fg color |
479 | XTerm_Color01 = 11, // not implemented |
404 | XTerm_Color01 = 11, // change bg color |
480 | XTerm_Color_cursor = 12, // change actual 'Cursor' color |
405 | XTerm_Color_cursor = 12, // change actual 'Cursor' color |
481 | XTerm_Color_pointer_fg = 13, // change actual 'Pointer' fg color |
406 | XTerm_Color_pointer_fg = 13, // change actual 'Pointer' fg color |
482 | XTerm_Color_pointer_bg = 14, // change actual 'Pointer' bg color |
407 | XTerm_Color_pointer_bg = 14, // change actual 'Pointer' bg color |
483 | XTerm_Color05 = 15, // not implemented (tektronix fg) |
408 | XTerm_Color05 = 15, // not implemented (tektronix fg) |
484 | XTerm_Color06 = 16, // not implemented (tektronix bg) |
409 | XTerm_Color06 = 16, // not implemented (tektronix bg) |
… | |
… | |
489 | XTerm_konsole30 = 30, // reserved for konsole |
414 | XTerm_konsole30 = 30, // reserved for konsole |
490 | XTerm_konsole31 = 31, // reserved for konsole |
415 | XTerm_konsole31 = 31, // reserved for konsole |
491 | XTerm_emacs51 = 51, // reserved for emacs shell |
416 | XTerm_emacs51 = 51, // reserved for emacs shell |
492 | /* |
417 | /* |
493 | * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) |
418 | * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) |
494 | * at least Rxvt_Color_BD and Rxvt_Color_UL clash with xterm |
|
|
495 | */ |
419 | */ |
496 | Rxvt_Color_BD = 18, // change actual 'Bold' color |
420 | |
497 | Rxvt_Color_UL = 19, // change actual 'Underline' color |
421 | // deprecated |
|
|
422 | Rxvt_Color_BD = 18, |
|
|
423 | Rxvt_Color_UL = 19, |
|
|
424 | Rxvt_restoreFG = 39, |
|
|
425 | Rxvt_restoreBG = 49, |
|
|
426 | |
498 | Rxvt_Pixmap = 20, // new bg pixmap |
427 | Rxvt_Pixmap = 20, // new bg pixmap |
499 | Rxvt_restoreFG = 39, // change default fg color |
|
|
500 | Rxvt_restoreBG = 49, // change default bg color |
|
|
501 | Rxvt_dumpscreen = 55, // dump scrollback and all of screen |
428 | Rxvt_dumpscreen = 55, // dump scrollback and all of screen |
502 | |
429 | |
503 | URxvt_locale = 701, // change locale |
430 | URxvt_locale = 701, // change locale |
504 | URxvt_version = 702, // request version |
431 | URxvt_version = 702, // request version |
505 | |
432 | |
506 | URxvt_Color_IT = 704, // change actual 'Italic' colour |
433 | URxvt_Color_IT = 704, // change actual 'Italic' colour |
507 | URxvt_Color_tint = 705, // change actual tint colour |
434 | URxvt_Color_tint = 705, // change actual tint colour |
508 | URxvt_Color_BD = 706, |
435 | URxvt_Color_BD = 706, // change actual 'Bold' color |
509 | URxvt_Color_UL = 707, |
436 | URxvt_Color_UL = 707, // change actual 'Underline' color |
510 | |
437 | |
511 | URxvt_font = 710, |
438 | URxvt_font = 710, |
512 | URxvt_boldFont = 711, |
439 | URxvt_boldFont = 711, |
513 | URxvt_italicFont = 712, |
440 | URxvt_italicFont = 712, |
514 | URxvt_boldItalicFont = 713, |
441 | URxvt_boldItalicFont = 713, |
… | |
… | |
631 | #define PrivMode_smoothScroll (1UL<<17) |
558 | #define PrivMode_smoothScroll (1UL<<17) |
632 | #define PrivMode_vt52 (1UL<<18) |
559 | #define PrivMode_vt52 (1UL<<18) |
633 | #define PrivMode_LFNL (1UL<<19) |
560 | #define PrivMode_LFNL (1UL<<19) |
634 | #define PrivMode_MouseBtnEvent (1UL<<20) |
561 | #define PrivMode_MouseBtnEvent (1UL<<20) |
635 | #define PrivMode_MouseAnyEvent (1UL<<21) |
562 | #define PrivMode_MouseAnyEvent (1UL<<21) |
|
|
563 | #define PrivMode_BracketPaste (1UL<<22) |
636 | |
564 | |
637 | #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent) |
565 | #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent) |
638 | |
566 | |
639 | #ifdef ALLOW_132_MODE |
567 | #ifdef ALLOW_132_MODE |
640 | # define PrivMode_Default (PrivMode_Autowrap|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) |
568 | # define PrivMode_Default (PrivMode_Autowrap|PrivMode_ShiftKeys|PrivMode_VisibleCursor|PrivMode_132OK) |
… | |
… | |
737 | #if ENABLE_STYLES |
665 | #if ENABLE_STYLES |
738 | # define FONTSET(style) fontset[GET_STYLE (style)] |
666 | # define FONTSET(style) fontset[GET_STYLE (style)] |
739 | #else |
667 | #else |
740 | # define FONTSET(style) fontset[0] |
668 | # define FONTSET(style) fontset[0] |
741 | #endif |
669 | #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 | |
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 | /****************************************************************************/ |
… | |
… | |
1029 | Opt_count |
927 | Opt_count |
1030 | }; |
928 | }; |
1031 | |
929 | |
1032 | /* ------------------------------------------------------------------------- */ |
930 | /* ------------------------------------------------------------------------- */ |
1033 | |
931 | |
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 { |
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; |
1056 | rxvt_color *pix_colors; |
936 | rxvt_color *pix_colors; |
1057 | Cursor TermWin_cursor; /* cursor for vt window */ |
937 | Cursor TermWin_cursor; /* cursor for vt window */ |
1058 | int sb_shadow; /* scrollbar shadow width */ |
|
|
1059 | int numlock_state; |
938 | int numlock_state; |
1060 | line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf |
939 | line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf |
1061 | line_t *drawn_buf; // text on screen |
940 | line_t *drawn_buf; // text on screen |
1062 | line_t *swap_buf; // lines for swap buffer |
941 | line_t *swap_buf; // lines for swap buffer |
1063 | char *tabs; /* per location: 1 == tab-stop */ |
942 | char *tabs; /* per location: 1 == tab-stop */ |
… | |
… | |
1104 | |
983 | |
1105 | unsigned char refresh_type, |
984 | unsigned char refresh_type, |
1106 | #ifdef META8_OPTION |
985 | #ifdef META8_OPTION |
1107 | meta_char, /* Alt-key prefix */ |
986 | meta_char, /* Alt-key prefix */ |
1108 | #endif |
987 | #endif |
1109 | scrollbar_align, |
|
|
1110 | selection_wait, |
988 | selection_wait, |
1111 | selection_type; |
989 | selection_type; |
1112 | /* ---------- */ |
990 | /* ---------- */ |
1113 | bool rvideo_state, rvideo_mode; |
991 | bool rvideo_state, rvideo_mode; |
1114 | #ifndef NO_BELL |
992 | #ifndef NO_BELL |
… | |
… | |
1132 | /* give proper Scroll behaviour */ |
1010 | /* give proper Scroll behaviour */ |
1133 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1011 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1134 | mouse_slip_wheel_speed, |
1012 | mouse_slip_wheel_speed, |
1135 | #endif |
1013 | #endif |
1136 | refresh_count, |
1014 | 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, |
1015 | window_vt_x, |
1142 | window_vt_y, |
1016 | window_vt_y, |
1143 | window_sb_x, |
1017 | window_sb_x, |
1144 | mouse_row, |
1018 | mouse_row, |
1145 | mouse_col, |
1019 | mouse_col, |
… | |
… | |
1187 | selection_request_time; |
1061 | selection_request_time; |
1188 | pid_t cmd_pid; /* process id of child */ |
1062 | pid_t cmd_pid; /* process id of child */ |
1189 | char * incr_buf; |
1063 | char * incr_buf; |
1190 | size_t incr_buf_size, incr_buf_fill; |
1064 | size_t incr_buf_size, incr_buf_fill; |
1191 | /* ---------- */ |
1065 | /* ---------- */ |
1192 | Cursor leftptr_cursor; |
|
|
1193 | /* ---------- */ |
|
|
1194 | struct mouse_event MEvent; |
1066 | struct mouse_event MEvent; |
1195 | XComposeStatus compose; |
1067 | XComposeStatus compose; |
1196 | ttymode_t tio; |
1068 | struct termios tio; |
1197 | row_col_t oldcursor; |
1069 | row_col_t oldcursor; |
1198 | #ifdef HAVE_BG_PIXMAP |
1070 | #ifdef HAVE_BG_PIXMAP |
1199 | bgPixmap_t bgPixmap; |
1071 | bgPixmap_t bgPixmap; |
1200 | #endif |
1072 | #endif |
1201 | #ifdef HAVE_AFTERIMAGE |
1073 | #ifdef HAVE_AFTERIMAGE |
… | |
… | |
1396 | void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); |
1268 | void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); |
1397 | void process_sgr_mode (unsigned int nargs, const int *arg); |
1269 | void process_sgr_mode (unsigned int nargs, const int *arg); |
1398 | void process_graphics (); |
1270 | void process_graphics (); |
1399 | // init.C |
1271 | // init.C |
1400 | void init_vars (); |
1272 | void init_vars (); |
1401 | void init_secondary (); |
|
|
1402 | const char **init_resources (int argc, const char *const *argv); |
1273 | const char **init_resources (int argc, const char *const *argv); |
|
|
1274 | void init (int argc, const char *const *argv, stringvec *envv); |
1403 | void init_env (); |
1275 | void init_env (); |
1404 | void set_locale (const char *locale); |
1276 | void set_locale (const char *locale); |
1405 | void init_xlocale (); |
1277 | void init_xlocale (); |
1406 | void init_command (const char *const *argv); |
1278 | void init_command (const char *const *argv); |
1407 | void run_command (const char *const *argv); |
1279 | void run_command (const char *const *argv); |
… | |
… | |
1414 | void tt_winch (); |
1286 | void tt_winch (); |
1415 | rxvt_term (); |
1287 | rxvt_term (); |
1416 | ~rxvt_term (); |
1288 | ~rxvt_term (); |
1417 | void destroy (); |
1289 | void destroy (); |
1418 | void emergency_cleanup (); |
1290 | void emergency_cleanup (); |
1419 | void init (int argc, const char *const *argv, stringvec *envv); |
|
|
1420 | void recolour_cursor (); |
1291 | void recolour_cursor (); |
1421 | void resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent); |
1292 | void resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent); |
1422 | void window_calc (unsigned int newwidth, unsigned int newheight); |
1293 | void window_calc (unsigned int newwidth, unsigned int newheight); |
1423 | bool set_fonts (); |
1294 | bool set_fonts (); |
1424 | void set_string_property (Atom prop, const char *str, int len = -1); |
1295 | void set_string_property (Atom prop, const char *str, int len = -1); |