… | |
… | |
18 | #include "encoding.h" |
18 | #include "encoding.h" |
19 | #include "rxvtfont.h" |
19 | #include "rxvtfont.h" |
20 | #include "rxvttoolkit.h" |
20 | #include "rxvttoolkit.h" |
21 | #include "iom.h" |
21 | #include "iom.h" |
22 | #include "salloc.h" |
22 | #include "salloc.h" |
|
|
23 | |
|
|
24 | #include "rxvtperl.h" |
23 | |
25 | |
24 | #if ENABLE_FRILLS |
26 | #if ENABLE_FRILLS |
25 | # define ENABLE_XEMBED 1 |
27 | # define ENABLE_XEMBED 1 |
26 | # define ENABLE_EWMH 1 |
28 | # define ENABLE_EWMH 1 |
27 | # define CURSOR_BLINK 1 |
29 | # define CURSOR_BLINK 1 |
… | |
… | |
207 | # define TERMENV "rxvt-unicode" |
209 | # define TERMENV "rxvt-unicode" |
208 | #endif |
210 | #endif |
209 | |
211 | |
210 | #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) |
212 | #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) |
211 | # define NO_MOUSE_REPORT_SCROLLBAR 1 |
213 | # define NO_MOUSE_REPORT_SCROLLBAR 1 |
212 | #endif |
|
|
213 | |
|
|
214 | #ifdef NO_RESOURCES |
|
|
215 | # undef USE_XGETDEFAULT |
|
|
216 | #endif |
214 | #endif |
217 | |
215 | |
218 | #if defined (ISO_14755) || defined (ENABLE_PERL) |
216 | #if defined (ISO_14755) || defined (ENABLE_PERL) |
219 | # define ENABLE_OVERLAY 1 |
217 | # define ENABLE_OVERLAY 1 |
220 | #endif |
218 | #endif |
… | |
… | |
697 | #define Col2Pixel(col) ((int32_t)Width2Pixel(col)) |
695 | #define Col2Pixel(col) ((int32_t)Width2Pixel(col)) |
698 | #define Row2Pixel(row) ((int32_t)Height2Pixel(row)) |
696 | #define Row2Pixel(row) ((int32_t)Height2Pixel(row)) |
699 | #define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth) |
697 | #define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth) |
700 | #define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight) |
698 | #define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight) |
701 | |
699 | |
|
|
700 | #define TEMP_ENV temp_environ temp_environ (envv) |
|
|
701 | |
|
|
702 | #define OPTION(opt) (options & (opt)) |
|
|
703 | #define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \ |
|
|
704 | | Opt_jumpScroll | Opt_secondaryScreen \ |
|
|
705 | | Opt_pastableTabs | Opt_intensityStyles) |
|
|
706 | |
702 | // for m >= -n, ensure remainder lies between 0..n-1 |
707 | // for m >= -n, ensure remainder lies between 0..n-1 |
703 | #define MOD(m,n) (((m) + (n)) % (n)) |
708 | #define MOD(m,n) (((m) + (n)) % (n)) |
704 | |
709 | |
705 | #define LINENO(n) MOD (term_start + int(n), total_rows) |
710 | #define LINENO(n) MOD (term_start + int(n), total_rows) |
706 | #define ROW(n) row_buf [LINENO (n)] |
711 | #define ROW(n) row_buf [LINENO (n)] |
… | |
… | |
832 | extern void rxvt_fatal (const char *fmt, ...) __attribute__ ((noreturn)); |
837 | extern void rxvt_fatal (const char *fmt, ...) __attribute__ ((noreturn)); |
833 | extern void rxvt_exit_failure () __attribute__ ((noreturn)); |
838 | extern void rxvt_exit_failure () __attribute__ ((noreturn)); |
834 | |
839 | |
835 | #define SET_LOCALE(locale) rxvt_set_locale (locale) |
840 | #define SET_LOCALE(locale) rxvt_set_locale (locale) |
836 | extern bool rxvt_set_locale (const char *locale); |
841 | extern bool rxvt_set_locale (const char *locale); |
837 | extern bool rxvt_push_locale (const char *locale); |
842 | extern void rxvt_push_locale (const char *locale); |
838 | extern void rxvt_pop_locale (); |
843 | extern void rxvt_pop_locale (); |
839 | |
844 | |
840 | /* |
|
|
841 | ***************************************************************************** |
845 | /****************************************************************************/ |
842 | * VARIABLES |
846 | |
843 | ***************************************************************************** |
|
|
844 | */ |
|
|
845 | #ifdef MENUBAR |
847 | #ifdef MENUBAR |
846 | # include "menubar.h" |
848 | # include "menubar.h" |
847 | #endif |
849 | #endif |
848 | |
850 | |
849 | #define BLINK_INTERVAL 0.5 |
851 | #define BLINK_INTERVAL 0.5 |
… | |
… | |
856 | # endif |
858 | # endif |
857 | # endif |
859 | # endif |
858 | # define __attribute__(x) |
860 | # define __attribute__(x) |
859 | #endif |
861 | #endif |
860 | |
862 | |
|
|
863 | /****************************************************************************/ |
|
|
864 | |
|
|
865 | #define LINE_LONGER 0x0001 // line is continued on the next row |
|
|
866 | #define LINE_FILTERED 0x0002 // line has been filtered |
|
|
867 | #define LINE_COMPRESSED 0x0004 // line has been compressed (NYI) |
|
|
868 | |
|
|
869 | struct line_t { |
|
|
870 | text_t *t; // terminal the text |
|
|
871 | rend_t *r; // rendition, uses RS_ flags |
|
|
872 | tlen_t_ l; // length of each text line, LINE_CONT == continued on next line |
|
|
873 | uint32_t f; // flags |
|
|
874 | |
|
|
875 | bool is_longer () |
|
|
876 | { |
|
|
877 | return f & LINE_LONGER; |
|
|
878 | } |
|
|
879 | |
|
|
880 | void is_longer (int set) |
|
|
881 | { |
|
|
882 | if (set) |
|
|
883 | f |= LINE_LONGER; |
|
|
884 | else |
|
|
885 | f &= ~LINE_LONGER; |
|
|
886 | } |
|
|
887 | |
|
|
888 | void clear () |
|
|
889 | { |
|
|
890 | t = 0; |
|
|
891 | r = 0; |
|
|
892 | l = 0; |
|
|
893 | f = 0; |
|
|
894 | } |
|
|
895 | |
|
|
896 | void touch () // call whenever a line is changed/touched/updated |
|
|
897 | { |
|
|
898 | #if ENABLE_PERL |
|
|
899 | f &= ~LINE_FILTERED; |
|
|
900 | #endif |
|
|
901 | } |
|
|
902 | |
|
|
903 | void touch (int col) |
|
|
904 | { |
|
|
905 | max_it (l, col); |
|
|
906 | touch (); |
|
|
907 | } |
|
|
908 | }; |
|
|
909 | |
|
|
910 | /****************************************************************************/ |
|
|
911 | |
861 | // primivite wrapper around mbstate_t to ensure initialisation |
912 | // primivite wrapper around mbstate_t to ensure initialisation |
862 | struct mbstate { |
913 | struct mbstate { |
863 | mbstate_t mbs; |
914 | mbstate_t mbs; |
864 | |
915 | |
865 | operator mbstate_t *() { return &mbs; } |
916 | operator mbstate_t *() { return &mbs; } |
866 | void reset () { memset (&mbs, 0, sizeof (mbs)); } |
917 | void reset () { memset (&mbs, 0, sizeof (mbs)); } |
867 | mbstate () { reset (); } |
918 | mbstate () { reset (); } |
868 | }; |
919 | }; |
869 | |
920 | |
|
|
921 | /****************************************************************************/ |
|
|
922 | |
870 | #define UNICODE_MASK 0x1fffffUL |
923 | #define UNICODE_MASK 0x1fffffUL |
871 | |
924 | |
872 | #if UNICODE3 |
925 | #if UNICODE3 |
873 | # define COMPOSE_LO 0x40000000UL |
926 | # define COMPOSE_LO 0x40000000UL |
874 | # define COMPOSE_HI 0x400fffffUL |
927 | # define COMPOSE_HI 0x400fffffUL |
875 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
928 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
876 | #else |
929 | #else |
|
|
930 | # if ENABLE_PERL |
|
|
931 | # define COMPOSE_LO 0xe000UL // our _own_ routiens don't like (illegal) surrogates |
|
|
932 | # define COMPOSE_HI 0xf8ffUL // in utf-8, so use private use area only |
|
|
933 | # else |
877 | # define COMPOSE_LO 0xd800UL |
934 | # define COMPOSE_LO 0xd800UL |
878 | # define COMPOSE_HI 0xf8ffUL // dfff should be safer, but... |
935 | # define COMPOSE_HI 0xf8ffUL |
879 | # define IS_COMPOSE(n) (COMPOSE_LO <= (n) && (n) <= COMPOSE_HI) |
936 | # endif |
|
|
937 | # define IS_COMPOSE(n) IN_RANGE_INC ((n), COMPOSE_LO, COMPOSE_HI) |
880 | #endif |
938 | #endif |
881 | |
939 | |
882 | #if ENABLE_COMBINING |
940 | #if ENABLE_COMBINING |
883 | // compose chars are used to represent composite characters |
941 | // compose chars are used to represent composite characters |
884 | // that are not representable in unicode, as well as characters |
942 | // that are not representable in unicode, as well as characters |
… | |
… | |
904 | }; |
962 | }; |
905 | |
963 | |
906 | extern class rxvt_composite_vec rxvt_composite; |
964 | extern class rxvt_composite_vec rxvt_composite; |
907 | #endif |
965 | #endif |
908 | |
966 | |
|
|
967 | /****************************************************************************/ |
909 | |
968 | |
910 | #ifdef KEYSYM_RESOURCE |
969 | #ifdef KEYSYM_RESOURCE |
911 | class keyboard_manager; |
970 | class keyboard_manager; |
912 | #endif |
971 | #endif |
913 | |
972 | |
914 | struct rxvt_term : zero_initialized, rxvt_vars { |
973 | struct rxvt_term : zero_initialized, rxvt_vars { |
915 | log_callback *log_hook; // log error messages through this hook, if != 0 |
974 | log_callback *log_hook; // log error messages through this hook, if != 0 |
916 | getfd_callback *getfd_hook; // convert remote to local fd, if != 0 |
975 | getfd_callback *getfd_hook; // convert remote to local fd, if != 0 |
917 | |
|
|
918 | #if ENABLE_PERL |
976 | #if ENABLE_PERL |
919 | void *self; // perl's $self |
977 | rxvt_perl_term perl; |
920 | #endif |
978 | #endif |
921 | |
|
|
922 | struct mbstate mbstate; // current input multibyte state |
979 | struct mbstate mbstate; // current input multibyte state |
923 | |
980 | |
924 | unsigned char want_refresh:1, |
981 | unsigned char want_refresh:1, |
925 | #ifdef TRANSPARENT |
982 | #ifdef TRANSPARENT |
926 | want_full_refresh:1, /* awaiting full screen refresh */ |
983 | want_full_refresh:1, /* awaiting full screen refresh */ |
… | |
… | |
1199 | |
1256 | |
1200 | bool pty_fill (); |
1257 | bool pty_fill (); |
1201 | |
1258 | |
1202 | void init_secondary (); |
1259 | void init_secondary (); |
1203 | const char **init_resources (int argc, const char *const *argv); |
1260 | const char **init_resources (int argc, const char *const *argv); |
|
|
1261 | const char *x_resource (const char *name); |
1204 | void init_env (); |
1262 | void init_env (); |
1205 | void set_locale (const char *locale); |
1263 | void set_locale (const char *locale); |
1206 | void init_xlocale (); |
1264 | void init_xlocale (); |
1207 | void init_command (const char *const *argv); |
1265 | void init_command (const char *const *argv); |
1208 | void run_command (const char *const *argv); |
1266 | void run_command (const char *const *argv); |
… | |
… | |
1245 | |
1303 | |
1246 | // command.C |
1304 | // command.C |
1247 | void lookup_key (XKeyEvent &ev); |
1305 | void lookup_key (XKeyEvent &ev); |
1248 | unsigned int cmd_write (const char *str, unsigned int count); |
1306 | unsigned int cmd_write (const char *str, unsigned int count); |
1249 | |
1307 | |
1250 | unicode_t next_char (); |
1308 | wchar_t next_char (); |
1251 | unicode_t cmd_getc (); |
1309 | wchar_t cmd_getc (); |
1252 | unicode_t next_octet (); |
1310 | uint32_t next_octet (); |
1253 | unicode_t cmd_get8 (); |
1311 | uint32_t cmd_get8 (); |
1254 | |
1312 | |
1255 | bool cmd_parse (); |
1313 | bool cmd_parse (); |
1256 | void mouse_report (XButtonEvent &ev); |
1314 | void mouse_report (XButtonEvent &ev); |
1257 | void button_press (XButtonEvent &ev); |
1315 | void button_press (XButtonEvent &ev); |
1258 | void button_release (XButtonEvent &ev); |
1316 | void button_release (XButtonEvent &ev); |
… | |
… | |
1385 | base += minBrightCOLOR - minCOLOR; |
1443 | base += minBrightCOLOR - minCOLOR; |
1386 | #endif |
1444 | #endif |
1387 | return base; |
1445 | return base; |
1388 | } |
1446 | } |
1389 | |
1447 | |
|
|
1448 | bool option (uint32_t opt) |
|
|
1449 | { |
|
|
1450 | return OPTION (opt); |
|
|
1451 | } |
|
|
1452 | |
|
|
1453 | void set_option (uint32_t opt, bool set) |
|
|
1454 | { |
|
|
1455 | if (set) |
|
|
1456 | options |= opt; |
|
|
1457 | else |
|
|
1458 | options &= ~opt; |
|
|
1459 | } |
|
|
1460 | |
1390 | void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs); |
1461 | void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs); |
1391 | void scr_blank_screen_mem (line_t &l, rend_t efs); |
1462 | void scr_blank_screen_mem (line_t &l, rend_t efs); |
1392 | int scr_scroll_text (int row1, int row2, int count); |
1463 | int scr_scroll_text (int row1, int row2, int count); |
1393 | void scr_reset (); |
1464 | void scr_reset (); |
1394 | void scr_release (); |
1465 | void scr_release (); |
… | |
… | |
1404 | void scr_touch (bool refresh); |
1475 | void scr_touch (bool refresh); |
1405 | void scr_expose (int x, int y, int width, int height, bool refresh); |
1476 | void scr_expose (int x, int y, int width, int height, bool refresh); |
1406 | rxvt_fontset *scr_find_fontset (rend_t r = DEFAULT_RSTYLE); |
1477 | rxvt_fontset *scr_find_fontset (rend_t r = DEFAULT_RSTYLE); |
1407 | void scr_recolour (); |
1478 | void scr_recolour (); |
1408 | void scr_remap_chars (); |
1479 | void scr_remap_chars (); |
1409 | void scr_remap_chars (const line_t &l); |
1480 | void scr_remap_chars (line_t &l); |
1410 | |
1481 | |
1411 | void scr_poweron (); |
1482 | void scr_poweron (); |
1412 | void scr_cursor (int mode); |
1483 | void scr_cursor (int mode); |
1413 | void scr_do_wrap (); |
1484 | void scr_do_wrap (); |
1414 | int scr_change_screen (int scrn); |
1485 | int scr_change_screen (int scrn); |
1415 | void scr_color (unsigned int color, int fgbg); |
1486 | void scr_color (unsigned int color, int fgbg); |
1416 | void scr_rendition (int set, int style); |
1487 | void scr_rendition (int set, int style); |
1417 | void scr_add_lines (const unicode_t *str, int nlines, int len); |
1488 | void scr_add_lines (const wchar_t *str, int len, int minlines = 0); |
1418 | void scr_backspace (); |
1489 | void scr_backspace (); |
1419 | void scr_tab (int count, bool ht = false); |
1490 | void scr_tab (int count, bool ht = false); |
1420 | void scr_gotorc (int row, int col, int relative); |
1491 | void scr_gotorc (int row, int col, int relative); |
1421 | void scr_index (enum page_dirn direction); |
1492 | void scr_index (enum page_dirn direction); |
1422 | void scr_erase_line (int mode); |
1493 | void scr_erase_line (int mode); |
… | |
… | |
1437 | int scr_move_to (int y, int len); |
1508 | int scr_move_to (int y, int len); |
1438 | int scr_page (enum page_dirn direction, int nlines); |
1509 | int scr_page (enum page_dirn direction, int nlines); |
1439 | int scr_changeview (unsigned int oldviewstart); |
1510 | int scr_changeview (unsigned int oldviewstart); |
1440 | void scr_bell (); |
1511 | void scr_bell (); |
1441 | void scr_printscreen (int fullhist); |
1512 | void scr_printscreen (int fullhist); |
|
|
1513 | void scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2); |
|
|
1514 | void scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle); |
1442 | void scr_reverse_selection (); |
1515 | void scr_reverse_selection (); |
1443 | void scr_dump (int fd); |
1516 | void scr_dump (int fd); |
1444 | void selection_check (int check_more); |
1517 | void selection_check (int check_more); |
1445 | void selection_paste (Window win, Atom prop, bool delete_prop); |
1518 | void selection_paste (Window win, Atom prop, bool delete_prop); |
1446 | void selection_property (Window win, Atom prop); |
1519 | void selection_property (Window win, Atom prop); |