… | |
… | |
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" |
52 | |
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
57 | #include <csignal> |
63 | #include <csignal> |
58 | |
|
|
59 | #define HAVE_SCHED_YIELD 1 //D//TODO//FIXME |
|
|
60 | #if HAVE_SCHED_YIELD |
|
|
61 | # include <sched.h> |
|
|
62 | #endif |
|
|
63 | |
64 | |
64 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
65 | |
66 | |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | |
68 | |
… | |
… | |
985 | SET_LOCALE (locale); |
986 | SET_LOCALE (locale); |
986 | |
987 | |
987 | display->flush (); |
988 | display->flush (); |
988 | |
989 | |
989 | if (want_refresh && !flush_ev.active) |
990 | if (want_refresh && !flush_ev.active) |
990 | flush_ev.start (NOW + 0.01); |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
991 | } |
992 | } |
992 | |
993 | |
993 | void |
994 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
995 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
996 | { |
… | |
… | |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1072 | } |
1072 | } |
1073 | } |
1073 | #endif |
1074 | #endif |
1074 | |
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 | |
1075 | bool |
1094 | bool |
1076 | rxvt_term::pty_fill () |
1095 | rxvt_term::pty_fill () |
1077 | { |
1096 | { |
1078 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1079 | |
1098 | |
… | |
… | |
1095 | return true; |
1114 | return true; |
1096 | } |
1115 | } |
1097 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1116 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1098 | { |
1117 | { |
1099 | #if HAVE_SCHED_YIELD |
1118 | #if HAVE_SCHED_YIELD |
1100 | sched_yield (); |
1119 | if (display->is_local) |
|
|
1120 | event_handler.cw_yield.start (); |
1101 | #endif |
1121 | #endif |
1102 | } |
1122 | } |
1103 | else |
1123 | else |
1104 | { |
1124 | { |
1105 | pty_ev.stop (); |
1125 | pty_ev.stop (); |
… | |
… | |
1681 | { |
1701 | { |
1682 | if (!focus) |
1702 | if (!focus) |
1683 | { |
1703 | { |
1684 | focus = 1; |
1704 | focus = 1; |
1685 | want_refresh = 1; |
1705 | want_refresh = 1; |
|
|
1706 | |
|
|
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1708 | |
1686 | #if USE_XIM |
1709 | #if USE_XIM |
1687 | if (Input_Context != NULL) |
1710 | if (Input_Context != NULL) |
1688 | { |
1711 | { |
1689 | IMSetStatusPosition (); |
1712 | IMSetStatusPosition (); |
1690 | XSetICFocus (Input_Context); |
1713 | XSetICFocus (Input_Context); |
… | |
… | |
1710 | if (focus) |
1733 | if (focus) |
1711 | { |
1734 | { |
1712 | focus = 0; |
1735 | focus = 0; |
1713 | want_refresh = 1; |
1736 | want_refresh = 1; |
1714 | |
1737 | |
|
|
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1739 | |
1715 | #if ENABLE_FRILLS || ISO_14755 |
1740 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1741 | if (iso14755buf) |
|
|
1742 | { |
1716 | iso14755buf = 0; |
1743 | iso14755buf = 0; |
1717 | #endif |
|
|
1718 | #if ENABLE_OVERLAY |
1744 | # if ENABLE_OVERLAY |
1719 | scr_overlay_off (); |
1745 | scr_overlay_off (); |
|
|
1746 | # endif |
|
|
1747 | } |
1720 | #endif |
1748 | #endif |
1721 | #if USE_XIM |
1749 | #if USE_XIM |
1722 | if (Input_Context != NULL) |
1750 | if (Input_Context != NULL) |
1723 | XUnsetICFocus (Input_Context); |
1751 | XUnsetICFocus (Input_Context); |
1724 | #endif |
1752 | #endif |
… | |
… | |
1768 | rxvt_term::button_press (XButtonEvent &ev) |
1796 | rxvt_term::button_press (XButtonEvent &ev) |
1769 | { |
1797 | { |
1770 | int reportmode = 0, clickintime; |
1798 | int reportmode = 0, clickintime; |
1771 | |
1799 | |
1772 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1800 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1801 | |
1773 | if (!bypass_keystate) |
1802 | if (!bypass_keystate) |
1774 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1803 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1775 | |
1804 | |
1776 | /* |
1805 | /* |
1777 | * VT window processing of button press |
1806 | * VT window processing of button press |
… | |
… | |
1826 | else |
1855 | else |
1827 | { |
1856 | { |
1828 | if (ev.button != MEvent.button) |
1857 | if (ev.button != MEvent.button) |
1829 | MEvent.clicks = 0; |
1858 | MEvent.clicks = 0; |
1830 | |
1859 | |
|
|
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1831 | switch (ev.button) |
1861 | switch (ev.button) |
1832 | { |
1862 | { |
1833 | case Button1: |
1863 | case Button1: |
1834 | /* allow meta + click to select rectangular areas */ |
1864 | /* allow meta + click to select rectangular areas */ |
1835 | /* should be done in screen.C */ |
1865 | /* should be done in screen.C */ |
1836 | #if ENABLE_FRILLS |
1866 | #if ENABLE_FRILLS |
1837 | selection.rect = !!(ev.state & ModMetaMask); |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1838 | #else |
1868 | #else |
1839 | selection.rect = false; |
1869 | selection.rect = false; |
1840 | #endif |
1870 | #endif |
1841 | |
1871 | |
1842 | /* allow shift+left click to extend selection */ |
1872 | /* allow shift+left click to extend selection */ |
1843 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1844 | { |
1874 | { |
1845 | if (MEvent.button == Button1 && clickintime) |
1875 | if (MEvent.button == Button1 && clickintime) |
1846 | selection_rotate (ev.x, ev.y); |
1876 | selection_rotate (ev.x, ev.y); |
1847 | else |
1877 | else |
1848 | selection_extend (ev.x, ev.y, 1); |
1878 | selection_extend (ev.x, ev.y, 1); |
1849 | } |
1879 | } |
1850 | else |
1880 | else |
1851 | { |
1881 | { |
1852 | if (MEvent.button == Button1 && clickintime) |
1882 | if (MEvent.button == Button1 && clickintime) |
1853 | MEvent.clicks++; |
1883 | MEvent.clicks++; |
1854 | else |
1884 | else |
1855 | MEvent.clicks = 1; |
1885 | MEvent.clicks = 1; |
1856 | |
1886 | |
1857 | selection_click (MEvent.clicks, ev.x, ev.y); |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1858 | } |
1888 | } |
1859 | |
1889 | |
1860 | MEvent.button = Button1; |
1890 | MEvent.button = Button1; |
1861 | break; |
1891 | break; |
1862 | |
1892 | |
1863 | case Button3: |
1893 | case Button3: |
1864 | if (MEvent.button == Button3 && clickintime) |
1894 | if (MEvent.button == Button3 && clickintime) |
1865 | selection_rotate (ev.x, ev.y); |
1895 | selection_rotate (ev.x, ev.y); |
1866 | else |
1896 | else |
1867 | selection_extend (ev.x, ev.y, 1); |
1897 | selection_extend (ev.x, ev.y, 1); |
1868 | |
1898 | |
1869 | MEvent.button = Button3; |
1899 | MEvent.button = Button3; |
1870 | break; |
1900 | break; |
1871 | } |
1901 | } |
1872 | } |
1902 | } |
1873 | |
1903 | |
1874 | MEvent.time = ev.time; |
1904 | MEvent.time = ev.time; |
1875 | return; |
1905 | return; |
1876 | } |
1906 | } |
1877 | |
1907 | |
… | |
… | |
2695 | |
2725 | |
2696 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2697 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2698 | { |
2728 | { |
2699 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2700 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2701 | break; |
2732 | break; |
2702 | } |
2733 | } |
2703 | |
2734 | |
2704 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
… | |
… | |
2741 | refresh_limit++; |
2772 | refresh_limit++; |
2742 | else |
2773 | else |
2743 | { |
2774 | { |
2744 | flag = true; |
2775 | flag = true; |
2745 | scr_refresh (refresh_type); |
2776 | scr_refresh (refresh_type); |
|
|
2777 | flush_ev.stop (); |
2746 | } |
2778 | } |
2747 | } |
2779 | } |
2748 | |
2780 | |
2749 | } |
2781 | } |
2750 | else |
2782 | else |
… | |
… | |
3930 | } |
3962 | } |
3931 | break; |
3963 | break; |
3932 | |
3964 | |
3933 | case URxvt_view_up: |
3965 | case URxvt_view_up: |
3934 | case URxvt_view_down: |
3966 | case URxvt_view_down: |
|
|
3967 | { |
3935 | int lines = atoi (str); |
3968 | int lines = atoi (str); |
3936 | |
3969 | |
3937 | if (lines) |
3970 | if (lines) |
3938 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3971 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3939 | else |
3972 | else |
3940 | { |
|
|
3941 | scr_erase_savelines (); |
3973 | scr_erase_savelines (); |
3942 | } |
3974 | } |
3943 | |
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 |
3944 | break; |
3983 | break; |
3945 | #endif |
3984 | #endif |
3946 | } |
3985 | } |
3947 | } |
3986 | } |
3948 | /*----------------------------------------------------------------------*/ |
3987 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4064 | if (mode) |
4103 | if (mode) |
4065 | SET_OPTION (Opt_intensityStyles); |
4104 | SET_OPTION (Opt_intensityStyles); |
4066 | else |
4105 | else |
4067 | CLR_OPTION (Opt_intensityStyles); |
4106 | CLR_OPTION (Opt_intensityStyles); |
4068 | |
4107 | |
4069 | want_refresh = 1; |
4108 | scr_touch (true); |
4070 | want_full_refresh = 1; |
|
|
4071 | break; |
4109 | break; |
4072 | #endif |
4110 | #endif |
4073 | case 1048: /* alternative cursor save */ |
4111 | case 1048: /* alternative cursor save */ |
4074 | case 1049: |
4112 | case 1049: |
4075 | if (OPTION (Opt_secondaryScreen)) |
4113 | if (OPTION (Opt_secondaryScreen)) |