… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
|
|
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
52 | |
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
… | |
… | |
155 | } |
161 | } |
156 | |
162 | |
157 | x--; |
163 | x--; |
158 | } |
164 | } |
159 | } |
165 | } |
160 | #endif |
|
|
161 | |
166 | |
162 | void |
167 | void |
163 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
168 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
164 | { |
169 | { |
165 | #if ENABLE_OVERLAY |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
170 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
171 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
172 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
173 | int len; |
170 | |
174 | |
… | |
… | |
238 | |
242 | |
239 | # if ENABLE_COMBINING |
243 | # if ENABLE_COMBINING |
240 | if (alloc) |
244 | if (alloc) |
241 | delete [] alloc; |
245 | delete [] alloc; |
242 | # endif |
246 | # endif |
243 | #endif |
|
|
244 | } |
247 | } |
|
|
248 | #endif |
245 | |
249 | |
246 | void |
250 | void |
247 | rxvt_term::commit_iso14755 () |
251 | rxvt_term::commit_iso14755 () |
248 | { |
252 | { |
249 | wchar_t ch[2]; |
253 | wchar_t ch[2]; |
… | |
… | |
982 | SET_LOCALE (locale); |
986 | SET_LOCALE (locale); |
983 | |
987 | |
984 | display->flush (); |
988 | display->flush (); |
985 | |
989 | |
986 | if (want_refresh && !flush_ev.active) |
990 | if (want_refresh && !flush_ev.active) |
987 | flush_ev.start (NOW + 0.01); |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
988 | } |
992 | } |
989 | |
993 | |
990 | void |
994 | void |
991 | rxvt_term::flush_cb (time_watcher &w) |
995 | rxvt_term::flush_cb (time_watcher &w) |
992 | { |
996 | { |
… | |
… | |
1067 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1068 | } |
1072 | } |
1069 | } |
1073 | } |
1070 | #endif |
1074 | #endif |
1071 | |
1075 | |
|
|
1076 | #if HAVE_SCHED_YIELD |
|
|
1077 | static struct event_handler |
|
|
1078 | { |
|
|
1079 | check_watcher cw_yield; |
|
|
1080 | |
|
|
1081 | void yield (check_watcher &w) |
|
|
1082 | { |
|
|
1083 | sched_yield (); |
|
|
1084 | w.stop (); |
|
|
1085 | } |
|
|
1086 | |
|
|
1087 | event_handler () |
|
|
1088 | : cw_yield (this, &event_handler::yield) |
|
|
1089 | { |
|
|
1090 | } |
|
|
1091 | } event_handler; |
|
|
1092 | #endif |
|
|
1093 | |
1072 | bool |
1094 | bool |
1073 | rxvt_term::pty_fill () |
1095 | rxvt_term::pty_fill () |
1074 | { |
1096 | { |
1075 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1076 | |
1098 | |
1077 | if (CBUFSIZ == n) |
1099 | if (CBUFSIZ == n) |
1078 | { |
1100 | { |
1079 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1101 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1080 | n = 0; |
1102 | n = 0; |
1081 | } |
1103 | } |
1082 | |
1104 | |
1083 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1084 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_ptr = cmdbuf_base; |
1085 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1086 | |
1108 | |
1087 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1088 | |
1110 | |
1089 | if (n > 0) |
1111 | if (r > 0) |
1090 | { |
1112 | { |
1091 | cmdbuf_endp += n; |
1113 | cmdbuf_endp += r; |
1092 | return true; |
1114 | return true; |
1093 | } |
1115 | } |
1094 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1116 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1117 | { |
|
|
1118 | #if HAVE_SCHED_YIELD |
|
|
1119 | if (display->is_local) |
|
|
1120 | event_handler.cw_yield.start (); |
|
|
1121 | #endif |
|
|
1122 | } |
|
|
1123 | else |
1095 | { |
1124 | { |
1096 | pty_ev.stop (); |
1125 | pty_ev.stop (); |
1097 | |
1126 | |
1098 | if (!OPTION (Opt_hold)) |
1127 | if (!OPTION (Opt_hold)) |
1099 | destroy (); |
1128 | destroy (); |
… | |
… | |
1672 | { |
1701 | { |
1673 | if (!focus) |
1702 | if (!focus) |
1674 | { |
1703 | { |
1675 | focus = 1; |
1704 | focus = 1; |
1676 | want_refresh = 1; |
1705 | want_refresh = 1; |
|
|
1706 | |
|
|
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1708 | |
1677 | #if USE_XIM |
1709 | #if USE_XIM |
1678 | if (Input_Context != NULL) |
1710 | if (Input_Context != NULL) |
1679 | { |
1711 | { |
1680 | IMSetStatusPosition (); |
1712 | IMSetStatusPosition (); |
1681 | XSetICFocus (Input_Context); |
1713 | XSetICFocus (Input_Context); |
… | |
… | |
1701 | if (focus) |
1733 | if (focus) |
1702 | { |
1734 | { |
1703 | focus = 0; |
1735 | focus = 0; |
1704 | want_refresh = 1; |
1736 | want_refresh = 1; |
1705 | |
1737 | |
|
|
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1739 | |
1706 | #if ENABLE_FRILLS || ISO_14755 |
1740 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1741 | if (iso14755buf) |
|
|
1742 | { |
1707 | iso14755buf = 0; |
1743 | iso14755buf = 0; |
1708 | #endif |
|
|
1709 | #if ENABLE_OVERLAY |
1744 | # if ENABLE_OVERLAY |
1710 | scr_overlay_off (); |
1745 | scr_overlay_off (); |
|
|
1746 | # endif |
|
|
1747 | } |
1711 | #endif |
1748 | #endif |
1712 | #if USE_XIM |
1749 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1750 | if (Input_Context != NULL) |
1714 | XUnsetICFocus (Input_Context); |
1751 | XUnsetICFocus (Input_Context); |
1715 | #endif |
1752 | #endif |
… | |
… | |
1759 | rxvt_term::button_press (XButtonEvent &ev) |
1796 | rxvt_term::button_press (XButtonEvent &ev) |
1760 | { |
1797 | { |
1761 | int reportmode = 0, clickintime; |
1798 | int reportmode = 0, clickintime; |
1762 | |
1799 | |
1763 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1800 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1801 | |
1764 | if (!bypass_keystate) |
1802 | if (!bypass_keystate) |
1765 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1803 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1766 | |
1804 | |
1767 | /* |
1805 | /* |
1768 | * VT window processing of button press |
1806 | * VT window processing of button press |
… | |
… | |
1817 | else |
1855 | else |
1818 | { |
1856 | { |
1819 | if (ev.button != MEvent.button) |
1857 | if (ev.button != MEvent.button) |
1820 | MEvent.clicks = 0; |
1858 | MEvent.clicks = 0; |
1821 | |
1859 | |
|
|
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1822 | switch (ev.button) |
1861 | switch (ev.button) |
1823 | { |
1862 | { |
1824 | case Button1: |
1863 | case Button1: |
1825 | /* allow meta + click to select rectangular areas */ |
1864 | /* allow meta + click to select rectangular areas */ |
1826 | /* should be done in screen.C */ |
1865 | /* should be done in screen.C */ |
1827 | #if ENABLE_FRILLS |
1866 | #if ENABLE_FRILLS |
1828 | selection.rect = !!(ev.state & ModMetaMask); |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1829 | #else |
1868 | #else |
1830 | selection.rect = false; |
1869 | selection.rect = false; |
1831 | #endif |
1870 | #endif |
1832 | |
1871 | |
1833 | /* allow shift+left click to extend selection */ |
1872 | /* allow shift+left click to extend selection */ |
1834 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1835 | { |
1874 | { |
1836 | if (MEvent.button == Button1 && clickintime) |
1875 | if (MEvent.button == Button1 && clickintime) |
1837 | selection_rotate (ev.x, ev.y); |
1876 | selection_rotate (ev.x, ev.y); |
1838 | else |
1877 | else |
1839 | selection_extend (ev.x, ev.y, 1); |
1878 | selection_extend (ev.x, ev.y, 1); |
1840 | } |
1879 | } |
1841 | else |
1880 | else |
1842 | { |
1881 | { |
1843 | if (MEvent.button == Button1 && clickintime) |
1882 | if (MEvent.button == Button1 && clickintime) |
1844 | MEvent.clicks++; |
1883 | MEvent.clicks++; |
1845 | else |
1884 | else |
1846 | MEvent.clicks = 1; |
1885 | MEvent.clicks = 1; |
1847 | |
1886 | |
1848 | selection_click (MEvent.clicks, ev.x, ev.y); |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1849 | } |
1888 | } |
1850 | |
1889 | |
1851 | MEvent.button = Button1; |
1890 | MEvent.button = Button1; |
1852 | break; |
1891 | break; |
1853 | |
1892 | |
1854 | case Button3: |
1893 | case Button3: |
1855 | if (MEvent.button == Button3 && clickintime) |
1894 | if (MEvent.button == Button3 && clickintime) |
1856 | selection_rotate (ev.x, ev.y); |
1895 | selection_rotate (ev.x, ev.y); |
1857 | else |
1896 | else |
1858 | selection_extend (ev.x, ev.y, 1); |
1897 | selection_extend (ev.x, ev.y, 1); |
1859 | |
1898 | |
1860 | MEvent.button = Button3; |
1899 | MEvent.button = Button3; |
1861 | break; |
1900 | break; |
1862 | } |
1901 | } |
1863 | } |
1902 | } |
1864 | |
1903 | |
1865 | MEvent.time = ev.time; |
1904 | MEvent.time = ev.time; |
1866 | return; |
1905 | return; |
1867 | } |
1906 | } |
1868 | |
1907 | |
… | |
… | |
2686 | |
2725 | |
2687 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2688 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2689 | { |
2728 | { |
2690 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2691 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2692 | break; |
2732 | break; |
2693 | } |
2733 | } |
2694 | |
2734 | |
2695 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
… | |
… | |
2732 | refresh_limit++; |
2772 | refresh_limit++; |
2733 | else |
2773 | else |
2734 | { |
2774 | { |
2735 | flag = true; |
2775 | flag = true; |
2736 | scr_refresh (refresh_type); |
2776 | scr_refresh (refresh_type); |
|
|
2777 | flush_ev.stop (); |
2737 | } |
2778 | } |
2738 | } |
2779 | } |
2739 | |
2780 | |
2740 | } |
2781 | } |
2741 | else |
2782 | else |
… | |
… | |
3921 | } |
3962 | } |
3922 | break; |
3963 | break; |
3923 | |
3964 | |
3924 | case URxvt_view_up: |
3965 | case URxvt_view_up: |
3925 | case URxvt_view_down: |
3966 | case URxvt_view_down: |
|
|
3967 | { |
3926 | int lines = atoi (str); |
3968 | int lines = atoi (str); |
3927 | |
3969 | |
3928 | if (lines) |
3970 | if (lines) |
3929 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3971 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3930 | else |
3972 | else |
3931 | { |
|
|
3932 | scr_erase_savelines (); |
3973 | scr_erase_savelines (); |
3933 | } |
3974 | } |
3934 | |
3975 | |
|
|
3976 | break; |
|
|
3977 | #endif |
|
|
3978 | |
|
|
3979 | #if ENABLE_PERL |
|
|
3980 | case URxvt_perl: |
|
|
3981 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
|
|
3982 | ; // no responses yet |
3935 | break; |
3983 | break; |
3936 | #endif |
3984 | #endif |
3937 | } |
3985 | } |
3938 | } |
3986 | } |
3939 | /*----------------------------------------------------------------------*/ |
3987 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4048 | } |
4096 | } |
4049 | |
4097 | |
4050 | /* extra handling for values with state unkept */ |
4098 | /* extra handling for values with state unkept */ |
4051 | switch (arg[i]) |
4099 | switch (arg[i]) |
4052 | { |
4100 | { |
|
|
4101 | #if ENABLE_STYLES |
|
|
4102 | case 1021: |
|
|
4103 | if (mode) |
|
|
4104 | SET_OPTION (Opt_intensityStyles); |
|
|
4105 | else |
|
|
4106 | CLR_OPTION (Opt_intensityStyles); |
|
|
4107 | |
|
|
4108 | scr_touch (true); |
|
|
4109 | break; |
|
|
4110 | #endif |
4053 | case 1048: /* alternative cursor save */ |
4111 | case 1048: /* alternative cursor save */ |
4054 | case 1049: |
4112 | case 1049: |
4055 | if (OPTION (Opt_secondaryScreen)) |
4113 | if (OPTION (Opt_secondaryScreen)) |
4056 | if (mode == 0) |
4114 | if (mode == 0) |
4057 | scr_cursor (RESTORE); |
4115 | scr_cursor (RESTORE); |
… | |
… | |
4140 | if (state) |
4198 | if (state) |
4141 | SET_OPTION (Opt_scrollTtyKeypress); |
4199 | SET_OPTION (Opt_scrollTtyKeypress); |
4142 | else |
4200 | else |
4143 | CLR_OPTION (Opt_scrollTtyKeypress); |
4201 | CLR_OPTION (Opt_scrollTtyKeypress); |
4144 | break; |
4202 | break; |
4145 | #if ENABLE_STYLES |
|
|
4146 | case 1021: |
|
|
4147 | if (state) |
|
|
4148 | SET_OPTION (Opt_intensityStyles); |
|
|
4149 | else |
|
|
4150 | CLR_OPTION (Opt_intensityStyles); |
|
|
4151 | #endif |
|
|
4152 | case 1047: /* secondary screen w/ clearing last */ |
4203 | case 1047: /* secondary screen w/ clearing last */ |
4153 | if (OPTION (Opt_secondaryScreen)) |
4204 | if (OPTION (Opt_secondaryScreen)) |
4154 | if (current_screen != PRIMARY) |
4205 | if (current_screen != PRIMARY) |
4155 | scr_erase_screen (2); |
4206 | scr_erase_screen (2); |
4156 | scr_change_screen (state); |
4207 | scr_change_screen (state); |
… | |
… | |
4315 | case 106: |
4366 | case 106: |
4316 | case 107: |
4367 | case 107: |
4317 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4368 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4318 | break; |
4369 | break; |
4319 | #endif |
4370 | #endif |
4320 | |
|
|
4321 | } |
4371 | } |
4322 | } |
4372 | } |
4323 | } |
4373 | } |
4324 | /*}}} */ |
4374 | /*}}} */ |
4325 | |
4375 | |