1 | /* |
|
|
2 | * $Id: rxvt.h,v 1.10 2003/12/02 21:49:46 pcg Exp $ |
|
|
3 | */ |
|
|
4 | |
|
|
5 | #ifndef _RXVT_H_ /* include once only */ |
1 | #ifndef RXVT_H_ /* include once only */ |
6 | #define _RXVT_H_ |
2 | #define RXVT_H_ |
7 | |
3 | |
8 | #include "rxvtlib.h" |
4 | #include "rxvtlib.h" |
9 | |
5 | |
10 | #include "feature.h" |
6 | #include "feature.h" |
11 | |
7 | |
… | |
… | |
15 | #include <X11/Xatom.h> |
11 | #include <X11/Xatom.h> |
16 | |
12 | |
17 | #include "defaultfont.h" |
13 | #include "defaultfont.h" |
18 | #include "rxvtcolor.h" |
14 | #include "rxvtcolor.h" |
19 | #include "iom.h" |
15 | #include "iom.h" |
|
|
16 | #include "salloc.h" |
|
|
17 | |
|
|
18 | #include <wchar.h> |
20 | |
19 | |
21 | /* |
20 | /* |
22 | ***************************************************************************** |
21 | ***************************************************************************** |
23 | * SYSTEM HACKS |
22 | * SYSTEM HACKS |
24 | ***************************************************************************** |
23 | ***************************************************************************** |
… | |
… | |
480 | Rs_backgroundPixmap, |
479 | Rs_backgroundPixmap, |
481 | #endif |
480 | #endif |
482 | #if (MENUBAR_MAX) |
481 | #if (MENUBAR_MAX) |
483 | Rs_menu, |
482 | Rs_menu, |
484 | #endif |
483 | #endif |
485 | #ifndef NO_BOLDFONT |
|
|
486 | Rs_boldFont, |
|
|
487 | #endif |
|
|
488 | #ifdef GREEK_SUPPORT |
484 | #ifdef GREEK_SUPPORT |
489 | Rs_greek_keyboard, |
485 | Rs_greek_keyboard, |
490 | Rs_greektoggle_key, |
486 | Rs_greektoggle_key, |
491 | #endif |
487 | #endif |
492 | Rs_loginShell, |
488 | Rs_loginShell, |
… | |
… | |
551 | Rs_answerbackstring, |
547 | Rs_answerbackstring, |
552 | Rs_tripleclickwords, |
548 | Rs_tripleclickwords, |
553 | Rs_cursorBlink, |
549 | Rs_cursorBlink, |
554 | Rs_pointerBlank, |
550 | Rs_pointerBlank, |
555 | Rs_pointerBlankDelay, |
551 | Rs_pointerBlankDelay, |
|
|
552 | Rs_imLocale, |
556 | NUM_RESOURCES |
553 | NUM_RESOURCES |
557 | }; |
|
|
558 | |
|
|
559 | enum { |
|
|
560 | TIMEOUT_INCR = 0, |
|
|
561 | NUM_TIMEOUTS |
|
|
562 | }; |
554 | }; |
563 | |
555 | |
564 | enum { |
556 | enum { |
565 | XA_COMPOUND_TEXT = 0, |
557 | XA_COMPOUND_TEXT = 0, |
566 | XA_MULTIPLE, |
558 | XA_MULTIPLE, |
… | |
… | |
666 | #define STRLEN(x) strlen((const char *)(x)) |
658 | #define STRLEN(x) strlen((const char *)(x)) |
667 | #define STRCHR(x, y) strchr((const char *)(x), (int)(y)) |
659 | #define STRCHR(x, y) strchr((const char *)(x), (int)(y)) |
668 | #define STRRCHR(x, y) strrchr((const char *)(x), (int)(y)) |
660 | #define STRRCHR(x, y) strrchr((const char *)(x), (int)(y)) |
669 | |
661 | |
670 | /* convert pixel dimensions to row/column values. Everything as int32_t */ |
662 | /* convert pixel dimensions to row/column values. Everything as int32_t */ |
671 | #define Pixel2Col(x) Pixel2Width((int32_t)(x) - (int32_t)R->TermWin.int_bwidth) |
663 | #define Pixel2Col(x) Pixel2Width((int32_t)(x) - (int32_t)TermWin.int_bwidth) |
672 | #define Pixel2Row(y) Pixel2Height((int32_t)(y) - (int32_t)R->TermWin.int_bwidth) |
664 | #define Pixel2Row(y) Pixel2Height((int32_t)(y) - (int32_t)TermWin.int_bwidth) |
673 | #define Pixel2Width(x) ((int32_t)(x) / (int32_t)R->TermWin.fwidth) |
665 | #define Pixel2Width(x) ((int32_t)(x) / (int32_t)TermWin.fwidth) |
674 | #define Pixel2Height(y) ((int32_t)(y) / (int32_t)R->TermWin.fheight) |
666 | #define Pixel2Height(y) ((int32_t)(y) / (int32_t)TermWin.fheight) |
675 | #define Col2Pixel(col) ((int32_t)Width2Pixel(col) + (int32_t)R->TermWin.int_bwidth) |
667 | #define Col2Pixel(col) ((int32_t)Width2Pixel(col) + (int32_t)TermWin.int_bwidth) |
676 | #define Row2Pixel(row) ((int32_t)Height2Pixel(row) + (int32_t)R->TermWin.int_bwidth) |
668 | #define Row2Pixel(row) ((int32_t)Height2Pixel(row) + (int32_t)TermWin.int_bwidth) |
677 | #define Width2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fwidth) |
669 | #define Width2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fwidth) |
678 | #define Height2Pixel(n) ((int32_t)(n) * (int32_t)R->TermWin.fheight) |
670 | #define Height2Pixel(n) ((int32_t)(n) * (int32_t)TermWin.fheight) |
679 | |
671 | |
680 | #define TermWin_TotalWidth() ((int32_t)R->TermWin.width + 2 * (int32_t)R->TermWin.int_bwidth) |
672 | #define TermWin_TotalWidth() ((int32_t)TermWin.width + 2 * (int32_t)TermWin.int_bwidth) |
681 | #define TermWin_TotalHeight() ((int32_t)R->TermWin.height + 2 * (int32_t)R->TermWin.int_bwidth) |
673 | #define TermWin_TotalHeight() ((int32_t)TermWin.height + 2 * (int32_t)TermWin.int_bwidth) |
682 | |
674 | |
683 | #define Xscreen DefaultScreen(R->Xdisplay) |
675 | #define Xscreen DefaultScreen(R->Xdisplay) |
684 | #define Xroot DefaultRootWindow(R->Xdisplay) |
676 | #define Xroot DefaultRootWindow(R->Xdisplay) |
685 | |
677 | |
686 | /* how to build & extract colors and attributes */ |
678 | /* how to build & extract colors and attributes */ |
… | |
… | |
718 | |
710 | |
719 | #define SET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) |
711 | #define SET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS))) |
720 | #define ISSET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) |
712 | #define ISSET_PIXCOLOR(h, x) ((h)->pixcolor_set[(x) / NPIXCLR_BITS] & (1 << ((x) % NPIXCLR_BITS))) |
721 | |
713 | |
722 | #ifdef HAVE_SCROLLBARS |
714 | #ifdef HAVE_SCROLLBARS |
723 | # define scrollbar_TotalWidth() (R->scrollBar.width + R->sb_shadow * 2) |
715 | # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2) |
724 | #else |
716 | #else |
725 | # define scrollbar_TotalWidth() (0) |
717 | # define scrollbar_TotalWidth() (0) |
726 | #endif |
718 | #endif |
727 | #define scrollbar_isMotion() (R->scrollBar.state == 'm') |
719 | #define scrollbar_isMotion() (R->scrollBar.state == 'm') |
728 | #define scrollbar_isUp() (R->scrollBar.state == 'U') |
720 | #define scrollbar_isUp() (R->scrollBar.state == 'U') |
729 | #define scrollbar_isDn() (R->scrollBar.state == 'D') |
721 | #define scrollbar_isDn() (R->scrollBar.state == 'D') |
730 | #define scrollbar_isUpDn() isupper (R->scrollBar.state) |
722 | #define scrollbar_isUpDn() isupper (R->scrollBar.state) |
731 | #define isScrollbarWindow(w) (R->scrollBar.state && (w) == R->scrollBar.win) |
723 | #define isScrollbarWindow(w) (R->scrollBar.state && (w) == R->scrollBar.win) |
732 | |
|
|
733 | #define scrollbar_setIdle() R->scrollBar.state = 1 |
|
|
734 | #define scrollbar_setMotion() R->scrollBar.state = 'm' |
|
|
735 | #define scrollbar_setUp() R->scrollBar.state = 'U' |
|
|
736 | #define scrollbar_setDn() R->scrollBar.state = 'D' |
|
|
737 | |
724 | |
738 | #define scrollbarnext_dnval() (R->scrollBar.end + (R->scrollBar.width + 1)) |
725 | #define scrollbarnext_dnval() (R->scrollBar.end + (R->scrollBar.width + 1)) |
739 | #define scrollbarnext_upButton(y) ((y) > R->scrollBar.end \ |
726 | #define scrollbarnext_upButton(y) ((y) > R->scrollBar.end \ |
740 | && (y) <= scrollbarnext_dnval()) |
727 | && (y) <= scrollbarnext_dnval()) |
741 | #define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval()) |
728 | #define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval()) |
… | |
… | |
754 | #define scrollbar_size() (R->scrollBar.end - R->scrollBar.beg \ |
741 | #define scrollbar_size() (R->scrollBar.end - R->scrollBar.beg \ |
755 | - scrollbar_minheight()) |
742 | - scrollbar_minheight()) |
756 | |
743 | |
757 | #if (MENUBAR_MAX > 1) |
744 | #if (MENUBAR_MAX > 1) |
758 | /* rendition style flags */ |
745 | /* rendition style flags */ |
759 | # define menuBar_height() (R->TermWin.fheight + SHADOW) |
746 | # define menuBar_height() (TermWin.fheight + SHADOW) |
760 | # define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) |
747 | # define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) |
761 | # define isMenuBarWindow(w) ((w) == R->menuBar.win) |
748 | # define isMenuBarWindow(w) ((w) == R->menuBar.win) |
762 | #else |
749 | #else |
763 | # define menuBar_height() (0) |
750 | # define menuBar_height() (0) |
764 | # define menuBar_TotalHeight() (0) |
751 | # define menuBar_TotalHeight() (0) |
… | |
… | |
773 | |
760 | |
774 | #ifndef STRICT_FONT_CHECKING |
761 | #ifndef STRICT_FONT_CHECKING |
775 | # define rxvt_get_fontwidest(font) ((font)->max_bounds.width) |
762 | # define rxvt_get_fontwidest(font) ((font)->max_bounds.width) |
776 | #endif |
763 | #endif |
777 | |
764 | |
778 | #define rxvt_Gr_ButtonPress(x,y) rxvt_Gr_ButtonReport (r, 'P',(x),(y)) |
765 | #define rxvt_Gr_ButtonPress(x,y) rxvt_Gr_ButtonReport (R, 'P',(x),(y)) |
779 | #define rxvt_Gr_ButtonRelease(x,y) rxvt_Gr_ButtonReport (r, 'R',(x),(y)) |
766 | #define rxvt_Gr_ButtonRelease(x,y) rxvt_Gr_ButtonReport (R, 'R',(x),(y)) |
780 | |
767 | |
781 | #ifdef UTMP_SUPPORT |
768 | #ifdef UTMP_SUPPORT |
782 | # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) |
769 | # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) |
783 | # undef HAVE_UTMPX_H |
770 | # undef HAVE_UTMPX_H |
784 | # undef HAVE_STRUCT_UTMPX |
771 | # undef HAVE_STRUCT_UTMPX |
… | |
… | |
842 | #endif |
829 | #endif |
843 | |
830 | |
844 | #define BLINK_INTERVAL 0.5 |
831 | #define BLINK_INTERVAL 0.5 |
845 | |
832 | |
846 | struct mbstate { |
833 | struct mbstate { |
847 | unsigned char orig; |
834 | mbstate_t mbs; |
848 | uint32_t reg; |
|
|
849 | int cnt; |
|
|
850 | |
835 | |
851 | mbstate () |
836 | mbstate () |
852 | { |
837 | { |
853 | cnt = 0; |
838 | MEMSET (&mbs, 0, sizeof (mbs)); |
854 | } |
839 | } |
855 | }; |
840 | }; |
856 | |
841 | |
857 | struct rxvt_term : rxvt_vars { |
842 | struct rxvt_term : rxvt_vars { |
858 | struct mbstate mbstate; |
843 | struct mbstate mbstate; |
… | |
… | |
874 | #endif |
859 | #endif |
875 | #ifdef POINTER_BLANK |
860 | #ifdef POINTER_BLANK |
876 | hidden_pointer:1, |
861 | hidden_pointer:1, |
877 | #endif |
862 | #endif |
878 | parsed_geometry:1, |
863 | parsed_geometry:1, |
879 | seen_input:1; /* wether any input has been seen so far */ |
864 | seen_input:1, /* wether any input has been seen so far */ |
|
|
865 | enc_utf8:1; /* wether terminal reads/writes utf-8 */ |
880 | |
866 | |
881 | unsigned char refresh_type, |
867 | unsigned char refresh_type, |
882 | #ifdef UTMP_SUPPORT |
868 | #ifdef UTMP_SUPPORT |
883 | next_utmp_action, |
869 | next_utmp_action, |
884 | #endif |
870 | #endif |
… | |
… | |
895 | #ifdef GREEK_SUPPORT |
881 | #ifdef GREEK_SUPPORT |
896 | short greek_mode; /* greek keyboard mode */ |
882 | short greek_mode; /* greek keyboard mode */ |
897 | #endif |
883 | #endif |
898 | short rvideo; |
884 | short rvideo; |
899 | int16_t num_scr; /* screen: number lines scrolled */ |
885 | int16_t num_scr; /* screen: number lines scrolled */ |
900 | uint16_t prev_ncol, /* screen: previous number of columns */ |
886 | unsigned int prev_ncol, /* screen: previous number of columns */ |
901 | prev_nrow; /* screen: previous number of rows */ |
887 | prev_nrow; /* screen: previous number of rows */ |
902 | #ifdef RXVT_GRAPHICS |
888 | #ifdef RXVT_GRAPHICS |
903 | uint16_t gr_prev_start; |
889 | uint16_t gr_prev_start; |
904 | #endif |
890 | #endif |
905 | /* ---------- */ |
891 | /* ---------- */ |
906 | rend_t rstyle; |
892 | rend_t rstyle; |
907 | /* ---------- */ |
893 | /* ---------- */ |
908 | uint32_t pixcolor_set[NPIXCLR_SETS]; |
894 | uint32_t pixcolor_set[NPIXCLR_SETS]; |
909 | /* ---------- */ |
895 | /* ---------- */ |
910 | #ifdef SELECTION_SCROLLING |
896 | #ifdef SELECTION_SCROLLING |
911 | int scroll_selection_delay, |
897 | int scroll_selection_delay, |
912 | scroll_selection_lines; |
898 | scroll_selection_lines; |
913 | enum page_dirn scroll_selection_dir; |
899 | enum page_dirn scroll_selection_dir; |
… | |
… | |
1069 | struct timeval lastcursorchange; |
1055 | struct timeval lastcursorchange; |
1070 | #endif |
1056 | #endif |
1071 | #ifdef POINTER_BLANK |
1057 | #ifdef POINTER_BLANK |
1072 | struct timeval lastmotion; |
1058 | struct timeval lastmotion; |
1073 | #endif |
1059 | #endif |
1074 | struct timeval timeout[NUM_TIMEOUTS]; |
|
|
1075 | |
1060 | |
1076 | /* these three don't need to be kept but do so to placate some mem checkers */ |
1061 | /* these three don't need to be kept but do so to placate some mem checkers */ |
1077 | char *env_windowid; /* environmental variable WINDOWID */ |
1062 | char *env_windowid; /* environmental variable WINDOWID */ |
1078 | char *env_display; /* environmental variable DISPLAY */ |
1063 | char *env_display; /* environmental variable DISPLAY */ |
1079 | char *env_term; /* environmental variable TERM */ |
1064 | char *env_term; /* environmental variable TERM */ |
1080 | char *env_colorfgbg; |
1065 | char *env_colorfgbg; |
1081 | char *buffer; |
1066 | char *buffer; |
1082 | char *locale; |
1067 | char *locale; |
|
|
1068 | char *codeset; |
1083 | char charsets[4]; |
1069 | char charsets[4]; |
1084 | unsigned char *v_buffer; /* pointer to physical buffer */ |
1070 | unsigned char *v_buffer; /* pointer to physical buffer */ |
1085 | unsigned int v_buflen; /* size of area to write */ |
1071 | unsigned int v_buflen; /* size of area to write */ |
1086 | char *newfont[MAX_NFONTS]; |
1072 | char *newfont[MAX_NFONTS]; |
1087 | #ifdef KEYSYM_RESOURCE |
1073 | #ifdef KEYSYM_RESOURCE |
… | |
… | |
1089 | #endif |
1075 | #endif |
1090 | const char *rs[NUM_RESOURCES]; |
1076 | const char *rs[NUM_RESOURCES]; |
1091 | /* command input buffering */ |
1077 | /* command input buffering */ |
1092 | unsigned char *cmdbuf_ptr, *cmdbuf_endp; |
1078 | unsigned char *cmdbuf_ptr, *cmdbuf_endp; |
1093 | unsigned char cmdbuf_base[BUFSIZ]; |
1079 | unsigned char cmdbuf_base[BUFSIZ]; |
1094 | unsigned char kbuf[KBUFSZ]; |
1080 | |
|
|
1081 | rxvt_salloc *ralloc; |
|
|
1082 | rxvt_salloc *talloc; |
|
|
1083 | |
|
|
1084 | void paste (const unsigned char *data, unsigned int len); |
1095 | |
1085 | |
1096 | void flush (); |
1086 | void flush (); |
1097 | |
1087 | |
1098 | void check_cb (check_watcher &w); check_watcher check_ev; |
1088 | void check_cb (check_watcher &w); check_watcher check_ev; |
1099 | void destroy_cb (time_watcher &w); time_watcher destroy_ev; |
1089 | void destroy_cb (time_watcher &w); time_watcher destroy_ev; |
1100 | |
1090 | |
1101 | void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; |
1091 | void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; |
1102 | void x_cb (io_watcher &w, short revents); io_watcher x_ev; |
1092 | void x_cb (io_watcher &w, short revents); io_watcher x_ev; |
|
|
1093 | |
|
|
1094 | void incr_cb (time_watcher &w); time_watcher incr_ev; |
1103 | |
1095 | |
1104 | #ifdef CURSOR_BLINK |
1096 | #ifdef CURSOR_BLINK |
1105 | void blink_cb (time_watcher &w); time_watcher blink_ev; |
1097 | void blink_cb (time_watcher &w); time_watcher blink_ev; |
1106 | #endif |
1098 | #endif |
1107 | |
1099 | |
… | |
… | |
1128 | bool pty_fill (); |
1120 | bool pty_fill (); |
1129 | void process_x_events (); |
1121 | void process_x_events (); |
1130 | |
1122 | |
1131 | void *operator new (size_t s); |
1123 | void *operator new (size_t s); |
1132 | void operator delete (void *p, size_t s); |
1124 | void operator delete (void *p, size_t s); |
|
|
1125 | |
|
|
1126 | void init_secondary (); |
|
|
1127 | const char **init_resources (int argc, const char *const *argv); |
|
|
1128 | void init_env (); |
|
|
1129 | void set_locale (const char *locale); |
|
|
1130 | void init_xlocale (); |
|
|
1131 | void init_command (const char *const *argv); |
|
|
1132 | int run_command (const char *const *argv); |
|
|
1133 | int run_child (const char *const *argv); |
|
|
1134 | |
|
|
1135 | void color_aliases(int idx); |
|
|
1136 | void recolour_cursor (); |
|
|
1137 | void create_windows (int argc, const char *const *argv); |
|
|
1138 | void resize_all_windows (unsigned int width, unsigned int height, int ignoreparent); |
|
|
1139 | void window_calc (unsigned int width, unsigned int height); |
|
|
1140 | void set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect, XRectangle * needed_rect); |
|
|
1141 | |
|
|
1142 | #if USE_XIM |
|
|
1143 | void set_size (XRectangle *size); |
|
|
1144 | void set_position (XPoint *pos); |
|
|
1145 | void set_color (unsigned long *fg, unsigned long *bg); |
|
|
1146 | #endif |
|
|
1147 | |
|
|
1148 | void resize_scrollbar (); |
|
|
1149 | |
|
|
1150 | void pixel_position (int *x, int *y); |
|
|
1151 | |
|
|
1152 | void selection_click (int clicks, int x, int y); |
|
|
1153 | void selection_extend (int x, int y, int flag); |
|
|
1154 | void selection_rotate (int x, int y); |
|
|
1155 | |
|
|
1156 | /* screen(!) */ |
|
|
1157 | void scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs); |
|
|
1158 | void scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs); |
|
|
1159 | int scr_scroll_text (int row1, int row2, int count, int spec); |
|
|
1160 | void scr_reset (); |
|
|
1161 | void scr_reset_realloc (); |
|
|
1162 | void scr_release (); |
|
|
1163 | void scr_clear (); |
|
|
1164 | void scr_refresh (unsigned char refresh_type); |
|
|
1165 | void scr_erase_screen (int mode); |
|
|
1166 | void scr_touch (bool refresh); |
|
|
1167 | void scr_expose (int x, int y, int width, int height, bool refresh); |
1133 | }; |
1168 | }; |
|
|
1169 | |
|
|
1170 | #define SET_LOCALE(locale) rxvt_set_locale (locale) |
|
|
1171 | extern void rxvt_set_locale (const char *locale); |
1134 | |
1172 | |
1135 | #ifndef __attribute__ |
1173 | #ifndef __attribute__ |
1136 | # ifdef __GNUC__ |
1174 | # ifdef __GNUC__ |
1137 | # if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) |
1175 | # if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) |
1138 | # define __attribute__(x) |
1176 | # define __attribute__(x) |