ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.210 by root, Tue Dec 20 20:58:31 2005 UTC vs.
Revision 1.233 by root, Wed Jan 4 01:16:34 2006 UTC

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
135rxvt_term::iso14755_54 (int x, int y) 141rxvt_term::iso14755_54 (int x, int y)
136{ 142{
137 x = Pixel2Col (x); 143 x = Pixel2Col (x);
138 y = Pixel2Row (y); 144 y = Pixel2Row (y);
139 145
140 if (x < 0 || x >= ncol 146 if (!IN_RANGE_EXC (x, 0, ncol)
141 || y < 0 || y >= nrow) 147 || !IN_RANGE_EXC (y, 0, nrow))
142 return; 148 return;
143 149
144 for (;;) 150 for (;;)
145 { 151 {
146 const line_t &l = save[y + saveLines - view_start]; 152 const line_t &l = ROW(y - view_start);
147 153
148 text_t t = l.t[x]; 154 text_t t = l.t[x];
149 155
150 if (t != NOCHAR || !x) 156 if (t != NOCHAR || !x)
151 { 157 {
152 iso14755_51 (l.t[x], l.r[x]); 158 iso14755_51 (l.t[x], l.r[x], x, y);
153 iso14755buf = ISO_14755_54; 159 iso14755buf = ISO_14755_54;
154 break; 160 break;
155 } 161 }
156 162
157 x--; 163 x--;
158 } 164 }
159
160} 165}
161#endif
162 166
163#if ENABLE_OVERLAY
164void 167void
165rxvt_term::iso14755_51 (unicode_t ch, rend_t r) 168rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y)
166{ 169{
167 rxvt_fontset *fs = FONTSET (r); 170 rxvt_fontset *fs = FONTSET (r);
168 rxvt_font *f = (*fs)[fs->find_font (ch)]; 171 rxvt_font *f = (*fs)[fs->find_font (ch)];
169 wchar_t *chr, *alloc, ch2, *fname; 172 wchar_t *chr, *alloc, ch2, *fname;
170 int len; 173 int len;
171 174
172 fname = rxvt_utf8towcs (f->name); 175 fname = rxvt_utf8towcs (f->name);
173 176
174#if ENABLE_COMBINING 177# if ENABLE_COMBINING
175 if (IS_COMPOSE (ch)) 178 if (IS_COMPOSE (ch))
176 { 179 {
177 len = rxvt_composite.expand (ch, 0); 180 len = rxvt_composite.expand (ch, 0);
178 alloc = chr = new wchar_t[len]; 181 alloc = chr = new wchar_t[len];
179 rxvt_composite.expand (ch, chr); 182 rxvt_composite.expand (ch, chr);
180 } 183 }
181 else 184 else
182#endif 185# endif
183 { 186 {
184 ch2 = ch; 187 ch2 = ch;
185 188
186 alloc = 0; 189 alloc = 0;
187 chr = &ch2; 190 chr = &ch2;
188 len = 1; 191 len = 1;
189 } 192 }
190 193
194 char attr[80]; // plenty
195
196 sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s",
197 (int)r,
198 fgcolor_of (r), bgcolor_of (r),
199 r & RS_Bold ? " bold" : "",
200 r & RS_Italic ? " italic" : "",
201 r & RS_Blink ? " blink" : "",
202 r & RS_RVid ? " rvid" : "",
203 r & RS_Uline ? " uline" : "",
204 r & RS_Careful ? " careful" : "");
205
191 int width = wcswidth (fname, wcslen (fname)); 206 int width = wcswidth (fname, wcslen (fname));
192 207
193 scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); 208 max_it (width, 8+5); // for char + hey
209 max_it (width, strlen (attr));
210
211 if (y >= 0)
212 {
213 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1;
214 x = 0;
215 }
216
217 scr_overlay_new (x, y, width, len + 2);
194 218
195 r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); 219 r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r));
196 220
197 for (int y = 0; y < len; y++) 221 for (int y = 0; y < len; y++)
198 { 222 {
201 ch = *chr++; 225 ch = *chr++;
202 226
203 sprintf (buf, "%8x", ch); 227 sprintf (buf, "%8x", ch);
204 scr_overlay_set (0, y, buf); 228 scr_overlay_set (0, y, buf);
205 scr_overlay_set (9, y, '='); 229 scr_overlay_set (9, y, '=');
206#if !UNICODE3 230# if !UNICODE3
207 if (ch >= 0x10000) 231 if (ch >= 0x10000)
208 ch = 0xfffd; 232 ch = 0xfffd;
209#endif 233# endif
210 scr_overlay_set (11, y, ch, r); 234 scr_overlay_set (11, y, ch, r);
211 scr_overlay_set (12, y, NOCHAR, r); 235 scr_overlay_set (12, y, NOCHAR, r);
212 } 236 }
213 237
238 scr_overlay_set (0, len , attr);
214 scr_overlay_set (0, len, fname); 239 scr_overlay_set (0, len + 1, fname);
215 240
216 free (fname); 241 free (fname);
217 242
218#if ENABLE_COMBINING 243# if ENABLE_COMBINING
219 if (alloc) 244 if (alloc)
220 delete [] alloc; 245 delete [] alloc;
221#endif 246# endif
222} 247}
223#endif 248#endif
224 249
225void 250void
226rxvt_term::commit_iso14755 () 251rxvt_term::commit_iso14755 ()
845 } 870 }
846 871
847 if (len <= 0) 872 if (len <= 0)
848 return; /* not mapped */ 873 return; /* not mapped */
849 874
850 if (options & Opt_scrollTtyKeypress) 875 if (OPTION (Opt_scrollTtyKeypress))
851 if (view_start) 876 if (view_start)
852 { 877 {
853 view_start = 0; 878 view_start = 0;
854 want_refresh = 1; 879 want_refresh = 1;
855 } 880 }
961 SET_LOCALE (locale); 986 SET_LOCALE (locale);
962 987
963 display->flush (); 988 display->flush ();
964 989
965 if (want_refresh && !flush_ev.active) 990 if (want_refresh && !flush_ev.active)
966 flush_ev.start (NOW + 0.01); 991 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
967} 992}
968 993
969void 994void
970rxvt_term::flush_cb (time_watcher &w) 995rxvt_term::flush_cb (time_watcher &w)
971{ 996{
1046 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1071 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1047 } 1072 }
1048} 1073}
1049#endif 1074#endif
1050 1075
1076#if HAVE_SCHED_YIELD
1077static 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
1051bool 1094bool
1052rxvt_term::pty_fill () 1095rxvt_term::pty_fill ()
1053{ 1096{
1054 ssize_t n = cmdbuf_endp - cmdbuf_ptr; 1097 ssize_t n = cmdbuf_endp - cmdbuf_ptr;
1055 1098
1056 if (CBUFSIZ == n) 1099 if (CBUFSIZ == n)
1057 { 1100 {
1058 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");
1059 n = 0; 1102 n = 0;
1060 } 1103 }
1061 1104
1062 memmove (cmdbuf_base, cmdbuf_ptr, n); 1105 memmove (cmdbuf_base, cmdbuf_ptr, n);
1063 cmdbuf_ptr = cmdbuf_base; 1106 cmdbuf_ptr = cmdbuf_base;
1064 cmdbuf_endp = cmdbuf_ptr + n; 1107 cmdbuf_endp = cmdbuf_ptr + n;
1065 1108
1066 n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); 1109 ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n);
1067 1110
1068 if (n > 0) 1111 if (r > 0)
1069 { 1112 {
1070 cmdbuf_endp += n; 1113 cmdbuf_endp += r;
1071 return true; 1114 return true;
1072 } 1115 }
1073 else if (n < 0 && errno != EAGAIN) 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
1124 {
1125 pty_ev.stop ();
1126
1127 if (!OPTION (Opt_hold))
1074 destroy (); 1128 destroy ();
1129 }
1075 1130
1076 return false; 1131 return false;
1077} 1132}
1078 1133
1079void 1134void
1099 recolour_cursor (); 1154 recolour_cursor ();
1100 1155
1101#ifdef POINTER_BLANK 1156#ifdef POINTER_BLANK
1102 hidden_pointer = 0; 1157 hidden_pointer = 0;
1103 1158
1104 if (options & Opt_pointerBlank) 1159 if (OPTION (Opt_pointerBlank))
1105 pointer_ev.start (NOW + pointerBlankDelay); 1160 pointer_ev.start (NOW + pointerBlankDelay);
1106#endif 1161#endif
1107} 1162}
1108 1163
1109#ifdef POINTER_BLANK 1164#ifdef POINTER_BLANK
1110void 1165void
1111rxvt_term::pointer_blank () 1166rxvt_term::pointer_blank ()
1112{ 1167{
1113 if (! (options & Opt_pointerBlank)) 1168 if (! OPTION (Opt_pointerBlank))
1114 return; 1169 return;
1115 1170
1116 XDefineCursor (display->display, vt, display->blank_cursor); 1171 XDefineCursor (display->display, vt, display->blank_cursor);
1117 XFlush (display->display); 1172 XFlush (display->display);
1118 1173
1216 1271
1217 SET_R (this); 1272 SET_R (this);
1218 SET_LOCALE (locale); 1273 SET_LOCALE (locale);
1219 1274
1220#if defined(CURSOR_BLINK) 1275#if defined(CURSOR_BLINK)
1221 if ((options & Opt_cursorBlink) && ev.type == KeyPress) 1276 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1222 { 1277 {
1223 if (hidden_cursor) 1278 if (hidden_cursor)
1224 { 1279 {
1225 hidden_cursor = 0; 1280 hidden_cursor = 0;
1226 want_refresh = 1; 1281 want_refresh = 1;
1229 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1284 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1230 } 1285 }
1231#endif 1286#endif
1232 1287
1233#if defined(POINTER_BLANK) 1288#if defined(POINTER_BLANK)
1234 if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) 1289 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1235 { 1290 {
1236 if (ev.type == MotionNotify 1291 if (ev.type == MotionNotify
1237 || ev.type == ButtonPress 1292 || ev.type == ButtonPress
1238 || ev.type == ButtonRelease) 1293 || ev.type == ButtonRelease)
1239 if (hidden_pointer) 1294 if (hidden_pointer)
1435 seen_resize = 1; 1490 seen_resize = 1;
1436 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1491 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1437 } 1492 }
1438 1493
1439#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1494#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1440 if (options & Opt_transparent) 1495 if (OPTION (Opt_transparent))
1441 check_our_parents (); 1496 check_our_parents ();
1442#endif 1497#endif
1443 } 1498 }
1444 break; 1499 break;
1445 1500
1601 } 1656 }
1602 1657
1603 scroll_selection_lines = Pixel2Height (dist) 1658 scroll_selection_lines = Pixel2Height (dist)
1604 / SELECTION_SCROLL_LINE_SPEEDUP 1659 / SELECTION_SCROLL_LINE_SPEEDUP
1605 + 1; 1660 + 1;
1606 MIN_IT (scroll_selection_lines, 1661 min_it (scroll_selection_lines,
1607 SELECTION_SCROLL_MAX_LINES); 1662 SELECTION_SCROLL_MAX_LINES);
1608 } 1663 }
1609 else 1664 else
1610 { 1665 {
1611 /* we are within the text window, so we 1666 /* we are within the text window, so we
1646{ 1701{
1647 if (!focus) 1702 if (!focus)
1648 { 1703 {
1649 focus = 1; 1704 focus = 1;
1650 want_refresh = 1; 1705 want_refresh = 1;
1706
1707 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1708
1651#if USE_XIM 1709#if USE_XIM
1652 if (Input_Context != NULL) 1710 if (Input_Context != NULL)
1653 { 1711 {
1654 IMSetStatusPosition (); 1712 IMSetStatusPosition ();
1655 XSetICFocus (Input_Context); 1713 XSetICFocus (Input_Context);
1656 } 1714 }
1657#endif 1715#endif
1658#if CURSOR_BLINK 1716#if CURSOR_BLINK
1659 if (options & Opt_cursorBlink) 1717 if (OPTION (Opt_cursorBlink))
1660 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1718 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1661#endif 1719#endif
1662#if OFF_FOCUS_FADING 1720#if OFF_FOCUS_FADING
1663 if (rs[Rs_fade]) 1721 if (rs[Rs_fade])
1664 { 1722 {
1675 if (focus) 1733 if (focus)
1676 { 1734 {
1677 focus = 0; 1735 focus = 0;
1678 want_refresh = 1; 1736 want_refresh = 1;
1679 1737
1738 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1739
1680#if ENABLE_FRILLS || ISO_14755 1740#if ENABLE_FRILLS || ISO_14755
1741 if (iso14755buf)
1742 {
1681 iso14755buf = 0; 1743 iso14755buf = 0;
1682#endif
1683#if ENABLE_OVERLAY 1744# if ENABLE_OVERLAY
1684 scr_overlay_off (); 1745 scr_overlay_off ();
1746# endif
1747 }
1685#endif 1748#endif
1686#if USE_XIM 1749#if USE_XIM
1687 if (Input_Context != NULL) 1750 if (Input_Context != NULL)
1688 XUnsetICFocus (Input_Context); 1751 XUnsetICFocus (Input_Context);
1689#endif 1752#endif
1690#if CURSOR_BLINK 1753#if CURSOR_BLINK
1691 if (options & Opt_cursorBlink) 1754 if (OPTION (Opt_cursorBlink))
1692 cursor_blink_ev.stop (); 1755 cursor_blink_ev.stop ();
1693 hidden_cursor = 0; 1756 hidden_cursor = 0;
1694#endif 1757#endif
1695#if OFF_FOCUS_FADING 1758#if OFF_FOCUS_FADING
1696 if (rs[Rs_fade]) 1759 if (rs[Rs_fade])
1720 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1783 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID])
1721 return; 1784 return;
1722 1785
1723 /* FALLTHROUGH */ 1786 /* FALLTHROUGH */
1724 case ReparentNotify: 1787 case ReparentNotify:
1725 if ((options & Opt_transparent) && check_our_parents () && am_transparent) 1788 if (OPTION (Opt_transparent) && check_our_parents () && am_transparent)
1726 want_refresh = want_full_refresh = 1; 1789 want_refresh = want_full_refresh = 1;
1727 break; 1790 break;
1728 } 1791 }
1729} 1792}
1730#endif 1793#endif
1733rxvt_term::button_press (XButtonEvent &ev) 1796rxvt_term::button_press (XButtonEvent &ev)
1734{ 1797{
1735 int reportmode = 0, clickintime; 1798 int reportmode = 0, clickintime;
1736 1799
1737 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1800 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1801
1738 if (!bypass_keystate) 1802 if (!bypass_keystate)
1739 reportmode = !! (priv_modes & PrivMode_mouse_report); 1803 reportmode = !! (priv_modes & PrivMode_mouse_report);
1740 1804
1741 /* 1805 /*
1742 * VT window processing of button press 1806 * VT window processing of button press
1791 else 1855 else
1792 { 1856 {
1793 if (ev.button != MEvent.button) 1857 if (ev.button != MEvent.button)
1794 MEvent.clicks = 0; 1858 MEvent.clicks = 0;
1795 1859
1860 if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END)))
1796 switch (ev.button) 1861 switch (ev.button)
1797 { 1862 {
1798 case Button1: 1863 case Button1:
1799 /* allow meta + click to select rectangular areas */ 1864 /* allow meta + click to select rectangular areas */
1800 /* should be done in screen.C */ 1865 /* should be done in screen.C */
1801#if ENABLE_FRILLS 1866#if ENABLE_FRILLS
1802 selection.rect = !!(ev.state & ModMetaMask); 1867 selection.rect = !!(ev.state & ModMetaMask);
1803#else 1868#else
1804 selection.rect = false; 1869 selection.rect = false;
1805#endif 1870#endif
1806 1871
1807 /* allow shift+left click to extend selection */ 1872 /* allow shift+left click to extend selection */
1808 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1873 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report))
1809 { 1874 {
1810 if (MEvent.button == Button1 && clickintime) 1875 if (MEvent.button == Button1 && clickintime)
1811 selection_rotate (ev.x, ev.y); 1876 selection_rotate (ev.x, ev.y);
1812 else 1877 else
1813 selection_extend (ev.x, ev.y, 1); 1878 selection_extend (ev.x, ev.y, 1);
1814 } 1879 }
1815 else 1880 else
1816 { 1881 {
1817 if (MEvent.button == Button1 && clickintime) 1882 if (MEvent.button == Button1 && clickintime)
1818 MEvent.clicks++; 1883 MEvent.clicks++;
1819 else 1884 else
1820 MEvent.clicks = 1; 1885 MEvent.clicks = 1;
1821 1886
1822 selection_click (MEvent.clicks, ev.x, ev.y); 1887 selection_click (MEvent.clicks, ev.x, ev.y);
1823 } 1888 }
1824 1889
1825 MEvent.button = Button1; 1890 MEvent.button = Button1;
1826 break; 1891 break;
1827 1892
1828 case Button3: 1893 case Button3:
1829 if (MEvent.button == Button3 && clickintime) 1894 if (MEvent.button == Button3 && clickintime)
1830 selection_rotate (ev.x, ev.y); 1895 selection_rotate (ev.x, ev.y);
1831 else 1896 else
1832 selection_extend (ev.x, ev.y, 1); 1897 selection_extend (ev.x, ev.y, 1);
1833 1898
1834 MEvent.button = Button3; 1899 MEvent.button = Button3;
1835 break; 1900 break;
1836 } 1901 }
1837 } 1902 }
1838 1903
1839 MEvent.time = ev.time; 1904 MEvent.time = ev.time;
1840 return; 1905 return;
1841 } 1906 }
1842 1907
2072 2137
2073 v = ev.button == Button4 ? UP : DN; 2138 v = ev.button == Button4 ? UP : DN;
2074 2139
2075 if (ev.state & ShiftMask) 2140 if (ev.state & ShiftMask)
2076 i = 1; 2141 i = 1;
2077 else if (options & Opt_mouseWheelScrollPage) 2142 else if (OPTION (Opt_mouseWheelScrollPage))
2078 i = nrow - 1; 2143 i = nrow - 1;
2079 else 2144 else
2080 i = 5; 2145 i = 5;
2081 2146
2082# ifdef MOUSE_SLIP_WHEELING 2147# ifdef MOUSE_SLIP_WHEELING
2368 XWindowAttributes wattr, wrootattr; 2433 XWindowAttributes wattr, wrootattr;
2369 dDisp; 2434 dDisp;
2370 2435
2371 pchanged = 0; 2436 pchanged = 0;
2372 2437
2373 if (!(options & Opt_transparent)) 2438 if (!OPTION (Opt_transparent))
2374 return pchanged; /* Don't try any more */ 2439 return pchanged; /* Don't try any more */
2375 2440
2376 XGetWindowAttributes (disp, display->root, &wrootattr); 2441 XGetWindowAttributes (disp, display->root, &wrootattr);
2377 rootdepth = wrootattr.depth; 2442 rootdepth = wrootattr.depth;
2378 2443
2452 nh += sy; 2517 nh += sy;
2453 ny = -sy; 2518 ny = -sy;
2454 sy = 0; 2519 sy = 0;
2455 } 2520 }
2456 2521
2457 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2522 min_it (nw, (unsigned int) (wrootattr.width - sx));
2458 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2523 min_it (nh, (unsigned int) (wrootattr.height - sy));
2459 2524
2460 XSync (disp, False); 2525 XSync (disp, False);
2461 allowedxerror = -1; 2526 allowedxerror = -1;
2462 image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2527 image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2463 2528
2656 if (ch == C0_LF) 2721 if (ch == C0_LF)
2657 nlines++; 2722 nlines++;
2658 2723
2659 refresh_count++; 2724 refresh_count++;
2660 2725
2661 if (!(options & Opt_jumpScroll) 2726 if (!OPTION (Opt_jumpScroll)
2662 || (refresh_count >= refresh_limit * (nrow - 1))) 2727 || (refresh_count >= refresh_limit * (nrow - 1)))
2663 { 2728 {
2664 refreshnow = true; 2729 refreshnow = true;
2730 refresh_count = 0;
2665 ch = NOCHAR; 2731 ch = NOCHAR;
2666 break; 2732 break;
2667 } 2733 }
2668 2734
2669 // scr_add_lines only works for nlines <= nrow - 1. 2735 // scr_add_lines only works for nlines <= nrow - 1.
2700 * the number of pages between refreshes is refresh_limit, which 2766 * the number of pages between refreshes is refresh_limit, which
2701 * is incremented here because we must be doing flat-out scrolling. 2767 * is incremented here because we must be doing flat-out scrolling.
2702 */ 2768 */
2703 if (refreshnow) 2769 if (refreshnow)
2704 { 2770 {
2705 if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2771 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2706 refresh_limit++; 2772 refresh_limit++;
2707 else 2773 else
2708 { 2774 {
2709 flag = true; 2775 flag = true;
2710 scr_refresh (refresh_type); 2776 scr_refresh (refresh_type);
2777 flush_ev.stop ();
2711 } 2778 }
2712 } 2779 }
2713 2780
2714 } 2781 }
2715 else 2782 else
3374 break; 3441 break;
3375 case 6: /* CPR requested */ 3442 case 6: /* CPR requested */
3376 scr_report_position (); 3443 scr_report_position ();
3377 break; 3444 break;
3378 case 7: /* unofficial extension */ 3445 case 7: /* unofficial extension */
3379 if (options & Opt_insecure) 3446 if (OPTION (Opt_insecure))
3380 tt_printf ("%-.250s\012", rs[Rs_display_name]); 3447 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3381 break; 3448 break;
3382 case 8: /* unofficial extension */ 3449 case 8: /* unofficial extension */
3383 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 3450 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
3384 break; 3451 break;
3548 break; 3615 break;
3549 case 20: /* report icon label */ 3616 case 20: /* report icon label */
3550 { 3617 {
3551 char *s; 3618 char *s;
3552 XGetIconName (disp, parent[0], &s); 3619 XGetIconName (disp, parent[0], &s);
3553 tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ 3620 tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */
3554 XFree (s); 3621 XFree (s);
3555 } 3622 }
3556 break; 3623 break;
3557 case 21: /* report window title */ 3624 case 21: /* report window title */
3558 { 3625 {
3559 char *s; 3626 char *s;
3560 XFetchName (disp, parent[0], &s); 3627 XFetchName (disp, parent[0], &s);
3561 tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ 3628 tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */
3562 XFree (s); 3629 XFree (s);
3563 } 3630 }
3564 break; 3631 break;
3565 } 3632 }
3566} 3633}
3842 // TODO, when secure mode? 3909 // TODO, when secure mode?
3843 break; 3910 break;
3844 3911
3845#ifdef MENUBAR 3912#ifdef MENUBAR
3846 case URxvt_Menu: 3913 case URxvt_Menu:
3847 if (options & Opt_insecure) 3914 if (OPTION (Opt_insecure))
3848 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked 3915 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3849 break; 3916 break;
3850#endif 3917#endif
3851#if 0 3918#if 0
3852 case XTerm_dumpscreen: /* no error notices */ 3919 case XTerm_dumpscreen: /* no error notices */
3868 case URxvt_italicFont: 3935 case URxvt_italicFont:
3869 case URxvt_boldItalicFont: 3936 case URxvt_boldItalicFont:
3870#endif 3937#endif
3871 if (query) 3938 if (query)
3872 tt_printf ("\33]%d;%-.250s%c", saveop, 3939 tt_printf ("\33]%d;%-.250s%c", saveop,
3873 (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc 3940 OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc
3874 ? fontset[op - URxvt_font]->fontdesc : "", 3941 ? fontset[op - URxvt_font]->fontdesc : "",
3875 resp); 3942 resp);
3876 else 3943 else
3877 { 3944 {
3878 const char *&res = rs[Rs_font + (op - URxvt_font)]; 3945 const char *&res = rs[Rs_font + (op - URxvt_font)];
3884 break; 3951 break;
3885 3952
3886#if ENABLE_FRILLS 3953#if ENABLE_FRILLS
3887 case URxvt_locale: 3954 case URxvt_locale:
3888 if (query) 3955 if (query)
3889 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); 3956 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp);
3890 else 3957 else
3891 { 3958 {
3892 set_locale (str); 3959 set_locale (str);
3893 pty.set_utf8_mode (enc_utf8); 3960 pty.set_utf8_mode (enc_utf8);
3894 init_xlocale (); 3961 init_xlocale ();
3895 } 3962 }
3896 break; 3963 break;
3897 3964
3898 case URxvt_view_up: 3965 case URxvt_view_up:
3899 case URxvt_view_down: 3966 case URxvt_view_down:
3967 {
3900 int lines = atoi (str); 3968 int lines = atoi (str);
3901 3969
3902 if (lines) 3970 if (lines)
3903 scr_page (op == URxvt_view_up ? UP : DN, lines); 3971 scr_page (op == URxvt_view_up ? UP : DN, lines);
3904 else 3972 else
3905 {
3906 scr_erase_savelines (); 3973 scr_erase_savelines ();
3907 } 3974 }
3908 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
3909 break; 3983 break;
3910#endif 3984#endif
3911 } 3985 }
3912} 3986}
3913/*----------------------------------------------------------------------*/ 3987/*----------------------------------------------------------------------*/
4022 } 4096 }
4023 4097
4024 /* extra handling for values with state unkept */ 4098 /* extra handling for values with state unkept */
4025 switch (arg[i]) 4099 switch (arg[i])
4026 { 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
4027 case 1048: /* alternative cursor save */ 4111 case 1048: /* alternative cursor save */
4028 case 1049: 4112 case 1049:
4029 if (options & Opt_secondaryScreen) 4113 if (OPTION (Opt_secondaryScreen))
4030 if (mode == 0) 4114 if (mode == 0)
4031 scr_cursor (RESTORE); 4115 scr_cursor (RESTORE);
4032 else if (mode == 1) 4116 else if (mode == 1)
4033 scr_cursor (SAVE); 4117 scr_cursor (SAVE);
4034 break; 4118 break;
4049 case 3: /* 80/132 */ 4133 case 3: /* 80/132 */
4050 if (priv_modes & PrivMode_132OK) 4134 if (priv_modes & PrivMode_132OK)
4051 set_widthheight (((state ? 132 : 80) * fwidth), height); 4135 set_widthheight (((state ? 132 : 80) * fwidth), height);
4052 break; 4136 break;
4053 case 4: /* smooth scrolling */ 4137 case 4: /* smooth scrolling */
4054 if (state) 4138 if (!state)
4055 options &= ~Opt_jumpScroll; 4139 SET_OPTION (Opt_jumpScroll);
4056 else 4140 else
4057 options |= Opt_jumpScroll; 4141 CLR_OPTION (Opt_jumpScroll);
4058 break; 4142 break;
4059 case 5: /* reverse video */ 4143 case 5: /* reverse video */
4060 scr_rvideo_mode (state); 4144 scr_rvideo_mode (state);
4061 break; 4145 break;
4062 case 6: /* relative/absolute origins */ 4146 case 6: /* relative/absolute origins */
4103#if 0 4187#if 0
4104 case 1001: 4188 case 1001:
4105 break; /* X11 mouse highlighting */ 4189 break; /* X11 mouse highlighting */
4106#endif 4190#endif
4107 case 1010: /* scroll to bottom on TTY output inhibit */ 4191 case 1010: /* scroll to bottom on TTY output inhibit */
4108 if (state) 4192 if (!state)
4109 options &= ~Opt_scrollTtyOutput; 4193 SET_OPTION (Opt_scrollTtyOutput);
4110 else 4194 else
4111 options |= Opt_scrollTtyOutput; 4195 CLR_OPTION (Opt_scrollTtyOutput);
4112 break; 4196 break;
4113 case 1011: /* scroll to bottom on key press */ 4197 case 1011: /* scroll to bottom on key press */
4114 if (state) 4198 if (state)
4115 options |= Opt_scrollTtyKeypress; 4199 SET_OPTION (Opt_scrollTtyKeypress);
4116 else 4200 else
4117 options &= ~Opt_scrollTtyKeypress; 4201 CLR_OPTION (Opt_scrollTtyKeypress);
4118 break; 4202 break;
4119 case 1047: /* secondary screen w/ clearing last */ 4203 case 1047: /* secondary screen w/ clearing last */
4120 if (options & Opt_secondaryScreen) 4204 if (OPTION (Opt_secondaryScreen))
4121 if (current_screen != PRIMARY) 4205 if (current_screen != PRIMARY)
4122 scr_erase_screen (2); 4206 scr_erase_screen (2);
4123 scr_change_screen (state); 4207 scr_change_screen (state);
4124 break; 4208 break;
4125 case 1049: /* secondary screen w/ clearing first */ 4209 case 1049: /* secondary screen w/ clearing first */
4126 scr_change_screen (state); 4210 scr_change_screen (state);
4127 if (options & Opt_secondaryScreen) 4211 if (OPTION (Opt_secondaryScreen))
4128 if (current_screen != PRIMARY) 4212 if (current_screen != PRIMARY)
4129 scr_erase_screen (2); 4213 scr_erase_screen (2);
4130 break; 4214 break;
4131 default: 4215 default:
4132 break; 4216 break;
4282 case 106: 4366 case 106:
4283 case 107: 4367 case 107:
4284 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); 4368 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg);
4285 break; 4369 break;
4286#endif 4370#endif
4287
4288 } 4371 }
4289 } 4372 }
4290} 4373}
4291/*}}} */ 4374/*}}} */
4292 4375
4373 } 4456 }
4374 4457
4375 memmove (v_buffer, v_buffer + written, v_buflen); 4458 memmove (v_buffer, v_buffer + written, v_buflen);
4376 } 4459 }
4377 else if (written != -1 || (errno != EAGAIN && errno != EINTR)) 4460 else if (written != -1 || (errno != EAGAIN && errno != EINTR))
4378 // original code just ignores this... 4461 pty_ev.set (EVENT_READ);
4379 destroy ();
4380} 4462}
4381 4463
4382/*----------------------- end-of-file (C source) -----------------------*/ 4464/*----------------------- end-of-file (C source) -----------------------*/
4383 4465

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines