1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.c |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: command.C,v 1.19 2003/12/18 05:45:11 pcg Exp $ |
|
|
5 | * |
4 | * |
6 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
7 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
8 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
10 | * - extensive modifications |
9 | * - extensive modifications |
11 | * Copyright (c) 1995 Garrett D'Amore <garrett@netcom.com> |
10 | * Copyright (c) 1995 Garrett D'Amore <garrett@netcom.com> |
12 | * - vt100 printing |
11 | * - vt100 printing |
13 | * Copyright (c) 1995 Steven Hirsch <hirsch@emba.uvm.edu> |
12 | * Copyright (c) 1995 Steven Hirsch <hirsch@emba.uvm.edu> |
14 | * - X11 mouse report mode and support for |
13 | * - X11 mouse report mode and support for |
15 | * DEC "private mode" save/restore functions. |
14 | * DEC "private mode" save/restore functions. |
… | |
… | |
21 | * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es> |
20 | * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es> |
22 | * - modification and cleanups for Solaris 2.x |
21 | * - modification and cleanups for Solaris 2.x |
23 | * and Linux 1.2.x |
22 | * and Linux 1.2.x |
24 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
23 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
25 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
24 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
26 | * - extensive modifications |
25 | * - extensive modifications |
27 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
28 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
29 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
30 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
|
|
30 | * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de> |
|
|
31 | * Copyright (c) 2007,2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
31 | * |
32 | * |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
34 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * the Free Software Foundation; either version 3 of the License, or |
35 | * (at your option) any later version. |
36 | * (at your option) any later version. |
36 | * |
37 | * |
37 | * This program is distributed in the hope that it will be useful, |
38 | * This program is distributed in the hope that it will be useful, |
38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
39 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
40 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
43 | * along with this program; if not, write to the Free Software |
44 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
46 | *----------------------------------------------------------------------*/ |
46 | |
47 | |
47 | /*{{{ includes: */ |
48 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "rxvt.h" |
|
|
51 | #include "rxvtperl.h" |
50 | #include "version.h" |
52 | #include "version.h" |
51 | #include "command.h" |
53 | #include "command.h" |
52 | |
54 | |
|
|
55 | #ifdef KEYSYM_RESOURCE |
|
|
56 | # include "keyboard.h" |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #include <signal.h> |
|
|
60 | |
|
|
61 | #if LINUX_YIELD_HACK |
|
|
62 | # include <time.h> |
|
|
63 | #endif |
|
|
64 | |
53 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
54 | |
66 | |
55 | /*{{{ Convert the keypress event into a string */ |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
56 | /* INTPROTO */ |
68 | |
57 | void |
69 | #if ENABLE_FRILLS || ISO_14755 |
58 | rxvt_lookup_key(pR_ XKeyEvent *ev) |
70 | |
|
|
71 | #define ISO_14755_STARTED 0x80000000UL |
|
|
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
|
|
73 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
|
|
74 | #define ISO_14755_54 0x10000000UL // code feedback (section 5.4) |
|
|
75 | #define ISO_14755_MASK 0x0fffffffUL |
|
|
76 | |
|
|
77 | #if ISO_14755 |
|
|
78 | static unsigned short iso14755_symtab[] = { |
|
|
79 | // keysym, unicode |
|
|
80 | XK_Left, 0x2190, |
|
|
81 | XK_KP_Left, 0x2190, |
|
|
82 | XK_Up, 0x2191, |
|
|
83 | XK_KP_Up, 0x2191, |
|
|
84 | XK_Right, 0x2192, |
|
|
85 | XK_KP_Right, 0x2192, |
|
|
86 | XK_Down, 0x2193, |
|
|
87 | XK_KP_Down, 0x2193, |
|
|
88 | XK_Linefeed, 0x21b4, |
|
|
89 | XK_Return, 0x21b5, |
|
|
90 | XK_KP_Enter, 0x21b5, |
|
|
91 | |
|
|
92 | XK_Prior, 0x21de, |
|
|
93 | XK_Next, 0x21df, |
|
|
94 | XK_Tab, 0x21e5, |
|
|
95 | XK_ISO_Left_Tab, 0x21e6, |
|
|
96 | XK_Shift_L, 0x21e7, |
|
|
97 | XK_Shift_R, 0x21e7, |
|
|
98 | |
|
|
99 | XK_Shift_Lock, 0x21eb, |
|
|
100 | XK_ISO_Lock, 0x21eb, |
|
|
101 | XK_Caps_Lock, 0x21ec, |
|
|
102 | XK_Num_Lock, 0x21ed, |
|
|
103 | XK_ISO_Level3_Shift, 0x21ee, |
|
|
104 | XK_ISO_Level3_Lock, 0x21ef, |
|
|
105 | XK_ISO_Group_Lock, 0x21f0, |
|
|
106 | XK_Home, 0x21f1, |
|
|
107 | XK_End, 0x21f2, |
|
|
108 | |
|
|
109 | XK_Execute, 0x2318, |
|
|
110 | XK_Begin, 0x2320, |
|
|
111 | XK_Delete, 0x2326, |
|
|
112 | XK_Clear, 0x2327, |
|
|
113 | XK_BackSpace, 0x232b, |
|
|
114 | XK_Insert, 0x2380, |
|
|
115 | XK_Control_L, 0x2388, |
|
|
116 | XK_Control_R, 0x2388, |
|
|
117 | XK_Pause, 0x2389, |
|
|
118 | XK_Break, 0x238a, |
|
|
119 | XK_Escape, 0x238b, |
|
|
120 | XK_Undo, 0x238c, |
|
|
121 | XK_Print, 0x2399, |
|
|
122 | |
|
|
123 | XK_space, 0x2423, |
|
|
124 | |
|
|
125 | #ifdef XK_KP_Begin |
|
|
126 | XK_KP_Prior, 0x21de, |
|
|
127 | XK_KP_Next, 0x21df, |
|
|
128 | XK_KP_Begin, 0x2320, |
|
|
129 | XK_KP_Insert, 0x2380, |
|
|
130 | XK_KP_Delete, 0x2326, |
|
|
131 | XK_KP_Space, 0x2422, |
|
|
132 | #endif |
|
|
133 | 0, |
|
|
134 | }; |
|
|
135 | |
|
|
136 | void ecb_cold |
|
|
137 | rxvt_term::iso14755_54 (int x, int y) |
59 | { |
138 | { |
60 | int ctrl, meta, shft, len; |
139 | x = Pixel2Col (x); |
61 | unsigned int newlen; |
140 | y = Pixel2Row (y); |
62 | KeySym keysym; |
141 | |
63 | #ifdef DEBUG_CMD |
142 | if (!IN_RANGE_EXC (x, 0, ncol) |
64 | static int debug_key = 1; /* accessible by a debugger only */ |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
|
|
144 | return; |
|
|
145 | |
|
|
146 | for (;;) |
|
|
147 | { |
|
|
148 | const line_t &l = ROW(y + view_start); |
|
|
149 | |
|
|
150 | text_t t = l.t[x]; |
|
|
151 | |
|
|
152 | if (t != NOCHAR || !x) |
|
|
153 | { |
|
|
154 | iso14755_51 (l.t[x], l.r[x], x, y, view_start); |
|
|
155 | iso14755buf = ISO_14755_54; |
|
|
156 | break; |
|
|
157 | } |
|
|
158 | |
|
|
159 | x--; |
|
|
160 | } |
|
|
161 | } |
|
|
162 | |
|
|
163 | void ecb_cold |
|
|
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y, int y2) |
|
|
165 | { |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
|
|
167 | wchar_t *chr, *alloc, ch2, **fname; |
|
|
168 | int len; |
|
|
169 | |
|
|
170 | # if ENABLE_COMBINING |
|
|
171 | if (IS_COMPOSE (ch)) |
|
|
172 | { |
|
|
173 | len = rxvt_composite.expand (ch, 0); |
|
|
174 | alloc = chr = new wchar_t[len]; |
|
|
175 | rxvt_composite.expand (ch, chr); |
|
|
176 | } |
|
|
177 | else |
65 | #endif |
178 | # endif |
66 | int valid_keysym; |
179 | { |
67 | unsigned char *kbuf = R->kbuf; |
180 | ch2 = ch; |
68 | |
181 | |
69 | /* |
182 | alloc = 0; |
70 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
183 | chr = &ch2; |
71 | * escape sequence to toggle the Keypad. |
184 | len = 1; |
72 | * |
185 | } |
73 | * Always permit `shift' to override the current setting |
|
|
74 | */ |
|
|
75 | shft = (ev->state & ShiftMask); |
|
|
76 | ctrl = (ev->state & ControlMask); |
|
|
77 | meta = (ev->state & R->ModMetaMask); |
|
|
78 | |
186 | |
79 | if (R->numlock_state || (ev->state & R->ModNumLockMask)) |
187 | char rowcol[40]; |
|
|
188 | snprintf (rowcol, sizeof rowcol, "col %d row %d @%d", x, y, y2); |
|
|
189 | |
|
|
190 | char attr[80]; // plenty |
|
|
191 | |
|
|
192 | sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", |
|
|
193 | (int)r, |
|
|
194 | fgcolor_of (r), bgcolor_of (r), |
|
|
195 | r & RS_Bold ? " bold" : "", |
|
|
196 | r & RS_Italic ? " italic" : "", |
|
|
197 | r & RS_Blink ? " blink" : "", |
|
|
198 | r & RS_RVid ? " rvid" : "", |
|
|
199 | r & RS_Uline ? " uline" : "", |
|
|
200 | r & RS_Careful ? " careful" : ""); |
|
|
201 | |
|
|
202 | int width = 0; |
|
|
203 | fname = rxvt_temp_buf<wchar_t *> (len); |
|
|
204 | for (int i = 0; i < len; i++) |
|
|
205 | { |
|
|
206 | rxvt_font *f = (*fs)[fs->find_font_idx (chr[i])]; |
|
|
207 | fname[i] = rxvt_utf8towcs (f->name); |
|
|
208 | max_it (width, wcswidth (fname[i], wcslen (fname[i]))); |
|
|
209 | } |
|
|
210 | |
|
|
211 | max_it (width, strlen (attr)); |
|
|
212 | |
|
|
213 | if (y >= 0) |
|
|
214 | { |
|
|
215 | y = (y >= nrow - len - 5 && x < width + 2) ? 0 : -1; |
|
|
216 | x = 0; |
|
|
217 | } |
|
|
218 | |
|
|
219 | scr_overlay_new (x, y, width, len * 2 + 2); |
|
|
220 | |
|
|
221 | scr_overlay_set (0, 0, rowcol); |
|
|
222 | |
|
|
223 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
|
|
224 | |
|
|
225 | for (int y = 0; y < len; y++) |
|
|
226 | { |
|
|
227 | char buf[9]; |
|
|
228 | |
|
|
229 | ch = *chr++; |
|
|
230 | |
|
|
231 | sprintf (buf, "%8x", ch); |
|
|
232 | scr_overlay_set (0, y + 1, buf); |
|
|
233 | scr_overlay_set (9, y + 1, '='); |
|
|
234 | # if !UNICODE_3 |
|
|
235 | if (ch >= 0x10000) |
|
|
236 | ch = 0xfffd; |
|
|
237 | # endif |
|
|
238 | scr_overlay_set (11, y + 1, ch, r); |
|
|
239 | |
|
|
240 | if (WCWIDTH (ch) >= 2) |
|
|
241 | scr_overlay_set (12, y + 1, NOCHAR, r); |
|
|
242 | } |
|
|
243 | |
|
|
244 | // { |
|
|
245 | // char buf[4+4+3+1]; |
|
|
246 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
247 | // scr_overlay_set (0, 0, buf); |
|
|
248 | // } |
|
|
249 | scr_overlay_set (0, len + 1, attr); |
|
|
250 | for (int i = 0; i < len; i++) |
|
|
251 | { |
|
|
252 | scr_overlay_set (0, len + 2 + i, fname[i]); |
|
|
253 | free (fname[i]); |
|
|
254 | } |
|
|
255 | |
|
|
256 | # if ENABLE_COMBINING |
|
|
257 | if (alloc) |
|
|
258 | delete [] alloc; |
|
|
259 | # endif |
|
|
260 | } |
|
|
261 | #endif |
|
|
262 | |
|
|
263 | void ecb_cold |
|
|
264 | rxvt_term::commit_iso14755 () |
|
|
265 | { |
|
|
266 | wchar_t ch = iso14755buf & ISO_14755_MASK; |
|
|
267 | |
|
|
268 | if (iso14755buf & ISO_14755_51) |
|
|
269 | { |
|
|
270 | char mb[MB_LEN_MAX]; |
|
|
271 | int len; |
|
|
272 | |
|
|
273 | // allow verbatim 0-bytes and control-bytes to be entered |
|
|
274 | if (ch >= 0x20) |
|
|
275 | len = wctomb (mb, ch); |
|
|
276 | else |
|
|
277 | { |
|
|
278 | mb[0] = ch; |
|
|
279 | len = 1; |
|
|
280 | } |
|
|
281 | |
|
|
282 | if (len > 0) |
|
|
283 | tt_write (mb, len); |
|
|
284 | else |
|
|
285 | scr_bell (); |
|
|
286 | } |
|
|
287 | |
|
|
288 | iso14755buf = 0; |
|
|
289 | } |
|
|
290 | |
|
|
291 | static int ecb_cold |
|
|
292 | hex_keyval (XKeyEvent &ev) |
|
|
293 | { |
|
|
294 | // check whether this event corresponds to a hex digit |
|
|
295 | // if the modifiers had not been pressed. |
|
|
296 | for (int index = 0; index < 8; index++) |
|
|
297 | { |
|
|
298 | KeySym k = XLookupKeysym (&ev, index); |
|
|
299 | |
|
|
300 | if (k >= XK_KP_0 && k <= XK_KP_9) return k - XK_KP_0; |
|
|
301 | else if (k >= XK_0 && k <= XK_9) return k - XK_0; |
|
|
302 | else if (k >= XK_a && k <= XK_f) return k - XK_a + 10; |
|
|
303 | else if (k >= XK_A && k <= XK_F) return k - XK_A + 10; |
|
|
304 | } |
|
|
305 | |
|
|
306 | return -1; |
|
|
307 | } |
|
|
308 | #endif |
|
|
309 | |
|
|
310 | static inline KeySym ecb_cold |
|
|
311 | translate_keypad (KeySym keysym, bool kp) |
|
|
312 | { |
|
|
313 | #ifdef XK_KP_Home |
|
|
314 | static const KeySym keypadtrans[] = { |
|
|
315 | XK_KP_7, // XK_KP_Home |
|
|
316 | XK_KP_4, // XK_KP_Left |
|
|
317 | XK_KP_8, // XK_KP_Up |
|
|
318 | XK_KP_6, // XK_KP_Right |
|
|
319 | XK_KP_2, // XK_KP_Down |
|
|
320 | XK_KP_9, // XK_KP_Prior |
|
|
321 | XK_KP_3, // XK_KP_Next |
|
|
322 | XK_KP_1, // XK_KP_End |
|
|
323 | XK_KP_5, // XK_KP_Begin |
|
|
324 | }; |
|
|
325 | |
|
|
326 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
327 | { |
|
|
328 | unsigned int index = keysym - XK_KP_Home; |
|
|
329 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
330 | } |
|
|
331 | else if (keysym == XK_KP_Insert) |
|
|
332 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
333 | # ifndef NO_DELETE_KEY |
|
|
334 | else if (keysym == XK_KP_Delete) |
|
|
335 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
336 | # endif |
|
|
337 | #endif |
|
|
338 | return keysym; |
|
|
339 | } |
|
|
340 | |
|
|
341 | static inline int ecb_cold |
|
|
342 | map_function_key (KeySym keysym) |
|
|
343 | { |
|
|
344 | int param = 0; |
|
|
345 | |
|
|
346 | if (IN_RANGE_INC (keysym, XK_F1, XK_F35)) |
|
|
347 | { |
|
|
348 | param = 11 + keysym - XK_F1; |
|
|
349 | if (keysym >= XK_F17) |
|
|
350 | param += 4; |
|
|
351 | else if (keysym >= XK_F15) |
|
|
352 | param += 3; |
|
|
353 | else if (keysym >= XK_F11) |
|
|
354 | param += 2; |
|
|
355 | else if (keysym >= XK_F6) |
|
|
356 | param += 1; |
|
|
357 | } |
|
|
358 | else |
|
|
359 | switch (keysym) |
80 | { |
360 | { |
81 | R->numlock_state = (ev->state & R->ModNumLockMask); |
361 | case XK_Find: |
82 | PrivMode((!R->numlock_state), PrivMode_aplKP); |
362 | param = 1; |
|
|
363 | break; |
|
|
364 | case XK_Insert: |
|
|
365 | param = 2; |
|
|
366 | break; |
|
|
367 | #ifdef DXK_Remove |
|
|
368 | case DXK_Remove: |
|
|
369 | #endif |
|
|
370 | case XK_Execute: |
|
|
371 | param = 3; |
|
|
372 | break; |
|
|
373 | case XK_Select: |
|
|
374 | param = 4; |
|
|
375 | break; |
|
|
376 | case XK_Prior: |
|
|
377 | param = 5; |
|
|
378 | break; |
|
|
379 | case XK_Next: |
|
|
380 | param = 6; |
|
|
381 | break; |
|
|
382 | case XK_Home: |
|
|
383 | param = 7; |
|
|
384 | break; |
|
|
385 | case XK_End: |
|
|
386 | param = 8; |
|
|
387 | break; |
|
|
388 | case XK_Help: |
|
|
389 | param = 28; |
|
|
390 | break; |
|
|
391 | case XK_Menu: |
|
|
392 | param = 29; |
|
|
393 | break; |
83 | } |
394 | } |
|
|
395 | return param; |
|
|
396 | } |
84 | |
397 | |
|
|
398 | static inline wchar_t * |
|
|
399 | rxvt_wcsdup (const wchar_t *str, int len) |
|
|
400 | { |
|
|
401 | wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t)); |
|
|
402 | memcpy (r, str, len * sizeof (wchar_t)); |
|
|
403 | r[len] = 0; |
|
|
404 | return r; |
|
|
405 | } |
|
|
406 | |
|
|
407 | void ecb_cold |
|
|
408 | rxvt_term::key_press (XKeyEvent &ev) |
|
|
409 | { |
|
|
410 | int ctrl, meta, shft, len; |
|
|
411 | KeySym keysym = NoSymbol; |
|
|
412 | char rkbuf[KBUFSZ + 1]; |
|
|
413 | char *kbuf = rkbuf + 1; |
|
|
414 | |
|
|
415 | #if ISO_14755 |
|
|
416 | if (iso14755buf & ISO_14755_52) |
|
|
417 | return; |
|
|
418 | #endif |
|
|
419 | |
|
|
420 | /* |
|
|
421 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
|
|
422 | * escape sequence to toggle the Keypad. |
|
|
423 | * |
|
|
424 | * Always permit `shift' to override the current setting |
|
|
425 | */ |
|
|
426 | shft = ev.state & ShiftMask; |
|
|
427 | ctrl = ev.state & ControlMask; |
|
|
428 | meta = ev.state & ModMetaMask; |
|
|
429 | |
85 | kbuf[0] = 0; |
430 | kbuf[0] = 0; |
86 | |
431 | |
87 | #ifdef USE_XIM |
432 | #if USE_XIM |
88 | if (R->Input_Context) |
433 | if (Input_Context) |
89 | { |
434 | { |
90 | Status status_return; |
435 | Status status_return; |
91 | |
436 | |
|
|
437 | #if 0 |
92 | #ifdef X_HAVE_UTF8_STRING |
438 | #ifdef X_HAVE_UTF8_STRING |
|
|
439 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
93 | len = Xutf8LookupString (R->Input_Context, ev, (char *)kbuf, |
440 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
94 | KBUFSZ, &keysym, &status_return); |
441 | KBUFSZ, &keysym, &status_return); |
95 | #else |
442 | else |
|
|
443 | #endif |
|
|
444 | #endif |
|
|
445 | { |
96 | wchar_t wkbuf[KBUFSZ + 1]; |
446 | wchar_t wkbuf[KBUFSZ + 1]; |
97 | |
447 | |
|
|
448 | // the XOpenIM manpage lies about hardcoding the locale |
|
|
449 | // at the point of XOpenIM, so temporarily switch locales |
|
|
450 | if (rs[Rs_imLocale]) |
|
|
451 | SET_LOCALE (rs[Rs_imLocale]); |
|
|
452 | |
98 | // assume wchar_t == unicode or better |
453 | // assume wchar_t == unicode or better |
99 | len = XwcLookupString (R->Input_Context, ev, wkbuf, |
454 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
100 | KBUFSZ, &keysym, &status_return); |
455 | KBUFSZ, &keysym, &status_return); |
101 | |
456 | |
|
|
457 | if (rs[Rs_imLocale]) |
|
|
458 | SET_LOCALE (locale); |
|
|
459 | |
102 | if (status_return == XLookupChars |
460 | if (status_return == XLookupChars |
103 | || status_return == XLookupBoth) |
461 | || status_return == XLookupBoth) |
104 | { |
|
|
105 | wkbuf[len] = 0; |
|
|
106 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
|
|
107 | } |
|
|
108 | else |
|
|
109 | len = 0; |
|
|
110 | #endif |
|
|
111 | valid_keysym = status_return == XLookupKeySym |
|
|
112 | || status_return == XLookupBoth; |
|
|
113 | } |
|
|
114 | else |
|
|
115 | #endif |
|
|
116 | { |
|
|
117 | len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose); |
|
|
118 | valid_keysym = !len; |
|
|
119 | } |
|
|
120 | |
|
|
121 | if (valid_keysym) |
|
|
122 | { |
|
|
123 | /* for some backwards compatibility */ |
|
|
124 | #if defined(HOTKEY_CTRL) || defined(HOTKEY_META) |
|
|
125 | # ifdef HOTKEY_CTRL |
|
|
126 | if (ctrl) |
|
|
127 | # else |
|
|
128 | if (meta) |
|
|
129 | # endif |
|
|
130 | { |
|
|
131 | if (keysym == R->ks_bigfont) |
|
|
132 | { |
|
|
133 | rxvt_change_font(aR_ 0, FONT_UP); |
|
|
134 | return; |
|
|
135 | } |
|
|
136 | else if (keysym == R->ks_smallfont) |
|
|
137 | { |
|
|
138 | rxvt_change_font(aR_ 0, FONT_DN); |
|
|
139 | return; |
|
|
140 | } |
|
|
141 | } |
|
|
142 | #endif |
|
|
143 | |
|
|
144 | if (R->TermWin.saveLines) { |
|
|
145 | #ifdef UNSHIFTED_SCROLLKEYS |
|
|
146 | if (!ctrl && !meta) { |
|
|
147 | #else |
|
|
148 | if (IS_SCROLL_MOD) { |
|
|
149 | #endif |
|
|
150 | int lnsppg; |
|
|
151 | |
|
|
152 | #ifdef PAGING_CONTEXT_LINES |
|
|
153 | lnsppg = R->TermWin.nrow - PAGING_CONTEXT_LINES; |
|
|
154 | #else |
|
|
155 | lnsppg = R->TermWin.nrow * 4 / 5; |
|
|
156 | #endif |
|
|
157 | if (keysym == XK_Prior) { |
|
|
158 | rxvt_scr_page(aR_ UP, lnsppg); |
|
|
159 | return; |
|
|
160 | } else if (keysym == XK_Next) { |
|
|
161 | rxvt_scr_page(aR_ DN, lnsppg); |
|
|
162 | return; |
|
|
163 | } |
|
|
164 | } |
|
|
165 | #ifdef SCROLL_ON_UPDOWN_KEYS |
|
|
166 | if (IS_SCROLL_MOD) { |
|
|
167 | if (keysym == XK_Up) { |
|
|
168 | rxvt_scr_page(aR_ UP, 1); |
|
|
169 | return; |
|
|
170 | } else if (keysym == XK_Down) { |
|
|
171 | rxvt_scr_page(aR_ DN, 1); |
|
|
172 | return; |
|
|
173 | } |
|
|
174 | } |
|
|
175 | #endif |
|
|
176 | #ifdef SCROLL_ON_HOMEEND_KEYS |
|
|
177 | if (IS_SCROLL_MOD) { |
|
|
178 | if (keysym == XK_Home) { |
|
|
179 | rxvt_scr_move_to(aR_ 0, 1); |
|
|
180 | return; |
|
|
181 | } else if (keysym == XK_End) { |
|
|
182 | rxvt_scr_move_to(aR_ 1, 0); |
|
|
183 | return; |
|
|
184 | } |
|
|
185 | } |
|
|
186 | #endif |
|
|
187 | } |
|
|
188 | |
|
|
189 | if (shft) { |
|
|
190 | /* Shift + F1 - F10 generates F11 - F20 */ |
|
|
191 | if (keysym >= XK_F1 && keysym <= XK_F10) { |
|
|
192 | keysym += (XK_F11 - XK_F1); |
|
|
193 | shft = 0; /* turn off Shift */ |
|
|
194 | } else if (!ctrl && !meta && (R->PrivateModes & PrivMode_ShiftKeys)) { |
|
|
195 | switch (keysym) { |
|
|
196 | /* normal XTerm key bindings */ |
|
|
197 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
|
|
198 | rxvt_selection_request(aR_ ev->time, 0, 0); |
|
|
199 | return; |
|
|
200 | /* rxvt extras */ |
|
|
201 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
|
|
202 | rxvt_change_font(aR_ 0, FONT_UP); |
|
|
203 | return; |
|
|
204 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
|
|
205 | rxvt_change_font(aR_ 0, FONT_DN); |
|
|
206 | return; |
|
|
207 | } |
|
|
208 | } |
|
|
209 | } |
|
|
210 | #ifdef PRINTPIPE |
|
|
211 | if (keysym == XK_Print) { |
|
|
212 | rxvt_scr_printscreen(aR_ ctrl | shft); |
|
|
213 | return; |
|
|
214 | } |
|
|
215 | #endif |
|
|
216 | #ifdef GREEK_SUPPORT |
|
|
217 | if (keysym == R->ks_greekmodeswith) { |
|
|
218 | R->greek_mode = !R->greek_mode; |
|
|
219 | if (R->greek_mode) { |
|
|
220 | rxvt_xterm_seq(aR_ XTerm_title, |
|
|
221 | (greek_getmode() == GREEK_ELOT928 |
|
|
222 | ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST); |
|
|
223 | greek_reset(); |
|
|
224 | } else |
|
|
225 | rxvt_xterm_seq(aR_ XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
|
|
226 | return; |
|
|
227 | } |
|
|
228 | #endif |
|
|
229 | |
|
|
230 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) { |
|
|
231 | #ifdef KEYSYM_RESOURCE |
|
|
232 | if (!(shft | ctrl) && R->Keysym_map[keysym & 0xFF] != NULL) { |
|
|
233 | unsigned int l; |
|
|
234 | const unsigned char *kbuf0; |
|
|
235 | const unsigned char ch = C0_ESC; |
|
|
236 | |
|
|
237 | kbuf0 = (R->Keysym_map[keysym & 0xFF]); |
|
|
238 | l = (unsigned int)*kbuf0++; |
|
|
239 | |
|
|
240 | /* escape prefix */ |
|
|
241 | if (meta) |
|
|
242 | # ifdef META8_OPTION |
|
|
243 | if (R->meta_char == C0_ESC) |
|
|
244 | # endif |
|
|
245 | R->tt_write (&ch, 1); |
|
|
246 | R->tt_write (kbuf0, l); |
|
|
247 | return; |
|
|
248 | } else |
|
|
249 | #endif |
|
|
250 | { |
|
|
251 | newlen = 1; |
|
|
252 | switch (keysym) { |
|
|
253 | #ifndef NO_BACKSPACE_KEY |
|
|
254 | case XK_BackSpace: |
|
|
255 | if (R->PrivateModes & PrivMode_HaveBackSpace) { |
|
|
256 | kbuf[0] = (!!(R->PrivateModes & PrivMode_BackSpace) |
|
|
257 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
258 | kbuf[1] = '\0'; |
|
|
259 | } else |
|
|
260 | STRCPY(kbuf, R->key_backspace); |
|
|
261 | # ifdef MULTICHAR_SET |
|
|
262 | if ((R->Options & Opt_mc_hack) && R->screen.cur.col > 0) { |
|
|
263 | int col, row; |
|
|
264 | |
|
|
265 | newlen = STRLEN(kbuf); |
|
|
266 | col = R->screen.cur.col - 1; |
|
|
267 | row = R->screen.cur.row + R->TermWin.saveLines; |
|
|
268 | if (IS_MULTI2(R->screen.rend[row][col])) |
|
|
269 | MEMMOVE(kbuf + newlen, kbuf, newlen + 1); |
|
|
270 | } |
|
|
271 | # endif |
|
|
272 | break; |
|
|
273 | #endif |
|
|
274 | #ifndef NO_DELETE_KEY |
|
|
275 | case XK_Delete: |
|
|
276 | STRCPY(kbuf, R->key_delete); |
|
|
277 | # ifdef MULTICHAR_SET |
|
|
278 | if (R->Options & Opt_mc_hack) { |
|
|
279 | int col, row; |
|
|
280 | |
|
|
281 | newlen = STRLEN(kbuf); |
|
|
282 | col = R->screen.cur.col; |
|
|
283 | row = R->screen.cur.row + R->TermWin.saveLines; |
|
|
284 | if (IS_MULTI1(R->screen.rend[row][col])) |
|
|
285 | MEMMOVE(kbuf + newlen, kbuf, newlen + 1); |
|
|
286 | } |
|
|
287 | # endif |
|
|
288 | break; |
|
|
289 | #endif |
|
|
290 | case XK_Tab: |
|
|
291 | if (shft) |
|
|
292 | STRCPY(kbuf, "\033[Z"); |
|
|
293 | else { |
|
|
294 | #ifdef CTRL_TAB_MAKES_META |
|
|
295 | if (ctrl) |
|
|
296 | meta = 1; |
|
|
297 | #endif |
|
|
298 | #ifdef MOD4_TAB_MAKES_META |
|
|
299 | if (ev->state & Mod4Mask) |
|
|
300 | meta = 1; |
|
|
301 | #endif |
|
|
302 | newlen = 0; |
|
|
303 | } |
|
|
304 | break; |
|
|
305 | |
|
|
306 | |
|
|
307 | #ifdef XK_KP_Left |
|
|
308 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
309 | case XK_KP_Down: /* \033Or or standard */ |
|
|
310 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
311 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
312 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
313 | STRCPY(kbuf, "\033OZ"); |
|
|
314 | kbuf[2] = ("txvr"[keysym - XK_KP_Left]); |
|
|
315 | break; |
|
|
316 | } else |
|
|
317 | /* translate to std. cursor key */ |
|
|
318 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
319 | /* FALLTHROUGH */ |
|
|
320 | #endif |
|
|
321 | case XK_Up: /* "\033[A" */ |
|
|
322 | case XK_Down: /* "\033[B" */ |
|
|
323 | case XK_Right: /* "\033[C" */ |
|
|
324 | case XK_Left: /* "\033[D" */ |
|
|
325 | STRCPY(kbuf, "\033[Z"); |
|
|
326 | kbuf[2] = ("DACB"[keysym - XK_Left]); |
|
|
327 | /* do Shift first */ |
|
|
328 | if (shft) |
|
|
329 | kbuf[2] = ("dacb"[keysym - XK_Left]); |
|
|
330 | else if (ctrl) { |
|
|
331 | kbuf[1] = 'O'; |
|
|
332 | kbuf[2] = ("dacb"[keysym - XK_Left]); |
|
|
333 | } else if (R->PrivateModes & PrivMode_aplCUR) |
|
|
334 | kbuf[1] = 'O'; |
|
|
335 | #ifdef MULTICHAR_SET |
|
|
336 | //TODO: ?? |
|
|
337 | if (R->Options & Opt_mc_hack) { |
|
|
338 | int col, row, m; |
|
|
339 | |
|
|
340 | col = R->screen.cur.col; |
|
|
341 | row = R->screen.cur.row + R->TermWin.saveLines; |
|
|
342 | m = 0; |
|
|
343 | if (keysym == XK_Right |
|
|
344 | && IS_MULTI1(R->screen.rend[row][col])) |
|
|
345 | m = 1; |
|
|
346 | else if (keysym == XK_Left) { |
|
|
347 | if (col > 0) { |
|
|
348 | if (IS_MULTI2(R->screen.rend[row][col - 1])) |
|
|
349 | m = 1; |
|
|
350 | } else if (R->screen.cur.row > 0) { |
|
|
351 | col = R->screen.tlen[--row]; |
|
|
352 | if (col == -1) |
|
|
353 | col = R->TermWin.ncol - 1; |
|
|
354 | else |
|
|
355 | col--; |
|
|
356 | if (col > 0 |
|
|
357 | && IS_MULTI2(R->screen.rend[row][col])) |
|
|
358 | m = 1; |
|
|
359 | } |
|
|
360 | } |
|
|
361 | if (m) |
|
|
362 | MEMMOVE(kbuf + 3, kbuf, 3 + 1); |
|
|
363 | } |
|
|
364 | #endif |
|
|
365 | break; |
|
|
366 | |
|
|
367 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
368 | # ifdef XK_KP_Prior |
|
|
369 | case XK_KP_Prior: |
|
|
370 | /* allow shift to override */ |
|
|
371 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
372 | STRCPY(kbuf, "\033Oy"); |
|
|
373 | break; |
|
|
374 | } |
|
|
375 | /* FALLTHROUGH */ |
|
|
376 | # endif |
|
|
377 | case XK_Prior: |
|
|
378 | STRCPY(kbuf, "\033[5~"); |
|
|
379 | break; |
|
|
380 | # ifdef XK_KP_Next |
|
|
381 | case XK_KP_Next: |
|
|
382 | /* allow shift to override */ |
|
|
383 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
384 | STRCPY(kbuf, "\033Os"); |
|
|
385 | break; |
|
|
386 | } |
|
|
387 | /* FALLTHROUGH */ |
|
|
388 | # endif |
|
|
389 | case XK_Next: |
|
|
390 | STRCPY(kbuf, "\033[6~"); |
|
|
391 | break; |
|
|
392 | #endif |
|
|
393 | case XK_KP_Enter: |
|
|
394 | /* allow shift to override */ |
|
|
395 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
396 | STRCPY(kbuf, "\033OM"); |
|
|
397 | } else { |
|
|
398 | kbuf[0] = '\r'; |
|
|
399 | kbuf[1] = '\0'; |
|
|
400 | } |
|
|
401 | break; |
|
|
402 | |
|
|
403 | #ifdef XK_KP_Begin |
|
|
404 | case XK_KP_Begin: |
|
|
405 | STRCPY(kbuf, "\033Ou"); |
|
|
406 | break; |
|
|
407 | |
|
|
408 | case XK_KP_Insert: |
|
|
409 | STRCPY(kbuf, "\033Op"); |
|
|
410 | break; |
|
|
411 | |
|
|
412 | case XK_KP_Delete: |
|
|
413 | STRCPY(kbuf, "\033On"); |
|
|
414 | break; |
|
|
415 | #endif |
|
|
416 | case XK_KP_F1: /* "\033OP" */ |
|
|
417 | case XK_KP_F2: /* "\033OQ" */ |
|
|
418 | case XK_KP_F3: /* "\033OR" */ |
|
|
419 | case XK_KP_F4: /* "\033OS" */ |
|
|
420 | STRCPY(kbuf, "\033OP"); |
|
|
421 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
422 | break; |
|
|
423 | |
|
|
424 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
425 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
426 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
427 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
428 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
429 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
430 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
431 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
432 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
433 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
434 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
435 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
436 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
437 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
438 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
439 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
440 | /* allow shift to override */ |
|
|
441 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
442 | STRCPY(kbuf, "\033Oj"); |
|
|
443 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
444 | } else { |
|
|
445 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
446 | kbuf[1] = '\0'; |
|
|
447 | } |
|
|
448 | break; |
|
|
449 | |
|
|
450 | case XK_Find: |
|
|
451 | STRCPY(kbuf, "\033[1~"); |
|
|
452 | break; |
|
|
453 | case XK_Insert: |
|
|
454 | STRCPY(kbuf, "\033[2~"); |
|
|
455 | break; |
|
|
456 | #ifdef DXK_Remove /* support for DEC remove like key */ |
|
|
457 | case DXK_Remove: |
|
|
458 | /* FALLTHROUGH */ |
|
|
459 | #endif |
|
|
460 | case XK_Execute: |
|
|
461 | STRCPY(kbuf, "\033[3~"); |
|
|
462 | break; |
|
|
463 | case XK_Select: |
|
|
464 | STRCPY(kbuf, "\033[4~"); |
|
|
465 | break; |
|
|
466 | #ifdef XK_KP_End |
|
|
467 | case XK_KP_End: |
|
|
468 | /* allow shift to override */ |
|
|
469 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
470 | STRCPY(kbuf, "\033Oq"); |
|
|
471 | break; |
|
|
472 | } |
|
|
473 | /* FALLTHROUGH */ |
|
|
474 | #endif |
|
|
475 | case XK_End: |
|
|
476 | STRCPY(kbuf, KS_END); |
|
|
477 | break; |
|
|
478 | #ifdef XK_KP_Home |
|
|
479 | case XK_KP_Home: |
|
|
480 | /* allow shift to override */ |
|
|
481 | if ((R->PrivateModes & PrivMode_aplKP) ? !shft : shft) { |
|
|
482 | STRCPY(kbuf, "\033Ow"); |
|
|
483 | break; |
|
|
484 | } |
|
|
485 | /* FALLTHROUGH */ |
|
|
486 | #endif |
|
|
487 | case XK_Home: |
|
|
488 | STRCPY(kbuf, KS_HOME); |
|
|
489 | break; |
|
|
490 | |
|
|
491 | #define FKEY(n, fkey) \ |
|
|
492 | sprintf((char *)kbuf,"\033[%2d~", (int)((n) + (keysym - fkey))) |
|
|
493 | |
|
|
494 | case XK_F1: /* "\033[11~" */ |
|
|
495 | case XK_F2: /* "\033[12~" */ |
|
|
496 | case XK_F3: /* "\033[13~" */ |
|
|
497 | case XK_F4: /* "\033[14~" */ |
|
|
498 | case XK_F5: /* "\033[15~" */ |
|
|
499 | FKEY(11, XK_F1); |
|
|
500 | break; |
|
|
501 | case XK_F6: /* "\033[17~" */ |
|
|
502 | case XK_F7: /* "\033[18~" */ |
|
|
503 | case XK_F8: /* "\033[19~" */ |
|
|
504 | case XK_F9: /* "\033[20~" */ |
|
|
505 | case XK_F10: /* "\033[21~" */ |
|
|
506 | FKEY(17, XK_F6); |
|
|
507 | break; |
|
|
508 | case XK_F11: /* "\033[23~" */ |
|
|
509 | case XK_F12: /* "\033[24~" */ |
|
|
510 | case XK_F13: /* "\033[25~" */ |
|
|
511 | case XK_F14: /* "\033[26~" */ |
|
|
512 | FKEY(23, XK_F11); |
|
|
513 | break; |
|
|
514 | case XK_F15: /* "\033[28~" */ |
|
|
515 | case XK_F16: /* "\033[29~" */ |
|
|
516 | FKEY(28, XK_F15); |
|
|
517 | break; |
|
|
518 | case XK_Help: /* "\033[28~" */ |
|
|
519 | FKEY(28, XK_Help); |
|
|
520 | break; |
|
|
521 | case XK_Menu: /* "\033[29~" */ |
|
|
522 | FKEY(29, XK_Menu); |
|
|
523 | break; |
|
|
524 | case XK_F17: /* "\033[31~" */ |
|
|
525 | case XK_F18: /* "\033[32~" */ |
|
|
526 | case XK_F19: /* "\033[33~" */ |
|
|
527 | case XK_F20: /* "\033[34~" */ |
|
|
528 | case XK_F21: /* "\033[35~" */ |
|
|
529 | case XK_F22: /* "\033[36~" */ |
|
|
530 | case XK_F23: /* "\033[37~" */ |
|
|
531 | case XK_F24: /* "\033[38~" */ |
|
|
532 | case XK_F25: /* "\033[39~" */ |
|
|
533 | case XK_F26: /* "\033[40~" */ |
|
|
534 | case XK_F27: /* "\033[41~" */ |
|
|
535 | case XK_F28: /* "\033[42~" */ |
|
|
536 | case XK_F29: /* "\033[43~" */ |
|
|
537 | case XK_F30: /* "\033[44~" */ |
|
|
538 | case XK_F31: /* "\033[45~" */ |
|
|
539 | case XK_F32: /* "\033[46~" */ |
|
|
540 | case XK_F33: /* "\033[47~" */ |
|
|
541 | case XK_F34: /* "\033[48~" */ |
|
|
542 | case XK_F35: /* "\033[49~" */ |
|
|
543 | FKEY(31, XK_F17); |
|
|
544 | break; |
|
|
545 | #undef FKEY |
|
|
546 | default: |
|
|
547 | newlen = 0; |
|
|
548 | break; |
|
|
549 | } |
|
|
550 | if (newlen) |
|
|
551 | len = STRLEN(kbuf); |
|
|
552 | } |
|
|
553 | /* |
|
|
554 | * Pass meta for all function keys, if 'meta' option set |
|
|
555 | */ |
|
|
556 | #ifdef META8_OPTION |
|
|
557 | if (meta && (R->meta_char == 0x80) && len > 0) |
|
|
558 | kbuf[len - 1] |= 0x80; |
|
|
559 | #endif |
|
|
560 | } else if (ctrl && keysym == XK_minus) { |
|
|
561 | len = 1; |
|
|
562 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
563 | } else { |
|
|
564 | #ifdef META8_OPTION |
|
|
565 | /* set 8-bit on */ |
|
|
566 | if (meta && (R->meta_char == 0x80)) { |
|
|
567 | unsigned char *ch; |
|
|
568 | |
|
|
569 | for (ch = kbuf; ch < kbuf + len; ch++) |
|
|
570 | *ch |= 0x80; |
|
|
571 | meta = 0; |
|
|
572 | } |
|
|
573 | #endif |
|
|
574 | #ifdef GREEK_SUPPORT |
|
|
575 | if (R->greek_mode) |
|
|
576 | len = greek_xlat(kbuf, len); |
|
|
577 | #endif |
|
|
578 | /* nil */ ; |
|
|
579 | } |
|
|
580 | } |
|
|
581 | |
|
|
582 | if (len <= 0) |
|
|
583 | return; /* not mapped */ |
|
|
584 | |
|
|
585 | if (R->Options & Opt_scrollTtyKeypress) |
|
|
586 | if (R->TermWin.view_start) { |
|
|
587 | R->TermWin.view_start = 0; |
|
|
588 | R->want_refresh = 1; |
|
|
589 | } |
|
|
590 | |
|
|
591 | /* |
|
|
592 | * these modifications only affect the static keybuffer |
|
|
593 | * pass Shift/Control indicators for function keys ending with `~' |
|
|
594 | * |
|
|
595 | * eg, |
|
|
596 | * Prior = "ESC[5~" |
|
|
597 | * Shift+Prior = "ESC[5$" |
|
|
598 | * Ctrl+Prior = "ESC[5^" |
|
|
599 | * Ctrl+Shift+Prior = "ESC[5@" |
|
|
600 | * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>). |
|
|
601 | */ |
|
|
602 | if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~') |
|
|
603 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
|
|
604 | |
|
|
605 | /* escape prefix */ |
|
|
606 | if (meta |
|
|
607 | #ifdef META8_OPTION |
|
|
608 | && (R->meta_char == C0_ESC) |
|
|
609 | #endif |
|
|
610 | ) { |
|
|
611 | const unsigned char ch = C0_ESC; |
|
|
612 | |
|
|
613 | R->tt_write(&ch, 1); |
|
|
614 | } |
|
|
615 | #ifdef DEBUG_CMD |
|
|
616 | if (debug_key) { /* Display keyboard buffer contents */ |
|
|
617 | char *p; |
|
|
618 | int i; |
|
|
619 | |
|
|
620 | fprintf(stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
621 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
622 | fprintf(stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
623 | fprintf(stderr, "'\n"); |
|
|
624 | } |
|
|
625 | #endif /* DEBUG_CMD */ |
|
|
626 | R->tt_write(kbuf, (unsigned int)len); |
|
|
627 | } |
|
|
628 | /*}}} */ |
|
|
629 | |
|
|
630 | #if (MENUBAR_MAX) |
|
|
631 | /*{{{ rxvt_cmd_write(), rxvt_cmd_getc() */ |
|
|
632 | /* attempt to `write' count to the input buffer */ |
|
|
633 | /* EXTPROTO */ |
|
|
634 | unsigned int |
|
|
635 | rxvt_cmd_write(pR_ const unsigned char *str, unsigned int count) |
|
|
636 | { |
|
|
637 | unsigned int n, s; |
|
|
638 | unsigned char *cmdbuf_base = R->cmdbuf_base, |
|
|
639 | *cmdbuf_endp = R->cmdbuf_endp, |
|
|
640 | *cmdbuf_ptr = R->cmdbuf_ptr; |
|
|
641 | |
|
|
642 | n = cmdbuf_ptr - cmdbuf_base; |
|
|
643 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
|
|
644 | if (n > 0 && s < count) { |
|
|
645 | MEMMOVE(cmdbuf_base, cmdbuf_ptr, |
|
|
646 | (unsigned int)(cmdbuf_endp - cmdbuf_ptr)); |
|
|
647 | cmdbuf_ptr = cmdbuf_base; |
|
|
648 | cmdbuf_endp -= n; |
|
|
649 | s += n; |
|
|
650 | } |
|
|
651 | if (count > s) { |
|
|
652 | rxvt_print_error("data loss: cmd_write too large"); |
|
|
653 | count = s; |
|
|
654 | } |
|
|
655 | for (; count--;) |
|
|
656 | *cmdbuf_endp++ = *str++; |
|
|
657 | R->cmdbuf_ptr = cmdbuf_ptr; |
|
|
658 | R->cmdbuf_endp = cmdbuf_endp; |
|
|
659 | return 0; |
|
|
660 | } |
|
|
661 | #endif /* MENUBAR_MAX */ |
|
|
662 | |
|
|
663 | void |
|
|
664 | rxvt_term::flush () |
|
|
665 | { |
|
|
666 | #ifdef TRANSPARENT |
|
|
667 | if (want_full_refresh) |
|
|
668 | { |
|
|
669 | want_full_refresh = 0; |
|
|
670 | rxvt_scr_clear (this); |
|
|
671 | rxvt_scr_touch (this, False); |
|
|
672 | want_refresh = 1; |
|
|
673 | } |
|
|
674 | #endif |
|
|
675 | |
|
|
676 | if (want_refresh) |
|
|
677 | { |
|
|
678 | rxvt_scr_refresh (this, refresh_type); |
|
|
679 | rxvt_scrollbar_show (this, 1); |
|
|
680 | #ifdef USE_XIM |
|
|
681 | rxvt_IMSendSpot (this); |
|
|
682 | #endif |
|
|
683 | } |
|
|
684 | |
|
|
685 | XFlush (Xdisplay); |
|
|
686 | #if 0 |
|
|
687 | if (XPending (Xdisplay)) process_x_events (); |
|
|
688 | if (XPending (Xdisplay)) process_x_events (); |
|
|
689 | #endif |
|
|
690 | } |
|
|
691 | |
|
|
692 | void |
|
|
693 | rxvt_term::check_cb (check_watcher &w) |
|
|
694 | { |
|
|
695 | SET_R (this); |
|
|
696 | SET_LOCALE (locale); |
|
|
697 | |
|
|
698 | flush (); |
|
|
699 | } |
|
|
700 | |
|
|
701 | void |
|
|
702 | rxvt_term::process_x_events () |
|
|
703 | { |
|
|
704 | do |
|
|
705 | { |
|
|
706 | XEvent xev; |
|
|
707 | |
|
|
708 | XNextEvent (Xdisplay, &xev); |
|
|
709 | |
|
|
710 | #if defined(CURSOR_BLINK) |
|
|
711 | if ((Options & Opt_cursorBlink) |
|
|
712 | && xev.type == KeyPress) |
|
|
713 | { |
|
|
714 | if (hidden_cursor) |
|
|
715 | { |
462 | { |
716 | hidden_cursor = 0; |
463 | /* make sure the user can type ctrl-@, i.e. NUL */ |
717 | want_refresh = 1; |
464 | if (len == 1 && *wkbuf == 0) |
718 | } |
|
|
719 | |
|
|
720 | blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
721 | } |
|
|
722 | #endif |
|
|
723 | |
|
|
724 | #if defined(POINTER_BLANK) |
|
|
725 | if ((Options & Opt_pointerBlank) |
|
|
726 | && (pointerBlankDelay > 0)) |
|
|
727 | { |
|
|
728 | if (xev.type == MotionNotify |
|
|
729 | || xev.type == ButtonPress |
|
|
730 | || xev.type == ButtonRelease) |
|
|
731 | if (hidden_pointer) |
|
|
732 | pointer_unblank (); |
|
|
733 | |
|
|
734 | if (xev.type == KeyPress && hidden_pointer == 0) |
|
|
735 | pointer_blank (); |
|
|
736 | } |
|
|
737 | #endif |
|
|
738 | |
|
|
739 | #ifdef USE_XIM |
|
|
740 | if (!XFilterEvent (&xev, xev.xany.window)) |
|
|
741 | #endif |
|
|
742 | rxvt_process_x_event (this, &xev); |
|
|
743 | } |
|
|
744 | while (XPending (Xdisplay)); |
|
|
745 | } |
|
|
746 | |
|
|
747 | void |
|
|
748 | rxvt_term::blink_cb (time_watcher &w) |
|
|
749 | { |
|
|
750 | w.at += BLINK_INTERVAL; |
|
|
751 | hidden_cursor = !hidden_cursor; |
|
|
752 | want_refresh = 1; |
|
|
753 | } |
|
|
754 | |
|
|
755 | void |
|
|
756 | rxvt_term::x_cb (io_watcher &w, short revents) |
|
|
757 | { |
|
|
758 | SET_R (this); |
|
|
759 | SET_LOCALE (locale); |
|
|
760 | |
|
|
761 | process_x_events (); |
|
|
762 | } |
|
|
763 | |
|
|
764 | bool |
|
|
765 | rxvt_term::pty_fill () |
|
|
766 | { |
|
|
767 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
|
|
768 | |
|
|
769 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
|
|
770 | cmdbuf_ptr = cmdbuf_base; |
|
|
771 | cmdbuf_endp = cmdbuf_ptr + n; |
|
|
772 | |
|
|
773 | n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); |
|
|
774 | |
|
|
775 | if (n > 0) |
|
|
776 | { |
|
|
777 | cmdbuf_endp += n; |
|
|
778 | return true; |
|
|
779 | } |
|
|
780 | else if (n < 0 && errno != EAGAIN) |
|
|
781 | destroy (); |
|
|
782 | |
|
|
783 | return false; |
|
|
784 | } |
|
|
785 | |
|
|
786 | void |
|
|
787 | rxvt_term::pty_cb (io_watcher &w, short revents) |
|
|
788 | { |
|
|
789 | SET_R (this); |
|
|
790 | SET_LOCALE (locale); |
|
|
791 | |
|
|
792 | if (revents & EVENT_WRITE) |
|
|
793 | tt_write (0, 0); |
|
|
794 | else if (revents & EVENT_READ) |
|
|
795 | { |
|
|
796 | bool flag = true; |
|
|
797 | |
|
|
798 | // loop, but don't allow a single term to monopolize us |
|
|
799 | // the number of loops is fully arbitrary, and thus wrong |
|
|
800 | while (flag && pty_fill ()) |
|
|
801 | { |
|
|
802 | if (!seen_input) |
|
|
803 | { |
|
|
804 | seen_input = 1; |
|
|
805 | /* once we know the shell is running, send the screen size. Again! */ |
|
|
806 | tt_winch (); |
|
|
807 | } |
|
|
808 | |
|
|
809 | uint32_t ch = NOCHAR; |
|
|
810 | |
|
|
811 | for (;;) |
|
|
812 | { |
|
|
813 | if (ch == NOCHAR) |
|
|
814 | ch = next_char (); |
|
|
815 | |
|
|
816 | if (ch == NOCHAR) // TODO: improve |
|
|
817 | break; |
|
|
818 | |
|
|
819 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
820 | { |
465 | { |
821 | /* Read a text string from the input buffer */ |
466 | kbuf[0] = 0; |
822 | uint32_t buf[BUFSIZ]; |
|
|
823 | bool refreshnow = false; |
|
|
824 | int nlines = 0; |
|
|
825 | uint32_t *str = buf; |
|
|
826 | |
|
|
827 | *str++ = ch; |
467 | len = 1; |
828 | |
|
|
829 | for (;;) |
|
|
830 | { |
|
|
831 | ch = next_char (); |
|
|
832 | |
|
|
833 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
834 | break; |
|
|
835 | else |
|
|
836 | { |
|
|
837 | *str++ = ch; |
|
|
838 | |
|
|
839 | if (ch == '\n') |
|
|
840 | { |
|
|
841 | nlines++; |
|
|
842 | refresh_count++; |
|
|
843 | |
|
|
844 | if (!(Options & Opt_jumpScroll) |
|
|
845 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
|
|
846 | { |
|
|
847 | refreshnow = true; |
|
|
848 | flag = false; |
|
|
849 | ch = NOCHAR; |
|
|
850 | break; |
|
|
851 | } |
|
|
852 | } |
|
|
853 | |
|
|
854 | if (str >= buf + BUFSIZ) |
|
|
855 | { |
|
|
856 | ch = NOCHAR; |
|
|
857 | break; |
|
|
858 | } |
|
|
859 | } |
|
|
860 | } |
|
|
861 | |
|
|
862 | rxvt_scr_add_lines (this, buf, nlines, str - buf); |
|
|
863 | |
|
|
864 | /* |
|
|
865 | * If there have been a lot of new lines, then update the screen |
|
|
866 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
867 | * the number of pages between refreshes is refresh_limit, which |
|
|
868 | * is incremented here because we must be doing flat-out scrolling. |
|
|
869 | * |
|
|
870 | * refreshing should be correct for small scrolls, because of the |
|
|
871 | * time-out |
|
|
872 | */ |
|
|
873 | if (refreshnow) |
|
|
874 | { |
|
|
875 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
876 | refresh_limit++; |
|
|
877 | |
|
|
878 | rxvt_scr_refresh (this, refresh_type); |
|
|
879 | } |
|
|
880 | |
|
|
881 | } |
468 | } |
882 | else |
469 | else |
883 | { |
470 | { |
884 | switch (ch) |
471 | wkbuf[len] = 0; |
|
|
472 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
|
|
473 | if (len < 0) |
885 | { |
474 | len = 0; |
886 | default: |
|
|
887 | rxvt_process_nonprinting (this, ch); |
|
|
888 | break; |
|
|
889 | case C0_ESC: /* escape char */ |
|
|
890 | rxvt_process_escape_seq (this); |
|
|
891 | break; |
|
|
892 | /*case 0x9b: */ /* CSI */ |
|
|
893 | /* rxvt_process_csi_seq (this); */ |
|
|
894 | } |
|
|
895 | |
|
|
896 | ch = NOCHAR; |
|
|
897 | } |
475 | } |
898 | } |
476 | } |
899 | } |
477 | else |
900 | } |
478 | len = 0; |
901 | } |
|
|
902 | |
|
|
903 | // read the next character, currently handles UTF-8 |
|
|
904 | // will probably handle all sorts of other stuff in the future |
|
|
905 | uint32_t |
|
|
906 | rxvt_term::next_char () |
|
|
907 | { |
|
|
908 | struct mbstate &s = mbstate; |
|
|
909 | |
|
|
910 | while (cmdbuf_ptr < cmdbuf_endp) |
|
|
911 | { |
|
|
912 | uint8_t ch = *cmdbuf_ptr; |
|
|
913 | |
|
|
914 | if (s.cnt) |
|
|
915 | { |
479 | } |
916 | if ((ch & 0xc0) == 0x80) |
480 | } |
|
|
481 | else |
|
|
482 | #endif |
|
|
483 | { |
|
|
484 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
|
|
485 | } |
|
|
486 | |
|
|
487 | if (keysym != NoSymbol) |
|
|
488 | { |
|
|
489 | KeySym orig_keysym = keysym; |
|
|
490 | |
|
|
491 | /* Shift + F1 - F10 generates F11 - F20 */ |
|
|
492 | if (shft && keysym >= XK_F1 && keysym <= XK_F10) |
|
|
493 | { |
|
|
494 | keysym += (XK_F11 - XK_F1); |
|
|
495 | shft = 0; /* turn off Shift */ |
|
|
496 | } |
|
|
497 | |
|
|
498 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
|
|
499 | { |
|
|
500 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
|
|
501 | unsigned int newlen = 1; |
|
|
502 | |
|
|
503 | if (ev.state & ModNumLockMask) |
|
|
504 | kp = false; |
|
|
505 | |
|
|
506 | keysym = translate_keypad (keysym, kp); |
|
|
507 | |
|
|
508 | switch (keysym) |
917 | { |
509 | { |
918 | cmdbuf_ptr++; |
510 | #ifndef NO_BACKSPACE_KEY |
|
|
511 | case XK_BackSpace: |
|
|
512 | if (priv_modes & PrivMode_HaveBackSpace) |
|
|
513 | { |
|
|
514 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
515 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
516 | kbuf[1] = '\0'; |
|
|
517 | } |
|
|
518 | else |
|
|
519 | strcpy (kbuf, rs[Rs_backspace_key]); |
|
|
520 | break; |
|
|
521 | #endif |
|
|
522 | #ifndef NO_DELETE_KEY |
|
|
523 | case XK_Delete: |
|
|
524 | strcpy (kbuf, rs[Rs_delete_key]); |
|
|
525 | break; |
|
|
526 | #endif |
|
|
527 | case XK_Tab: |
|
|
528 | if (shft) |
|
|
529 | strcpy (kbuf, "\033[Z"); |
|
|
530 | else |
|
|
531 | { |
|
|
532 | #ifdef CTRL_TAB_MAKES_META |
|
|
533 | if (ctrl) |
|
|
534 | meta = 1; |
|
|
535 | #endif |
|
|
536 | #ifdef MOD4_TAB_MAKES_META |
|
|
537 | if (ev.state & Mod4Mask) |
|
|
538 | meta = 1; |
|
|
539 | #endif |
|
|
540 | newlen = 0; |
|
|
541 | } |
|
|
542 | break; |
919 | |
543 | |
920 | /* continuation */ |
544 | case XK_Up: /* "\033[A" */ |
921 | s.reg = (s.reg << 6) | (ch & 0x7f); |
545 | case XK_Down: /* "\033[B" */ |
|
|
546 | case XK_Right: /* "\033[C" */ |
|
|
547 | case XK_Left: /* "\033[D" */ |
|
|
548 | strcpy (kbuf, "\033[Z"); |
|
|
549 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
550 | /* do Shift first */ |
|
|
551 | if (shft) |
|
|
552 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
553 | else if (ctrl) |
|
|
554 | { |
|
|
555 | kbuf[1] = 'O'; |
|
|
556 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
557 | } |
|
|
558 | else if (priv_modes & PrivMode_aplCUR) |
|
|
559 | kbuf[1] = 'O'; |
|
|
560 | break; |
922 | |
561 | |
923 | if (--s.cnt == 0 && s.reg >= 128) /* if !inrange then corruption or Racking */ |
562 | case XK_KP_Enter: |
|
|
563 | /* allow shift to override */ |
|
|
564 | if (kp) |
|
|
565 | { |
|
|
566 | strcpy (kbuf, "\033OM"); |
|
|
567 | break; |
|
|
568 | } |
|
|
569 | |
|
|
570 | /* FALLTHROUGH */ |
|
|
571 | |
|
|
572 | case XK_Return: |
|
|
573 | if (priv_modes & PrivMode_LFNL) |
|
|
574 | { |
|
|
575 | kbuf[0] = '\015'; |
|
|
576 | kbuf[1] = '\012'; |
|
|
577 | kbuf[2] = '\0'; |
|
|
578 | } |
|
|
579 | else |
|
|
580 | { |
|
|
581 | kbuf[0] = '\015'; |
|
|
582 | kbuf[1] = '\0'; |
|
|
583 | } |
|
|
584 | break; |
|
|
585 | |
|
|
586 | case XK_KP_F1: /* "\033OP" */ |
|
|
587 | case XK_KP_F2: /* "\033OQ" */ |
|
|
588 | case XK_KP_F3: /* "\033OR" */ |
|
|
589 | case XK_KP_F4: /* "\033OS" */ |
|
|
590 | strcpy (kbuf, "\033OP"); |
|
|
591 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
592 | break; |
|
|
593 | |
|
|
594 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
595 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
596 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
597 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
598 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
599 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
600 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
601 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
602 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
603 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
604 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
605 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
606 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
607 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
608 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
609 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
610 | /* allow shift to override */ |
|
|
611 | if (kp) |
|
|
612 | { |
|
|
613 | strcpy (kbuf, "\033Oj"); |
|
|
614 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
615 | } |
|
|
616 | else |
|
|
617 | { |
|
|
618 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
619 | kbuf[1] = '\0'; |
|
|
620 | } |
|
|
621 | break; |
|
|
622 | |
|
|
623 | default: |
|
|
624 | { |
|
|
625 | int param = map_function_key (keysym); |
|
|
626 | if (param > 0) |
|
|
627 | sprintf (kbuf,"\033[%d~", param); |
|
|
628 | else |
|
|
629 | newlen = 0; |
|
|
630 | } |
|
|
631 | break; |
|
|
632 | } |
|
|
633 | |
|
|
634 | if (newlen) |
|
|
635 | len = strlen (kbuf); |
|
|
636 | |
|
|
637 | if (len > 0) |
|
|
638 | { |
|
|
639 | /* |
|
|
640 | * pass Shift/Control indicators for function keys ending with `~' |
|
|
641 | * |
|
|
642 | * eg, |
|
|
643 | * Prior = "ESC[5~" |
|
|
644 | * Shift+Prior = "ESC[5$" |
|
|
645 | * Ctrl+Prior = "ESC[5^" |
|
|
646 | * Ctrl+Shift+Prior = "ESC[5@" |
|
|
647 | */ |
|
|
648 | if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~') |
|
|
649 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
|
|
650 | |
|
|
651 | /* |
|
|
652 | * Pass meta for all function keys, if 'meta' option set |
|
|
653 | */ |
|
|
654 | #ifdef META8_OPTION |
|
|
655 | if (meta && (meta_char == 0x80)) |
|
|
656 | kbuf[len - 1] |= 0x80; |
|
|
657 | #endif |
|
|
658 | } |
|
|
659 | |
|
|
660 | } |
|
|
661 | else if (ctrl && keysym == XK_minus) |
|
|
662 | { |
|
|
663 | len = 1; |
|
|
664 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
665 | } |
|
|
666 | else if (keysym == XK_ISO_Left_Tab) |
|
|
667 | { |
|
|
668 | strcpy (kbuf, "\033[Z"); |
|
|
669 | len = 3; |
|
|
670 | } |
|
|
671 | else |
|
|
672 | { |
|
|
673 | #ifdef META8_OPTION |
|
|
674 | /* set 8-bit on */ |
|
|
675 | if (meta && (meta_char == 0x80)) |
|
|
676 | { |
|
|
677 | char *ch; |
|
|
678 | |
|
|
679 | for (ch = kbuf; ch < kbuf + len; ch++) |
|
|
680 | *ch |= 0x80; |
|
|
681 | } |
|
|
682 | #endif |
|
|
683 | /* nil */ ; |
|
|
684 | } |
|
|
685 | |
|
|
686 | keysym = orig_keysym; |
|
|
687 | } |
|
|
688 | |
|
|
689 | /* escape prefix */ |
|
|
690 | if (len && meta |
|
|
691 | #ifdef META8_OPTION |
|
|
692 | && meta_char == C0_ESC |
|
|
693 | #endif |
|
|
694 | ) |
|
|
695 | { |
|
|
696 | *--kbuf = C0_ESC; |
|
|
697 | len++; |
|
|
698 | } |
|
|
699 | |
|
|
700 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
701 | return; |
|
|
702 | |
|
|
703 | if (keysym != NoSymbol) |
|
|
704 | { |
|
|
705 | #ifdef KEYSYM_RESOURCE |
|
|
706 | if (keyboard->dispatch (this, keysym, ev.state, kbuf, len)) |
|
|
707 | return; |
|
|
708 | #endif |
|
|
709 | |
|
|
710 | if (saveLines) |
|
|
711 | { |
|
|
712 | #ifdef UNSHIFTED_SCROLLKEYS |
|
|
713 | if (!ctrl && !meta) |
|
|
714 | #else |
|
|
715 | if (IS_SCROLL_MOD) |
|
|
716 | #endif |
|
|
717 | { |
|
|
718 | int lnsppg; |
|
|
719 | |
|
|
720 | #ifdef PAGING_CONTEXT_LINES |
|
|
721 | lnsppg = nrow - PAGING_CONTEXT_LINES; |
|
|
722 | #else |
|
|
723 | lnsppg = nrow * 4 / 5; |
|
|
724 | #endif |
|
|
725 | max_it (lnsppg, 1); |
|
|
726 | |
|
|
727 | if (keysym == XK_Prior) |
|
|
728 | { |
|
|
729 | scr_page (lnsppg); |
924 | return s.reg; |
730 | return; |
|
|
731 | } |
|
|
732 | else if (keysym == XK_Next) |
|
|
733 | { |
|
|
734 | scr_page (-lnsppg); |
|
|
735 | return; |
|
|
736 | } |
|
|
737 | } |
|
|
738 | #ifdef SCROLL_ON_UPDOWN_KEYS |
|
|
739 | if (IS_SCROLL_MOD) |
|
|
740 | { |
|
|
741 | if (keysym == XK_Up) |
|
|
742 | { |
|
|
743 | scr_page (1); |
|
|
744 | return; |
|
|
745 | } |
|
|
746 | else if (keysym == XK_Down) |
|
|
747 | { |
|
|
748 | scr_page (-1); |
|
|
749 | return; |
|
|
750 | } |
|
|
751 | } |
|
|
752 | #endif |
|
|
753 | #ifdef SCROLL_ON_HOMEEND_KEYS |
|
|
754 | if (IS_SCROLL_MOD) |
|
|
755 | { |
|
|
756 | if (keysym == XK_Home) |
|
|
757 | { |
|
|
758 | scr_changeview (top_row); |
|
|
759 | return; |
|
|
760 | } |
|
|
761 | else if (keysym == XK_End) |
|
|
762 | { |
|
|
763 | scr_changeview (0); |
|
|
764 | return; |
|
|
765 | } |
|
|
766 | } |
|
|
767 | #endif |
|
|
768 | } |
925 | |
769 | |
926 | continue; |
770 | if (shft) |
|
|
771 | { |
|
|
772 | if (!ctrl && !meta && (priv_modes & PrivMode_ShiftKeys)) |
|
|
773 | { |
|
|
774 | switch (keysym) |
|
|
775 | { |
|
|
776 | /* normal XTerm key bindings */ |
|
|
777 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
|
|
778 | selection_request (ev.time); |
|
|
779 | return; |
|
|
780 | #if TODO |
|
|
781 | /* rxvt extras */ |
|
|
782 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
|
|
783 | return; |
|
|
784 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
|
|
785 | return; |
|
|
786 | #endif |
|
|
787 | } |
|
|
788 | } |
|
|
789 | } |
|
|
790 | |
|
|
791 | if (ctrl && meta && (keysym == XK_c || keysym == XK_v)) |
|
|
792 | { |
|
|
793 | if (keysym == XK_v) |
|
|
794 | selection_request (ev.time, Sel_Clipboard); |
|
|
795 | else if (selection.len > 0) |
|
|
796 | { |
|
|
797 | free (selection.clip_text); |
|
|
798 | selection.clip_text = rxvt_wcsdup (selection.text, selection.len); |
|
|
799 | selection.clip_len = selection.len; |
|
|
800 | selection_grab (CurrentTime, true); |
|
|
801 | } |
|
|
802 | |
|
|
803 | return; |
|
|
804 | } |
|
|
805 | |
|
|
806 | #if ENABLE_FRILLS || ISO_14755 |
|
|
807 | // ISO 14755 support |
|
|
808 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) |
|
|
809 | { |
|
|
810 | int hv; |
|
|
811 | |
|
|
812 | if (iso14755buf & ISO_14755_51 |
|
|
813 | && (keysym == XK_space || keysym == XK_KP_Space |
|
|
814 | || keysym == XK_Return || keysym == XK_KP_Enter)) |
|
|
815 | { |
|
|
816 | commit_iso14755 (); |
|
|
817 | iso14755buf = ISO_14755_51; |
|
|
818 | # if ISO_14755 |
|
|
819 | iso14755_51 (0); |
|
|
820 | # endif |
|
|
821 | return; |
|
|
822 | } |
|
|
823 | else if (keysym == XK_BackSpace) |
|
|
824 | { |
|
|
825 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
826 | # if ISO_14755 |
|
|
827 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
|
|
828 | # endif |
|
|
829 | return; |
|
|
830 | } |
|
|
831 | else if ((hv = hex_keyval (ev)) >= 0) |
|
|
832 | { |
|
|
833 | iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) |
|
|
834 | | hv | ISO_14755_51; |
|
|
835 | # if ISO_14755 |
|
|
836 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
|
|
837 | # endif |
|
|
838 | return; |
927 | } |
839 | } |
928 | else |
840 | else |
929 | { |
841 | { |
930 | s.cnt = 0; |
842 | # if ISO_14755 |
931 | return s.orig; /* the _occasional_ non-utf-8 character may slip through... */ |
843 | scr_overlay_off (); |
|
|
844 | # endif |
|
|
845 | iso14755buf = 0; |
932 | } |
846 | } |
933 | } |
847 | } |
|
|
848 | else if (option (Opt_iso14755) && |
|
|
849 | ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
|
|
850 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))) |
|
|
851 | if (!(iso14755buf & ISO_14755_STARTED)) |
|
|
852 | { |
|
|
853 | iso14755buf |= ISO_14755_STARTED; |
|
|
854 | # if ISO_14755 |
|
|
855 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
|
|
856 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
|
|
857 | # endif |
|
|
858 | } |
|
|
859 | #endif |
|
|
860 | |
|
|
861 | #ifdef PRINTPIPE |
|
|
862 | if (keysym == XK_Print) |
|
|
863 | { |
|
|
864 | scr_printscreen (ctrl | shft); |
|
|
865 | return; |
|
|
866 | } |
|
|
867 | #endif |
|
|
868 | } |
|
|
869 | |
|
|
870 | if (len <= 0) |
|
|
871 | return; /* not mapped */ |
|
|
872 | |
|
|
873 | tt_write_user_input (kbuf, (unsigned int)len); |
|
|
874 | } |
|
|
875 | |
|
|
876 | void ecb_cold |
|
|
877 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
878 | { |
|
|
879 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
880 | KeySym keysym; |
|
|
881 | |
|
|
882 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
883 | #endif |
|
|
884 | |
|
|
885 | #if ENABLE_FRILLS || ISO_14755 |
|
|
886 | // ISO 14755 support |
|
|
887 | if (iso14755buf) |
|
|
888 | if (iso14755buf & ISO_14755_52) |
934 | |
889 | { |
935 | if ((ch & 0xc0) == 0xc0) |
890 | # if ISO_14755 |
|
|
891 | scr_overlay_off (); |
|
|
892 | # endif |
|
|
893 | # if ISO_14755 |
|
|
894 | // iso14755 part 5.2 handling: release time |
|
|
895 | // first: controls |
|
|
896 | if ((ev.state & ControlMask) |
|
|
897 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
898 | || (keysym >= 0x61 && keysym <= 0x7f))) |
936 | { |
899 | { |
937 | cmdbuf_ptr++; |
900 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
901 | commit_iso14755 (); |
938 | |
902 | |
939 | /* first byte */ |
903 | return; |
940 | s.orig = ch; /* for broken encodings */ |
|
|
941 | s.reg = ch; |
|
|
942 | if ((ch & 0xe0) == 0xc0) { s.reg &= 0x1f; s.cnt = 1; } |
|
|
943 | if ((ch & 0xf0) == 0xe0) { s.reg &= 0x0f; s.cnt = 2; } |
|
|
944 | if ((ch & 0xf8) == 0xf0) { s.reg &= 0x07; s.cnt = 3; } |
|
|
945 | if ((ch & 0xfc) == 0xf8) { s.reg &= 0x03; s.cnt = 4; } |
|
|
946 | if ((ch & 0xfe) == 0xfc) { s.reg &= 0x01; s.cnt = 5; } |
|
|
947 | } |
904 | } |
948 | else |
905 | |
|
|
906 | for (unsigned short *i = iso14755_symtab; i[0]; i += 2) |
|
|
907 | if (i[0] == keysym) |
949 | { |
908 | { |
950 | cmdbuf_ptr++; /* _occasional_ non-utf8 may slip through... */ |
909 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
910 | commit_iso14755 (); |
|
|
911 | |
951 | return ch; |
912 | return; |
952 | } |
913 | } |
953 | } |
|
|
954 | |
914 | |
955 | return NOCHAR; |
915 | scr_bell (); |
956 | } |
916 | # endif |
|
|
917 | iso14755buf = 0; |
957 | |
918 | |
958 | /* rxvt_cmd_getc() - Return next input character */ |
|
|
959 | /* |
|
|
960 | * Return the next input character after first passing any keyboard input |
|
|
961 | * to the command. |
|
|
962 | */ |
|
|
963 | /* INTPROTO */ |
|
|
964 | uint32_t |
|
|
965 | rxvt_cmd_getc(pR) |
|
|
966 | { |
|
|
967 | for (;;) |
|
|
968 | { |
|
|
969 | uint32_t c = R->next_char (); |
|
|
970 | if (c != NOCHAR) |
|
|
971 | return c; |
919 | return; |
972 | |
|
|
973 | // incomplete sequences should occur rarely, still, a better solution |
|
|
974 | // would be preferred. either setjmp/longjmp or better design. |
|
|
975 | fcntl (R->cmd_fd, F_SETFL, 0); |
|
|
976 | R->pty_fill (); |
|
|
977 | fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); |
|
|
978 | } |
920 | } |
979 | |
921 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
980 | #if 0 |
922 | { |
981 | #define TIMEOUT_USEC 5000 |
923 | # if ISO_14755 |
982 | fd_set readfds; |
924 | scr_overlay_off (); |
983 | int quick_timeout, select_res; |
|
|
984 | int want_motion_time, want_keypress_time; |
|
|
985 | struct timeval value; |
|
|
986 | #if defined(POINTER_BLANK) || defined(CURSOR_BLINK) |
|
|
987 | struct timeval tp; |
|
|
988 | #endif |
925 | # endif |
|
|
926 | if (iso14755buf & ISO_14755_51) |
|
|
927 | commit_iso14755 (); |
|
|
928 | #if ISO_14755 |
|
|
929 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
930 | { |
|
|
931 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
989 | |
932 | |
990 | for (;;) { |
933 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
991 | /* loop until we can return something */ |
934 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
935 | } |
|
|
936 | # endif |
|
|
937 | else |
|
|
938 | iso14755buf = 0; |
|
|
939 | } |
|
|
940 | #endif |
992 | |
941 | |
993 | if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ |
942 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
994 | R->tt_write(NULL, 0); |
943 | return; |
995 | |
944 | |
996 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
945 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
997 | if (R->mouse_slip_wheel_speed) { |
946 | if (!(ev.state & ControlMask)) |
998 | quick_timeout = 1; |
947 | slip_wheel_ev.stop (); |
999 | if (!R->mouse_slip_wheel_delay-- |
948 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1000 | && rxvt_scr_page(aR_ R->mouse_slip_wheel_speed > 0 ? UP : DN, |
949 | mouse_slip_wheel_speed = 0; |
1001 | abs(R->mouse_slip_wheel_speed))) { |
950 | #endif |
1002 | R->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
951 | } |
1003 | R->refresh_type |= SMOOTH_REFRESH; |
952 | |
1004 | R->want_refresh = 1; |
953 | void |
|
|
954 | rxvt_term::flush () |
|
|
955 | { |
|
|
956 | flush_ev.stop (); |
|
|
957 | |
|
|
958 | #ifdef HAVE_IMG |
|
|
959 | if (bg_flags & BG_NEEDS_REFRESH) |
|
|
960 | { |
|
|
961 | bg_flags &= ~BG_NEEDS_REFRESH; |
|
|
962 | scr_touch (false); |
1005 | } |
963 | } |
1006 | } |
964 | #endif |
1007 | #endif /* MOUSE_WHEEL && MOUSE_SLIP_WHEELING */ |
965 | |
|
|
966 | if (want_refresh) |
|
|
967 | { |
|
|
968 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
969 | { |
|
|
970 | int row = view_start; |
|
|
971 | int end_row = row + nrow; |
|
|
972 | |
|
|
973 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
974 | --row; |
|
|
975 | |
|
|
976 | do |
|
|
977 | { |
|
|
978 | int start_row = row; |
|
|
979 | line_t *l; |
|
|
980 | |
|
|
981 | do |
|
|
982 | { |
|
|
983 | l = &ROW (row++); |
|
|
984 | |
|
|
985 | if (!(l->f & LINE_FILTERED)) |
|
|
986 | { |
|
|
987 | // line not filtered, mark it as filtered |
|
|
988 | l->f |= LINE_FILTERED; |
|
|
989 | while (l->is_longer ()) |
|
|
990 | { |
|
|
991 | l = &ROW (row++); |
|
|
992 | l->f |= LINE_FILTERED; |
|
|
993 | } |
|
|
994 | |
|
|
995 | // and filter it |
|
|
996 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
997 | |
|
|
998 | break; |
|
|
999 | } |
|
|
1000 | } |
|
|
1001 | while (l->is_longer () && row < end_row); |
|
|
1002 | } |
|
|
1003 | while (row < end_row); |
|
|
1004 | } |
|
|
1005 | |
|
|
1006 | scr_refresh (); |
|
|
1007 | scrollBar.show (1); |
|
|
1008 | #if USE_XIM |
|
|
1009 | im_send_spot (); |
|
|
1010 | #endif |
|
|
1011 | } |
|
|
1012 | |
|
|
1013 | display->flush (); |
|
|
1014 | } |
|
|
1015 | |
|
|
1016 | /* checks whether a refresh is requested and starts the refresh timer */ |
|
|
1017 | void |
|
|
1018 | rxvt_term::refresh_check () |
|
|
1019 | { |
|
|
1020 | if (want_refresh && !flush_ev.is_active ()) |
|
|
1021 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
|
|
1022 | |
|
|
1023 | display->flush (); |
|
|
1024 | } |
|
|
1025 | |
|
|
1026 | void |
|
|
1027 | rxvt_term::flush_cb (ev::timer &w, int revents) |
|
|
1028 | { |
|
|
1029 | make_current (); |
|
|
1030 | |
|
|
1031 | refresh_count = 0; |
|
|
1032 | flush (); |
|
|
1033 | } |
|
|
1034 | |
|
|
1035 | #ifdef CURSOR_BLINK |
|
|
1036 | void |
|
|
1037 | rxvt_term::cursor_blink_reset () |
|
|
1038 | { |
|
|
1039 | if (!focus) |
|
|
1040 | return; |
|
|
1041 | |
|
|
1042 | if (hidden_cursor) |
|
|
1043 | { |
|
|
1044 | hidden_cursor = 0; |
|
|
1045 | want_refresh = 1; |
|
|
1046 | } |
|
|
1047 | |
|
|
1048 | if (option (Opt_cursorBlink) || (priv_modes & PrivMode_BlinkingCursor)) |
|
|
1049 | cursor_blink_ev.again (); |
|
|
1050 | else |
|
|
1051 | cursor_blink_ev.stop (); |
|
|
1052 | } |
|
|
1053 | |
|
|
1054 | void |
|
|
1055 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
|
|
1056 | { |
|
|
1057 | hidden_cursor = !hidden_cursor; |
|
|
1058 | want_refresh = 1; |
|
|
1059 | refresh_check (); |
|
|
1060 | } |
|
|
1061 | #endif |
|
|
1062 | |
|
|
1063 | #ifdef TEXT_BLINK |
|
|
1064 | void |
|
|
1065 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
|
|
1066 | { |
|
|
1067 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
|
|
1068 | { |
|
|
1069 | hidden_text = !hidden_text; |
|
|
1070 | want_refresh = 1; |
|
|
1071 | refresh_check (); |
|
|
1072 | } |
|
|
1073 | else |
|
|
1074 | w.stop (); |
|
|
1075 | } |
|
|
1076 | #endif |
|
|
1077 | |
|
|
1078 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1079 | void |
|
|
1080 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
|
|
1081 | { |
|
|
1082 | if ((scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) |
|
|
1083 | && scr_page (scrollBar.state == SB_STATE_UP ? UP : DN, 1)) |
|
|
1084 | { |
|
|
1085 | want_refresh = 1; |
|
|
1086 | refresh_check (); |
|
|
1087 | } |
|
|
1088 | else |
|
|
1089 | w.stop (); |
|
|
1090 | } |
|
|
1091 | #endif |
|
|
1092 | |
1008 | #ifdef SELECTION_SCROLLING |
1093 | #ifdef SELECTION_SCROLLING |
1009 | if (R->pending_scroll_selection) { |
|
|
1010 | quick_timeout = 1; |
|
|
1011 | if (!R->scroll_selection_delay-- |
|
|
1012 | && rxvt_scr_page(aR_ R->scroll_selection_dir, |
|
|
1013 | R->scroll_selection_lines)) { |
|
|
1014 | rxvt_selection_extend(aR_ R->selection_save_x, |
|
|
1015 | R->selection_save_y, R->selection_save_state); |
|
|
1016 | R->scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY; |
|
|
1017 | R->refresh_type |= SMOOTH_REFRESH; |
|
|
1018 | R->want_refresh = 1; |
|
|
1019 | } |
|
|
1020 | } |
|
|
1021 | #endif |
|
|
1022 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1023 | if (scrollbar_isUp() || scrollbar_isDn()) { |
|
|
1024 | quick_timeout = 1; |
|
|
1025 | if (!R->scroll_arrow_delay-- |
|
|
1026 | && rxvt_scr_page(aR_ scrollbar_isUp() ? UP : DN, 1)) { |
|
|
1027 | R->scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; |
|
|
1028 | R->refresh_type |= SMOOTH_REFRESH; |
|
|
1029 | R->want_refresh = 1; |
|
|
1030 | } |
|
|
1031 | } |
|
|
1032 | #endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ |
|
|
1033 | |
|
|
1034 | #ifdef TRANSPARENT |
|
|
1035 | quick_timeout |= R->want_full_refresh; |
|
|
1036 | #endif |
|
|
1037 | #endif |
|
|
1038 | } |
|
|
1039 | |
|
|
1040 | void |
1094 | void |
|
|
1095 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
|
|
1096 | { |
|
|
1097 | if (scr_page (scroll_selection_lines)) |
|
|
1098 | { |
|
|
1099 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
|
|
1100 | want_refresh = 1; |
|
|
1101 | refresh_check (); |
|
|
1102 | } |
|
|
1103 | else |
|
|
1104 | w.stop (); |
|
|
1105 | } |
|
|
1106 | #endif |
|
|
1107 | |
|
|
1108 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1109 | void |
|
|
1110 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
|
|
1111 | { |
|
|
1112 | if (scr_page (mouse_slip_wheel_speed)) |
|
|
1113 | { |
|
|
1114 | want_refresh = 1; |
|
|
1115 | refresh_check (); |
|
|
1116 | } |
|
|
1117 | |
|
|
1118 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
|
|
1119 | { |
|
|
1120 | mouse_slip_wheel_speed = 0; |
|
|
1121 | w.stop (); |
|
|
1122 | } |
|
|
1123 | } |
|
|
1124 | #endif |
|
|
1125 | |
|
|
1126 | #if LINUX_YIELD_HACK |
|
|
1127 | static struct event_handler |
|
|
1128 | { |
|
|
1129 | ev::prepare yield_ev; |
|
|
1130 | |
|
|
1131 | void yield_cb (ev::prepare &w, int revents) |
|
|
1132 | { |
|
|
1133 | // this should really be sched_yield(), but the linux guys thought |
|
|
1134 | // that giving a process calling sched_yield () less cpu time than |
|
|
1135 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1136 | // allowed by the sus... as is returning ENOSYS. |
|
|
1137 | // since the linux guys additionally thought that breaking the only |
|
|
1138 | // known workaround against their unusable sched_yield hack is cool, |
|
|
1139 | // we just nanosleep a bit and hope for the best. |
|
|
1140 | |
|
|
1141 | struct timespec ts = { 0, 1000 }; |
|
|
1142 | nanosleep (&ts, 0); |
|
|
1143 | |
|
|
1144 | w.stop (); |
|
|
1145 | } |
|
|
1146 | |
|
|
1147 | event_handler () |
|
|
1148 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1149 | { |
|
|
1150 | } |
|
|
1151 | } event_handler; |
|
|
1152 | #endif |
|
|
1153 | |
|
|
1154 | /* make sure all the cmd data is at beginning of cmdbuf */ |
|
|
1155 | void |
|
|
1156 | rxvt_term::cmdbuf_reify () |
|
|
1157 | { |
|
|
1158 | if (cmdbuf_ptr == cmdbuf_base) |
|
|
1159 | return; |
|
|
1160 | |
|
|
1161 | ssize_t used = cmdbuf_endp - cmdbuf_ptr; |
|
|
1162 | |
|
|
1163 | memmove (cmdbuf_base, cmdbuf_ptr, used); |
|
|
1164 | cmdbuf_ptr = cmdbuf_base; |
|
|
1165 | cmdbuf_endp = cmdbuf_ptr + used; |
|
|
1166 | |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | #if defined (KEYSYM_RESOURCE) |
|
|
1170 | void |
|
|
1171 | rxvt_term::cmdbuf_append (const char *str, size_t count) |
|
|
1172 | { |
|
|
1173 | cmdbuf_reify (); |
|
|
1174 | |
|
|
1175 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
|
|
1176 | |
|
|
1177 | if (count > avail) |
|
|
1178 | return; |
|
|
1179 | |
|
|
1180 | memcpy (cmdbuf_endp, str, count); |
|
|
1181 | cmdbuf_endp += count; |
|
|
1182 | |
|
|
1183 | cmd_parse (); |
|
|
1184 | } |
|
|
1185 | #endif |
|
|
1186 | |
|
|
1187 | bool |
|
|
1188 | rxvt_term::pty_fill () |
|
|
1189 | { |
|
|
1190 | cmdbuf_reify (); |
|
|
1191 | |
|
|
1192 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
|
|
1193 | |
|
|
1194 | if (!avail) |
|
|
1195 | { |
|
|
1196 | // normally this indicates a "too long" command sequence - just drop the data we have |
|
|
1197 | cmdbuf_ptr = cmdbuf_base; |
|
|
1198 | cmdbuf_endp = cmdbuf_ptr; |
|
|
1199 | avail = CBUFSIZ; |
|
|
1200 | } |
|
|
1201 | |
|
|
1202 | ssize_t r = read (pty->pty, cmdbuf_endp, avail); |
|
|
1203 | |
|
|
1204 | if (r > 0) |
|
|
1205 | { |
|
|
1206 | cmdbuf_endp += r; |
|
|
1207 | return true; |
|
|
1208 | } |
|
|
1209 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1210 | { |
|
|
1211 | #if LINUX_YIELD_HACK |
|
|
1212 | if (display->is_local) |
|
|
1213 | event_handler.yield_ev.start (); |
|
|
1214 | #endif |
|
|
1215 | } |
|
|
1216 | else |
|
|
1217 | { |
|
|
1218 | pty_ev.stop (); |
|
|
1219 | |
|
|
1220 | if (!option (Opt_hold)) |
|
|
1221 | destroy (); |
|
|
1222 | } |
|
|
1223 | |
|
|
1224 | return false; |
|
|
1225 | } |
|
|
1226 | |
|
|
1227 | void |
|
|
1228 | rxvt_term::pty_cb (ev::io &w, int revents) |
|
|
1229 | { |
|
|
1230 | make_current (); |
|
|
1231 | |
|
|
1232 | if (revents & ev::READ) |
|
|
1233 | // loop, but don't allow a single term to monopolize us |
|
|
1234 | for (int i = CBUFCNT; i-- && pty_fill (); ) |
|
|
1235 | cmd_parse (); |
|
|
1236 | |
|
|
1237 | if (revents & ev::WRITE) |
|
|
1238 | pty_write (); |
|
|
1239 | |
|
|
1240 | refresh_check (); |
|
|
1241 | } |
|
|
1242 | |
|
|
1243 | void ecb_cold |
1041 | rxvt_term::pointer_unblank () |
1244 | rxvt_term::pointer_unblank () |
1042 | { |
1245 | { |
1043 | XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); |
1246 | XDefineCursor (dpy, vt, TermWin_cursor); |
1044 | recolour_cursor (); |
1247 | recolor_cursor (); |
1045 | |
1248 | |
1046 | #ifdef POINTER_BLANK |
1249 | #ifdef POINTER_BLANK |
1047 | hidden_pointer = 0; |
1250 | hidden_pointer = 0; |
1048 | |
1251 | |
1049 | if (Options & Opt_pointerBlank) |
1252 | if (option (Opt_pointerBlank)) |
1050 | pointer_ev.start (NOW + pointerBlankDelay); |
1253 | pointer_ev.start (pointerBlankDelay); |
1051 | #endif |
1254 | #endif |
1052 | } |
1255 | } |
1053 | |
1256 | |
1054 | #ifdef POINTER_BLANK |
1257 | #ifdef POINTER_BLANK |
|
|
1258 | void ecb_cold |
|
|
1259 | rxvt_term::pointer_blank () |
|
|
1260 | { |
|
|
1261 | if (!option (Opt_pointerBlank)) |
|
|
1262 | return; |
|
|
1263 | |
|
|
1264 | XDefineCursor (dpy, vt, display->blank_cursor); |
|
|
1265 | XFlush (dpy); |
|
|
1266 | |
|
|
1267 | hidden_pointer = 1; |
|
|
1268 | } |
|
|
1269 | |
|
|
1270 | void ecb_cold |
|
|
1271 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
|
|
1272 | { |
|
|
1273 | make_current (); |
|
|
1274 | |
|
|
1275 | pointer_blank (); |
|
|
1276 | } |
|
|
1277 | #endif |
|
|
1278 | |
1055 | void |
1279 | void |
1056 | rxvt_term::pointer_blank () |
1280 | rxvt_term::mouse_report (XButtonEvent &ev) |
1057 | { |
1281 | { |
1058 | pointer_ev.stop (); |
1282 | int button_number, state = 0; |
|
|
1283 | int x, y; |
|
|
1284 | bool release = ev.type == ButtonRelease; |
1059 | |
1285 | |
1060 | if (!(Options & Opt_pointerBlank)) |
1286 | x = Pixel2Col (ev.x) + 1; |
|
|
1287 | y = Pixel2Row (ev.y) + 1; |
|
|
1288 | |
|
|
1289 | if (ev.type == MotionNotify) |
|
|
1290 | { |
|
|
1291 | if (x == mouse_row && y == mouse_col) |
|
|
1292 | return; |
|
|
1293 | |
|
|
1294 | mouse_row = x; |
|
|
1295 | mouse_col = y; |
|
|
1296 | state += 32; |
|
|
1297 | } |
|
|
1298 | |
|
|
1299 | button_number = MEvent.button - Button1; |
|
|
1300 | /* add 0x3D for wheel events, like xterm does */ |
|
|
1301 | if (button_number >= 3) |
|
|
1302 | button_number += 64 - 3; |
|
|
1303 | |
|
|
1304 | if (priv_modes & PrivMode_MouseX10) |
|
|
1305 | { |
|
|
1306 | /* |
|
|
1307 | * do not report ButtonRelease |
|
|
1308 | * no state info allowed |
|
|
1309 | */ |
|
|
1310 | if (release) |
|
|
1311 | return; |
|
|
1312 | } |
|
|
1313 | else |
|
|
1314 | { |
|
|
1315 | /* XTerm mouse reporting needs these values: |
|
|
1316 | * 4 = Shift |
|
|
1317 | * 8 = Meta |
|
|
1318 | * 16 = Control |
|
|
1319 | * plus will add in our own Double-Click reporting |
|
|
1320 | * 32 = Double Click |
|
|
1321 | */ |
|
|
1322 | state += ((MEvent.state & ShiftMask) ? 4 : 0) |
|
|
1323 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
|
|
1324 | + ((MEvent.state & ControlMask) ? 16 : 0); |
|
|
1325 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1326 | state += ((MEvent.clicks > 1) ? 32 : 0); |
|
|
1327 | #endif |
|
|
1328 | } |
|
|
1329 | |
|
|
1330 | int code = 32 + (release ? 3 : button_number) + state; |
|
|
1331 | |
|
|
1332 | #if DEBUG_MOUSEREPORT |
|
|
1333 | fprintf (stderr, "Mouse ["); |
|
|
1334 | if (state & 16) |
|
|
1335 | fputc ('C', stderr); |
|
|
1336 | if (state & 4) |
|
|
1337 | fputc ('S', stderr); |
|
|
1338 | if (state & 8) |
|
|
1339 | fputc ('A', stderr); |
|
|
1340 | if (state & 32) |
|
|
1341 | fputc ('2', stderr); |
|
|
1342 | fprintf (stderr, "]: <%d>, %d/%d\n", |
|
|
1343 | button_number, |
|
|
1344 | x, |
|
|
1345 | y); |
|
|
1346 | #endif |
|
|
1347 | |
|
|
1348 | #if ENABLE_FRILLS |
|
|
1349 | if (priv_modes & PrivMode_ExtMouseSGR) |
|
|
1350 | tt_printf ("\033[<%d;%d;%d%c", |
|
|
1351 | button_number + state, |
|
|
1352 | x, |
|
|
1353 | y, |
|
|
1354 | release ? 'm' : 'M'); |
|
|
1355 | else if (priv_modes & PrivMode_ExtMouseUrxvt) |
|
|
1356 | tt_printf ("\033[%d;%d;%dM", |
|
|
1357 | code, |
|
|
1358 | x, |
|
|
1359 | y); |
|
|
1360 | else if (priv_modes & PrivMode_ExtMouseUTF8) |
|
|
1361 | tt_printf ("\033[M%c%lc%lc", |
|
|
1362 | code, |
|
|
1363 | wint_t (32 + x), |
|
|
1364 | wint_t (32 + y)); |
|
|
1365 | else |
|
|
1366 | #endif |
|
|
1367 | tt_printf ("\033[M%c%c%c", |
|
|
1368 | code, |
|
|
1369 | 32 + x, |
|
|
1370 | 32 + y); |
|
|
1371 | } |
|
|
1372 | |
|
|
1373 | /*{{{ process an X event */ |
|
|
1374 | void ecb_hot |
|
|
1375 | rxvt_term::x_cb (XEvent &ev) |
|
|
1376 | { |
|
|
1377 | make_current (); |
|
|
1378 | |
|
|
1379 | dLocal (Display *, dpy); |
|
|
1380 | |
|
|
1381 | if (ev.xany.window == vt |
|
|
1382 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1383 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1061 | return; |
1384 | return; |
1062 | |
1385 | |
1063 | XDefineCursor (Xdisplay, TermWin.vt, blank_cursor); |
1386 | // for XQueryPointer |
1064 | XFlush (Xdisplay); |
|
|
1065 | |
|
|
1066 | hidden_pointer = 1; |
|
|
1067 | } |
|
|
1068 | |
|
|
1069 | void |
|
|
1070 | rxvt_term::pointer_cb (time_watcher &w) |
|
|
1071 | { |
|
|
1072 | SET_R (this); |
|
|
1073 | SET_LOCALE (locale); |
|
|
1074 | |
|
|
1075 | pointer_blank (); |
|
|
1076 | } |
|
|
1077 | #endif |
|
|
1078 | |
|
|
1079 | /* INTPROTO */ |
|
|
1080 | void |
|
|
1081 | rxvt_mouse_report(pR_ const XButtonEvent *ev) |
|
|
1082 | { |
|
|
1083 | int button_number, key_state = 0; |
|
|
1084 | int x, y; |
|
|
1085 | |
|
|
1086 | x = ev->x; |
|
|
1087 | y = ev->y; |
|
|
1088 | rxvt_pixel_position(aR_ &x, &y); |
|
|
1089 | |
|
|
1090 | if (R->MEvent.button == AnyButton) { |
|
|
1091 | button_number = 3; |
|
|
1092 | } else { |
|
|
1093 | button_number = R->MEvent.button - Button1; |
|
|
1094 | /* add 0x3D for wheel events, like xterm does */ |
|
|
1095 | if (button_number >= 3) |
|
|
1096 | button_number += (64 - 3); |
|
|
1097 | } |
|
|
1098 | |
|
|
1099 | if (R->PrivateModes & PrivMode_MouseX10) { |
|
|
1100 | /* |
|
|
1101 | * do not report ButtonRelease |
|
|
1102 | * no state info allowed |
|
|
1103 | */ |
|
|
1104 | key_state = 0; |
|
|
1105 | if (button_number == 3) |
|
|
1106 | return; |
|
|
1107 | } else { |
|
|
1108 | /* XTerm mouse reporting needs these values: |
|
|
1109 | * 4 = Shift |
|
|
1110 | * 8 = Meta |
|
|
1111 | * 16 = Control |
|
|
1112 | * plus will add in our own Double-Click reporting |
|
|
1113 | * 32 = Double Click |
|
|
1114 | */ |
|
|
1115 | key_state = ((R->MEvent.state & ShiftMask) ? 4 : 0) |
|
|
1116 | + ((R->MEvent.state & R->ModMetaMask) ? 8 : 0) |
|
|
1117 | + ((R->MEvent.state & ControlMask) ? 16 : 0); |
|
|
1118 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1119 | key_state += ((R->MEvent.clicks > 1) ? 32 : 0); |
|
|
1120 | #endif |
|
|
1121 | } |
|
|
1122 | |
|
|
1123 | #ifdef DEBUG_MOUSEREPORT |
|
|
1124 | fprintf(stderr, "Mouse ["); |
|
|
1125 | if (key_state & 16) |
|
|
1126 | fputc('C', stderr); |
|
|
1127 | if (key_state & 4) |
|
|
1128 | fputc('S', stderr); |
|
|
1129 | if (key_state & 8) |
|
|
1130 | fputc('A', stderr); |
|
|
1131 | if (key_state & 32) |
|
|
1132 | fputc('2', stderr); |
|
|
1133 | fprintf(stderr, "]: <%d>, %d/%d\n", |
|
|
1134 | button_number, |
|
|
1135 | x + 1, |
|
|
1136 | y + 1); |
|
|
1137 | #else |
|
|
1138 | R->tt_printf("\033[M%c%c%c", |
|
|
1139 | (32 + button_number + key_state), |
|
|
1140 | (32 + x + 1), |
|
|
1141 | (32 + y + 1)); |
|
|
1142 | #endif |
|
|
1143 | } |
|
|
1144 | |
|
|
1145 | #ifdef USING_W11LIB |
|
|
1146 | /* EXTPROTO */ |
|
|
1147 | void |
|
|
1148 | rxvt_W11_process_x_event(XEvent *ev) |
|
|
1149 | { |
|
|
1150 | rxvt_t *r = rxvt_get_r(); |
|
|
1151 | |
|
|
1152 | rxvt_process_x_event(aR_ ev); |
|
|
1153 | } |
|
|
1154 | #endif |
|
|
1155 | |
|
|
1156 | /*{{{ process an X event */ |
|
|
1157 | /* INTPROTO */ |
|
|
1158 | void |
|
|
1159 | rxvt_process_x_event(pR_ XEvent *ev) |
|
|
1160 | { |
|
|
1161 | int i, want_timeout; |
|
|
1162 | Window unused_root, unused_child; |
1387 | Window unused_root, unused_child; |
1163 | int unused_root_x, unused_root_y; |
1388 | int unused_root_x, unused_root_y; |
1164 | unsigned int unused_mask; |
1389 | unsigned int unused_mask; |
1165 | |
1390 | |
1166 | #ifdef DEBUG_X |
|
|
1167 | const char *const eventnames[] = |
|
|
1168 | { /* mason - this matches my system */ |
|
|
1169 | "", |
|
|
1170 | "", |
|
|
1171 | "KeyPress", |
|
|
1172 | "KeyRelease", |
|
|
1173 | "ButtonPress", |
|
|
1174 | "ButtonRelease", |
|
|
1175 | "MotionNotify", |
|
|
1176 | "EnterNotify", |
|
|
1177 | "LeaveNotify", |
|
|
1178 | "FocusIn", |
|
|
1179 | "FocusOut", |
|
|
1180 | "KeymapNotify", |
|
|
1181 | "Expose", |
|
|
1182 | "GraphicsExpose", |
|
|
1183 | "NoExpose", |
|
|
1184 | "VisibilityNotify", |
|
|
1185 | "CreateNotify", |
|
|
1186 | "DestroyNotify", |
|
|
1187 | "UnmapNotify", |
|
|
1188 | "MapNotify", |
|
|
1189 | "MapRequest", |
|
|
1190 | "ReparentNotify", |
|
|
1191 | "ConfigureNotify", |
|
|
1192 | "ConfigureRequest", |
|
|
1193 | "GravityNotify", |
|
|
1194 | "ResizeRequest", |
|
|
1195 | "CirculateNotify", |
|
|
1196 | "CirculateRequest", |
|
|
1197 | "PropertyNotify", |
|
|
1198 | "SelectionClear", |
|
|
1199 | "SelectionRequest", |
|
|
1200 | "SelectionNotify", |
|
|
1201 | "ColormapNotify", |
|
|
1202 | "ClientMessage", |
|
|
1203 | "MappingNotify" |
|
|
1204 | }; |
|
|
1205 | #endif |
|
|
1206 | |
|
|
1207 | #ifdef DEBUG_X |
|
|
1208 | struct timeval tp; |
|
|
1209 | struct tm *ltt; |
|
|
1210 | (void)gettimeofday(&tp, NULL); |
|
|
1211 | ltt = localtime(&(tp.tv_sec)); |
|
|
1212 | D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); |
|
|
1213 | #endif |
|
|
1214 | |
|
|
1215 | switch (ev->type) { |
1391 | switch (ev.type) |
|
|
1392 | { |
1216 | case KeyPress: |
1393 | case KeyPress: |
1217 | rxvt_lookup_key(aR_ (XKeyEvent *)ev); |
1394 | key_press (ev.xkey); |
1218 | break; |
1395 | break; |
1219 | |
1396 | |
1220 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1221 | case KeyRelease: |
1397 | case KeyRelease: |
1222 | { |
1398 | key_release (ev.xkey); |
1223 | if (!(ev->xkey.state & ControlMask)) |
|
|
1224 | R->mouse_slip_wheel_speed = 0; |
|
|
1225 | else { |
|
|
1226 | KeySym ks; |
|
|
1227 | |
|
|
1228 | ks = XKeycodeToKeysym(R->Xdisplay, ev->xkey.keycode, 0); |
|
|
1229 | if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1230 | R->mouse_slip_wheel_speed = 0; |
|
|
1231 | } |
|
|
1232 | break; |
1399 | break; |
1233 | } |
|
|
1234 | #endif |
|
|
1235 | |
1400 | |
1236 | case ButtonPress: |
1401 | case ButtonPress: |
1237 | rxvt_button_press(aR_ (XButtonEvent *)ev); |
1402 | button_press (ev.xbutton); |
1238 | break; |
1403 | break; |
1239 | |
1404 | |
1240 | case ButtonRelease: |
1405 | case ButtonRelease: |
1241 | rxvt_button_release(aR_ (XButtonEvent *)ev); |
1406 | button_release (ev.xbutton); |
1242 | break; |
1407 | break; |
1243 | |
1408 | |
1244 | case ClientMessage: |
1409 | case ClientMessage: |
1245 | if (ev->xclient.format == 32 |
1410 | if (ev.xclient.format == 32 |
1246 | && (Atom)ev->xclient.data.l[0] == R->xa[XA_WMDELETEWINDOW]) |
1411 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1247 | R->destroy (); |
1412 | { |
1248 | #ifdef OFFIX_DND |
|
|
1249 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1250 | else if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] |
1413 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1251 | && (ev->xclient.data.l[0] == DndFile |
1414 | { |
1252 | || ev->xclient.data.l[0] == DndDir |
1415 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
1253 | || ev->xclient.data.l[0] == DndLink)) { |
1416 | { |
1254 | /* Get Dnd data */ |
1417 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1255 | Atom ActualType; |
1418 | { |
1256 | int ActualFormat; |
1419 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1257 | unsigned char *data; |
1420 | destroy (); |
1258 | unsigned long Size, RemainingBytes; |
1421 | } |
|
|
1422 | #if ENABLE_EWMH |
|
|
1423 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
|
|
1424 | XSendEvent (dpy, ev.xclient.window = display->root, |
|
|
1425 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
|
|
1426 | &ev); |
|
|
1427 | #endif |
|
|
1428 | } |
|
|
1429 | } |
|
|
1430 | #if ENABLE_XEMBED |
|
|
1431 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1432 | { |
|
|
1433 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1434 | focus_in (); |
|
|
1435 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1436 | focus_out (); |
|
|
1437 | } |
|
|
1438 | #endif |
|
|
1439 | } |
|
|
1440 | break; |
1259 | |
1441 | |
1260 | XGetWindowProperty(R->Xdisplay, Xroot, |
|
|
1261 | R->xa[XA_DNDSELECTION], |
|
|
1262 | 0L, 1000000L, |
|
|
1263 | False, AnyPropertyType, |
|
|
1264 | &ActualType, &ActualFormat, |
|
|
1265 | &Size, &RemainingBytes, |
|
|
1266 | &data); |
|
|
1267 | XChangeProperty(R->Xdisplay, Xroot, |
|
|
1268 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1269 | 8, PropModeReplace, |
|
|
1270 | data, STRLEN(data)); |
|
|
1271 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, True); |
|
|
1272 | XSetInputFocus(R->Xdisplay, Xroot, RevertToNone, CurrentTime); |
|
|
1273 | } |
|
|
1274 | #endif /* OFFIX_DND */ |
|
|
1275 | break; |
|
|
1276 | |
|
|
1277 | case MappingNotify: |
|
|
1278 | XRefreshKeyboardMapping(&(ev->xmapping)); |
|
|
1279 | break; |
|
|
1280 | |
|
|
1281 | /* |
1442 | /* |
1282 | * XXX: this is not the _current_ arrangement |
1443 | * XXX: this is not the _current_ arrangement |
1283 | * Here's my conclusion: |
1444 | * Here's my conclusion: |
1284 | * If the window is completely unobscured, use bitblt's |
1445 | * If the window is completely unobscured, use bitblt's |
1285 | * to scroll. Even then, they're only used when doing partial |
1446 | * to scroll. Even then, they're only used when doing partial |
1286 | * screen scrolling. When partially obscured, we have to fill |
1447 | * screen scrolling. When partially obscured, we have to fill |
1287 | * in the GraphicsExpose parts, which means that after each refresh, |
1448 | * in the GraphicsExpose parts, which means that after each refresh, |
1288 | * we need to wait for the graphics expose or Noexpose events, |
1449 | * we need to wait for the graphics expose or Noexpose events, |
1289 | * which ought to make things real slow! |
1450 | * which ought to make things real slow! |
1290 | */ |
1451 | */ |
1291 | case VisibilityNotify: |
1452 | case VisibilityNotify: |
1292 | switch (ev->xvisibility.state) |
1453 | switch (ev.xvisibility.state) |
1293 | { |
1454 | { |
1294 | case VisibilityUnobscured: |
1455 | case VisibilityUnobscured: |
1295 | R->refresh_type = FAST_REFRESH; |
1456 | refresh_type = FAST_REFRESH; |
1296 | break; |
1457 | break; |
1297 | case VisibilityPartiallyObscured: |
1458 | case VisibilityPartiallyObscured: |
1298 | R->refresh_type = SLOW_REFRESH; |
1459 | refresh_type = SLOW_REFRESH; |
1299 | break; |
1460 | break; |
1300 | default: |
1461 | default: |
1301 | R->refresh_type = NO_REFRESH; |
1462 | refresh_type = NO_REFRESH; |
1302 | break; |
1463 | break; |
1303 | } |
1464 | } |
1304 | break; |
1465 | break; |
1305 | |
1466 | |
1306 | case FocusIn: |
1467 | case FocusIn: |
1307 | if (!R->TermWin.focus) { |
1468 | if (ev.xfocus.detail != NotifyInferior |
1308 | R->TermWin.focus = 1; |
1469 | && ev.xfocus.detail != NotifyPointer |
1309 | R->want_refresh = 1; |
1470 | && ev.xfocus.mode != NotifyGrab) |
1310 | #ifdef USE_XIM |
1471 | focus_in (); |
1311 | if (R->Input_Context != NULL) |
1472 | break; |
1312 | XSetICFocus(R->Input_Context); |
|
|
1313 | #endif |
|
|
1314 | #ifdef CURSOR_BLINK |
|
|
1315 | if (R->Options & Opt_cursorBlink) |
|
|
1316 | R->blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1317 | #endif |
|
|
1318 | } |
|
|
1319 | break; |
|
|
1320 | |
1473 | |
1321 | case FocusOut: |
1474 | case FocusOut: |
1322 | if (R->TermWin.focus) { |
1475 | if (ev.xfocus.detail != NotifyInferior |
1323 | R->TermWin.focus = 0; |
1476 | && ev.xfocus.detail != NotifyPointer |
1324 | R->want_refresh = 1; |
1477 | && ev.xfocus.mode != NotifyGrab) |
1325 | #ifdef USE_XIM |
1478 | focus_out (); |
1326 | if (R->Input_Context != NULL) |
1479 | break; |
1327 | XUnsetICFocus(R->Input_Context); |
|
|
1328 | #endif |
|
|
1329 | #ifdef CURSOR_BLINK |
|
|
1330 | if (R->Options & Opt_cursorBlink) |
|
|
1331 | R->blink_ev.stop (); |
|
|
1332 | R->hidden_cursor = 0; |
|
|
1333 | #endif |
|
|
1334 | } |
|
|
1335 | break; |
|
|
1336 | |
1480 | |
1337 | case ConfigureNotify: |
1481 | case ConfigureNotify: |
1338 | if (ev->xconfigure.window == R->TermWin.parent[0]) { |
1482 | if (ev.xconfigure.window == parent) |
1339 | int height, width; |
1483 | { |
|
|
1484 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
|
|
1485 | ; |
1340 | |
1486 | |
1341 | do { /* Wrap lots of configures into one */ |
1487 | bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE); |
1342 | width = ev->xconfigure.width; |
|
|
1343 | height = ev->xconfigure.height; |
|
|
1344 | D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
|
|
1345 | } while (XCheckTypedWindowEvent(R->Xdisplay, ev->xconfigure.window, |
|
|
1346 | ConfigureNotify, ev)); |
|
|
1347 | if (R->szHint.width != width || R->szHint.height != height) { |
|
|
1348 | D_SIZE((stderr, "Size: Resizing from: %4d x %4d", R->szHint.width, R->szHint.height)); |
|
|
1349 | rxvt_resize_all_windows(aR_ (unsigned int)width, |
|
|
1350 | (unsigned int)height, 1); |
|
|
1351 | } |
|
|
1352 | #ifdef DEBUG_SIZE |
|
|
1353 | else { |
|
|
1354 | D_SIZE((stderr, "Size: Not resizing")); |
|
|
1355 | } |
|
|
1356 | #endif |
|
|
1357 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
|
|
1358 | if (R->Options & Opt_transparent) { |
|
|
1359 | rxvt_check_our_parents(aR); |
|
|
1360 | if (R->am_transparent) |
|
|
1361 | R->want_full_refresh = 1; |
|
|
1362 | } |
|
|
1363 | #endif |
|
|
1364 | } |
|
|
1365 | break; |
|
|
1366 | |
1488 | |
|
|
1489 | if (want_position_change) |
|
|
1490 | { |
|
|
1491 | int x, y; |
|
|
1492 | |
|
|
1493 | if (ev.xconfigure.send_event) |
|
|
1494 | { |
|
|
1495 | x = ev.xconfigure.x; |
|
|
1496 | y = ev.xconfigure.y; |
|
|
1497 | } |
|
|
1498 | else |
|
|
1499 | get_window_origin (x, y); |
|
|
1500 | |
|
|
1501 | if (x != parent_x || y != parent_y) |
|
|
1502 | { |
|
|
1503 | parent_x = x; |
|
|
1504 | parent_y = y; |
|
|
1505 | HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END)); |
|
|
1506 | } |
|
|
1507 | } |
|
|
1508 | |
|
|
1509 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
|
|
1510 | { |
|
|
1511 | seen_resize = 1; |
|
|
1512 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
|
|
1513 | } |
|
|
1514 | |
|
|
1515 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1516 | } |
|
|
1517 | break; |
|
|
1518 | |
|
|
1519 | case PropertyNotify: |
|
|
1520 | HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1521 | break; |
|
|
1522 | |
1367 | case SelectionClear: |
1523 | case SelectionClear: |
1368 | rxvt_selection_clear(aR); |
1524 | selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]); |
1369 | break; |
1525 | break; |
1370 | |
1526 | |
1371 | case SelectionNotify: |
|
|
1372 | if (R->selection_wait == Sel_normal) |
|
|
1373 | rxvt_selection_paste(aR_ ev->xselection.requestor, |
|
|
1374 | ev->xselection.property, True); |
|
|
1375 | break; |
|
|
1376 | |
|
|
1377 | case SelectionRequest: |
1527 | case SelectionRequest: |
1378 | rxvt_selection_send(aR_ &(ev->xselectionrequest)); |
1528 | selection_send (ev.xselectionrequest); |
1379 | break; |
1529 | break; |
1380 | |
1530 | |
|
|
1531 | case MapNotify: |
|
|
1532 | mapped = 1; |
|
|
1533 | #ifdef TEXT_BLINK |
|
|
1534 | text_blink_ev.start (); |
|
|
1535 | #endif |
|
|
1536 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1537 | break; |
|
|
1538 | |
1381 | case UnmapNotify: |
1539 | case UnmapNotify: |
1382 | R->TermWin.mapped = 0; |
1540 | mapped = 0; |
1383 | break; |
1541 | #ifdef TEXT_BLINK |
|
|
1542 | text_blink_ev.stop (); |
|
|
1543 | #endif |
|
|
1544 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1545 | break; |
1384 | |
1546 | |
|
|
1547 | case GraphicsExpose: |
|
|
1548 | case Expose: |
|
|
1549 | if (ev.xany.window == vt) |
|
|
1550 | { |
|
|
1551 | do |
|
|
1552 | { |
|
|
1553 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
|
|
1554 | ev.xexpose.width, ev.xexpose.height, false); |
|
|
1555 | } |
|
|
1556 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
|
|
1557 | |
|
|
1558 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
|
|
1559 | |
|
|
1560 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1561 | { |
|
|
1562 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
|
|
1563 | ev.xexpose.width, ev.xexpose.height, false); |
|
|
1564 | } |
|
|
1565 | |
|
|
1566 | want_refresh = 1; |
|
|
1567 | } |
|
|
1568 | else |
|
|
1569 | { |
|
|
1570 | XEvent unused_event; |
|
|
1571 | |
|
|
1572 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
|
|
1573 | ; |
|
|
1574 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
|
|
1575 | ; |
|
|
1576 | |
|
|
1577 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
|
|
1578 | { |
|
|
1579 | scrollBar.state = SB_STATE_IDLE; |
|
|
1580 | scrollBar.show (0); |
|
|
1581 | } |
|
|
1582 | } |
|
|
1583 | break; |
|
|
1584 | |
1385 | case MapNotify: |
1585 | case MotionNotify: |
1386 | R->TermWin.mapped = 1; |
1586 | #ifdef POINTER_BLANK |
1387 | break; |
1587 | if (hidden_pointer) |
|
|
1588 | pointer_unblank (); |
|
|
1589 | #endif |
|
|
1590 | if (!bypass_keystate |
|
|
1591 | && ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
|
|
1592 | || priv_modes & PrivMode_MouseAnyEvent)) |
|
|
1593 | mouse_report (ev.xbutton); |
|
|
1594 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
|
|
1595 | break; |
1388 | |
1596 | |
|
|
1597 | if (ev.xany.window == vt) |
|
|
1598 | { |
|
|
1599 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1600 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1601 | ; // nop |
|
|
1602 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
|
|
1603 | { |
|
|
1604 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
|
|
1605 | ; |
|
|
1606 | |
|
|
1607 | XQueryPointer (dpy, vt, |
|
|
1608 | &unused_root, &unused_child, |
|
|
1609 | &unused_root_x, &unused_root_y, |
|
|
1610 | &ev.xbutton.x, &ev.xbutton.y, |
|
|
1611 | &ev.xbutton.state); |
|
|
1612 | #ifdef MOUSE_THRESHOLD |
|
|
1613 | /* deal with a `jumpy' mouse */ |
|
|
1614 | if (ev.xmotion.time - MEvent.time > MOUSE_THRESHOLD) |
|
|
1615 | #endif |
|
|
1616 | { |
|
|
1617 | #if ISO_14755 |
|
|
1618 | // 5.4 |
|
|
1619 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
|
|
1620 | { |
|
|
1621 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
|
|
1622 | break; |
|
|
1623 | } |
|
|
1624 | #endif |
|
|
1625 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
|
|
1626 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1627 | |
|
|
1628 | #ifdef SELECTION_SCROLLING |
|
|
1629 | if (ev.xbutton.y < int_bwidth |
|
|
1630 | || Pixel2Row (ev.xbutton.y) > (nrow-1)) |
|
|
1631 | { |
|
|
1632 | page_dirn scroll_selection_dir; |
|
|
1633 | int dist; |
|
|
1634 | |
|
|
1635 | /* don't clobber the current delay if we are |
|
|
1636 | * already in the middle of scrolling. |
|
|
1637 | */ |
|
|
1638 | if (!sel_scroll_ev.is_active ()) |
|
|
1639 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
|
|
1640 | |
|
|
1641 | /* save the event params so we can highlight |
|
|
1642 | * the selection in the pending-scroll loop |
|
|
1643 | */ |
|
|
1644 | selection_save_x = ev.xbutton.x; |
|
|
1645 | selection_save_y = ev.xbutton.y; |
|
|
1646 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
|
|
1647 | |
|
|
1648 | /* calc number of lines to scroll */ |
|
|
1649 | if (ev.xbutton.y < int_bwidth) |
|
|
1650 | { |
|
|
1651 | scroll_selection_dir = UP; |
|
|
1652 | dist = int_bwidth - ev.xbutton.y; |
|
|
1653 | } |
|
|
1654 | else |
|
|
1655 | { |
|
|
1656 | scroll_selection_dir = DN; |
|
|
1657 | dist = ev.xbutton.y - (int_bwidth + vt_height); |
|
|
1658 | } |
|
|
1659 | |
|
|
1660 | scroll_selection_lines = Pixel2Height (dist) |
|
|
1661 | / SELECTION_SCROLL_LINE_SPEEDUP |
|
|
1662 | + 1; |
|
|
1663 | min_it (scroll_selection_lines, |
|
|
1664 | SELECTION_SCROLL_MAX_LINES); |
|
|
1665 | scroll_selection_lines *= scroll_selection_dir; |
|
|
1666 | } |
|
|
1667 | else |
|
|
1668 | { |
|
|
1669 | /* we are within the text window, so we |
|
|
1670 | * shouldn't be scrolling |
|
|
1671 | */ |
|
|
1672 | sel_scroll_ev.stop(); |
|
|
1673 | } |
|
|
1674 | #endif |
|
|
1675 | } |
|
|
1676 | } |
|
|
1677 | } |
|
|
1678 | else if (scrollBar.state == SB_STATE_MOTION && ev.xany.window == scrollBar.win) |
|
|
1679 | { |
|
|
1680 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
|
|
1681 | MotionNotify, &ev)) |
|
|
1682 | ; |
|
|
1683 | |
|
|
1684 | XQueryPointer (dpy, scrollBar.win, |
|
|
1685 | &unused_root, &unused_child, |
|
|
1686 | &unused_root_x, &unused_root_y, |
|
|
1687 | &ev.xbutton.x, &ev.xbutton.y, |
|
|
1688 | &unused_mask); |
|
|
1689 | scr_move_to (scrollBar.position (ev.xbutton.y) - csrO, |
|
|
1690 | scrollBar.size ()); |
|
|
1691 | want_refresh = 1; |
|
|
1692 | scrollBar.show (1); |
|
|
1693 | } |
|
|
1694 | break; |
|
|
1695 | } |
|
|
1696 | |
|
|
1697 | #if defined(CURSOR_BLINK) |
|
|
1698 | if (ev.type == KeyPress) |
|
|
1699 | cursor_blink_reset (); |
|
|
1700 | #endif |
|
|
1701 | |
|
|
1702 | #if defined(POINTER_BLANK) |
|
|
1703 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1704 | { |
|
|
1705 | if (ev.type == MotionNotify |
|
|
1706 | || ev.type == ButtonPress |
|
|
1707 | || ev.type == ButtonRelease) |
|
|
1708 | if (hidden_pointer) |
|
|
1709 | pointer_unblank (); |
|
|
1710 | |
|
|
1711 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1712 | pointer_blank (); |
|
|
1713 | } |
|
|
1714 | #endif |
|
|
1715 | |
|
|
1716 | refresh_check (); |
|
|
1717 | } |
|
|
1718 | |
|
|
1719 | #if ENABLE_FRILLS |
|
|
1720 | void ecb_cold |
|
|
1721 | rxvt_term::set_urgency (bool enable) |
|
|
1722 | { |
|
|
1723 | if (enable == urgency_hint) |
|
|
1724 | return; |
|
|
1725 | |
|
|
1726 | if (XWMHints *h = XGetWMHints (dpy, parent)) |
|
|
1727 | { |
|
|
1728 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1729 | XSetWMHints (dpy, parent, h); |
|
|
1730 | urgency_hint = enable; |
|
|
1731 | XFree (h); |
|
|
1732 | } |
|
|
1733 | } |
|
|
1734 | #endif |
|
|
1735 | |
|
|
1736 | void ecb_cold |
|
|
1737 | rxvt_term::focus_in () |
|
|
1738 | { |
|
|
1739 | if (!focus) |
|
|
1740 | { |
|
|
1741 | focus = 1; |
|
|
1742 | want_refresh = 1; |
|
|
1743 | |
|
|
1744 | #if USE_XIM |
|
|
1745 | if (Input_Context != NULL) |
|
|
1746 | { |
|
|
1747 | im_set_position (); |
|
|
1748 | XSetICFocus (Input_Context); |
|
|
1749 | } |
|
|
1750 | #endif |
|
|
1751 | #if CURSOR_BLINK |
|
|
1752 | if (option (Opt_cursorBlink)) |
|
|
1753 | cursor_blink_ev.again (); |
|
|
1754 | #endif |
|
|
1755 | #if OFF_FOCUS_FADING |
|
|
1756 | if (rs[Rs_fade]) |
|
|
1757 | { |
|
|
1758 | pix_colors = pix_colors_focused; |
|
|
1759 | scr_recolor (); |
|
|
1760 | } |
|
|
1761 | #endif |
|
|
1762 | #if ENABLE_FRILLS |
|
|
1763 | if (option (Opt_urgentOnBell)) |
|
|
1764 | set_urgency (0); |
|
|
1765 | |
|
|
1766 | if (priv_modes & PrivMode_FocusEvent) |
|
|
1767 | tt_printf ("\x1b[I"); |
|
|
1768 | #endif |
|
|
1769 | |
|
|
1770 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1771 | } |
|
|
1772 | } |
|
|
1773 | |
|
|
1774 | void ecb_cold |
|
|
1775 | rxvt_term::focus_out () |
|
|
1776 | { |
|
|
1777 | if (focus) |
|
|
1778 | { |
|
|
1779 | focus = 0; |
|
|
1780 | want_refresh = 1; |
|
|
1781 | |
|
|
1782 | #if ENABLE_FRILLS |
|
|
1783 | if (option (Opt_urgentOnBell)) |
|
|
1784 | set_urgency (0); |
|
|
1785 | |
|
|
1786 | if (priv_modes & PrivMode_FocusEvent) |
|
|
1787 | tt_printf ("\x1b[O"); |
|
|
1788 | #endif |
|
|
1789 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1790 | if (iso14755buf) |
|
|
1791 | { |
|
|
1792 | iso14755buf = 0; |
|
|
1793 | # if ISO_14755 |
|
|
1794 | scr_overlay_off (); |
|
|
1795 | # endif |
|
|
1796 | } |
|
|
1797 | #endif |
|
|
1798 | #if USE_XIM |
|
|
1799 | if (Input_Context != NULL) |
|
|
1800 | XUnsetICFocus (Input_Context); |
|
|
1801 | #endif |
|
|
1802 | #if CURSOR_BLINK |
|
|
1803 | if (option (Opt_cursorBlink)) |
|
|
1804 | cursor_blink_ev.stop (); |
|
|
1805 | |
|
|
1806 | hidden_cursor = 0; |
|
|
1807 | #endif |
|
|
1808 | #if OFF_FOCUS_FADING |
|
|
1809 | if (rs[Rs_fade]) |
|
|
1810 | { |
|
|
1811 | pix_colors = pix_colors_unfocused; |
|
|
1812 | scr_recolor (); |
|
|
1813 | } |
|
|
1814 | #endif |
|
|
1815 | |
|
|
1816 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1817 | } |
|
|
1818 | } |
|
|
1819 | |
|
|
1820 | void ecb_cold |
|
|
1821 | rxvt_term::update_fade_color (unsigned int idx, bool first_time) |
|
|
1822 | { |
|
|
1823 | #if OFF_FOCUS_FADING |
|
|
1824 | if (rs[Rs_fade]) |
|
|
1825 | { |
|
|
1826 | if (!first_time) |
|
|
1827 | pix_colors_focused [idx].free (this); |
|
|
1828 | |
|
|
1829 | rgba c; |
|
|
1830 | pix_colors [Color_fade].get (c); |
|
|
1831 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1832 | } |
|
|
1833 | #endif |
|
|
1834 | } |
|
|
1835 | |
|
|
1836 | #if ENABLE_PERL |
|
|
1837 | void ecb_hot |
|
|
1838 | rxvt_term::rootwin_cb (XEvent &ev) |
|
|
1839 | { |
|
|
1840 | make_current (); |
|
|
1841 | |
|
|
1842 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1843 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1844 | return; |
|
|
1845 | |
|
|
1846 | switch (ev.type) |
|
|
1847 | { |
1389 | case PropertyNotify: |
1848 | case PropertyNotify: |
1390 | if (ev->xproperty.atom == R->xa[XA_VT_SELECTION]) { |
|
|
1391 | if (ev->xproperty.state == PropertyNewValue) |
|
|
1392 | rxvt_selection_property(aR_ ev->xproperty.window, |
|
|
1393 | ev->xproperty.atom); |
|
|
1394 | break; |
|
|
1395 | } |
|
|
1396 | #ifdef TRANSPARENT |
|
|
1397 | /* |
1849 | /* |
1398 | * if user used some Esetroot compatible prog to set the root bg, |
1850 | * if user used some Esetroot compatible prog to set the root bg, |
1399 | * use the property to determine the pixmap. We use it later on. |
1851 | * use the property to determine the pixmap. We use it later on. |
|
|
1852 | */ |
|
|
1853 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
|
|
1854 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
|
|
1855 | { |
|
|
1856 | HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END)); |
|
|
1857 | } |
|
|
1858 | |
|
|
1859 | break; |
|
|
1860 | } |
|
|
1861 | |
|
|
1862 | refresh_check (); |
|
|
1863 | } |
|
|
1864 | #endif |
|
|
1865 | |
|
|
1866 | void |
|
|
1867 | rxvt_term::button_press (XButtonEvent &ev) |
|
|
1868 | { |
|
|
1869 | int reportmode = 0, clickintime; |
|
|
1870 | |
|
|
1871 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1872 | |
|
|
1873 | if (!bypass_keystate) |
|
|
1874 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
|
|
1875 | |
|
|
1876 | /* |
|
|
1877 | * VT window processing of button press |
1400 | */ |
1878 | */ |
1401 | if (R->xa[XA_XROOTPMAPID] == 0) |
1879 | if (ev.window == vt) |
1402 | R->xa[XA_XROOTPMAPID] = XInternAtom(R->Xdisplay, |
1880 | { |
1403 | "_XROOTPMAP_ID", False); |
1881 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1404 | if (ev->xproperty.atom != R->xa[XA_XROOTPMAPID]) |
1882 | return; |
1405 | break; |
|
|
1406 | /* FALLTHROUGH */ |
|
|
1407 | case ReparentNotify: |
|
|
1408 | if ((R->Options & Opt_transparent) && rxvt_check_our_parents(aR)) { |
|
|
1409 | if (R->am_transparent) |
|
|
1410 | R->want_full_refresh = 1; |
|
|
1411 | } |
|
|
1412 | #endif /* TRANSPARENT */ |
|
|
1413 | break; |
|
|
1414 | |
1883 | |
1415 | case GraphicsExpose: |
1884 | #if ISO_14755 |
1416 | case Expose: |
1885 | // 5.4 |
1417 | if (ev->xany.window == R->TermWin.vt) { |
1886 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1418 | #ifdef NO_SLOW_LINK_SUPPORT |
1887 | { |
1419 | rxvt_scr_expose(aR_ ev->xexpose.x, ev->xexpose.y, |
1888 | iso14755_54 (ev.x, ev.y); |
1420 | ev->xexpose.width, ev->xexpose.height, False); |
1889 | return; |
|
|
1890 | } |
|
|
1891 | #endif |
|
|
1892 | |
|
|
1893 | clickintime = ev.time - MEvent.time < multiClickTime; |
|
|
1894 | |
|
|
1895 | if (reportmode) |
|
|
1896 | { |
|
|
1897 | /* mouse report from vt window */ |
|
|
1898 | /* save the xbutton state (for ButtonRelease) */ |
|
|
1899 | MEvent.state = ev.state; |
|
|
1900 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1901 | if (ev.button == MEvent.button && clickintime) |
|
|
1902 | { |
|
|
1903 | /* same button, within allowed time */ |
|
|
1904 | MEvent.clicks++; |
|
|
1905 | |
|
|
1906 | if (MEvent.clicks > 1) |
|
|
1907 | { |
|
|
1908 | /* only report double clicks */ |
|
|
1909 | MEvent.clicks = 2; |
|
|
1910 | mouse_report (ev); |
|
|
1911 | |
|
|
1912 | /* don't report the release */ |
|
|
1913 | MEvent.clicks = 0; |
|
|
1914 | MEvent.button = AnyButton; |
|
|
1915 | } |
|
|
1916 | } |
|
|
1917 | else |
|
|
1918 | { |
|
|
1919 | /* different button, or time expired */ |
|
|
1920 | MEvent.clicks = 1; |
|
|
1921 | MEvent.button = ev.button; |
|
|
1922 | mouse_report (ev); |
|
|
1923 | } |
1421 | #else |
1924 | #else |
1422 | // don't understand this, so commented it out |
1925 | MEvent.button = ev.button; |
1423 | rxvt_scr_expose(aR_ ev->xexpose.x, ev->xexpose.y, |
1926 | mouse_report (ev); |
1424 | ev->xexpose.width, ev->xexpose.height, False); |
1927 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1425 | //rxvt_scr_expose(aR_ ev->xexpose.x, 0, |
|
|
1426 | // ev->xexpose.width, R->TermWin.height, False); |
|
|
1427 | #endif |
|
|
1428 | R->want_refresh = 1; |
|
|
1429 | } else { |
|
|
1430 | XEvent unused_xevent; |
|
|
1431 | |
1928 | |
1432 | while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, |
|
|
1433 | Expose, |
|
|
1434 | &unused_xevent)) ; |
|
|
1435 | while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, |
|
|
1436 | GraphicsExpose, |
|
|
1437 | &unused_xevent)) ; |
|
|
1438 | if (isScrollbarWindow(ev->xany.window)) { |
|
|
1439 | R->scrollBar.setIdle(); |
|
|
1440 | rxvt_scrollbar_show(aR_ 0); |
|
|
1441 | } |
|
|
1442 | #ifdef MENUBAR |
|
|
1443 | if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window)) |
|
|
1444 | rxvt_menubar_expose(aR); |
|
|
1445 | #endif |
|
|
1446 | #ifdef RXVT_GRAPHICS |
|
|
1447 | rxvt_Gr_expose(aR_ ev->xany.window); |
|
|
1448 | #endif |
|
|
1449 | } |
|
|
1450 | break; |
|
|
1451 | |
|
|
1452 | case MotionNotify: |
|
|
1453 | #ifdef POINTER_BLANK |
|
|
1454 | if (R->hidden_pointer) |
|
|
1455 | R->pointer_unblank (); |
|
|
1456 | #endif |
|
|
1457 | #if MENUBAR |
|
|
1458 | if (isMenuBarWindow(ev->xany.window)) { |
|
|
1459 | rxvt_menubar_control(aR_ &(ev->xbutton)); |
|
|
1460 | break; |
|
|
1461 | } |
|
|
1462 | #endif |
|
|
1463 | if ((R->PrivateModes & PrivMode_mouse_report) && !(R->bypass_keystate)) |
|
|
1464 | break; |
|
|
1465 | |
|
|
1466 | if (ev->xany.window == R->TermWin.vt) { |
|
|
1467 | if ((ev->xbutton.state & (Button1Mask | Button3Mask))) { |
|
|
1468 | while (XCheckTypedWindowEvent(R->Xdisplay, R->TermWin.vt, |
|
|
1469 | MotionNotify, ev)) ; |
|
|
1470 | XQueryPointer(R->Xdisplay, R->TermWin.vt, |
|
|
1471 | &unused_root, &unused_child, |
|
|
1472 | &unused_root_x, &unused_root_y, |
|
|
1473 | &(ev->xbutton.x), &(ev->xbutton.y), |
|
|
1474 | &unused_mask); |
|
|
1475 | #ifdef MOUSE_THRESHOLD |
|
|
1476 | /* deal with a `jumpy' mouse */ |
|
|
1477 | if ((ev->xmotion.time - R->MEvent.time) > MOUSE_THRESHOLD) { |
|
|
1478 | #endif |
|
|
1479 | rxvt_selection_extend(aR_ (ev->xbutton.x), (ev->xbutton.y), |
|
|
1480 | (ev->xbutton.state & Button3Mask) ? 2 : 0); |
|
|
1481 | #ifdef SELECTION_SCROLLING |
|
|
1482 | if (ev->xbutton.y<R->TermWin.int_bwidth || |
|
|
1483 | Pixel2Row(ev->xbutton.y)>(R->TermWin.nrow-1)) { |
|
|
1484 | int dist; |
|
|
1485 | |
|
|
1486 | R->pending_scroll_selection=1; |
|
|
1487 | |
|
|
1488 | /* don't clobber the current delay if we are |
|
|
1489 | * already in the middle of scrolling. |
|
|
1490 | */ |
|
|
1491 | if (R->scroll_selection_delay<=0) |
|
|
1492 | R->scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; |
|
|
1493 | |
|
|
1494 | /* save the event params so we can highlight |
|
|
1495 | * the selection in the pending-scroll loop |
|
|
1496 | */ |
|
|
1497 | R->selection_save_x=ev->xbutton.x; |
|
|
1498 | R->selection_save_y=ev->xbutton.y; |
|
|
1499 | R->selection_save_state= |
|
|
1500 | (ev->xbutton.state & Button3Mask) ? 2 : 0; |
|
|
1501 | |
|
|
1502 | /* calc number of lines to scroll */ |
|
|
1503 | if (ev->xbutton.y<R->TermWin.int_bwidth) { |
|
|
1504 | R->scroll_selection_dir = UP; |
|
|
1505 | dist = R->TermWin.int_bwidth - ev->xbutton.y; |
|
|
1506 | } |
|
|
1507 | else { |
|
|
1508 | R->scroll_selection_dir = DN; |
|
|
1509 | dist = ev->xbutton.y - |
|
|
1510 | (R->TermWin.int_bwidth + R->TermWin.height); |
|
|
1511 | } |
|
|
1512 | R->scroll_selection_lines=(Pixel2Height(dist)/ |
|
|
1513 | SELECTION_SCROLL_LINE_SPEEDUP)+1; |
|
|
1514 | MIN_IT(R->scroll_selection_lines, |
|
|
1515 | SELECTION_SCROLL_MAX_LINES); |
|
|
1516 | } |
|
|
1517 | else { |
|
|
1518 | /* we are within the text window, so we |
|
|
1519 | * shouldn't be scrolling |
|
|
1520 | */ |
|
|
1521 | R->pending_scroll_selection = 0; |
|
|
1522 | } |
|
|
1523 | #endif |
|
|
1524 | #ifdef MOUSE_THRESHOLD |
|
|
1525 | } |
|
|
1526 | #endif |
|
|
1527 | } |
|
|
1528 | } else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion()) { |
|
|
1529 | while (XCheckTypedWindowEvent(R->Xdisplay, R->scrollBar.win, |
|
|
1530 | MotionNotify, ev)) ; |
|
|
1531 | XQueryPointer(R->Xdisplay, R->scrollBar.win, |
|
|
1532 | &unused_root, &unused_child, |
|
|
1533 | &unused_root_x, &unused_root_y, |
|
|
1534 | &(ev->xbutton.x), &(ev->xbutton.y), |
|
|
1535 | &unused_mask); |
|
|
1536 | rxvt_scr_move_to(aR_ scrollbar_position(ev->xbutton.y) - R->csrO, |
|
|
1537 | scrollbar_size()); |
|
|
1538 | rxvt_scr_refresh(aR_ R->refresh_type); |
|
|
1539 | R->refresh_limit = 0; |
|
|
1540 | rxvt_scrollbar_show(aR_ 1); |
|
|
1541 | } |
|
|
1542 | break; |
|
|
1543 | } |
|
|
1544 | } |
|
|
1545 | |
|
|
1546 | /* INTPROTO */ |
|
|
1547 | void |
|
|
1548 | rxvt_button_press(pR_ XButtonEvent *ev) |
|
|
1549 | { |
|
|
1550 | int reportmode = 0, clickintime; |
|
|
1551 | |
|
|
1552 | R->bypass_keystate = ev->state & (R->ModMetaMask | ShiftMask); |
|
|
1553 | if (!R->bypass_keystate) |
|
|
1554 | reportmode = !!(R->PrivateModes & PrivMode_mouse_report); |
|
|
1555 | /* |
|
|
1556 | * VT window processing of button press |
|
|
1557 | */ |
|
|
1558 | if (ev->window == R->TermWin.vt) |
|
|
1559 | { |
1929 | } |
1560 | #if RXVT_GRAPHICS |
1930 | else |
1561 | if (ev->subwindow != None) |
|
|
1562 | rxvt_Gr_ButtonPress (ev->x, ev->y); |
|
|
1563 | else |
|
|
1564 | #endif |
|
|
1565 | { |
1931 | { |
1566 | clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME; |
1932 | if (ev.button != MEvent.button) |
1567 | if (reportmode) |
1933 | MEvent.clicks = 0; |
|
|
1934 | |
|
|
1935 | switch (ev.button) |
1568 | { |
1936 | { |
1569 | /* mouse report from vt window */ |
1937 | case Button1: |
1570 | /* save the xbutton state (for ButtonRelease) */ |
1938 | /* allow meta + click to select rectangular areas */ |
1571 | R->MEvent.state = ev->state; |
1939 | /* should be done in screen.C */ |
1572 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1940 | #if ENABLE_FRILLS |
1573 | if (ev->button == R->MEvent.button && clickintime) |
1941 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1942 | #else |
|
|
1943 | selection.rect = false; |
|
|
1944 | #endif |
|
|
1945 | |
|
|
1946 | /* allow shift+left click to extend selection */ |
|
|
1947 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1574 | { |
1948 | { |
1575 | /* same button, within alloted time */ |
1949 | if (MEvent.button == Button1 && clickintime) |
1576 | R->MEvent.clicks++; |
1950 | selection_rotate (ev.x, ev.y); |
1577 | if (R->MEvent.clicks > 1) |
1951 | else |
|
|
1952 | selection_extend (ev.x, ev.y, 1); |
1578 | { |
1953 | } |
1579 | /* only report double clicks */ |
|
|
1580 | R->MEvent.clicks = 2; |
|
|
1581 | rxvt_mouse_report(aR_ ev); |
|
|
1582 | |
|
|
1583 | /* don't report the release */ |
|
|
1584 | R->MEvent.clicks = 0; |
|
|
1585 | R->MEvent.button = AnyButton; |
|
|
1586 | } |
|
|
1587 | } |
|
|
1588 | else |
1954 | else |
1589 | { |
1955 | { |
1590 | /* different button, or time expired */ |
1956 | if (MEvent.button == Button1 && clickintime) |
1591 | R->MEvent.clicks = 1; |
1957 | MEvent.clicks++; |
1592 | R->MEvent.button = ev->button; |
1958 | else |
1593 | rxvt_mouse_report(aR_ ev); |
1959 | MEvent.clicks = 1; |
1594 | } |
1960 | |
1595 | #else |
1961 | selection_click (MEvent.clicks, ev.x, ev.y); |
1596 | R->MEvent.button = ev->button; |
1962 | } |
1597 | rxvt_mouse_report(aR_ ev); |
1963 | |
1598 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1964 | MEvent.button = Button1; |
|
|
1965 | break; |
|
|
1966 | |
|
|
1967 | case Button3: |
|
|
1968 | if (MEvent.button == Button3 && clickintime) |
|
|
1969 | selection_rotate (ev.x, ev.y); |
|
|
1970 | else |
|
|
1971 | selection_extend (ev.x, ev.y, 1); |
|
|
1972 | |
|
|
1973 | MEvent.button = Button3; |
|
|
1974 | break; |
|
|
1975 | } |
1599 | } |
1976 | } |
|
|
1977 | |
|
|
1978 | MEvent.time = ev.time; |
|
|
1979 | return; |
|
|
1980 | } |
|
|
1981 | |
|
|
1982 | /* |
|
|
1983 | * Scrollbar window processing of button press |
|
|
1984 | */ |
|
|
1985 | if (scrollBar.state && ev.window == scrollBar.win) |
|
|
1986 | { |
|
|
1987 | page_dirn direction = NO_DIR; |
|
|
1988 | |
|
|
1989 | if (scrollBar.upButton (ev.y)) |
|
|
1990 | direction = UP; /* up */ |
|
|
1991 | else if (scrollBar.dnButton (ev.y)) |
|
|
1992 | direction = DN; /* down */ |
|
|
1993 | |
|
|
1994 | scrollBar.state = SB_STATE_IDLE; |
|
|
1995 | /* |
|
|
1996 | * Rxvt-style scrollbar: |
|
|
1997 | * move up if mouse is above slider |
|
|
1998 | * move dn if mouse is below slider |
|
|
1999 | * |
|
|
2000 | * XTerm-style scrollbar: |
|
|
2001 | * Move display proportional to pointer location |
|
|
2002 | * pointer near top -> scroll one line |
|
|
2003 | * pointer near bot -> scroll full page |
|
|
2004 | */ |
|
|
2005 | #ifndef NO_SCROLLBAR_REPORT |
|
|
2006 | if (reportmode) |
|
|
2007 | { |
|
|
2008 | /* |
|
|
2009 | * Mouse report disabled scrollbar: |
|
|
2010 | * arrow buttons - send up/down |
|
|
2011 | * click on scrollbar - send pageup/down |
|
|
2012 | */ |
|
|
2013 | if (direction == UP) |
|
|
2014 | tt_printf ("\033[A"); |
|
|
2015 | else if (direction == DN) |
|
|
2016 | tt_printf ("\033[B"); |
1600 | else |
2017 | else |
|
|
2018 | switch (ev.button) |
1601 | { |
2019 | { |
1602 | if (ev->button != R->MEvent.button) |
2020 | case Button2: |
1603 | R->MEvent.clicks = 0; |
2021 | tt_printf ("\014"); |
1604 | switch (ev->button) |
2022 | break; |
|
|
2023 | case Button1: |
|
|
2024 | tt_printf ("\033[6~"); |
|
|
2025 | break; |
|
|
2026 | case Button3: |
|
|
2027 | tt_printf ("\033[5~"); |
|
|
2028 | break; |
|
|
2029 | } |
|
|
2030 | } |
|
|
2031 | else |
|
|
2032 | #endif /* NO_SCROLLBAR_REPORT */ |
|
|
2033 | { |
|
|
2034 | if (direction != NO_DIR) |
|
|
2035 | { |
|
|
2036 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2037 | if (!cont_scroll_ev.is_active ()) |
|
|
2038 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
|
|
2039 | #endif |
|
|
2040 | if (scr_page (direction, 1)) |
|
|
2041 | { |
|
|
2042 | if (direction == UP) |
|
|
2043 | scrollBar.state = SB_STATE_UP; |
|
|
2044 | else |
|
|
2045 | scrollBar.state = SB_STATE_DOWN; |
|
|
2046 | } |
|
|
2047 | } |
|
|
2048 | else |
|
|
2049 | switch (ev.button) |
|
|
2050 | { |
|
|
2051 | case Button2: |
|
|
2052 | switch (scrollBar.align) |
1605 | { |
2053 | { |
1606 | case Button1: |
2054 | case SB_ALIGN_TOP: |
1607 | if (R->MEvent.button == Button1 && clickintime) |
|
|
1608 | R->MEvent.clicks++; |
|
|
1609 | else |
2055 | csrO = 0; |
1610 | R->MEvent.clicks = 1; |
|
|
1611 | rxvt_selection_click(aR_ R->MEvent.clicks, ev->x, ev->y); |
|
|
1612 | R->MEvent.button = Button1; |
|
|
1613 | break; |
2056 | break; |
1614 | |
2057 | case SB_ALIGN_CENTRE: |
1615 | case Button3: |
2058 | csrO = (scrollBar.bot - scrollBar.top) / 2; |
1616 | if (R->MEvent.button == Button3 && clickintime) |
|
|
1617 | rxvt_selection_rotate(aR_ ev->x, ev->y); |
|
|
1618 | else |
|
|
1619 | rxvt_selection_extend(aR_ ev->x, ev->y, 1); |
|
|
1620 | R->MEvent.button = Button3; |
|
|
1621 | break; |
2059 | break; |
1622 | } |
2060 | case SB_ALIGN_BOTTOM: |
1623 | } |
2061 | csrO = scrollBar.bot - scrollBar.top; |
1624 | R->MEvent.time = ev->time; |
2062 | break; |
1625 | return; |
2063 | } |
1626 | } |
|
|
1627 | } |
|
|
1628 | |
2064 | |
1629 | /* |
2065 | if (scrollBar.style == SB_STYLE_XTERM |
1630 | * Scrollbar window processing of button press |
2066 | || scrollBar.above_slider (ev.y) |
1631 | */ |
2067 | || scrollBar.below_slider (ev.y)) |
1632 | if (isScrollbarWindow(ev->window)) |
2068 | scr_move_to (scrollBar.position (ev.y) - csrO, scrollBar.size ()); |
1633 | { |
|
|
1634 | R->scrollBar.setIdle (); |
|
|
1635 | /* |
|
|
1636 | * Rxvt-style scrollbar: |
|
|
1637 | * move up if mouse is above slider |
|
|
1638 | * move dn if mouse is below slider |
|
|
1639 | * |
|
|
1640 | * XTerm-style scrollbar: |
|
|
1641 | * Move display proportional to pointer location |
|
|
1642 | * pointer near top -> scroll one line |
|
|
1643 | * pointer near bot -> scroll full page |
|
|
1644 | */ |
|
|
1645 | #ifndef NO_SCROLLBAR_REPORT |
|
|
1646 | if (reportmode) { |
|
|
1647 | /* |
|
|
1648 | * Mouse report disabled scrollbar: |
|
|
1649 | * arrow buttons - send up/down |
|
|
1650 | * click on scrollbar - send pageup/down |
|
|
1651 | */ |
|
|
1652 | if ((R->scrollBar.style == R_SB_NEXT |
|
|
1653 | && scrollbarnext_upButton(ev->y)) |
|
|
1654 | || (R->scrollBar.style == R_SB_RXVT |
|
|
1655 | && scrollbarrxvt_upButton(ev->y))) |
|
|
1656 | R->tt_printf("\033[A"); |
|
|
1657 | else if ((R->scrollBar.style == R_SB_NEXT |
|
|
1658 | && scrollbarnext_dnButton(ev->y)) |
|
|
1659 | || (R->scrollBar.style == R_SB_RXVT |
|
|
1660 | && scrollbarrxvt_dnButton(ev->y))) |
|
|
1661 | R->tt_printf("\033[B"); |
|
|
1662 | else |
|
|
1663 | switch (ev->button) { |
|
|
1664 | case Button2: |
|
|
1665 | R->tt_printf("\014"); |
|
|
1666 | break; |
|
|
1667 | case Button1: |
|
|
1668 | R->tt_printf("\033[6~"); |
|
|
1669 | break; |
|
|
1670 | case Button3: |
|
|
1671 | R->tt_printf("\033[5~"); |
|
|
1672 | break; |
|
|
1673 | } |
|
|
1674 | } |
|
|
1675 | else |
|
|
1676 | #endif /* NO_SCROLLBAR_REPORT */ |
|
|
1677 | { |
|
|
1678 | char upordown = 0; |
|
|
1679 | |
2069 | |
1680 | if (R->scrollBar.style == R_SB_NEXT) { |
2070 | scrollBar.state = SB_STATE_MOTION; |
1681 | if (scrollbarnext_upButton(ev->y)) |
2071 | break; |
1682 | upordown = -1; /* up */ |
|
|
1683 | else if (scrollbarnext_dnButton(ev->y)) |
|
|
1684 | upordown = 1; /* down */ |
|
|
1685 | } else if (R->scrollBar.style == R_SB_RXVT) { |
|
|
1686 | if (scrollbarrxvt_upButton(ev->y)) |
|
|
1687 | upordown = -1; /* up */ |
|
|
1688 | else if (scrollbarrxvt_dnButton(ev->y)) |
|
|
1689 | upordown = 1; /* down */ |
|
|
1690 | } |
|
|
1691 | if (upordown) { |
|
|
1692 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1693 | R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; |
|
|
1694 | #endif |
|
|
1695 | if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) { |
|
|
1696 | if (upordown < 0) |
|
|
1697 | R->scrollBar.setUp (); |
|
|
1698 | else |
|
|
1699 | R->scrollBar.setDn (); |
|
|
1700 | } |
|
|
1701 | } else |
|
|
1702 | switch (ev->button) { |
|
|
1703 | case Button2: |
|
|
1704 | switch (R->scrollbar_align) { |
|
|
1705 | case R_SB_ALIGN_TOP: |
|
|
1706 | R->csrO = 0; |
|
|
1707 | break; |
|
|
1708 | case R_SB_ALIGN_CENTRE: |
|
|
1709 | R->csrO = (R->scrollBar.bot - R->scrollBar.top) / 2; |
|
|
1710 | break; |
|
|
1711 | case R_SB_ALIGN_BOTTOM: |
|
|
1712 | R->csrO = R->scrollBar.bot - R->scrollBar.top; |
|
|
1713 | break; |
|
|
1714 | } |
|
|
1715 | if (R->scrollBar.style == R_SB_XTERM |
|
|
1716 | || scrollbar_above_slider(ev->y) |
|
|
1717 | || scrollbar_below_slider(ev->y)) |
|
|
1718 | rxvt_scr_move_to(aR_ |
|
|
1719 | scrollbar_position(ev->y) - R->csrO, |
|
|
1720 | scrollbar_size()); |
|
|
1721 | R->scrollBar.setMotion (); |
|
|
1722 | break; |
|
|
1723 | |
2072 | |
1724 | case Button1: |
2073 | case Button1: |
1725 | if (R->scrollbar_align == R_SB_ALIGN_CENTRE) |
2074 | if (scrollBar.align == SB_ALIGN_CENTRE) |
1726 | R->csrO = ev->y - R->scrollBar.top; |
2075 | csrO = ev.y - scrollBar.top; |
1727 | /* FALLTHROUGH */ |
2076 | /* FALLTHROUGH */ |
1728 | |
2077 | |
1729 | case Button3: |
2078 | case Button3: |
1730 | if (R->scrollBar.style != R_SB_XTERM) { |
2079 | if (scrollBar.style != SB_STYLE_XTERM) |
1731 | if (scrollbar_above_slider(ev->y)) |
2080 | { |
|
|
2081 | if (scrollBar.above_slider (ev.y)) |
1732 | # ifdef RXVT_SCROLL_FULL |
2082 | # ifdef RXVT_SCROLL_FULL |
1733 | rxvt_scr_page(aR_ UP, R->TermWin.nrow - 1); |
2083 | scr_page (UP, nrow - 1); |
1734 | # else |
2084 | # else |
1735 | rxvt_scr_page(aR_ UP, R->TermWin.nrow / 4); |
2085 | scr_page (UP, nrow / 4); |
1736 | # endif |
2086 | # endif |
1737 | else if (scrollbar_below_slider(ev->y)) |
2087 | else if (scrollBar.below_slider (ev.y)) |
1738 | # ifdef RXVT_SCROLL_FULL |
2088 | # ifdef RXVT_SCROLL_FULL |
1739 | rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1); |
2089 | scr_page (DN, nrow - 1); |
1740 | # else |
2090 | # else |
1741 | rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4); |
2091 | scr_page (DN, nrow / 4); |
1742 | # endif |
2092 | # endif |
1743 | else |
2093 | else |
1744 | R->scrollBar.setMotion (); |
2094 | scrollBar.state = SB_STATE_MOTION; |
1745 | } else { |
2095 | } |
1746 | rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP), |
2096 | else |
1747 | (R->TermWin.nrow |
2097 | { |
1748 | * scrollbar_position(ev->y) |
2098 | scr_page ((ev.button == Button1 ? DN : UP), |
1749 | / scrollbar_size())); |
2099 | (nrow |
|
|
2100 | * scrollBar.position (ev.y) |
|
|
2101 | / scrollBar.size ())); |
|
|
2102 | } |
|
|
2103 | |
|
|
2104 | break; |
|
|
2105 | } |
|
|
2106 | } |
|
|
2107 | |
|
|
2108 | return; |
1750 | } |
2109 | } |
1751 | break; |
|
|
1752 | } |
|
|
1753 | } |
|
|
1754 | return; |
|
|
1755 | } |
|
|
1756 | #if MENUBAR |
|
|
1757 | /* |
|
|
1758 | * Menubar window processing of button press |
|
|
1759 | */ |
|
|
1760 | if (isMenuBarWindow(ev->window)) |
|
|
1761 | rxvt_menubar_control(aR_ ev); |
|
|
1762 | #endif |
|
|
1763 | } |
2110 | } |
1764 | |
2111 | |
1765 | /* INTPROTO */ |
|
|
1766 | void |
2112 | void |
1767 | rxvt_button_release(pR_ XButtonEvent *ev) |
2113 | rxvt_term::button_release (XButtonEvent &ev) |
1768 | { |
2114 | { |
1769 | int reportmode = 0; |
2115 | int reportmode = 0; |
1770 | |
2116 | |
1771 | R->csrO = 0; /* reset csr Offset */ |
2117 | csrO = 0; /* reset csr Offset */ |
1772 | if (!R->bypass_keystate) |
2118 | if (!bypass_keystate) |
1773 | reportmode = !!(R->PrivateModes & PrivMode_mouse_report); |
2119 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1774 | |
2120 | |
1775 | if (scrollbar_isUpDn()) { |
2121 | if (scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) |
1776 | R->scrollBar.setIdle (); |
|
|
1777 | rxvt_scrollbar_show(aR_ 0); |
|
|
1778 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1779 | R->refresh_type &= ~SMOOTH_REFRESH; |
|
|
1780 | #endif |
|
|
1781 | } |
2122 | { |
|
|
2123 | scrollBar.state = SB_STATE_IDLE; |
|
|
2124 | scrollBar.show (0); |
|
|
2125 | } |
|
|
2126 | |
1782 | #ifdef SELECTION_SCROLLING |
2127 | #ifdef SELECTION_SCROLLING |
1783 | R->pending_scroll_selection=0; |
2128 | sel_scroll_ev.stop(); |
1784 | #endif |
2129 | #endif |
1785 | if (ev->window == R->TermWin.vt) |
2130 | |
|
|
2131 | if (ev.window == vt) |
1786 | { |
2132 | { |
1787 | #ifdef RXVT_GRAPHICS |
2133 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
1788 | if (ev->subwindow != None) |
2134 | return; |
1789 | rxvt_Gr_ButtonRelease(ev->x, ev->y); |
2135 | |
1790 | else |
2136 | #if ISO_14755 |
|
|
2137 | // 5.4 |
|
|
2138 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
|
|
2139 | return; |
1791 | #endif |
2140 | #endif |
1792 | { |
2141 | |
1793 | if (reportmode) |
2142 | if (reportmode) |
1794 | { |
2143 | { |
1795 | /* mouse report from vt window */ |
2144 | /* mouse report from vt window */ |
1796 | /* don't report release of wheel "buttons" */ |
2145 | /* don't report release of wheel "buttons" */ |
1797 | if (ev->button >= 4) |
2146 | if (ev.button >= 4) |
1798 | return; |
2147 | return; |
1799 | #ifdef MOUSE_REPORT_DOUBLECLICK |
2148 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1800 | /* only report the release of 'slow' single clicks */ |
2149 | /* only report the release of 'slow' single clicks */ |
1801 | if (R->MEvent.button != AnyButton |
2150 | if (MEvent.button != AnyButton |
1802 | && (ev->button != R->MEvent.button |
2151 | && (ev.button != MEvent.button |
1803 | || (ev->time - R->MEvent.time |
2152 | || (ev.time - MEvent.time |
1804 | > MULTICLICK_TIME / 2))) |
2153 | > multiClickTime / 2))) |
1805 | { |
2154 | { |
1806 | R->MEvent.clicks = 0; |
2155 | MEvent.clicks = 0; |
1807 | R->MEvent.button = AnyButton; |
2156 | MEvent.button = ev.button; |
1808 | rxvt_mouse_report(aR_ ev); |
2157 | mouse_report (ev); |
1809 | } |
2158 | } |
1810 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2159 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
1811 | R->MEvent.button = AnyButton; |
2160 | MEvent.button = ev.button; |
1812 | rxvt_mouse_report(aR_ ev); |
2161 | mouse_report (ev); |
1813 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2162 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1814 | return; |
2163 | return; |
1815 | } |
2164 | } |
|
|
2165 | |
1816 | /* |
2166 | /* |
1817 | * dumb hack to compensate for the failure of click-and-drag |
2167 | * dumb hack to compensate for the failure of click-and-drag |
1818 | * when overriding mouse reporting |
2168 | * when overriding mouse reporting |
1819 | */ |
2169 | */ |
1820 | if (R->PrivateModes & PrivMode_mouse_report |
2170 | if (priv_modes & PrivMode_mouse_report |
1821 | && R->bypass_keystate |
2171 | && bypass_keystate |
1822 | && ev->button == Button1 && R->MEvent.clicks <= 1) |
2172 | && ev.button == Button1 && MEvent.clicks <= 1) |
1823 | rxvt_selection_extend(aR_ ev->x, ev->y, 0); |
2173 | selection_extend (ev.x, ev.y, 0); |
1824 | |
2174 | |
1825 | switch (ev->button) { |
2175 | switch (ev.button) |
|
|
2176 | { |
1826 | case Button1: |
2177 | case Button1: |
1827 | case Button3: |
2178 | case Button3: |
1828 | rxvt_selection_make(aR_ ev->time); |
2179 | selection_make (ev.time); |
1829 | break; |
2180 | break; |
|
|
2181 | |
1830 | case Button2: |
2182 | case Button2: |
1831 | rxvt_selection_request(aR_ ev->time, ev->x, ev->y); |
2183 | if (IN_RANGE_EXC (ev.x, 0, vt_width) && IN_RANGE_EXC (ev.y, 0, vt_height)) // inside window? |
1832 | break; |
2184 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
|
|
2185 | break; |
|
|
2186 | |
1833 | #ifdef MOUSE_WHEEL |
2187 | #ifdef MOUSE_WHEEL |
1834 | case Button4: |
2188 | case Button4: |
1835 | case Button5: |
2189 | case Button5: |
1836 | { |
2190 | { |
1837 | int i; |
2191 | int lines; |
1838 | page_dirn v; |
2192 | page_dirn dirn; |
1839 | |
2193 | |
1840 | v = (ev->button == Button4) ? UP : DN; |
2194 | dirn = ev.button == Button4 ? UP : DN; |
|
|
2195 | |
1841 | if (ev->state & ShiftMask) |
2196 | if (ev.state & ShiftMask) |
1842 | i = 1; |
2197 | lines = 1; |
1843 | else if ((R->Options & Opt_mouseWheelScrollPage)) |
2198 | else if (option (Opt_mouseWheelScrollPage)) |
1844 | i = R->TermWin.nrow - 1; |
2199 | lines = nrow - 1; |
1845 | else |
2200 | else |
1846 | i = 5; |
2201 | lines = 5; |
|
|
2202 | |
1847 | # ifdef MOUSE_SLIP_WHEELING |
2203 | # ifdef MOUSE_SLIP_WHEELING |
1848 | if (ev->state & ControlMask) |
2204 | if (ev.state & ControlMask) |
1849 | { |
2205 | { |
1850 | R->mouse_slip_wheel_speed += (v ? -1 : 1); |
2206 | mouse_slip_wheel_speed += dirn; |
1851 | R->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
2207 | clamp_it (mouse_slip_wheel_speed, -nrow, nrow); |
1852 | } |
2208 | |
|
|
2209 | if (!slip_wheel_ev.is_active ()) |
|
|
2210 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
|
|
2211 | } |
|
|
2212 | else |
1853 | # endif |
2213 | # endif |
1854 | # ifdef JUMP_MOUSE_WHEEL |
|
|
1855 | rxvt_scr_page(aR_ v, i); |
|
|
1856 | rxvt_scr_refresh(aR_ SMOOTH_REFRESH); |
|
|
1857 | rxvt_scrollbar_show(aR_ 1); |
|
|
1858 | # else |
|
|
1859 | for (; i--;) |
|
|
1860 | { |
2214 | { |
1861 | rxvt_scr_page(aR_ v, 1); |
2215 | scr_page (dirn, lines); |
1862 | rxvt_scr_refresh(aR_ SMOOTH_REFRESH); |
2216 | scrollBar.show (1); |
1863 | rxvt_scrollbar_show(aR_ 1); |
2217 | } |
1864 | } |
2218 | } |
|
|
2219 | break; |
1865 | # endif |
2220 | #endif |
1866 | } |
|
|
1867 | break; |
|
|
1868 | #endif |
|
|
1869 | } |
|
|
1870 | } |
|
|
1871 | } |
2221 | } |
1872 | #ifdef MENUBAR |
|
|
1873 | else if (isMenuBarWindow(ev->window)) |
|
|
1874 | rxvt_menubar_control(aR_ ev); |
|
|
1875 | #endif |
|
|
1876 | } |
|
|
1877 | |
|
|
1878 | |
|
|
1879 | #ifdef TRANSPARENT |
|
|
1880 | /* |
|
|
1881 | * Check our parents are still who we think they are. |
|
|
1882 | * Do transparency updates if required |
|
|
1883 | */ |
|
|
1884 | /* EXTPROTO */ |
|
|
1885 | int |
|
|
1886 | rxvt_check_our_parents(pR) |
|
|
1887 | { |
|
|
1888 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
1889 | unsigned long nitems, bytes_after; |
|
|
1890 | Atom atype; |
|
|
1891 | unsigned char *prop = NULL; |
|
|
1892 | Window root, oldp, *list; |
|
|
1893 | Pixmap rootpixmap = None; |
|
|
1894 | XWindowAttributes wattr, wrootattr; |
|
|
1895 | |
|
|
1896 | pchanged = 0; |
|
|
1897 | |
|
|
1898 | if (!(R->Options & Opt_transparent)) |
|
|
1899 | return pchanged; /* Don't try any more */ |
|
|
1900 | |
|
|
1901 | XGetWindowAttributes(R->Xdisplay, Xroot, &wrootattr); |
|
|
1902 | rootdepth = wrootattr.depth; |
|
|
1903 | |
|
|
1904 | XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); |
|
|
1905 | if (rootdepth != wattr.depth) { |
|
|
1906 | if (R->am_transparent) { |
|
|
1907 | pchanged = 1; |
|
|
1908 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
|
|
1909 | R->PixColors[Color_bg]); |
|
|
1910 | R->am_transparent = R->am_pixmap_trans = 0; |
|
|
1911 | } |
|
|
1912 | return pchanged; /* Don't try any more */ |
|
|
1913 | } |
|
|
1914 | |
|
|
1915 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
1916 | XSync(R->Xdisplay, False); |
|
|
1917 | |
|
|
1918 | /* |
|
|
1919 | * Make the frame window set by the window manager have |
|
|
1920 | * the root background. Some window managers put multiple nested frame |
|
|
1921 | * windows for each client, so we have to take care about that. |
|
|
1922 | */ |
|
|
1923 | i = (R->xa[XA_XROOTPMAPID] != 0 |
|
|
1924 | && (XGetWindowProperty(R->Xdisplay, Xroot, R->xa[XA_XROOTPMAPID], |
|
|
1925 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
1926 | &nitems, &bytes_after, &prop) == Success)); |
|
|
1927 | if (!i || prop == NULL) |
|
|
1928 | have_pixmap = 0; |
|
|
1929 | else { |
|
|
1930 | have_pixmap = 1; |
|
|
1931 | rootpixmap = *((Pixmap *)prop); |
|
|
1932 | XFree(prop); |
|
|
1933 | } |
|
|
1934 | if (have_pixmap) { |
|
|
1935 | /* |
|
|
1936 | * Copy Xroot pixmap transparency |
|
|
1937 | */ |
|
|
1938 | int sx, sy, nx, ny; |
|
|
1939 | unsigned int nw, nh; |
|
|
1940 | Window cr; |
|
|
1941 | XImage *image; |
|
|
1942 | GC gc; |
|
|
1943 | XGCValues gcvalue; |
|
|
1944 | |
|
|
1945 | XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], Xroot, |
|
|
1946 | 0, 0, &sx, &sy, &cr); |
|
|
1947 | nw = (unsigned int)R->szHint.width; |
|
|
1948 | nh = (unsigned int)R->szHint.height; |
|
|
1949 | nx = ny = 0; |
|
|
1950 | if (sx < 0) { |
|
|
1951 | nw += sx; |
|
|
1952 | nx = -sx; |
|
|
1953 | sx = 0; |
|
|
1954 | } |
|
|
1955 | if (sy < 0) { |
|
|
1956 | nh += sy; |
|
|
1957 | ny = -sy; |
|
|
1958 | sy = 0; |
|
|
1959 | } |
|
|
1960 | MIN_IT(nw, (unsigned int)(wrootattr.width - sx)); |
|
|
1961 | MIN_IT(nh, (unsigned int)(wrootattr.height - sy)); |
|
|
1962 | R->allowedxerror = -1; |
|
|
1963 | image = XGetImage(R->Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes, |
|
|
1964 | ZPixmap); |
|
|
1965 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
1966 | /* XXX: may need a delay here? */ |
|
|
1967 | R->allowedxerror = 0; |
|
|
1968 | if (image == NULL) { |
|
|
1969 | if (R->am_transparent && R->am_pixmap_trans) { |
|
|
1970 | pchanged = 1; |
|
|
1971 | if (R->TermWin.pixmap != None) { |
|
|
1972 | XFreePixmap(R->Xdisplay, R->TermWin.pixmap); |
|
|
1973 | R->TermWin.pixmap = None; |
|
|
1974 | } |
|
|
1975 | } |
2222 | } |
1976 | R->am_pixmap_trans = 0; |
|
|
1977 | } else { |
|
|
1978 | if (R->TermWin.pixmap != None) |
|
|
1979 | XFreePixmap(R->Xdisplay, R->TermWin.pixmap); |
|
|
1980 | R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, |
|
|
1981 | (unsigned int)R->szHint.width, |
|
|
1982 | (unsigned int)R->szHint.height, |
|
|
1983 | (unsigned int)image->depth); |
|
|
1984 | gc = XCreateGC(R->Xdisplay, R->TermWin.vt, 0UL, &gcvalue); |
|
|
1985 | XPutImage(R->Xdisplay, R->TermWin.pixmap, gc, image, 0, 0, |
|
|
1986 | nx, ny, (unsigned int)image->width, |
|
|
1987 | (unsigned int)image->height); |
|
|
1988 | XFreeGC(R->Xdisplay, gc); |
|
|
1989 | XDestroyImage(image); |
|
|
1990 | XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, |
|
|
1991 | R->TermWin.pixmap); |
|
|
1992 | if (!R->am_transparent || !R->am_pixmap_trans) |
|
|
1993 | pchanged = 1; |
|
|
1994 | R->am_transparent = R->am_pixmap_trans = 1; |
|
|
1995 | } |
|
|
1996 | } |
|
|
1997 | if (!R->am_pixmap_trans) { |
|
|
1998 | unsigned int n; |
|
|
1999 | /* |
|
|
2000 | * InheritPixmap transparency |
|
|
2001 | */ |
|
|
2002 | D_X((stderr, "InheritPixmap Seeking to %08lx", Xroot)); |
|
|
2003 | for (i = 1; i < (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
|
|
2004 | i++) { |
|
|
2005 | oldp = R->TermWin.parent[i]; |
|
|
2006 | XQueryTree(R->Xdisplay, R->TermWin.parent[i - 1], &root, |
|
|
2007 | &R->TermWin.parent[i], &list, &n); |
|
|
2008 | XFree(list); |
|
|
2009 | D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, R->TermWin.parent[i])); |
|
|
2010 | if (R->TermWin.parent[i] == Xroot) { |
|
|
2011 | if (oldp != None) |
|
|
2012 | pchanged = 1; |
|
|
2013 | break; |
|
|
2014 | } |
|
|
2015 | if (oldp != R->TermWin.parent[i]) |
|
|
2016 | pchanged = 1; |
|
|
2017 | } |
|
|
2018 | n = 0; |
|
|
2019 | if (pchanged) { |
|
|
2020 | for (; n < (unsigned int)i; n++) { |
|
|
2021 | XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr); |
|
|
2022 | D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL")); |
|
|
2023 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) { |
|
|
2024 | n = (int)(sizeof(R->TermWin.parent) / sizeof(Window)) + 1; |
|
|
2025 | break; |
|
|
2026 | } |
|
|
2027 | } |
|
|
2028 | } |
|
|
2029 | if (n > (int)(sizeof(R->TermWin.parent) |
|
|
2030 | / sizeof(R->TermWin.parent[0]))) { |
|
|
2031 | D_X((stderr, "InheritPixmap Turning off")); |
|
|
2032 | XSetWindowBackground(R->Xdisplay, R->TermWin.parent[0], |
|
|
2033 | R->PixColors[Color_fg]); |
|
|
2034 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
|
|
2035 | R->PixColors[Color_bg]); |
|
|
2036 | R->am_transparent = 0; |
|
|
2037 | /* XXX: also turn off Opt_transparent? */ |
|
|
2038 | } else { |
|
|
2039 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2040 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2041 | # ifdef HAVE_NANOSLEEP |
|
|
2042 | struct timespec rqt; |
|
|
2043 | |
|
|
2044 | rqt.tv_sec = 1; |
|
|
2045 | rqt.tv_nsec = 0; |
|
|
2046 | nanosleep(&rqt, NULL); |
|
|
2047 | # else |
|
|
2048 | sleep(1); |
|
|
2049 | # endif |
|
|
2050 | D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); |
|
|
2051 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2052 | XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.parent[n], |
|
|
2053 | ParentRelative); |
|
|
2054 | XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, |
|
|
2055 | ParentRelative); |
|
|
2056 | R->am_transparent = 1; |
|
|
2057 | } |
|
|
2058 | for (; i < (int)(sizeof(R->TermWin.parent) / sizeof(Window)); i++) |
|
|
2059 | R->TermWin.parent[i] = None; |
|
|
2060 | } |
|
|
2061 | return pchanged; |
|
|
2062 | } |
2223 | } |
2063 | #endif |
|
|
2064 | |
2224 | |
2065 | /*}}} */ |
2225 | /*}}} */ |
|
|
2226 | |
|
|
2227 | void ecb_hot |
|
|
2228 | rxvt_term::cmd_parse () |
|
|
2229 | { |
|
|
2230 | wchar_t ch = NOCHAR; |
|
|
2231 | char *seq_begin; // remember start of esc-sequence here |
|
|
2232 | |
|
|
2233 | for (;;) |
|
|
2234 | { |
|
|
2235 | if (ecb_unlikely (ch == NOCHAR)) |
|
|
2236 | { |
|
|
2237 | seq_begin = cmdbuf_ptr; |
|
|
2238 | ch = next_char (); |
|
|
2239 | |
|
|
2240 | if (ch == NOCHAR) |
|
|
2241 | break; |
|
|
2242 | } |
|
|
2243 | |
|
|
2244 | if (ecb_likely (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
|
|
2245 | { |
|
|
2246 | if (ecb_unlikely (!seen_input)) |
|
|
2247 | { |
|
|
2248 | seen_input = 1; |
|
|
2249 | // many badly-written programs (e.g. jed) contain a race condition: |
|
|
2250 | // they first read the screensize and then install a SIGWINCH handler. |
|
|
2251 | // some window managers resize the window early, and these programs |
|
|
2252 | // then sometimes get the size wrong. |
|
|
2253 | // unfortunately other programs are even more buggy and dislike |
|
|
2254 | // being sent SIGWINCH, so only do it when we were in fact being |
|
|
2255 | // resized. |
|
|
2256 | if (seen_resize && cmd_pid) |
|
|
2257 | kill (-cmd_pid, SIGWINCH); |
|
|
2258 | } |
|
|
2259 | |
|
|
2260 | /* Read a text string from the input buffer */ |
|
|
2261 | wchar_t buf[UBUFSIZ]; |
|
|
2262 | bool refreshnow = false; |
|
|
2263 | int nlines = 0; |
|
|
2264 | wchar_t *str = buf; |
|
|
2265 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
|
|
2266 | |
|
|
2267 | for (;;) |
|
|
2268 | { |
|
|
2269 | if (ecb_unlikely (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
|
|
2270 | break; |
|
|
2271 | |
|
|
2272 | *str++ = ch; |
|
|
2273 | |
|
|
2274 | if (ecb_unlikely (ch == C0_LF || str >= eol)) |
|
|
2275 | { |
|
|
2276 | if (ch == C0_LF) |
|
|
2277 | nlines++; |
|
|
2278 | |
|
|
2279 | refresh_count++; |
|
|
2280 | |
|
|
2281 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
|
|
2282 | { |
|
|
2283 | refresh_count = 0; |
|
|
2284 | |
|
|
2285 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2286 | { |
|
|
2287 | refreshnow = true; |
|
|
2288 | ch = NOCHAR; |
|
|
2289 | break; |
|
|
2290 | } |
|
|
2291 | } |
|
|
2292 | |
|
|
2293 | // scr_add_lines only works for nlines <= nrow - 1. |
|
|
2294 | if (nlines >= nrow - 1) |
|
|
2295 | { |
|
|
2296 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2297 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
|
|
2298 | scr_add_lines (buf, str - buf, nlines); |
|
|
2299 | |
|
|
2300 | nlines = 0; |
|
|
2301 | str = buf; |
|
|
2302 | eol = str + min (ncol, UBUFSIZ); |
|
|
2303 | } |
|
|
2304 | |
|
|
2305 | if (str >= eol) |
|
|
2306 | { |
|
|
2307 | if (eol >= buf + UBUFSIZ) |
|
|
2308 | { |
|
|
2309 | ch = NOCHAR; |
|
|
2310 | break; |
|
|
2311 | } |
|
|
2312 | else |
|
|
2313 | eol = min (eol + ncol, buf + UBUFSIZ); |
|
|
2314 | } |
|
|
2315 | |
|
|
2316 | } |
|
|
2317 | |
|
|
2318 | seq_begin = cmdbuf_ptr; |
|
|
2319 | ch = next_char (); |
|
|
2320 | } |
|
|
2321 | |
|
|
2322 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2323 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
|
|
2324 | scr_add_lines (buf, str - buf, nlines); |
|
|
2325 | |
|
|
2326 | /* |
|
|
2327 | * If there have been a lot of new lines, then update the screen |
|
|
2328 | * What the heck we'll cheat and only refresh less than every page-full. |
|
|
2329 | * if skipScroll is enabled. |
|
|
2330 | */ |
|
|
2331 | if (refreshnow) |
|
|
2332 | { |
|
|
2333 | scr_refresh (); |
|
|
2334 | want_refresh = 1; |
|
|
2335 | } |
|
|
2336 | } |
|
|
2337 | else |
|
|
2338 | { |
|
|
2339 | try |
|
|
2340 | { |
|
|
2341 | process_nonprinting (ch); |
|
|
2342 | } |
|
|
2343 | catch (const class out_of_input &o) |
|
|
2344 | { |
|
|
2345 | // we ran out of input, retry later |
|
|
2346 | cmdbuf_ptr = seq_begin; |
|
|
2347 | break; |
|
|
2348 | } |
|
|
2349 | |
|
|
2350 | ch = NOCHAR; |
|
|
2351 | } |
|
|
2352 | } |
|
|
2353 | } |
|
|
2354 | |
|
|
2355 | // read the next character |
|
|
2356 | wchar_t ecb_hot |
|
|
2357 | rxvt_term::next_char () NOTHROW |
|
|
2358 | { |
|
|
2359 | while (cmdbuf_ptr < cmdbuf_endp) |
|
|
2360 | { |
|
|
2361 | // assume 7-bit to be ascii ALWAYS (always true in POSIX) |
|
|
2362 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f)) |
|
|
2363 | return *cmdbuf_ptr++; |
|
|
2364 | |
|
|
2365 | wchar_t wc; |
|
|
2366 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
|
|
2367 | |
|
|
2368 | if (len == (size_t)-2) |
|
|
2369 | { |
|
|
2370 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
2371 | cmdbuf_ptr = cmdbuf_endp; |
|
|
2372 | break; |
|
|
2373 | } |
|
|
2374 | |
|
|
2375 | if (len == (size_t)-1) |
|
|
2376 | { |
|
|
2377 | mbstate.reset (); // reset now undefined conversion state |
|
|
2378 | // a -1 might indicate that a previous incomplete char is invalid (previous return -2) |
|
|
2379 | // in which case we "erroneously" return the next byte which might be valid. |
|
|
2380 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
2381 | } |
|
|
2382 | |
|
|
2383 | // assume wchar == unicode |
|
|
2384 | cmdbuf_ptr += len; |
|
|
2385 | return wc & UNICODE_MASK; |
|
|
2386 | } |
|
|
2387 | |
|
|
2388 | return NOCHAR; |
|
|
2389 | } |
|
|
2390 | |
|
|
2391 | // read the next octet |
|
|
2392 | uint32_t ecb_hot |
|
|
2393 | rxvt_term::next_octet () NOTHROW |
|
|
2394 | { |
|
|
2395 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2396 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2397 | : NOCHAR; |
|
|
2398 | } |
|
|
2399 | |
|
|
2400 | static class out_of_input out_of_input; |
|
|
2401 | |
|
|
2402 | wchar_t ecb_hot |
|
|
2403 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
|
|
2404 | { |
|
|
2405 | wchar_t c = next_char (); |
|
|
2406 | |
|
|
2407 | if (c == NOCHAR) |
|
|
2408 | throw out_of_input; |
|
|
2409 | |
|
|
2410 | return c; |
|
|
2411 | } |
|
|
2412 | |
|
|
2413 | uint32_t ecb_hot |
|
|
2414 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
|
|
2415 | { |
|
|
2416 | uint32_t c = next_octet (); |
|
|
2417 | |
|
|
2418 | if (c == NOCHAR) |
|
|
2419 | throw out_of_input; |
|
|
2420 | |
|
|
2421 | return c; |
|
|
2422 | } |
2066 | |
2423 | |
2067 | /*{{{ print pipe */ |
2424 | /*{{{ print pipe */ |
2068 | /*----------------------------------------------------------------------*/ |
2425 | /*----------------------------------------------------------------------*/ |
2069 | #ifdef PRINTPIPE |
2426 | #ifdef PRINTPIPE |
2070 | /* EXTPROTO */ |
2427 | FILE * ecb_cold |
2071 | FILE * |
|
|
2072 | rxvt_popen_printer(pR) |
2428 | rxvt_term::popen_printer () |
2073 | { |
2429 | { |
2074 | FILE *stream = popen(R->rs[Rs_print_pipe], "w"); |
2430 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2075 | |
2431 | |
2076 | if (stream == NULL) |
2432 | if (stream == NULL) |
2077 | rxvt_print_error("can't open printer pipe"); |
2433 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
|
|
2434 | |
2078 | return stream; |
2435 | return stream; |
2079 | } |
2436 | } |
2080 | |
2437 | |
2081 | /* EXTPROTO */ |
2438 | int ecb_cold |
2082 | int |
|
|
2083 | rxvt_pclose_printer (FILE *stream) |
2439 | rxvt_term::pclose_printer (FILE *stream) |
2084 | { |
2440 | { |
2085 | fflush (stream); |
2441 | fflush (stream); |
2086 | /* pclose() reported not to work on SunOS 4.1.3 */ |
|
|
2087 | # if defined (__sun__) /* TODO: RESOLVE THIS */ |
|
|
2088 | /* pclose works provided SIGCHLD handler uses waitpid */ |
|
|
2089 | return pclose (stream); /* return fclose (stream); */ |
|
|
2090 | # else |
|
|
2091 | return pclose (stream); |
2442 | return pclose (stream); |
2092 | # endif |
|
|
2093 | } |
2443 | } |
2094 | |
2444 | |
2095 | /* |
2445 | /* |
2096 | * simulate attached vt100 printer |
2446 | * simulate attached vt100 printer |
2097 | */ |
2447 | */ |
2098 | /* INTPROTO */ |
2448 | void ecb_cold |
2099 | void |
|
|
2100 | rxvt_process_print_pipe(pR) |
2449 | rxvt_term::process_print_pipe () |
2101 | { |
2450 | { |
2102 | int done; |
2451 | FILE *fd = popen_printer (); |
2103 | FILE *fd; |
|
|
2104 | |
2452 | |
2105 | if ((fd = rxvt_popen_printer(aR)) == NULL) |
2453 | if (!fd) |
2106 | return; |
2454 | return; |
2107 | |
2455 | |
2108 | /* |
2456 | /* |
2109 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2457 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2110 | * is received. |
2458 | * is received. |
2111 | */ |
2459 | */ |
2112 | for (done = 0; !done;) { |
2460 | for (int done = 0; !done; ) |
|
|
2461 | { |
2113 | unsigned char buf[8]; |
2462 | unsigned char buf[8]; |
2114 | unsigned char ch; |
2463 | unicode_t ch; |
2115 | unsigned int i, len; |
2464 | unsigned int i, len; |
2116 | |
2465 | |
2117 | if ((ch = rxvt_cmd_getc(aR)) != C0_ESC) { |
2466 | if ((ch = cmd_getc ()) != C0_ESC) |
|
|
2467 | { |
2118 | if (putc(ch, fd) == EOF) |
2468 | if (putc (ch, fd) == EOF) |
2119 | break; /* done = 1 */ |
2469 | break; /* done = 1 */ |
2120 | } else { |
2470 | } |
|
|
2471 | else |
|
|
2472 | { |
2121 | len = 0; |
2473 | len = 0; |
2122 | buf[len++] = ch; |
2474 | buf[len++] = ch; |
2123 | |
2475 | |
2124 | if ((buf[len++] = rxvt_cmd_getc(aR)) == '[') { |
2476 | if ((buf[len++] = cmd_getc ()) == '[') |
2125 | if ((ch = rxvt_cmd_getc(aR)) == '?') { |
2477 | { |
2126 | buf[len++] = '?'; |
2478 | if ((ch = cmd_getc ()) == '?') |
2127 | ch = rxvt_cmd_getc(aR); |
2479 | { |
2128 | } |
2480 | buf[len++] = '?'; |
|
|
2481 | ch = cmd_getc (); |
|
|
2482 | } |
2129 | if ((buf[len++] = ch) == '4') { |
2483 | if ((buf[len++] = ch) == '4') |
|
|
2484 | { |
2130 | if ((buf[len++] = rxvt_cmd_getc(aR)) == 'i') |
2485 | if ((buf[len++] = cmd_getc ()) == 'i') |
2131 | break; /* done = 1 */ |
2486 | break; /* done = 1 */ |
2132 | } |
2487 | } |
|
|
2488 | } |
|
|
2489 | |
|
|
2490 | for (i = 0; i < len; i++) |
|
|
2491 | if (putc (buf[i], fd) == EOF) |
|
|
2492 | { |
|
|
2493 | done = 1; |
|
|
2494 | break; |
|
|
2495 | } |
|
|
2496 | } |
2133 | } |
2497 | } |
2134 | for (i = 0; i < len; i++) |
2498 | |
2135 | if (putc(buf[i], fd) == EOF) { |
|
|
2136 | done = 1; |
|
|
2137 | break; |
|
|
2138 | } |
|
|
2139 | } |
|
|
2140 | } |
|
|
2141 | rxvt_pclose_printer(fd); |
2499 | pclose_printer (fd); |
2142 | } |
2500 | } |
2143 | #endif /* PRINTPIPE */ |
2501 | #endif /* PRINTPIPE */ |
2144 | /*}}} */ |
2502 | /*}}} */ |
2145 | |
2503 | |
2146 | /* *INDENT-OFF* */ |
|
|
2147 | enum { |
2504 | enum { |
2148 | C1_40 = 0x40, |
2505 | C1_40 = 0x40, |
2149 | C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, |
2506 | C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, |
2150 | C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, |
2507 | C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, |
2151 | C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, |
2508 | C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, |
2152 | C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC |
2509 | C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC, |
2153 | }; |
2510 | }; |
2154 | /* *INDENT-ON* */ |
|
|
2155 | |
2511 | |
2156 | /*{{{ process non-printing single characters */ |
2512 | /*{{{ process non-printing single characters */ |
2157 | /* INTPROTO */ |
2513 | void ecb_hot |
2158 | void |
2514 | rxvt_term::process_nonprinting (unicode_t ch) |
2159 | rxvt_process_nonprinting(pR_ unsigned char ch) |
|
|
2160 | { |
2515 | { |
2161 | switch (ch) { |
2516 | switch (ch) |
|
|
2517 | { |
|
|
2518 | case C0_ESC: |
|
|
2519 | process_escape_seq (); |
|
|
2520 | break; |
2162 | case C0_ENQ: /* terminal Status */ |
2521 | case C0_ENQ: /* terminal Status */ |
2163 | if (R->rs[Rs_answerbackstring]) |
2522 | if (rs[Rs_answerbackstring]) |
2164 | R->tt_write( |
2523 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2165 | (const unsigned char *)R->rs[Rs_answerbackstring], |
2524 | else |
2166 | (unsigned int)STRLEN(R->rs[Rs_answerbackstring])); |
2525 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2167 | else |
2526 | break; |
2168 | R->tt_write((unsigned char *)VT100_ANS, |
|
|
2169 | (unsigned int)STRLEN(VT100_ANS)); |
|
|
2170 | break; |
|
|
2171 | case C0_BEL: /* bell */ |
2527 | case C0_BEL: /* bell */ |
2172 | rxvt_scr_bell(aR); |
2528 | scr_bell (); |
2173 | break; |
2529 | break; |
2174 | case C0_BS: /* backspace */ |
2530 | case C0_BS: /* backspace */ |
2175 | rxvt_scr_backspace(aR); |
2531 | scr_backspace (); |
2176 | break; |
2532 | break; |
2177 | case C0_HT: /* tab */ |
2533 | case C0_HT: /* tab */ |
2178 | rxvt_scr_tab(aR_ 1); |
2534 | scr_tab (1); |
2179 | break; |
2535 | break; |
2180 | case C0_CR: /* carriage return */ |
2536 | case C0_CR: /* carriage return */ |
2181 | rxvt_scr_gotorc(aR_ 0, 0, R_RELATIVE); |
2537 | scr_gotorc (0, 0, R_RELATIVE); |
2182 | break; |
2538 | break; |
2183 | case C0_VT: /* vertical tab, form feed */ |
2539 | case C0_VT: /* vertical tab, form feed */ |
2184 | case C0_FF: |
2540 | case C0_FF: |
2185 | case C0_LF: /* line feed */ |
2541 | case C0_LF: /* line feed */ |
2186 | rxvt_scr_index(aR_ UP); |
2542 | scr_index (UP); |
2187 | break; |
2543 | break; |
2188 | case C0_SO: /* shift out - acs */ |
2544 | case C0_SO: /* shift out - acs */ |
2189 | rxvt_scr_charset_choose(aR_ 1); |
2545 | scr_charset_choose (1); |
2190 | break; |
2546 | break; |
2191 | case C0_SI: /* shift in - acs */ |
2547 | case C0_SI: /* shift in - acs */ |
2192 | rxvt_scr_charset_choose(aR_ 0); |
2548 | scr_charset_choose (0); |
2193 | break; |
2549 | break; |
|
|
2550 | |
|
|
2551 | #ifdef EIGHT_BIT_CONTROLS |
|
|
2552 | // 8-bit controls |
|
|
2553 | case 0x90: /* DCS */ |
|
|
2554 | process_dcs_seq (); |
|
|
2555 | break; |
|
|
2556 | case 0x9b: /* CSI */ |
|
|
2557 | process_csi_seq (); |
|
|
2558 | break; |
|
|
2559 | case 0x9d: /* OSC */ |
|
|
2560 | process_osc_seq (); |
|
|
2561 | break; |
|
|
2562 | #endif |
2194 | } |
2563 | } |
2195 | } |
2564 | } |
2196 | /*}}} */ |
2565 | /*}}} */ |
2197 | |
2566 | |
2198 | |
2567 | |
2199 | /*{{{ process VT52 escape sequences */ |
2568 | /*{{{ process VT52 escape sequences */ |
2200 | /* INTPROTO */ |
2569 | void ecb_cold |
2201 | void |
2570 | rxvt_term::process_escape_vt52 (unicode_t ch) |
2202 | rxvt_process_escape_vt52(pR_ unsigned char ch) |
|
|
2203 | { |
2571 | { |
2204 | int row, col; |
2572 | int row, col; |
|
|
2573 | |
|
|
2574 | switch (ch) |
2205 | |
2575 | { |
2206 | switch (ch) { |
|
|
2207 | case 'A': /* cursor up */ |
2576 | case 'A': /* cursor up */ |
2208 | rxvt_scr_gotorc(aR_ -1, 0, R_RELATIVE | C_RELATIVE); |
2577 | scr_gotorc (-1, 0, R_RELATIVE | C_RELATIVE); |
2209 | break; |
2578 | break; |
2210 | case 'B': /* cursor down */ |
2579 | case 'B': /* cursor down */ |
2211 | rxvt_scr_gotorc(aR_ 1, 0, R_RELATIVE | C_RELATIVE); |
2580 | scr_gotorc (1, 0, R_RELATIVE | C_RELATIVE); |
2212 | break; |
2581 | break; |
2213 | case 'C': /* cursor right */ |
2582 | case 'C': /* cursor right */ |
2214 | rxvt_scr_gotorc(aR_ 0, 1, R_RELATIVE | C_RELATIVE); |
2583 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
2215 | break; |
2584 | break; |
2216 | case 'D': /* cursor left */ |
2585 | case 'D': /* cursor left */ |
2217 | rxvt_scr_gotorc(aR_ 0, -1, R_RELATIVE | C_RELATIVE); |
2586 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
2218 | break; |
2587 | break; |
2219 | case 'H': /* cursor home */ |
2588 | case 'H': /* cursor home */ |
2220 | rxvt_scr_gotorc(aR_ 0, 0, 0); |
2589 | scr_gotorc (0, 0, 0); |
2221 | break; |
2590 | break; |
2222 | case 'I': /* cursor up and scroll down if needed */ |
2591 | case 'I': /* cursor up and scroll down if needed */ |
2223 | rxvt_scr_index(aR_ DN); |
2592 | scr_index (DN); |
2224 | break; |
2593 | break; |
2225 | case 'J': /* erase to end of screen */ |
2594 | case 'J': /* erase to end of screen */ |
2226 | rxvt_scr_erase_screen(aR_ 0); |
2595 | scr_erase_screen (0); |
2227 | break; |
2596 | break; |
2228 | case 'K': /* erase to end of line */ |
2597 | case 'K': /* erase to end of line */ |
2229 | rxvt_scr_erase_line(aR_ 0); |
2598 | scr_erase_line (0); |
2230 | break; |
2599 | break; |
2231 | case 'Y': /* move to specified row and col */ |
2600 | case 'Y': /* move to specified row and col */ |
2232 | /* full command is 'ESC Y row col' where row and col |
2601 | /* full command is 'ESC Y row col' where row and col |
2233 | * are encoded by adding 32 and sending the ascii |
2602 | * are encoded by adding 32 and sending the ascii |
2234 | * character. eg. SPACE = 0, '+' = 13, '0' = 18, |
2603 | * character. eg. SPACE = 0, '+' = 13, '0' = 18, |
2235 | * etc. */ |
2604 | * etc. */ |
2236 | row = rxvt_cmd_getc(aR) - ' '; |
2605 | row = cmd_getc () - ' '; |
2237 | col = rxvt_cmd_getc(aR) - ' '; |
2606 | col = cmd_getc () - ' '; |
2238 | rxvt_scr_gotorc(aR_ row, col, 0); |
2607 | scr_gotorc (row, col, 0); |
2239 | break; |
2608 | break; |
2240 | case 'Z': /* identify the terminal type */ |
2609 | case 'Z': /* identify the terminal type */ |
2241 | R->tt_printf("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2610 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2242 | break; |
2611 | break; |
2243 | case '<': /* turn off VT52 mode */ |
2612 | case '<': /* turn off VT52 mode */ |
2244 | PrivMode(0, PrivMode_vt52); |
2613 | priv_modes &= ~PrivMode_vt52; |
2245 | break; |
2614 | break; |
2246 | case 'F': /* use special graphics character set */ |
2615 | case 'F': /* use special graphics character set */ |
2247 | case 'G': /* use regular character set */ |
2616 | case 'G': /* use regular character set */ |
2248 | /* unimplemented */ |
2617 | /* unimplemented */ |
2249 | break; |
2618 | break; |
2250 | case '=': /* use alternate keypad mode */ |
2619 | case '=': /* use alternate keypad mode */ |
2251 | case '>': /* use regular keypad mode */ |
2620 | case '>': /* use regular keypad mode */ |
2252 | /* unimplemented */ |
2621 | /* unimplemented */ |
2253 | break; |
2622 | break; |
2254 | } |
2623 | } |
2255 | } |
2624 | } |
2256 | /*}}} */ |
2625 | /*}}} */ |
2257 | |
2626 | |
2258 | |
2627 | |
2259 | /*{{{ process escape sequences */ |
2628 | /*{{{ process escape sequences */ |
2260 | /* INTPROTO */ |
2629 | void ecb_hot |
2261 | void |
|
|
2262 | rxvt_process_escape_seq(pR) |
2630 | rxvt_term::process_escape_seq () |
2263 | { |
2631 | { |
2264 | unsigned char ch = rxvt_cmd_getc(aR); |
2632 | unicode_t ch = cmd_getc (); |
2265 | |
2633 | |
2266 | if (R->PrivateModes & PrivMode_vt52) { |
2634 | if (priv_modes & PrivMode_vt52) |
2267 | rxvt_process_escape_vt52(aR_ ch); |
|
|
2268 | return; |
|
|
2269 | } |
|
|
2270 | |
2635 | { |
|
|
2636 | process_escape_vt52 (ch); |
|
|
2637 | return; |
|
|
2638 | } |
|
|
2639 | |
2271 | switch (ch) { |
2640 | switch (ch) |
2272 | /* case 1: do_tek_mode (); break; */ |
2641 | { |
2273 | case '#': |
2642 | case '#': |
2274 | if (rxvt_cmd_getc(aR) == '8') |
2643 | if (cmd_getc () == '8') |
2275 | rxvt_scr_E(aR); |
2644 | scr_E (); |
2276 | break; |
2645 | break; |
2277 | case '(': |
2646 | case '(': |
2278 | rxvt_scr_charset_set(aR_ 0, (unsigned int)rxvt_cmd_getc(aR)); |
2647 | scr_charset_set (0, (unsigned int)cmd_getc ()); |
2279 | break; |
2648 | break; |
2280 | case ')': |
2649 | case ')': |
2281 | rxvt_scr_charset_set(aR_ 1, (unsigned int)rxvt_cmd_getc(aR)); |
2650 | scr_charset_set (1, (unsigned int)cmd_getc ()); |
2282 | break; |
2651 | break; |
2283 | case '*': |
2652 | case '*': |
2284 | rxvt_scr_charset_set(aR_ 2, (unsigned int)rxvt_cmd_getc(aR)); |
2653 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2285 | break; |
2654 | break; |
2286 | case '+': |
2655 | case '+': |
2287 | rxvt_scr_charset_set(aR_ 3, (unsigned int)rxvt_cmd_getc(aR)); |
2656 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2288 | break; |
2657 | break; |
2289 | #ifdef MULTICHAR_SET |
2658 | #if !ENABLE_MINIMAL |
2290 | case '$': |
|
|
2291 | rxvt_scr_charset_set(aR_ -2, (unsigned int)rxvt_cmd_getc(aR)); |
|
|
2292 | break; |
|
|
2293 | #endif |
|
|
2294 | #ifndef NO_FRILLS |
|
|
2295 | case '6': |
2659 | case '6': |
2296 | rxvt_scr_backindex(aR); |
2660 | scr_backindex (); |
2297 | break; |
2661 | break; |
2298 | #endif |
2662 | #endif |
2299 | case '7': |
2663 | case '7': |
2300 | rxvt_scr_cursor(aR_ SAVE); |
2664 | scr_cursor (SAVE); |
2301 | break; |
2665 | break; |
2302 | case '8': |
2666 | case '8': |
2303 | rxvt_scr_cursor(aR_ RESTORE); |
2667 | scr_cursor (RESTORE); |
2304 | break; |
2668 | break; |
2305 | #ifndef NO_FRILLS |
2669 | #if !ENABLE_MINIMAL |
2306 | case '9': |
2670 | case '9': |
2307 | rxvt_scr_forwardindex(aR); |
2671 | scr_forwardindex (); |
2308 | break; |
2672 | break; |
2309 | #endif |
2673 | #endif |
|
|
2674 | // DECPAM/DECPNM |
2310 | case '=': |
2675 | case '=': |
|
|
2676 | priv_modes |= PrivMode_aplKP; |
|
|
2677 | break; |
2311 | case '>': |
2678 | case '>': |
2312 | PrivMode((ch == '='), PrivMode_aplKP); |
2679 | priv_modes &= ~PrivMode_aplKP; |
2313 | break; |
2680 | break; |
2314 | |
2681 | |
2315 | case C1_40: |
2682 | case C1_40: |
2316 | rxvt_cmd_getc(aR); |
2683 | cmd_getc (); |
2317 | break; |
2684 | break; |
2318 | case C1_44: |
2685 | case C1_44: |
2319 | rxvt_scr_index(aR_ UP); |
2686 | scr_index (UP); |
2320 | break; |
2687 | break; |
2321 | |
2688 | |
2322 | /* 8.3.87: NEXT LINE */ |
2689 | /* 8.3.87: NEXT LINE */ |
2323 | case C1_NEL: /* ESC E */ |
2690 | case C1_NEL: /* ESC E */ |
2324 | { |
|
|
2325 | uint32_t nlcr[] = { '\n', '\r' }; |
|
|
2326 | rxvt_scr_add_lines(aR_ nlcr, 1, 2); |
|
|
2327 | } |
2691 | { |
2328 | break; |
2692 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
|
|
2693 | scr_add_lines (nlcr, ecb_array_length (nlcr), 1); |
|
|
2694 | } |
|
|
2695 | break; |
2329 | |
2696 | |
|
|
2697 | #if 0 // disabled because embedded newlines can make exploits easier |
2330 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2698 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2331 | case C1_ESA: /* ESC G */ |
2699 | case C1_ESA: /* ESC G */ |
2332 | rxvt_process_graphics(aR); |
2700 | // used by original rxvt for rob nations own graphics mode |
2333 | break; |
2701 | if (cmd_getc () == 'Q' && option (Opt_insecure)) |
|
|
2702 | tt_printf ("\033G0\012"); /* query graphics - no graphics */ |
|
|
2703 | break; |
|
|
2704 | #endif |
2334 | |
2705 | |
2335 | /* 8.3.63: CHARACTER TABULATION SET */ |
2706 | /* 8.3.63: CHARACTER TABULATION SET */ |
2336 | case C1_HTS: /* ESC H */ |
2707 | case C1_HTS: /* ESC H */ |
2337 | rxvt_scr_set_tab(aR_ 1); |
2708 | scr_set_tab (1); |
2338 | break; |
2709 | break; |
2339 | |
2710 | |
2340 | /* 8.3.105: REVERSE LINE FEED */ |
2711 | /* 8.3.105: REVERSE LINE FEED */ |
2341 | case C1_RI: /* ESC M */ |
2712 | case C1_RI: /* ESC M */ |
2342 | rxvt_scr_index(aR_ DN); |
2713 | scr_index (DN); |
2343 | break; |
2714 | break; |
2344 | |
2715 | |
2345 | /* 8.3.142: SINGLE-SHIFT TWO */ |
2716 | /* 8.3.142: SINGLE-SHIFT TWO */ |
2346 | /*case C1_SS2: scr_single_shift (2); break; */ |
2717 | /* case C1_SS2: break; */ |
2347 | |
2718 | |
2348 | /* 8.3.143: SINGLE-SHIFT THREE */ |
2719 | /* 8.3.143: SINGLE-SHIFT THREE */ |
2349 | /*case C1_SS3: scr_single_shift (3); break; */ |
2720 | /* case C1_SS3: break; */ |
2350 | |
2721 | |
2351 | /* 8.3.27: DEVICE CONTROL STRING */ |
2722 | /* 8.3.27: DEVICE CONTROL STRING */ |
2352 | case C1_DCS: /* ESC P */ |
2723 | case C1_DCS: /* ESC P */ |
2353 | rxvt_process_dcs_seq(aR); |
2724 | process_dcs_seq (); |
2354 | break; |
2725 | break; |
2355 | |
2726 | |
2356 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2727 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2357 | case C1_SCI: /* ESC Z */ |
2728 | case C1_SCI: /* ESC Z */ |
2358 | R->tt_write((const unsigned char *)ESCZ_ANSWER, |
2729 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2359 | (unsigned int)(sizeof(ESCZ_ANSWER) - 1)); |
|
|
2360 | break; /* steal obsolete ESC [ c */ |
2730 | break; /* steal obsolete ESC [ c */ |
2361 | |
2731 | |
2362 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2732 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
2363 | case C1_CSI: /* ESC [ */ |
2733 | case C1_CSI: /* ESC [ */ |
2364 | rxvt_process_csi_seq(aR); |
2734 | process_csi_seq (); |
2365 | break; |
2735 | break; |
2366 | |
2736 | |
2367 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2737 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
2368 | case C1_OSC: /* ESC ] */ |
2738 | case C1_OSC: /* ESC ] */ |
2369 | rxvt_process_osc_seq(aR); |
2739 | process_osc_seq (); |
2370 | break; |
2740 | break; |
2371 | |
2741 | |
2372 | /* 8.3.106: RESET TO INITIAL STATE */ |
2742 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
2373 | case 'c': |
2743 | case 'c': |
2374 | rxvt_scr_poweron(aR); |
2744 | mbstate.reset (); |
2375 | rxvt_scrollbar_show(aR_ 1); |
2745 | scr_poweron (); |
2376 | break; |
2746 | scrollBar.show (1); |
|
|
2747 | break; |
2377 | |
2748 | |
2378 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2749 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2379 | case 'n': |
2750 | case 'n': |
2380 | rxvt_scr_charset_choose(aR_ 2); |
2751 | scr_charset_choose (2); |
2381 | break; |
2752 | break; |
2382 | |
2753 | |
2383 | /* 8.3.81: LOCKING-SHIFT THREE (see ISO2022) */ |
2754 | /* 8.3.81: LOCKING-SHIFT THREE (see ISO2022) */ |
2384 | case 'o': |
2755 | case 'o': |
2385 | rxvt_scr_charset_choose(aR_ 3); |
2756 | scr_charset_choose (3); |
2386 | break; |
2757 | break; |
2387 | } |
2758 | } |
2388 | } |
2759 | } |
2389 | /*}}} */ |
2760 | /*}}} */ |
2390 | |
2761 | |
2391 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2762 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2392 | /* *INDENT-OFF* */ |
|
|
2393 | enum { |
2763 | enum { |
2394 | CSI_ICH = 0x40, |
2764 | CSI_ICH = 0x40, |
2395 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2765 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2396 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2766 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2397 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2767 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2398 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2768 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2399 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2769 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2400 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2770 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2401 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2771 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2402 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2772 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2403 | }; |
2773 | }; |
2404 | |
2774 | |
2405 | #define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ |
2775 | #define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \ |
2406 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2776 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2407 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2777 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2408 | #define get_byte_array_bit(array, bit) \ |
2778 | #define get_byte_array_bit(array, bit) \ |
2409 | (!!((array)[(bit) / 8] & (128 >> ((bit) & 7)))) |
2779 | (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7)))) |
2410 | |
2780 | |
2411 | const unsigned char csi_defaults[] = { |
2781 | static const unsigned char csi_defaults[] = |
|
|
2782 | { |
2412 | make_byte(1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2783 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2413 | make_byte(1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2784 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2414 | make_byte(1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2785 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2415 | make_byte(1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
2786 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
2416 | make_byte(1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ |
2787 | make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ |
2417 | make_byte(0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ |
2788 | make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ |
2418 | make_byte(0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ |
2789 | make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ |
2419 | make_byte(0,0,0,0,0,0,0,0) /* x, y, z, {, |, }, ~, */ |
2790 | make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ |
2420 | }; |
2791 | }; |
2421 | /* *INDENT-ON* */ |
|
|
2422 | |
2792 | |
2423 | /* INTPROTO */ |
2793 | void ecb_hot |
|
|
2794 | rxvt_term::process_csi_seq () |
|
|
2795 | { |
|
|
2796 | unicode_t ch, priv, prev_ch, i; |
|
|
2797 | unsigned int nargs, p; |
|
|
2798 | int n, ndef; |
|
|
2799 | int arg[ESC_ARGS] = { }; |
|
|
2800 | |
|
|
2801 | nargs = 0; |
|
|
2802 | |
|
|
2803 | priv = 0; |
|
|
2804 | ch = cmd_getc (); |
|
|
2805 | if ((ch >= '<' && ch <= '?') || ch == '!') |
|
|
2806 | { |
|
|
2807 | /* '<' '=' '>' '?' '!' */ |
|
|
2808 | priv = ch; |
|
|
2809 | ch = cmd_getc (); |
|
|
2810 | } |
|
|
2811 | |
|
|
2812 | prev_ch = 0; |
|
|
2813 | /* read any numerical arguments */ |
|
|
2814 | for (n = -1; ch < CSI_ICH; ) |
|
|
2815 | { |
|
|
2816 | if (isdigit (ch)) |
|
|
2817 | { |
|
|
2818 | if (n < 0) |
|
|
2819 | n = ch - '0'; |
|
|
2820 | else |
|
|
2821 | n = n * 10 + ch - '0'; |
|
|
2822 | } |
|
|
2823 | else if (ch == ';') |
|
|
2824 | { |
|
|
2825 | if (nargs < ESC_ARGS) |
|
|
2826 | arg[nargs++] = n; |
|
|
2827 | n = -1; |
|
|
2828 | } |
|
|
2829 | else if (IS_CONTROL (ch)) |
|
|
2830 | process_nonprinting (ch); |
|
|
2831 | |
|
|
2832 | prev_ch = ch; |
|
|
2833 | ch = cmd_getc (); |
|
|
2834 | } |
|
|
2835 | |
|
|
2836 | if (ch > CSI_7F) |
|
|
2837 | return; |
|
|
2838 | |
|
|
2839 | if (nargs < ESC_ARGS) |
|
|
2840 | arg[nargs++] = n; |
|
|
2841 | |
|
|
2842 | i = ch - CSI_ICH; |
|
|
2843 | ndef = get_byte_array_bit (csi_defaults, i); |
|
|
2844 | for (p = 0; p < nargs; p++) |
|
|
2845 | if (arg[p] == -1) |
|
|
2846 | arg[p] = ndef; |
|
|
2847 | |
|
|
2848 | /* |
|
|
2849 | * private mode handling |
|
|
2850 | */ |
|
|
2851 | if (priv) |
|
|
2852 | { |
|
|
2853 | switch (priv) |
|
|
2854 | { |
|
|
2855 | case '>': |
|
|
2856 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
2857 | { |
|
|
2858 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2859 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2860 | // |
|
|
2861 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2862 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
|
|
2863 | // versions. |
|
|
2864 | // |
|
|
2865 | tt_printf ("\033[>%d;95;0c", 'U'); |
|
|
2866 | } |
|
|
2867 | break; |
|
|
2868 | |
|
|
2869 | case '?': |
|
|
2870 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
|
|
2871 | process_terminal_mode (ch, priv, nargs, arg); |
|
|
2872 | break; |
|
|
2873 | |
|
|
2874 | case '!': |
|
|
2875 | if (ch == CSI_70) |
|
|
2876 | { |
|
|
2877 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2878 | scr_soft_reset (); |
|
|
2879 | |
|
|
2880 | static const int pm_h[] = { 7, 25 }; |
|
|
2881 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1006, 1015, 1049 }; |
|
|
2882 | |
|
|
2883 | process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h); |
|
|
2884 | process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l); |
|
|
2885 | } |
|
|
2886 | break; |
|
|
2887 | } |
|
|
2888 | |
|
|
2889 | return; |
|
|
2890 | } |
|
|
2891 | |
|
|
2892 | switch (ch) |
|
|
2893 | { |
|
|
2894 | /* |
|
|
2895 | * ISO/IEC 6429:1992 (E) CSI sequences (defaults in parentheses) |
|
|
2896 | */ |
|
|
2897 | #ifdef PRINTPIPE |
|
|
2898 | case CSI_MC: /* 8.3.83: (0) MEDIA COPY */ |
|
|
2899 | switch (arg[0]) |
|
|
2900 | { |
|
|
2901 | case 0: /* initiate transfer to primary aux device */ |
|
|
2902 | scr_printscreen (0); |
|
|
2903 | break; |
|
|
2904 | case 5: /* start relay to primary aux device */ |
|
|
2905 | process_print_pipe (); |
|
|
2906 | break; |
|
|
2907 | } |
|
|
2908 | break; |
|
|
2909 | #endif |
|
|
2910 | |
|
|
2911 | case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ |
|
|
2912 | case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ |
|
|
2913 | arg[0] = -arg[0]; |
|
|
2914 | /* FALLTHROUGH */ |
|
|
2915 | case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ |
|
|
2916 | case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ |
|
|
2917 | scr_gotorc (arg[0], 0, RELATIVE); |
|
|
2918 | break; |
|
|
2919 | |
|
|
2920 | case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ |
|
|
2921 | case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ |
|
|
2922 | #ifdef ISO6429 |
|
|
2923 | arg[0] = -arg[0]; |
|
|
2924 | #else /* emulate common DEC VTs */ |
|
|
2925 | arg[0] = arg[0] ? -arg[0] : -1; |
|
|
2926 | #endif |
|
|
2927 | /* FALLTHROUGH */ |
|
|
2928 | case CSI_CUF: /* 8.3.20: (1) CURSOR RIGHT */ |
|
|
2929 | case CSI_HPR: /* 8.3.60: (1) CHARACTER POSITION FORWARD */ |
|
|
2930 | #ifdef ISO6429 |
|
|
2931 | scr_gotorc (0, arg[0], RELATIVE); |
|
|
2932 | #else /* emulate common DEC VTs */ |
|
|
2933 | scr_gotorc (0, arg[0] ? arg[0] : 1, RELATIVE); |
|
|
2934 | #endif |
|
|
2935 | break; |
|
|
2936 | |
|
|
2937 | case CSI_CPL: /* 8.3.13: (1) CURSOR PRECEDING LINE */ |
|
|
2938 | arg[0] = -arg[0]; |
|
|
2939 | /* FALLTHROUGH */ |
|
|
2940 | case CSI_CNL: /* 8.3.12: (1) CURSOR NEXT LINE */ |
|
|
2941 | scr_gotorc (arg[0], 0, R_RELATIVE); |
|
|
2942 | break; |
|
|
2943 | |
|
|
2944 | case CSI_CHA: /* 8.3.9: (1) CURSOR CHARACTER ABSOLUTE */ |
|
|
2945 | case CSI_HPA: /* 8.3.58: (1) CURSOR POSITION ABSOLUTE */ |
|
|
2946 | scr_gotorc (0, arg[0] - 1, R_RELATIVE); |
|
|
2947 | break; |
|
|
2948 | |
|
|
2949 | case CSI_VPA: /* 8.3.159: (1) LINE POSITION ABSOLUTE */ |
|
|
2950 | scr_gotorc (arg[0] - 1, 0, C_RELATIVE); |
|
|
2951 | break; |
|
|
2952 | |
|
|
2953 | case CSI_CUP: /* 8.3.21: (1,1) CURSOR POSITION */ |
|
|
2954 | case CSI_HVP: /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */ |
|
|
2955 | scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0); |
|
|
2956 | break; |
|
|
2957 | |
|
|
2958 | case CSI_CBT: /* 8.3.7: (1) CURSOR BACKWARD TABULATION */ |
|
|
2959 | arg[0] = -arg[0]; |
|
|
2960 | /* FALLTHROUGH */ |
|
|
2961 | case CSI_CHT: /* 8.3.10: (1) CURSOR FORWARD TABULATION */ |
|
|
2962 | scr_tab (arg[0]); |
|
|
2963 | break; |
|
|
2964 | |
|
|
2965 | case CSI_ED: /* 8.3.40: (0) ERASE IN PAGE */ |
|
|
2966 | scr_erase_screen (arg[0]); |
|
|
2967 | break; |
|
|
2968 | |
|
|
2969 | case CSI_EL: /* 8.3.42: (0) ERASE IN LINE */ |
|
|
2970 | scr_erase_line (arg[0]); |
|
|
2971 | break; |
|
|
2972 | |
|
|
2973 | case CSI_ICH: /* 8.3.65: (1) INSERT CHARACTER */ |
|
|
2974 | scr_insdel_chars (arg[0], INSERT); |
|
|
2975 | break; |
|
|
2976 | |
|
|
2977 | case CSI_IL: /* 8.3.68: (1) INSERT LINE */ |
|
|
2978 | scr_insdel_lines (arg[0], INSERT); |
|
|
2979 | break; |
|
|
2980 | |
|
|
2981 | case CSI_DL: /* 8.3.33: (1) DELETE LINE */ |
|
|
2982 | scr_insdel_lines (arg[0], DELETE); |
|
|
2983 | break; |
|
|
2984 | |
|
|
2985 | case CSI_ECH: /* 8.3.39: (1) ERASE CHARACTER */ |
|
|
2986 | scr_insdel_chars (arg[0], ERASE); |
|
|
2987 | break; |
|
|
2988 | |
|
|
2989 | case CSI_DCH: /* 8.3.26: (1) DELETE CHARACTER */ |
|
|
2990 | scr_insdel_chars (arg[0], DELETE); |
|
|
2991 | break; |
|
|
2992 | |
|
|
2993 | case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ |
|
|
2994 | arg[0] = -arg[0]; |
|
|
2995 | /* FALLTHROUGH */ |
|
|
2996 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
|
|
2997 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
|
|
2998 | break; |
|
|
2999 | |
|
|
3000 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
|
|
3001 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
|
|
3002 | break; |
|
|
3003 | |
|
|
3004 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
|
|
3005 | process_sgr_mode (nargs, arg); |
|
|
3006 | break; |
|
|
3007 | |
|
|
3008 | case CSI_DSR: /* 8.3.36: (0) DEVICE STATUS REPORT */ |
|
|
3009 | switch (arg[0]) |
|
|
3010 | { |
|
|
3011 | case 5: /* DSR requested */ |
|
|
3012 | tt_printf ("\033[0n"); |
|
|
3013 | break; |
|
|
3014 | case 6: /* CPR requested */ |
|
|
3015 | scr_report_position (); |
|
|
3016 | break; |
|
|
3017 | case 7: /* unofficial extension */ |
|
|
3018 | if (option (Opt_insecure)) |
|
|
3019 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
|
|
3020 | break; |
|
|
3021 | case 8: /* unofficial extension */ |
|
|
3022 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
|
|
3023 | break; |
|
|
3024 | } |
|
|
3025 | break; |
|
|
3026 | |
|
|
3027 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
|
|
3028 | switch (arg[0]) |
|
|
3029 | { |
|
|
3030 | case 0: /* char tab stop cleared at active position */ |
|
|
3031 | scr_set_tab (0); |
|
|
3032 | break; |
|
|
3033 | /* case 1: */ /* line tab stop cleared in active line */ |
|
|
3034 | /* case 2: */ /* char tab stops cleared in active line */ |
|
|
3035 | case 3: /* all char tab stops are cleared */ |
|
|
3036 | /* case 4: */ /* all line tab stops are cleared */ |
|
|
3037 | case 5: /* all tab stops are cleared */ |
|
|
3038 | scr_set_tab (-1); |
|
|
3039 | break; |
|
|
3040 | } |
|
|
3041 | break; |
|
|
3042 | |
|
|
3043 | case CSI_CTC: /* 8.3.17: (0) CURSOR TABULATION CONTROL */ |
|
|
3044 | switch (arg[0]) |
|
|
3045 | { |
|
|
3046 | case 0: /* char tab stop set at active position */ |
|
|
3047 | scr_set_tab (1); |
|
|
3048 | break; /* = ESC H */ |
|
|
3049 | /* case 1: */ /* line tab stop set at active line */ |
|
|
3050 | case 2: /* char tab stop cleared at active position */ |
|
|
3051 | scr_set_tab (0); |
|
|
3052 | break; /* = ESC [ 0 g */ |
|
|
3053 | /* case 3: */ /* line tab stop cleared at active line */ |
|
|
3054 | /* case 4: */ /* char tab stops cleared at active line */ |
|
|
3055 | case 5: /* all char tab stops are cleared */ |
|
|
3056 | scr_set_tab (-1); |
|
|
3057 | break; /* = ESC [ 3 g */ |
|
|
3058 | /* case 6: */ /* all line tab stops are cleared */ |
|
|
3059 | } |
|
|
3060 | break; |
|
|
3061 | |
|
|
3062 | case CSI_RM: /* 8.3.107: RESET MODE */ |
|
|
3063 | if (arg[0] == 4) |
|
|
3064 | scr_insert_mode (0); |
|
|
3065 | else if (arg[0] == 20) |
|
|
3066 | priv_modes &= ~PrivMode_LFNL; |
|
|
3067 | break; |
|
|
3068 | |
|
|
3069 | case CSI_SM: /* 8.3.126: SET MODE */ |
|
|
3070 | if (arg[0] == 4) |
|
|
3071 | scr_insert_mode (1); |
|
|
3072 | else if (arg[0] == 20) |
|
|
3073 | priv_modes |= PrivMode_LFNL; |
|
|
3074 | break; |
|
|
3075 | |
|
|
3076 | case CSI_71: // DECSCUSR: set cursor style |
|
|
3077 | if (prev_ch == ' ') |
|
|
3078 | set_cursor_style (arg[0]); |
|
|
3079 | break; |
|
|
3080 | |
|
|
3081 | /* |
|
|
3082 | * PRIVATE USE beyond this point. All CSI_7? sequences here |
|
|
3083 | */ |
|
|
3084 | case CSI_72: /* DECSTBM: set top and bottom margins */ |
|
|
3085 | if (nargs == 1) |
|
|
3086 | scr_scroll_region (arg[0] - 1, MAX_ROWS - 1); |
|
|
3087 | else if (nargs == 0 || arg[0] >= arg[1]) |
|
|
3088 | scr_scroll_region (0, MAX_ROWS - 1); |
|
|
3089 | else |
|
|
3090 | scr_scroll_region (arg[0] - 1, arg[1] - 1); |
|
|
3091 | break; |
|
|
3092 | |
|
|
3093 | case CSI_73: |
|
|
3094 | scr_cursor (SAVE); |
|
|
3095 | break; |
|
|
3096 | case CSI_75: |
|
|
3097 | scr_cursor (RESTORE); |
|
|
3098 | break; |
|
|
3099 | |
|
|
3100 | #if !ENABLE_MINIMAL |
|
|
3101 | case CSI_74: |
|
|
3102 | process_window_ops (arg, nargs); |
|
|
3103 | break; |
|
|
3104 | #endif |
|
|
3105 | |
|
|
3106 | case CSI_78: /* DECREQTPARM */ |
|
|
3107 | if (arg[0] == 0 || arg[0] == 1) |
|
|
3108 | tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2); |
|
|
3109 | break; |
|
|
3110 | |
|
|
3111 | default: |
|
|
3112 | break; |
|
|
3113 | } |
|
|
3114 | } |
|
|
3115 | /*}}} */ |
|
|
3116 | |
|
|
3117 | #if !ENABLE_MINIMAL |
2424 | void |
3118 | void |
2425 | rxvt_process_csi_seq(pR) |
|
|
2426 | { |
|
|
2427 | unsigned char ch, priv, i; |
|
|
2428 | unsigned int nargs, p; |
|
|
2429 | int n, ndef; |
|
|
2430 | int arg[ESC_ARGS]; |
|
|
2431 | |
|
|
2432 | for (nargs = ESC_ARGS; nargs > 0;) |
|
|
2433 | arg[--nargs] = 0; |
|
|
2434 | |
|
|
2435 | priv = 0; |
|
|
2436 | ch = rxvt_cmd_getc(aR); |
|
|
2437 | if (ch >= '<' && ch <= '?') { /* '<' '=' '>' '?' */ |
|
|
2438 | priv = ch; |
|
|
2439 | ch = rxvt_cmd_getc(aR); |
|
|
2440 | } |
|
|
2441 | /* read any numerical arguments */ |
|
|
2442 | for (n = -1; ch < CSI_ICH; ) { |
|
|
2443 | if (isdigit(ch)) { |
|
|
2444 | if (n < 0) |
|
|
2445 | n = ch - '0'; |
|
|
2446 | else |
|
|
2447 | n = n * 10 + ch - '0'; |
|
|
2448 | } else if (ch == ';') { |
|
|
2449 | if (nargs < ESC_ARGS) |
|
|
2450 | arg[nargs++] = n; |
|
|
2451 | n = -1; |
|
|
2452 | } else if (ch == '\b') { |
|
|
2453 | rxvt_scr_backspace(aR); |
|
|
2454 | } else if (ch == C0_ESC) { |
|
|
2455 | rxvt_process_escape_seq(aR); |
|
|
2456 | return; |
|
|
2457 | } else if (ch < ' ') { |
|
|
2458 | rxvt_process_nonprinting(aR_ ch); |
|
|
2459 | } |
|
|
2460 | ch = rxvt_cmd_getc(aR); |
|
|
2461 | } |
|
|
2462 | |
|
|
2463 | if (ch > CSI_7F) |
|
|
2464 | return; |
|
|
2465 | |
|
|
2466 | if (nargs < ESC_ARGS) |
|
|
2467 | arg[nargs++] = n; |
|
|
2468 | |
|
|
2469 | i = ch - CSI_ICH; |
|
|
2470 | ndef = get_byte_array_bit(csi_defaults, i); |
|
|
2471 | for (p = 0; p < nargs; p++) |
|
|
2472 | if (arg[p] == -1) |
|
|
2473 | arg[p] = ndef; |
|
|
2474 | |
|
|
2475 | #ifdef DEBUG_CMD |
|
|
2476 | fprintf(stderr, "CSI "); |
|
|
2477 | for (p = 0; p < nargs; p++) |
|
|
2478 | fprintf(stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
2479 | fprintf(stderr, "%c\n", ch); |
|
|
2480 | #endif |
|
|
2481 | |
|
|
2482 | /* |
|
|
2483 | * private mode handling |
|
|
2484 | */ |
|
|
2485 | if (priv) { |
|
|
2486 | switch (priv) { |
|
|
2487 | case '>': |
|
|
2488 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
2489 | R->tt_printf("\033[>%d;%-.8s;0c", 'R', VSTRING); |
|
|
2490 | break; |
|
|
2491 | case '?': |
|
|
2492 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
|
|
2493 | rxvt_process_terminal_mode(aR_ ch, priv, nargs, arg); |
|
|
2494 | break; |
|
|
2495 | } |
|
|
2496 | return; |
|
|
2497 | } |
|
|
2498 | |
|
|
2499 | switch (ch) { |
|
|
2500 | /* |
|
|
2501 | * ISO/IEC 6429:1992(E) CSI sequences (defaults in parentheses) |
|
|
2502 | */ |
|
|
2503 | #ifdef PRINTPIPE |
|
|
2504 | case CSI_MC: /* 8.3.83: (0) MEDIA COPY */ |
|
|
2505 | switch (arg[0]) { |
|
|
2506 | case 0: /* initiate transfer to primary aux device */ |
|
|
2507 | rxvt_scr_printscreen(aR_ 0); |
|
|
2508 | break; |
|
|
2509 | case 5: /* start relay to primary aux device */ |
|
|
2510 | rxvt_process_print_pipe(aR); |
|
|
2511 | break; |
|
|
2512 | } |
|
|
2513 | break; |
|
|
2514 | #endif |
|
|
2515 | |
|
|
2516 | case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ |
|
|
2517 | case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ |
|
|
2518 | arg[0] = -arg[0]; |
|
|
2519 | /* FALLTHROUGH */ |
|
|
2520 | case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ |
|
|
2521 | case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ |
|
|
2522 | rxvt_scr_gotorc(aR_ arg[0], 0, RELATIVE); |
|
|
2523 | break; |
|
|
2524 | |
|
|
2525 | case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ |
|
|
2526 | case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ |
|
|
2527 | #ifdef ISO6429 |
|
|
2528 | arg[0] = -arg[0]; |
|
|
2529 | #else /* emulate common DEC VTs */ |
|
|
2530 | arg[0] = arg[0] ? -arg[0] : -1; |
|
|
2531 | #endif |
|
|
2532 | /* FALLTHROUGH */ |
|
|
2533 | case CSI_CUF: /* 8.3.20: (1) CURSOR RIGHT */ |
|
|
2534 | case CSI_HPR: /* 8.3.60: (1) CHARACTER POSITION FORWARD */ |
|
|
2535 | #ifdef ISO6429 |
|
|
2536 | rxvt_scr_gotorc(aR_ 0, arg[0], RELATIVE); |
|
|
2537 | #else /* emulate common DEC VTs */ |
|
|
2538 | rxvt_scr_gotorc(aR_ 0, arg[0] ? arg[0] : 1, RELATIVE); |
|
|
2539 | #endif |
|
|
2540 | break; |
|
|
2541 | |
|
|
2542 | case CSI_CPL: /* 8.3.13: (1) CURSOR PRECEDING LINE */ |
|
|
2543 | arg[0] = -arg[0]; |
|
|
2544 | /* FALLTHROUGH */ |
|
|
2545 | case CSI_CNL: /* 8.3.12: (1) CURSOR NEXT LINE */ |
|
|
2546 | rxvt_scr_gotorc(aR_ arg[0], 0, R_RELATIVE); |
|
|
2547 | break; |
|
|
2548 | |
|
|
2549 | case CSI_CHA: /* 8.3.9: (1) CURSOR CHARACTER ABSOLUTE */ |
|
|
2550 | case CSI_HPA: /* 8.3.58: (1) CURSOR POSITION ABSOLUTE */ |
|
|
2551 | rxvt_scr_gotorc(aR_ 0, arg[0] - 1, R_RELATIVE); |
|
|
2552 | break; |
|
|
2553 | |
|
|
2554 | case CSI_VPA: /* 8.3.159: (1) LINE POSITION ABSOLUTE */ |
|
|
2555 | rxvt_scr_gotorc(aR_ arg[0] - 1, 0, C_RELATIVE); |
|
|
2556 | break; |
|
|
2557 | |
|
|
2558 | case CSI_CUP: /* 8.3.21: (1,1) CURSOR POSITION */ |
|
|
2559 | case CSI_HVP: /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */ |
|
|
2560 | rxvt_scr_gotorc(aR_ arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0); |
|
|
2561 | break; |
|
|
2562 | |
|
|
2563 | case CSI_CBT: /* 8.3.7: (1) CURSOR BACKWARD TABULATION */ |
|
|
2564 | arg[0] = -arg[0]; |
|
|
2565 | /* FALLTHROUGH */ |
|
|
2566 | case CSI_CHT: /* 8.3.10: (1) CURSOR FORWARD TABULATION */ |
|
|
2567 | rxvt_scr_tab(aR_ arg[0]); |
|
|
2568 | break; |
|
|
2569 | |
|
|
2570 | case CSI_ED: /* 8.3.40: (0) ERASE IN PAGE */ |
|
|
2571 | rxvt_scr_erase_screen(aR_ arg[0]); |
|
|
2572 | break; |
|
|
2573 | |
|
|
2574 | case CSI_EL: /* 8.3.42: (0) ERASE IN LINE */ |
|
|
2575 | rxvt_scr_erase_line(aR_ arg[0]); |
|
|
2576 | break; |
|
|
2577 | |
|
|
2578 | case CSI_ICH: /* 8.3.65: (1) INSERT CHARACTER */ |
|
|
2579 | rxvt_scr_insdel_chars(aR_ arg[0], INSERT); |
|
|
2580 | break; |
|
|
2581 | |
|
|
2582 | case CSI_IL: /* 8.3.68: (1) INSERT LINE */ |
|
|
2583 | rxvt_scr_insdel_lines(aR_ arg[0], INSERT); |
|
|
2584 | break; |
|
|
2585 | |
|
|
2586 | case CSI_DL: /* 8.3.33: (1) DELETE LINE */ |
|
|
2587 | rxvt_scr_insdel_lines(aR_ arg[0], DELETE); |
|
|
2588 | break; |
|
|
2589 | |
|
|
2590 | case CSI_ECH: /* 8.3.39: (1) ERASE CHARACTER */ |
|
|
2591 | rxvt_scr_insdel_chars(aR_ arg[0], ERASE); |
|
|
2592 | break; |
|
|
2593 | |
|
|
2594 | case CSI_DCH: /* 8.3.26: (1) DELETE CHARACTER */ |
|
|
2595 | rxvt_scr_insdel_chars(aR_ arg[0], DELETE); |
|
|
2596 | break; |
|
|
2597 | |
|
|
2598 | case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ |
|
|
2599 | arg[0] = -arg[0]; |
|
|
2600 | /* FALLTHROUGH */ |
|
|
2601 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
|
|
2602 | R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, arg[0], 0); |
|
|
2603 | break; |
|
|
2604 | |
|
|
2605 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
|
|
2606 | R->tt_write((const unsigned char *)VT100_ANS, |
|
|
2607 | (unsigned int)(sizeof(VT100_ANS) - 1)); |
|
|
2608 | break; |
|
|
2609 | |
|
|
2610 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
|
|
2611 | rxvt_process_sgr_mode(aR_ nargs, arg); |
|
|
2612 | break; |
|
|
2613 | |
|
|
2614 | case CSI_DSR: /* 8.3.36: (0) DEVICE STATUS REPORT */ |
|
|
2615 | switch (arg[0]) { |
|
|
2616 | case 5: /* DSR requested */ |
|
|
2617 | R->tt_printf("\033[0n"); |
|
|
2618 | break; |
|
|
2619 | case 6: /* CPR requested */ |
|
|
2620 | rxvt_scr_report_position(aR); |
|
|
2621 | break; |
|
|
2622 | #if defined (ENABLE_DISPLAY_ANSWER) |
|
|
2623 | case 7: /* unofficial extension */ |
|
|
2624 | R->tt_printf("%-.250s\n", R->rs[Rs_display_name]); |
|
|
2625 | break; |
|
|
2626 | #endif |
|
|
2627 | case 8: /* unofficial extension */ |
|
|
2628 | rxvt_xterm_seq(aR_ XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
|
|
2629 | break; |
|
|
2630 | } |
|
|
2631 | break; |
|
|
2632 | |
|
|
2633 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
|
|
2634 | switch (arg[0]) { |
|
|
2635 | case 0: /* char tab stop cleared at active position */ |
|
|
2636 | rxvt_scr_set_tab(aR_ 0); |
|
|
2637 | break; |
|
|
2638 | /* case 1: */ /* line tab stop cleared in active line */ |
|
|
2639 | /* case 2: */ /* char tab stops cleared in active line */ |
|
|
2640 | case 3: /* all char tab stops are cleared */ |
|
|
2641 | /* case 4: */ /* all line tab stops are cleared */ |
|
|
2642 | case 5: /* all tab stops are cleared */ |
|
|
2643 | rxvt_scr_set_tab(aR_ -1); |
|
|
2644 | break; |
|
|
2645 | } |
|
|
2646 | break; |
|
|
2647 | |
|
|
2648 | case CSI_CTC: /* 8.3.17: (0) CURSOR TABULATION CONTROL */ |
|
|
2649 | switch (arg[0]) { |
|
|
2650 | case 0: /* char tab stop set at active position */ |
|
|
2651 | rxvt_scr_set_tab(aR_ 1); |
|
|
2652 | break; /* = ESC H */ |
|
|
2653 | /* case 1: */ /* line tab stop set at active line */ |
|
|
2654 | case 2: /* char tab stop cleared at active position */ |
|
|
2655 | rxvt_scr_set_tab(aR_ 0); |
|
|
2656 | break; /* = ESC [ 0 g */ |
|
|
2657 | /* case 3: */ /* line tab stop cleared at active line */ |
|
|
2658 | /* case 4: */ /* char tab stops cleared at active line */ |
|
|
2659 | case 5: /* all char tab stops are cleared */ |
|
|
2660 | rxvt_scr_set_tab(aR_ -1); |
|
|
2661 | break; /* = ESC [ 3 g */ |
|
|
2662 | /* case 6: */ /* all line tab stops are cleared */ |
|
|
2663 | } |
|
|
2664 | break; |
|
|
2665 | |
|
|
2666 | case CSI_RM: /* 8.3.107: RESET MODE */ |
|
|
2667 | if (arg[0] == 4) |
|
|
2668 | rxvt_scr_insert_mode(aR_ 0); |
|
|
2669 | break; |
|
|
2670 | |
|
|
2671 | case CSI_SM: /* 8.3.126: SET MODE */ |
|
|
2672 | if (arg[0] == 4) |
|
|
2673 | rxvt_scr_insert_mode(aR_ 1); |
|
|
2674 | break; |
|
|
2675 | |
|
|
2676 | /* |
|
|
2677 | * PRIVATE USE beyond this point. All CSI_7? sequences here |
|
|
2678 | */ |
|
|
2679 | case CSI_72: /* DECSTBM: set top and bottom margins */ |
|
|
2680 | if (nargs == 1) |
|
|
2681 | rxvt_scr_scroll_region(aR_ arg[0] - 1, MAX_ROWS - 1); |
|
|
2682 | else if (nargs == 0 || arg[0] >= arg[1]) |
|
|
2683 | rxvt_scr_scroll_region(aR_ 0, MAX_ROWS - 1); |
|
|
2684 | else |
|
|
2685 | rxvt_scr_scroll_region(aR_ arg[0] - 1, arg[1] - 1); |
|
|
2686 | break; |
|
|
2687 | |
|
|
2688 | case CSI_73: |
|
|
2689 | rxvt_scr_cursor(aR_ SAVE); |
|
|
2690 | break; |
|
|
2691 | case CSI_75: |
|
|
2692 | rxvt_scr_cursor(aR_ RESTORE); |
|
|
2693 | break; |
|
|
2694 | |
|
|
2695 | #ifndef NO_FRILLS |
|
|
2696 | case CSI_74: |
|
|
2697 | rxvt_process_window_ops(aR_ arg, nargs); |
|
|
2698 | break; |
|
|
2699 | #endif |
|
|
2700 | |
|
|
2701 | case CSI_78: /* DECREQTPARM */ |
|
|
2702 | if (arg[0] == 0 || arg[0] == 1) |
|
|
2703 | R->tt_printf("\033[%d;1;1;112;112;1;0x", arg[0] + 2); |
|
|
2704 | /* FALLTHROUGH */ |
|
|
2705 | |
|
|
2706 | default: |
|
|
2707 | break; |
|
|
2708 | } |
|
|
2709 | } |
|
|
2710 | /*}}} */ |
|
|
2711 | |
|
|
2712 | #ifndef NO_FRILLS |
|
|
2713 | /* ARGSUSED */ |
|
|
2714 | /* INTPROTO */ |
|
|
2715 | void |
|
|
2716 | rxvt_process_window_ops(pR_ const int *args, unsigned int nargs) |
3119 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
2717 | { |
3120 | { |
2718 | int x, y; |
3121 | int x, y; |
2719 | #if 0 |
|
|
2720 | char *s; |
|
|
2721 | #endif |
|
|
2722 | XWindowAttributes wattr; |
3122 | XWindowAttributes wattr; |
2723 | Window wdummy; |
3123 | Window wdummy; |
2724 | |
3124 | |
|
|
3125 | dLocal (Display *, dpy); |
|
|
3126 | |
2725 | if (nargs == 0) |
3127 | if (nargs == 0) |
2726 | return; |
3128 | return; |
|
|
3129 | |
2727 | switch (args[0]) { |
3130 | switch (args[0]) |
|
|
3131 | { |
2728 | /* |
3132 | /* |
2729 | * commands |
3133 | * commands |
2730 | */ |
3134 | */ |
2731 | case 1: /* deiconify window */ |
3135 | case 1: /* deiconify window */ |
2732 | XMapWindow(R->Xdisplay, R->TermWin.parent[0]); |
3136 | XMapWindow (dpy, parent); |
2733 | break; |
3137 | break; |
2734 | case 2: /* iconify window */ |
3138 | case 2: /* iconify window */ |
2735 | XIconifyWindow(R->Xdisplay, R->TermWin.parent[0], |
3139 | XIconifyWindow (dpy, parent, display->screen); |
2736 | DefaultScreen(R->Xdisplay)); |
3140 | break; |
2737 | break; |
|
|
2738 | case 3: /* set position (pixels) */ |
3141 | case 3: /* set position (pixels) */ |
2739 | XMoveWindow(R->Xdisplay, R->TermWin.parent[0], args[1], args[2]); |
3142 | XMoveWindow (dpy, parent, args[1], args[2]); |
2740 | break; |
3143 | break; |
2741 | case 4: /* set size (pixels) */ |
3144 | case 4: /* set size (pixels) */ |
2742 | rxvt_set_widthheight(aR_ (unsigned int)args[2], (unsigned int)args[1]); |
3145 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
2743 | break; |
3146 | break; |
2744 | case 5: /* raise window */ |
3147 | case 5: /* raise window */ |
2745 | XRaiseWindow(R->Xdisplay, R->TermWin.parent[0]); |
3148 | XRaiseWindow (dpy, parent); |
2746 | break; |
3149 | break; |
2747 | case 6: /* lower window */ |
3150 | case 6: /* lower window */ |
2748 | XLowerWindow(R->Xdisplay, R->TermWin.parent[0]); |
3151 | XLowerWindow (dpy, parent); |
2749 | break; |
3152 | break; |
2750 | case 7: /* refresh window */ |
3153 | case 7: /* refresh window */ |
2751 | rxvt_scr_touch(aR_ True); |
3154 | scr_touch (true); |
2752 | break; |
3155 | break; |
2753 | case 8: /* set size (chars) */ |
3156 | case 8: /* set size (chars) */ |
2754 | rxvt_set_widthheight(aR_ (unsigned int)(args[2] * R->TermWin.fwidth), |
3157 | set_widthheight ((unsigned int) (args[2] * fwidth), |
2755 | (unsigned int)(args[1] * R->TermWin.fheight)); |
3158 | (unsigned int) (args[1] * fheight)); |
2756 | break; |
3159 | break; |
|
|
3160 | |
|
|
3161 | //case 9: NYI, TODO, restore maximized window or maximize window |
2757 | default: |
3162 | default: |
2758 | if (args[0] >= 24) /* set height (chars) */ |
3163 | if (args[0] >= 24) /* set height (chars) */ |
2759 | rxvt_set_widthheight(aR_ (unsigned int)R->TermWin.width, |
3164 | set_widthheight ((unsigned int)vt_width, |
2760 | (unsigned int)(args[1] * R->TermWin.fheight)); |
3165 | (unsigned int) (args[1] * fheight)); |
2761 | break; |
3166 | break; |
|
|
3167 | |
2762 | /* |
3168 | /* |
2763 | * reports - some output format copied from XTerm |
3169 | * reports - some output format copied from XTerm |
2764 | */ |
3170 | */ |
2765 | case 11: /* report window state */ |
3171 | case 11: /* report window state */ |
2766 | XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); |
3172 | XGetWindowAttributes (dpy, parent, &wattr); |
2767 | R->tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3173 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
2768 | break; |
3174 | break; |
2769 | case 13: /* report window position */ |
3175 | case 13: /* report window position */ |
2770 | XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); |
3176 | XGetWindowAttributes (dpy, parent, &wattr); |
2771 | XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], wattr.root, |
3177 | XTranslateCoordinates (dpy, parent, wattr.root, |
2772 | -wattr.border_width, -wattr.border_width, |
3178 | -wattr.border_width, -wattr.border_width, |
2773 | &x, &y, &wdummy); |
3179 | &x, &y, &wdummy); |
2774 | R->tt_printf("\033[3;%d;%dt", x, y); |
3180 | tt_printf ("\033[3;%d;%dt", x, y); |
2775 | break; |
3181 | break; |
2776 | case 14: /* report window size (pixels) */ |
3182 | case 14: /* report window size (pixels) */ |
2777 | XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[0], &wattr); |
3183 | XGetWindowAttributes (dpy, parent, &wattr); |
2778 | R->tt_printf("\033[4;%d;%dt", wattr.height, wattr.width); |
3184 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
2779 | break; |
3185 | break; |
|
|
3186 | case 18: /* report text area size (chars) */ |
|
|
3187 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
|
|
3188 | break; |
2780 | case 18: /* report window size (chars) */ |
3189 | case 19: /* report window size (chars) */ |
2781 | R->tt_printf("\033[8;%d;%dt", R->TermWin.nrow, R->TermWin.ncol); |
3190 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
2782 | break; |
3191 | break; |
2783 | #if 0 /* XXX: currently disabled due to security concerns */ |
|
|
2784 | case 20: /* report icon label */ |
3192 | case 20: /* report icon label */ |
2785 | XGetIconName(R->Xdisplay, R->TermWin.parent[0], &s); |
3193 | { |
2786 | R->tt_printf("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ |
3194 | char *s; |
2787 | break; |
3195 | XGetIconName (dpy, parent, &s); |
|
|
3196 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
|
|
3197 | XFree (s); |
|
|
3198 | } |
|
|
3199 | break; |
2788 | case 21: /* report window title */ |
3200 | case 21: /* report window title */ |
2789 | XFetchName(R->Xdisplay, R->TermWin.parent[0], &s); |
3201 | { |
2790 | R->tt_printf("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ |
3202 | char *s; |
2791 | break; |
3203 | XFetchName (dpy, parent, &s); |
2792 | #endif |
3204 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
|
|
3205 | XFree (s); |
|
|
3206 | } |
|
|
3207 | break; |
2793 | } |
3208 | } |
2794 | } |
3209 | } |
2795 | #endif |
3210 | #endif |
2796 | |
3211 | |
2797 | /*----------------------------------------------------------------------*/ |
3212 | /*----------------------------------------------------------------------*/ |
2798 | /* |
3213 | /* |
2799 | * get input up until STRING TERMINATOR (or BEL) |
3214 | * get input up until STRING TERMINATOR (or BEL) |
2800 | * ends_how is terminator used. returned input must be free()d |
3215 | * ends_how is terminator used. returned input must be free()'d |
2801 | */ |
3216 | */ |
2802 | /* INTPROTO */ |
3217 | char * |
2803 | unsigned char * |
3218 | rxvt_term::get_to_st (unicode_t &ends_how) |
2804 | rxvt_get_to_st(pR_ unsigned char *ends_how) |
|
|
2805 | { |
3219 | { |
2806 | int seen_esc = 0; /* seen escape? */ |
3220 | unicode_t ch; |
|
|
3221 | bool seen_esc = false; |
2807 | unsigned int n = 0; |
3222 | unsigned int n = 0; |
2808 | unsigned char *s; |
3223 | wchar_t string[CBUFSIZ]; |
2809 | unsigned char ch, string[STRING_MAX]; |
|
|
2810 | |
3224 | |
2811 | for (; (ch = rxvt_cmd_getc(aR));) { |
3225 | while ((ch = cmd_getc ()) != NOCHAR) |
2812 | if (ch == C0_BEL |
3226 | { |
2813 | || ch == CHAR_ST |
3227 | if (seen_esc) |
2814 | || (ch == 0x5c && seen_esc)) /* 7bit ST */ |
3228 | { |
|
|
3229 | if (ch == 0x5c) /* 7bit ST */ |
|
|
3230 | break; |
|
|
3231 | else |
|
|
3232 | return NULL; |
|
|
3233 | } |
|
|
3234 | else if (ch == C0_ESC) |
|
|
3235 | { |
|
|
3236 | seen_esc = true; |
|
|
3237 | continue; |
|
|
3238 | } |
|
|
3239 | else if (ch == C0_BEL || ch == CHAR_ST) |
2815 | break; |
3240 | break; |
2816 | if (ch == C0_ESC) { |
3241 | else if (ch == C0_SYN) |
2817 | seen_esc = 1; |
3242 | ch = cmd_get8 (); |
2818 | continue; |
3243 | else if (ch < 0x20) |
2819 | } else if (ch == '\t') |
|
|
2820 | ch = ' '; /* translate '\t' to space */ |
|
|
2821 | else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) |
|
|
2822 | return NULL; /* other control character - exit */ |
3244 | return NULL; /* other control character - exit */ |
|
|
3245 | |
|
|
3246 | seen_esc = false; |
|
|
3247 | |
2823 | if (n < sizeof(string) - 1) |
3248 | if (n >= sizeof (string) - 1) |
|
|
3249 | // stop at some sane length |
|
|
3250 | return NULL; |
|
|
3251 | |
2824 | string[n++] = ch; |
3252 | string[n++] = ch; |
2825 | seen_esc = 0; |
|
|
2826 | } |
3253 | } |
|
|
3254 | |
2827 | string[n++] = '\0'; |
3255 | string[n++] = '\0'; |
2828 | if ((s = (unsigned char *)rxvt_malloc(n)) == NULL) |
3256 | |
2829 | return NULL; |
|
|
2830 | *ends_how = (ch == 0x5c ? C0_ESC : ch); |
3257 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
2831 | STRNCPY(s, string, n); |
3258 | |
2832 | return s; |
3259 | return rxvt_wcstombs (string); |
2833 | } |
3260 | } |
2834 | |
3261 | |
2835 | /*----------------------------------------------------------------------*/ |
3262 | /*----------------------------------------------------------------------*/ |
2836 | /* |
3263 | /* |
2837 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3264 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
2838 | */ |
3265 | */ |
2839 | /* INTPROTO */ |
|
|
2840 | void |
3266 | void |
2841 | rxvt_process_dcs_seq(pR) |
3267 | rxvt_term::process_dcs_seq () |
2842 | { |
3268 | { |
2843 | unsigned char eh, *s; |
3269 | /* |
2844 | /* |
|
|
2845 | * Not handled yet |
3270 | * Not handled yet |
2846 | */ |
3271 | */ |
2847 | s = rxvt_get_to_st(aR_ &eh); |
3272 | |
|
|
3273 | unicode_t eh; |
|
|
3274 | char *s = get_to_st (eh); |
2848 | if (s) |
3275 | if (s) |
2849 | free(s); |
3276 | free (s); |
|
|
3277 | |
2850 | return; |
3278 | return; |
2851 | } |
3279 | } |
2852 | |
3280 | |
2853 | /*----------------------------------------------------------------------*/ |
3281 | /*----------------------------------------------------------------------*/ |
2854 | /* |
3282 | /* |
2855 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3283 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
2856 | */ |
3284 | */ |
2857 | /* INTPROTO */ |
|
|
2858 | void |
3285 | void |
2859 | rxvt_process_osc_seq(pR) |
3286 | rxvt_term::process_osc_seq () |
2860 | { |
3287 | { |
2861 | unsigned char ch, eh, *s; |
3288 | int arg; |
2862 | int arg; |
|
|
2863 | |
3289 | |
2864 | ch = rxvt_cmd_getc(aR); |
3290 | unicode_t ch = cmd_getc (); |
2865 | for (arg = 0; isdigit(ch); ch = rxvt_cmd_getc(aR)) |
3291 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
2866 | arg = arg * 10 + (ch - '0'); |
3292 | arg = arg * 10 + (ch - '0'); |
2867 | |
3293 | |
2868 | if (ch == ';') { |
3294 | if (ch == ';') |
2869 | s = rxvt_get_to_st(aR_ &eh); |
3295 | { |
2870 | if (s) { |
3296 | unicode_t eh; |
2871 | /* |
3297 | char *s = get_to_st (eh); |
2872 | * rxvt_menubar_dispatch() violates the constness of the string, |
3298 | |
2873 | * so do it here |
3299 | if (s) |
2874 | */ |
3300 | { |
2875 | if (arg == XTerm_Menu) |
3301 | process_xterm_seq (arg, s, eh); |
2876 | #if 0 /* XXX: currently disabled due to security concerns */ |
3302 | free (s); |
2877 | rxvt_menubar_dispatch(aR_ (char *)s); |
3303 | } |
2878 | #else |
3304 | } |
2879 | 0; |
3305 | } |
2880 | #endif |
3306 | |
|
|
3307 | static unsigned int |
|
|
3308 | colorcube_index (unsigned int idx_r, |
|
|
3309 | unsigned int idx_g, |
|
|
3310 | unsigned int idx_b) |
|
|
3311 | { |
|
|
3312 | assert (idx_r < Red_levels); |
|
|
3313 | assert (idx_g < Green_levels); |
|
|
3314 | assert (idx_b < Blue_levels); |
|
|
3315 | |
|
|
3316 | return idx_r * Blue_levels * Green_levels + |
|
|
3317 | idx_g * Blue_levels + |
|
|
3318 | idx_b; |
|
|
3319 | } |
|
|
3320 | |
|
|
3321 | /* |
|
|
3322 | * Find the nearest color slot in the hidden color cube, |
|
|
3323 | * adapt its value to the 32bit RGBA color. |
|
|
3324 | */ |
|
|
3325 | unsigned int |
|
|
3326 | rxvt_term::map_rgb24_color (unsigned int r, unsigned int g, unsigned int b, unsigned int a) |
|
|
3327 | { |
|
|
3328 | r &= 0xff; |
|
|
3329 | g &= 0xff; |
|
|
3330 | b &= 0xff; |
|
|
3331 | a &= 0xff; |
|
|
3332 | |
|
|
3333 | uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; |
|
|
3334 | |
|
|
3335 | unsigned int idx_r = r * (Red_levels - 1) / 0xff; |
|
|
3336 | unsigned int idx_g = g * (Green_levels - 1) / 0xff; |
|
|
3337 | unsigned int idx_b = b * (Blue_levels - 1) / 0xff; |
|
|
3338 | unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); |
|
|
3339 | |
|
|
3340 | /* we allow one of the 6 directly neighbouring colours */ |
|
|
3341 | /* to replace the current color, if they not used recently */ |
|
|
3342 | static const signed char dxyz[][3] = { |
|
|
3343 | 0, 0, 0, |
|
|
3344 | 0, 0, +1, |
|
|
3345 | 0, 0, -1, |
|
|
3346 | 0, +1, 0, |
|
|
3347 | 0, -1, 0, |
|
|
3348 | +1, 0, 0, |
|
|
3349 | -1, 0, 0, |
|
|
3350 | }; |
|
|
3351 | |
|
|
3352 | for (int n = 0; n < ecb_array_length (dxyz); ++n) |
|
|
3353 | { |
|
|
3354 | int r = idx_r + dxyz[n][0]; |
|
|
3355 | int g = idx_g + dxyz[n][1]; |
|
|
3356 | int b = idx_b + dxyz[n][2]; |
|
|
3357 | |
|
|
3358 | if (!IN_RANGE_EXC (r, 0, Red_levels )) continue; |
|
|
3359 | if (!IN_RANGE_EXC (g, 0, Green_levels)) continue; |
|
|
3360 | if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue; |
|
|
3361 | |
|
|
3362 | unsigned int index = colorcube_index (r, g, b); |
|
|
3363 | |
|
|
3364 | if (rgb24_color[index] == color) |
|
|
3365 | { |
|
|
3366 | rgb24_seqno[index] = ++rgb24_sequence; |
|
|
3367 | return index + minTermCOLOR24; |
|
|
3368 | } |
|
|
3369 | |
|
|
3370 | // minor issue: could update index 0 few more times |
|
|
3371 | if ((rgb24_seqno[index] | rgb24_color[index]) == 0) |
|
|
3372 | { |
|
|
3373 | idx = index; |
|
|
3374 | goto update; |
|
|
3375 | } |
|
|
3376 | |
|
|
3377 | // like (rgb24_seqno[idx] > rgb24_seqno[index]) |
|
|
3378 | // but also handles wrap around values good enough |
|
|
3379 | if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff) |
|
|
3380 | idx = index; |
|
|
3381 | } |
|
|
3382 | |
|
|
3383 | update: |
|
|
3384 | rgb24_color[idx] = color; |
|
|
3385 | rgb24_seqno[idx] = ++rgb24_sequence; |
|
|
3386 | |
|
|
3387 | idx += minTermCOLOR24; |
|
|
3388 | pix_colors_focused [idx].free (this); |
|
|
3389 | pix_colors_focused [idx].set (this, rgba (r * 0x0101, g * 0x0101, b * 0x0101, a * 0x0101)); |
|
|
3390 | update_fade_color (idx, false); |
|
|
3391 | |
|
|
3392 | return idx; |
|
|
3393 | } |
|
|
3394 | |
|
|
3395 | void |
|
|
3396 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
|
|
3397 | { |
|
|
3398 | if (str[0] == '?' && !str[1]) |
|
|
3399 | { |
|
|
3400 | rgba c; |
|
|
3401 | pix_colors_focused[color].get (c); |
|
|
3402 | |
|
|
3403 | #if XFT |
|
|
3404 | if (c.a != rgba::MAX_CC) |
|
|
3405 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.r, c.g, c.b, c.a, resp); |
2881 | else |
3406 | else |
2882 | rxvt_xterm_seq(aR_ arg, (char *)s, eh); |
3407 | #endif |
2883 | free(s); |
3408 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
2884 | } |
|
|
2885 | } |
3409 | } |
|
|
3410 | else |
|
|
3411 | set_window_color (color, str); |
2886 | } |
3412 | } |
|
|
3413 | |
2887 | /* |
3414 | /* |
2888 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3415 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
2889 | * 0 = change iconName/title |
|
|
2890 | * 1 = change iconName |
|
|
2891 | * 2 = change title |
|
|
2892 | * 4 = change color |
|
|
2893 | * 12 = change text color |
|
|
2894 | * 13 = change mouse foreground color |
|
|
2895 | * 17 = change highlight character colour |
|
|
2896 | * 18 = change bold character color |
|
|
2897 | * 19 = change underlined character color |
|
|
2898 | * 46 = change logfile (not implemented) |
|
|
2899 | * 50 = change font |
|
|
2900 | * |
|
|
2901 | * rxvt extensions: |
|
|
2902 | * 10 = menu (may change in future) |
|
|
2903 | * 20 = bg pixmap |
|
|
2904 | * 39 = change default fg color |
|
|
2905 | * 49 = change default bg color |
|
|
2906 | * 55 = dump scrollback buffer and all of screen |
|
|
2907 | */ |
3416 | */ |
2908 | /* EXTPROTO */ |
|
|
2909 | void |
3417 | void |
2910 | rxvt_xterm_seq(pR_ int op, const char *str, unsigned char resp __attribute__((unused))) |
3418 | rxvt_term::process_xterm_seq (int op, char *str, char resp) |
2911 | { |
3419 | { |
2912 | int changed = 0; |
3420 | int color; |
2913 | int color; |
|
|
2914 | char *buf, *name; |
3421 | char *buf, *name; |
|
|
3422 | bool query = str[0] == '?' && !str[1]; |
|
|
3423 | int saveop = op; |
2915 | |
3424 | |
|
|
3425 | dLocal (Display *, dpy); |
|
|
3426 | |
2916 | assert(str != NULL); |
3427 | assert (str != NULL); |
|
|
3428 | |
|
|
3429 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3430 | return; |
|
|
3431 | |
2917 | switch (op) { |
3432 | switch (op) |
|
|
3433 | { |
2918 | case XTerm_name: |
3434 | case XTerm_name: |
2919 | rxvt_set_title(aR_ str); |
3435 | set_title (str); |
2920 | /* FALLTHROUGH */ |
3436 | /* FALLTHROUGH */ |
2921 | case XTerm_iconName: |
3437 | case XTerm_iconName: |
2922 | rxvt_set_iconName(aR_ str); |
3438 | set_icon_name (str); |
2923 | break; |
3439 | break; |
2924 | case XTerm_title: |
3440 | case XTerm_title: |
2925 | rxvt_set_title(aR_ str); |
3441 | set_title (str); |
2926 | break; |
3442 | break; |
|
|
3443 | case XTerm_property: |
|
|
3444 | if (str[0] == '?') |
|
|
3445 | { |
|
|
3446 | Atom prop = display->atom (str + 1); |
|
|
3447 | Atom actual_type; |
|
|
3448 | int actual_format; |
|
|
3449 | unsigned long nitems; |
|
|
3450 | unsigned long bytes_after; |
|
|
3451 | unsigned char *value = 0; |
|
|
3452 | const char *str = ""; |
|
|
3453 | |
|
|
3454 | if (prop |
|
|
3455 | && XGetWindowProperty (dpy, parent, |
|
|
3456 | prop, 0, 1<<16, 0, AnyPropertyType, |
|
|
3457 | &actual_type, &actual_format, |
|
|
3458 | &nitems, &bytes_after, &value) == Success |
|
|
3459 | && actual_type != None |
|
|
3460 | && actual_format == 8) |
|
|
3461 | str = (const char *)(value); |
|
|
3462 | |
|
|
3463 | tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp); |
|
|
3464 | |
|
|
3465 | XFree (value); |
|
|
3466 | } |
|
|
3467 | else |
|
|
3468 | { |
|
|
3469 | char *eq = strchr (str, '='); |
|
|
3470 | |
|
|
3471 | if (eq) |
|
|
3472 | { |
|
|
3473 | *eq = 0; |
|
|
3474 | set_utf8_property (display->atom (str), eq + 1); |
|
|
3475 | } |
|
|
3476 | else |
|
|
3477 | XDeleteProperty (dpy, parent, |
|
|
3478 | display->atom (str)); |
|
|
3479 | } |
|
|
3480 | break; |
|
|
3481 | |
2927 | case XTerm_Color: |
3482 | case XTerm_Color: |
2928 | for (buf = (char *)str; buf && *buf;) { |
3483 | for (buf = (char *)str; buf && *buf;) |
|
|
3484 | { |
2929 | if ((name = STRCHR(buf, ';')) == NULL) |
3485 | if ((name = strchr (buf, ';')) == NULL) |
2930 | break; |
3486 | break; |
|
|
3487 | |
2931 | *name++ = '\0'; |
3488 | *name++ = '\0'; |
2932 | color = atoi(buf); |
3489 | color = atoi (buf) + minCOLOR; |
2933 | if (color < 0 || color >= TOTAL_COLORS) |
3490 | |
2934 | break; |
3491 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
|
|
3492 | break; |
|
|
3493 | |
2935 | if ((buf = STRCHR(name, ';')) != NULL) |
3494 | if ((buf = strchr (name, ';')) != NULL) |
2936 | *buf++ = '\0'; |
3495 | *buf++ = '\0'; |
2937 | rxvt_set_window_color(aR_ color + minCOLOR, name); |
3496 | |
2938 | } |
3497 | process_color_seq (op, color, name, resp); |
2939 | break; |
3498 | } |
|
|
3499 | break; |
|
|
3500 | case Rxvt_restoreFG: |
|
|
3501 | case XTerm_Color00: |
|
|
3502 | process_color_seq (op, Color_fg, str, resp); |
|
|
3503 | break; |
|
|
3504 | case Rxvt_restoreBG: |
|
|
3505 | case XTerm_Color01: |
|
|
3506 | process_color_seq (op, Color_bg, str, resp); |
|
|
3507 | break; |
2940 | #ifndef NO_CURSORCOLOR |
3508 | #ifndef NO_CURSORCOLOR |
2941 | case XTerm_Color_cursor: |
3509 | case XTerm_Color_cursor: |
2942 | rxvt_set_window_color(aR_ Color_cursor, str); |
3510 | process_color_seq (op, Color_cursor, str, resp); |
2943 | break; |
3511 | break; |
2944 | #endif |
3512 | #endif |
2945 | case XTerm_Color_pointer: |
3513 | case XTerm_Color_pointer_fg: |
2946 | rxvt_set_window_color(aR_ Color_pointer, str); |
3514 | process_color_seq (op, Color_pointer_fg, str, resp); |
2947 | break; |
3515 | break; |
|
|
3516 | case XTerm_Color_pointer_bg: |
|
|
3517 | process_color_seq (op, Color_pointer_bg, str, resp); |
|
|
3518 | break; |
|
|
3519 | #ifdef OPTION_HC |
|
|
3520 | case XTerm_Color_HC: |
|
|
3521 | process_color_seq (op, Color_HC, str, resp); |
|
|
3522 | break; |
|
|
3523 | case XTerm_Color_HTC: |
|
|
3524 | process_color_seq (op, Color_HTC, str, resp); |
|
|
3525 | break; |
|
|
3526 | #endif |
2948 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3527 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2949 | case XTerm_Color_BD: |
3528 | case URxvt_Color_BD: |
2950 | rxvt_set_window_color(aR_ Color_BD, str); |
3529 | process_color_seq (op, Color_BD, str, resp); |
2951 | break; |
3530 | break; |
2952 | case XTerm_Color_UL: |
3531 | case URxvt_Color_UL: |
2953 | rxvt_set_window_color(aR_ Color_UL, str); |
3532 | process_color_seq (op, Color_UL, str, resp); |
2954 | break; |
3533 | break; |
2955 | case XTerm_Color_RV: |
3534 | case URxvt_Color_IT: |
2956 | rxvt_set_window_color(aR_ Color_RV, str); |
3535 | process_color_seq (op, Color_IT, str, resp); |
2957 | break; |
3536 | break; |
2958 | #endif |
3537 | #endif |
|
|
3538 | case URxvt_Color_border: |
|
|
3539 | process_color_seq (op, Color_border, str, resp); |
|
|
3540 | break; |
2959 | |
3541 | |
2960 | case XTerm_Menu: |
|
|
2961 | /* |
|
|
2962 | * rxvt_menubar_dispatch() violates the constness of the string, |
|
|
2963 | * so DON'T do it here |
|
|
2964 | */ |
|
|
2965 | break; |
|
|
2966 | case XTerm_Pixmap: |
|
|
2967 | if (*str != ';') { |
|
|
2968 | #if XPM_BACKGROUND |
|
|
2969 | rxvt_scale_pixmap(aR_ ""); /* reset to default scaling */ |
|
|
2970 | rxvt_set_bgPixmap(aR_ str); /* change pixmap */ |
|
|
2971 | #endif |
|
|
2972 | rxvt_scr_touch(aR_ True); |
|
|
2973 | } |
|
|
2974 | while ((str = STRCHR(str, ';')) != NULL) { |
|
|
2975 | str++; |
|
|
2976 | #if XPM_BACKGROUND |
|
|
2977 | changed += rxvt_scale_pixmap(aR_ str); |
|
|
2978 | #endif |
|
|
2979 | } |
|
|
2980 | if (changed) { |
|
|
2981 | #ifdef XPM_BACKGROUND |
|
|
2982 | rxvt_resize_pixmap(aR); |
|
|
2983 | #endif |
|
|
2984 | rxvt_scr_touch(aR_ True); |
|
|
2985 | } |
|
|
2986 | break; |
|
|
2987 | |
|
|
2988 | case XTerm_restoreFG: |
|
|
2989 | rxvt_set_window_color(aR_ Color_fg, str); |
|
|
2990 | break; |
|
|
2991 | case XTerm_restoreBG: |
|
|
2992 | rxvt_set_window_color(aR_ Color_bg, str); |
|
|
2993 | break; |
|
|
2994 | case XTerm_logfile: |
3542 | case XTerm_logfile: |
2995 | break; |
3543 | // TODO, when secure mode? |
2996 | case XTerm_font: |
3544 | break; |
2997 | rxvt_change_font(aR_ 0, str); |
3545 | |
2998 | break; |
|
|
2999 | #if 0 |
3546 | #if 0 |
3000 | case XTerm_dumpscreen: /* no error notices */ |
3547 | case Rxvt_dumpscreen: /* no error notices */ |
3001 | { |
3548 | { |
3002 | int fd; |
3549 | int fd; |
3003 | if ((fd = open(str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) { |
3550 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3004 | rxvt_scr_dump(aR_ fd); |
3551 | { |
3005 | close(fd); |
3552 | scr_dump (fd); |
3006 | } |
3553 | close (fd); |
3007 | } |
3554 | } |
3008 | break; |
3555 | } |
|
|
3556 | break; |
|
|
3557 | #endif |
|
|
3558 | case XTerm_font: |
|
|
3559 | op = URxvt_font; |
|
|
3560 | case URxvt_font: |
|
|
3561 | #if ENABLE_STYLES |
|
|
3562 | case URxvt_boldFont: |
|
|
3563 | case URxvt_italicFont: |
|
|
3564 | case URxvt_boldItalicFont: |
|
|
3565 | #endif |
|
|
3566 | if (query) |
|
|
3567 | tt_printf ("\33]%d;%-.250s%c", saveop, |
|
|
3568 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
|
|
3569 | ? fontset[op - URxvt_font]->fontdesc : "", |
|
|
3570 | resp); |
|
|
3571 | else |
|
|
3572 | { |
|
|
3573 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
|
|
3574 | |
|
|
3575 | res = strdup (str); |
|
|
3576 | allocated.push_back ((void *)res); |
|
|
3577 | set_fonts (); |
|
|
3578 | } |
|
|
3579 | break; |
|
|
3580 | |
|
|
3581 | case URxvt_version: |
|
|
3582 | if (query) |
|
|
3583 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3584 | op, |
|
|
3585 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3586 | resp); |
|
|
3587 | break; |
|
|
3588 | |
|
|
3589 | #if !ENABLE_MINIMAL |
|
|
3590 | case URxvt_locale: |
|
|
3591 | if (query) |
|
|
3592 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
|
|
3593 | else |
|
|
3594 | { |
|
|
3595 | set_locale (str); |
|
|
3596 | pty->set_utf8_mode (enc_utf8); |
|
|
3597 | init_xlocale (); |
|
|
3598 | } |
|
|
3599 | break; |
|
|
3600 | |
|
|
3601 | case URxvt_view_up: |
|
|
3602 | case URxvt_view_down: |
|
|
3603 | { |
|
|
3604 | int lines = atoi (str); |
|
|
3605 | |
|
|
3606 | if (lines) |
|
|
3607 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
|
|
3608 | else |
|
|
3609 | scr_erase_savelines (); |
|
|
3610 | } |
|
|
3611 | |
|
|
3612 | break; |
|
|
3613 | #endif |
|
|
3614 | |
|
|
3615 | #if ENABLE_PERL |
|
|
3616 | case URxvt_perl: |
|
|
3617 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
|
|
3618 | break; |
3009 | #endif |
3619 | #endif |
3010 | } |
3620 | } |
3011 | } |
3621 | } |
3012 | /*----------------------------------------------------------------------*/ |
3622 | /*----------------------------------------------------------------------*/ |
3013 | |
3623 | |
… | |
… | |
3019 | * 's' = save |
3629 | * 's' = save |
3020 | * 'r' = restore |
3630 | * 'r' = restore |
3021 | * 't' = toggle |
3631 | * 't' = toggle |
3022 | * so no need for fancy checking |
3632 | * so no need for fancy checking |
3023 | */ |
3633 | */ |
3024 | /* INTPROTO */ |
3634 | int ecb_cold |
3025 | int |
|
|
3026 | rxvt_privcases(pR_ int mode, unsigned long bit) |
3635 | rxvt_term::privcases (int mode, unsigned long bit) |
3027 | { |
3636 | { |
3028 | int state; |
3637 | int state; |
3029 | |
3638 | |
3030 | if (mode == 's') { |
3639 | if (mode == 's') |
3031 | R->SavedModes |= (R->PrivateModes & bit); |
3640 | { |
3032 | return -1; |
3641 | if (priv_modes & bit) |
|
|
3642 | SavedModes |= bit; |
3033 | } else { |
3643 | else |
|
|
3644 | SavedModes &= ~bit; |
|
|
3645 | return -1; |
|
|
3646 | } |
|
|
3647 | else |
|
|
3648 | { |
3034 | if (mode == 'r') |
3649 | if (mode == 'r') |
3035 | state = (R->SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3650 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3036 | else |
3651 | else |
3037 | state = (mode == 't') ? !(R->PrivateModes & bit) : mode; |
3652 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3038 | PrivMode(state, bit); |
3653 | |
|
|
3654 | if (state) |
|
|
3655 | priv_modes |= bit; |
|
|
3656 | else |
|
|
3657 | priv_modes &= ~bit; |
3039 | } |
3658 | } |
|
|
3659 | |
3040 | return state; |
3660 | return state; |
3041 | } |
3661 | } |
3042 | |
3662 | |
3043 | /* we're not using priv _yet_ */ |
3663 | /* we're not using priv _yet_ */ |
3044 | /* INTPROTO */ |
|
|
3045 | void |
3664 | void |
3046 | rxvt_process_terminal_mode(pR_ int mode, int priv __attribute__((unused)), unsigned int nargs, const int *arg) |
3665 | rxvt_term::process_terminal_mode (int mode, int priv ecb_unused, unsigned int nargs, const int *arg) |
3047 | { |
3666 | { |
3048 | unsigned int i, j; |
3667 | unsigned int i, j; |
3049 | int state; |
3668 | int state; |
|
|
3669 | |
3050 | static const struct { |
3670 | static const struct |
|
|
3671 | { |
3051 | const int argval; |
3672 | const int argval; |
3052 | const unsigned long bit; |
3673 | const unsigned long bit; |
3053 | } argtopriv[] = { |
3674 | } argtopriv[] = { |
3054 | { 1, PrivMode_aplCUR }, |
3675 | { 1, PrivMode_aplCUR }, // DECCKM |
3055 | { 2, PrivMode_vt52 }, |
3676 | { 2, PrivMode_vt52 }, // DECANM |
3056 | { 3, PrivMode_132 }, |
3677 | { 3, PrivMode_132 }, // DECCOLM |
3057 | { 4, PrivMode_smoothScroll }, |
3678 | { 4, PrivMode_smoothScroll }, // DECSCLM |
3058 | { 5, PrivMode_rVideo }, |
3679 | { 5, PrivMode_rVideo }, // DECSCNM |
3059 | { 6, PrivMode_relOrigin }, |
3680 | { 6, PrivMode_relOrigin }, // DECOM |
3060 | { 7, PrivMode_Autowrap }, |
3681 | { 7, PrivMode_Autowrap }, // DECAWM |
3061 | { 9, PrivMode_MouseX10 }, |
3682 | // 8, auto-repeat keys // DECARM |
3062 | #ifdef menuBar_esc |
3683 | { 9, PrivMode_MouseX10 }, |
3063 | { menuBar_esc, PrivMode_menuBar }, |
3684 | { 12, PrivMode_BlinkingCursor }, |
3064 | #endif |
3685 | // 18 end FF to printer after print screen |
|
|
3686 | // 19 Print screen prints full screen/scroll region |
|
|
3687 | { 25, PrivMode_VisibleCursor }, // DECTCEM cnorm/cvvis/civis |
3065 | #ifdef scrollBar_esc |
3688 | #ifdef scrollBar_esc |
3066 | { scrollBar_esc, PrivMode_scrollBar }, |
3689 | { scrollBar_esc, PrivMode_scrollBar }, |
3067 | #endif |
3690 | #endif |
3068 | { 25, PrivMode_VisibleCursor }, |
3691 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3069 | { 35, PrivMode_ShiftKeys }, |
3692 | // 38, tektronix mode // DECTEK |
3070 | { 40, PrivMode_132OK }, |
3693 | { 40, PrivMode_132OK }, |
3071 | { 47, PrivMode_Screen }, |
3694 | // 41 xterm more fixes NYI |
3072 | { 66, PrivMode_aplKP }, |
3695 | // 45 margin bell NYI |
|
|
3696 | // 46 start logging |
|
|
3697 | { 47, PrivMode_Screen }, |
|
|
3698 | { 66, PrivMode_aplKP }, // DECNKM |
3073 | #ifndef NO_BACKSPACE_KEY |
3699 | #ifndef NO_BACKSPACE_KEY |
3074 | { 67, PrivMode_BackSpace }, |
3700 | { 67, PrivMode_BackSpace }, // DECBKM |
3075 | #endif |
3701 | #endif |
3076 | { 1000, PrivMode_MouseX11 }, |
3702 | { 1000, PrivMode_MouseX11 }, |
3077 | { 1010, PrivMode_TtyOutputInh }, |
3703 | { 1002, PrivMode_MouseBtnEvent }, |
3078 | { 1011, PrivMode_Keypress }, |
3704 | { 1003, PrivMode_MouseAnyEvent }, |
3079 | { 1047, PrivMode_Screen }, |
3705 | #if ENABLE_FRILLS |
3080 | }; |
3706 | { 1004, PrivMode_FocusEvent }, |
|
|
3707 | { 1005, PrivMode_ExtMouseUTF8 }, |
|
|
3708 | { 1006, PrivMode_ExtMouseSGR }, |
|
|
3709 | #endif |
|
|
3710 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
|
|
3711 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3712 | #if ENABLE_FRILLS |
|
|
3713 | { 1015, PrivMode_ExtMouseUrxvt }, // urxvt extension of 1005 |
|
|
3714 | #endif |
|
|
3715 | // 1035 enable modifiers for alt, numlock NYI |
|
|
3716 | // 1036 send ESC for meta keys NYI |
|
|
3717 | // 1037 send DEL for keypad delete NYI |
|
|
3718 | { 1047, PrivMode_Screen }, |
|
|
3719 | // 1048 save and restore cursor, implemented in code |
|
|
3720 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
|
|
3721 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3722 | { 2004, PrivMode_BracketPaste }, |
|
|
3723 | }; |
3081 | |
3724 | |
3082 | if (nargs == 0) |
3725 | if (nargs == 0) |
3083 | return; |
3726 | return; |
3084 | |
3727 | |
3085 | /* make lo/hi boolean */ |
3728 | /* make lo/hi boolean */ |
3086 | if (mode == 'l') |
3729 | if (mode == 'l') |
3087 | mode = 0; /* reset */ |
3730 | mode = 0; /* reset */ |
3088 | else if (mode == 'h') |
3731 | else if (mode == 'h') |
3089 | mode = 1; /* set */ |
3732 | mode = 1; /* set */ |
3090 | |
3733 | |
3091 | for (i = 0; i < nargs; i++) { |
3734 | for (i = 0; i < nargs; i++) |
|
|
3735 | { |
3092 | state = -1; |
3736 | state = -1; |
3093 | |
3737 | |
3094 | /* basic handling */ |
3738 | /* basic handling */ |
3095 | for (j = 0; j < (sizeof(argtopriv)/sizeof(argtopriv[0])); j++) |
3739 | for (j = 0; j < ecb_array_length (argtopriv); j++) |
3096 | if (argtopriv[j].argval == arg[i]) { |
3740 | if (argtopriv[j].argval == arg[i]) |
|
|
3741 | { |
3097 | state = rxvt_privcases(aR_ mode, argtopriv[j].bit); |
3742 | state = privcases (mode, argtopriv[j].bit); |
3098 | break; |
3743 | break; |
3099 | } |
3744 | } |
3100 | |
3745 | |
3101 | /* extra handling for values with state unkept */ |
3746 | /* extra handling for values with state unkept */ |
3102 | if (state == -1) |
|
|
3103 | switch (arg[i]) { |
3747 | switch (arg[i]) |
|
|
3748 | { |
|
|
3749 | #if ENABLE_STYLES |
|
|
3750 | case 1021: |
|
|
3751 | set_option (Opt_intensityStyles, mode); |
|
|
3752 | |
|
|
3753 | scr_touch (true); |
|
|
3754 | break; |
|
|
3755 | #endif |
3104 | case 1048: /* alternative cursor save */ |
3756 | case 1048: /* alternative cursor save */ |
3105 | if (mode == 0) |
3757 | if (option (Opt_secondaryScreen)) |
3106 | rxvt_scr_cursor(aR_ RESTORE); |
3758 | if (mode == 0) |
3107 | else if (mode == 1) |
3759 | scr_cursor (RESTORE); |
3108 | rxvt_scr_cursor(aR_ SAVE); |
3760 | else if (mode == 1) |
3109 | /* FALLTHROUGH */ |
3761 | scr_cursor (SAVE); |
3110 | default: |
3762 | break; |
3111 | continue; /* for(;i;) */ |
3763 | } |
3112 | } |
|
|
3113 | |
3764 | |
|
|
3765 | if (state >= 0) |
3114 | /* extra handling for values with valid 0 or 1 state */ |
3766 | /* extra handling for values with valid 0 or 1 state */ |
3115 | switch (arg[i]) { |
3767 | switch (arg[i]) |
|
|
3768 | { |
3116 | /* case 1: - application cursor keys */ |
3769 | /* case 1: - application cursor keys */ |
3117 | case 2: /* VT52 mode */ |
3770 | case 2: /* VT52 mode */ |
3118 | /* oddball mode. should be set regardless of set/reset |
3771 | /* oddball mode. should be set regardless of set/reset |
3119 | * parameter. Return from VT52 mode with an ESC < from |
3772 | * parameter. Return from VT52 mode with an ESC < from |
3120 | * within VT52 mode |
3773 | * within VT52 mode |
3121 | */ |
3774 | */ |
3122 | PrivMode(1, PrivMode_vt52); |
3775 | priv_modes |= PrivMode_vt52; |
3123 | break; |
3776 | break; |
3124 | case 3: /* 80/132 */ |
3777 | case 3: /* 80/132 */ |
3125 | if (R->PrivateModes & PrivMode_132OK) |
3778 | if (priv_modes & PrivMode_132OK) |
3126 | rxvt_set_widthheight(aR_ |
3779 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
3127 | (unsigned int)((state ? 132 : 80) * R->TermWin.fwidth), |
3780 | break; |
3128 | (unsigned int)R->TermWin.height); |
|
|
3129 | break; |
|
|
3130 | case 4: /* smooth scrolling */ |
3781 | case 4: /* smooth scrolling */ |
3131 | if (state) |
3782 | set_option (Opt_jumpScroll, !state); |
3132 | R->Options &= ~Opt_jumpScroll; |
3783 | break; |
3133 | else |
|
|
3134 | R->Options |= Opt_jumpScroll; |
|
|
3135 | break; |
|
|
3136 | case 5: /* reverse video */ |
3784 | case 5: /* reverse video */ |
3137 | rxvt_scr_rvideo_mode(aR_ state); |
3785 | scr_rvideo_mode (state); |
3138 | break; |
3786 | break; |
3139 | case 6: /* relative/absolute origins */ |
3787 | case 6: /* relative/absolute origins */ |
3140 | rxvt_scr_relative_origin(aR_ state); |
3788 | scr_relative_origin (state); |
3141 | break; |
3789 | break; |
3142 | case 7: /* autowrap */ |
3790 | case 7: /* autowrap */ |
3143 | rxvt_scr_autowrap(aR_ state); |
3791 | scr_autowrap (state); |
3144 | break; |
3792 | break; |
3145 | /* case 8: - auto repeat, can't do on a per window basis */ |
3793 | /* case 8: - auto repeat, can't do on a per window basis */ |
3146 | case 9: /* X10 mouse reporting */ |
3794 | case 9: /* X10 mouse reporting */ |
3147 | if (state) /* orthogonal */ |
3795 | if (state) /* orthogonal */ |
3148 | R->PrivateModes &= ~(PrivMode_MouseX11); |
3796 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3149 | break; |
3797 | break; |
3150 | #ifdef menuBar_esc |
|
|
3151 | case menuBar_esc: |
|
|
3152 | #ifdef MENUBAR |
|
|
3153 | rxvt_map_menuBar(aR_ state); |
|
|
3154 | #endif |
|
|
3155 | break; |
|
|
3156 | #endif |
|
|
3157 | #ifdef scrollBar_esc |
3798 | #ifdef scrollBar_esc |
3158 | case scrollBar_esc: |
3799 | case scrollBar_esc: |
3159 | if (rxvt_scrollbar_mapping(aR_ state)) { |
3800 | scrollBar.map (state); |
3160 | rxvt_resize_all_windows(aR_ 0, 0, 0); |
3801 | resize_all_windows (0, 0, 0); |
3161 | rxvt_scr_touch(aR_ True); |
3802 | scr_touch (true); |
3162 | } |
3803 | break; |
3163 | break; |
|
|
3164 | #endif |
3804 | #endif |
|
|
3805 | #ifdef CURSOR_BLINK |
|
|
3806 | case 12: |
|
|
3807 | cursor_blink_reset (); |
|
|
3808 | break; |
|
|
3809 | #endif |
3165 | case 25: /* visible/invisible cursor */ |
3810 | case 25: /* visible/invisible cursor */ |
3166 | rxvt_scr_cursor_visible(aR_ state); |
3811 | scr_cursor_visible (state); |
3167 | break; |
3812 | break; |
3168 | /* case 35: - shift keys */ |
3813 | /* case 35: - shift keys */ |
3169 | /* case 40: - 80 <--> 132 mode */ |
3814 | /* case 40: - 80 <--> 132 mode */ |
3170 | case 47: /* secondary screen */ |
3815 | case 47: /* secondary screen */ |
3171 | rxvt_scr_change_screen(aR_ state); |
3816 | scr_change_screen (state); |
3172 | break; |
3817 | break; |
3173 | /* case 66: - application key pad */ |
3818 | /* case 66: - application key pad */ |
3174 | /* case 67: - backspace key */ |
3819 | /* case 67: - backspace key */ |
3175 | case 1000: /* X11 mouse reporting */ |
3820 | case 1000: /* X11 mouse reporting */ |
3176 | if (state) /* orthogonal */ |
3821 | if (state) /* orthogonal */ |
3177 | R->PrivateModes &= ~(PrivMode_MouseX10); |
3822 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3178 | break; |
3823 | break; |
3179 | #if 0 |
3824 | case 1002: |
3180 | case 1001: |
3825 | case 1003: |
3181 | break; /* X11 mouse highlighting */ |
3826 | if (state) |
3182 | #endif |
3827 | { |
|
|
3828 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3829 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3830 | mouse_row = mouse_col = 0; |
|
|
3831 | vt_emask_mouse = PointerMotionMask; |
|
|
3832 | } |
|
|
3833 | else |
|
|
3834 | vt_emask_mouse = NoEventMask; |
|
|
3835 | |
|
|
3836 | vt_select_input (); |
|
|
3837 | break; |
3183 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3838 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3184 | if (state) |
3839 | set_option (Opt_scrollTtyOutput, !state); |
3185 | R->Options &= ~Opt_scrollTtyOutput; |
3840 | break; |
3186 | else |
|
|
3187 | R->Options |= Opt_scrollTtyOutput; |
|
|
3188 | break; |
|
|
3189 | case 1011: /* scroll to bottom on key press */ |
3841 | case 1011: /* scroll to bottom on key press */ |
3190 | if (state) |
3842 | set_option (Opt_scrollTtyKeypress, state); |
3191 | R->Options |= Opt_scrollTtyKeypress; |
3843 | break; |
3192 | else |
|
|
3193 | R->Options &= ~Opt_scrollTtyKeypress; |
|
|
3194 | break; |
|
|
3195 | case 1047: /* secondary screen w/ clearing */ |
3844 | case 1047: /* secondary screen w/ clearing last */ |
3196 | if (R->current_screen != PRIMARY) |
3845 | if (option (Opt_secondaryScreen)) |
3197 | rxvt_scr_erase_screen(aR_ 2); |
3846 | if (!state) |
3198 | rxvt_scr_change_screen(aR_ state); |
3847 | scr_erase_screen (2); |
3199 | /* FALLTHROUGH */ |
3848 | |
3200 | default: |
3849 | scr_change_screen (state); |
3201 | break; |
3850 | break; |
3202 | } |
3851 | case 1049: /* secondary screen w/ clearing first */ |
|
|
3852 | if (option (Opt_secondaryScreen)) |
|
|
3853 | if (state) |
|
|
3854 | scr_cursor (SAVE); |
|
|
3855 | |
|
|
3856 | scr_change_screen (state); |
|
|
3857 | |
|
|
3858 | if (option (Opt_secondaryScreen)) |
|
|
3859 | if (state) |
|
|
3860 | scr_erase_screen (2); |
|
|
3861 | else |
|
|
3862 | scr_cursor (RESTORE); |
|
|
3863 | break; |
|
|
3864 | default: |
|
|
3865 | break; |
|
|
3866 | } |
3203 | } |
3867 | } |
3204 | } |
3868 | } |
3205 | /*}}} */ |
3869 | /*}}} */ |
3206 | |
3870 | |
3207 | /*{{{ process sgr sequences */ |
3871 | /*{{{ process sgr sequences */ |
3208 | /* INTPROTO */ |
3872 | void ecb_hot |
|
|
3873 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
|
|
3874 | { |
|
|
3875 | unsigned int i; |
|
|
3876 | short rendset; |
|
|
3877 | int rendstyle; |
|
|
3878 | |
|
|
3879 | if (nargs == 0) |
|
|
3880 | { |
|
|
3881 | scr_rendition (0, ~RS_None); |
|
|
3882 | return; |
|
|
3883 | } |
|
|
3884 | |
|
|
3885 | for (i = 0; i < nargs; i++) |
|
|
3886 | { |
|
|
3887 | rendset = -1; |
|
|
3888 | switch (arg[i]) |
|
|
3889 | { |
|
|
3890 | case 0: |
|
|
3891 | rendset = 0, rendstyle = ~RS_None; |
|
|
3892 | break; |
|
|
3893 | case 1: |
|
|
3894 | rendset = 1, rendstyle = RS_Bold; |
|
|
3895 | break; |
|
|
3896 | //case 2: // low intensity |
|
|
3897 | case 3: |
|
|
3898 | rendset = 1, rendstyle = RS_Italic; |
|
|
3899 | break; |
|
|
3900 | case 4: |
|
|
3901 | rendset = 1, rendstyle = RS_Uline; |
|
|
3902 | break; |
|
|
3903 | case 5: // slowly blinking |
|
|
3904 | case 6: // rapidly blinking |
|
|
3905 | rendset = 1, rendstyle = RS_Blink; |
|
|
3906 | break; |
|
|
3907 | //case 6: // scoansi light background |
|
|
3908 | case 7: |
|
|
3909 | rendset = 1, rendstyle = RS_RVid; |
|
|
3910 | break; |
|
|
3911 | case 8: |
|
|
3912 | // invisible. NYI |
|
|
3913 | break; |
|
|
3914 | //case 9: // crossed out |
|
|
3915 | //case 10: // scoansi acs off, primary font |
|
|
3916 | //case 11: // scoansi acs on, first alt font |
|
|
3917 | //case 12: // scoansi acs on, |0x80, second alt font |
|
|
3918 | //... |
|
|
3919 | //case 19: // ninth alt font |
|
|
3920 | //case 20: // gothic |
|
|
3921 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
|
|
3922 | rendset = 0, rendstyle = RS_Bold; |
|
|
3923 | break; |
|
|
3924 | case 22: // bold off (vt220) |
|
|
3925 | rendset = 0, rendstyle = RS_Bold; |
|
|
3926 | break; |
|
|
3927 | case 23: // disable italic |
|
|
3928 | rendset = 0, rendstyle = RS_Italic; |
|
|
3929 | break; |
|
|
3930 | case 24: // underline off (vt220) |
|
|
3931 | rendset = 0, rendstyle = RS_Uline; |
|
|
3932 | break; |
|
|
3933 | case 25: // blink off (vt220) |
|
|
3934 | rendset = 0, rendstyle = RS_Blink; |
|
|
3935 | break; |
|
|
3936 | case 26: // variable spacing (iso 8613) |
|
|
3937 | rendset = 0, rendstyle = RS_Blink; |
|
|
3938 | break; |
|
|
3939 | case 27: // reverse off (vt220) |
|
|
3940 | rendset = 0, rendstyle = RS_RVid; |
|
|
3941 | break; |
|
|
3942 | //case 28: // visible. NYI |
|
|
3943 | //case 29: // not crossed-out |
|
|
3944 | } |
|
|
3945 | |
|
|
3946 | if (rendset != -1) |
|
|
3947 | { |
|
|
3948 | scr_rendition (rendset, rendstyle); |
|
|
3949 | continue; /* for (;i;) */ |
|
|
3950 | } |
|
|
3951 | |
|
|
3952 | switch (arg[i]) |
|
|
3953 | { |
|
|
3954 | case 30: |
|
|
3955 | case 31: /* set fg color */ |
|
|
3956 | case 32: |
|
|
3957 | case 33: |
|
|
3958 | case 34: |
|
|
3959 | case 35: |
|
|
3960 | case 36: |
|
|
3961 | case 37: |
|
|
3962 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
|
|
3963 | break; |
|
|
3964 | case 39: /* default fg */ |
|
|
3965 | scr_color (Color_fg, Color_fg); |
|
|
3966 | break; |
|
|
3967 | |
|
|
3968 | case 40: |
|
|
3969 | case 41: /* set bg color */ |
|
|
3970 | case 42: |
|
|
3971 | case 43: |
|
|
3972 | case 44: |
|
|
3973 | case 45: |
|
|
3974 | case 46: |
|
|
3975 | case 47: |
|
|
3976 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
|
|
3977 | break; |
|
|
3978 | case 49: /* default bg */ |
|
|
3979 | scr_color (Color_bg, Color_bg); |
|
|
3980 | break; |
|
|
3981 | |
|
|
3982 | case 38: // set fg color, ISO 8613-6 |
|
|
3983 | case 48: // set bg color, ISO 8613-6 |
|
|
3984 | { |
|
|
3985 | unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; |
|
|
3986 | unsigned int idx; |
|
|
3987 | |
|
|
3988 | if (nargs > i + 2 && arg[i + 1] == 5) |
|
|
3989 | { |
|
|
3990 | idx = minCOLOR + arg[i + 2]; |
|
|
3991 | i += 2; |
|
|
3992 | |
|
|
3993 | scr_color (idx, fgbg); |
|
|
3994 | } |
|
|
3995 | else if (nargs > i + 4 && arg[i + 1] == 2) |
|
|
3996 | { |
|
|
3997 | unsigned int r = arg[i + 2]; |
|
|
3998 | unsigned int g = arg[i + 3]; |
|
|
3999 | unsigned int b = arg[i + 4]; |
|
|
4000 | unsigned int a = 0xff; |
|
|
4001 | |
|
|
4002 | idx = map_rgb24_color (r, g, b, a); |
|
|
4003 | |
|
|
4004 | i += 4; |
|
|
4005 | |
|
|
4006 | scr_color (idx, fgbg); |
|
|
4007 | } |
|
|
4008 | } |
|
|
4009 | break; |
|
|
4010 | |
|
|
4011 | //case 50: // not variable spacing |
|
|
4012 | |
|
|
4013 | #if !ENABLE_MINIMAL |
|
|
4014 | case 90: |
|
|
4015 | case 91: /* set bright fg color */ |
|
|
4016 | case 92: |
|
|
4017 | case 93: |
|
|
4018 | case 94: |
|
|
4019 | case 95: |
|
|
4020 | case 96: |
|
|
4021 | case 97: |
|
|
4022 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); |
|
|
4023 | break; |
|
|
4024 | case 100: |
|
|
4025 | case 101: /* set bright bg color */ |
|
|
4026 | case 102: |
|
|
4027 | case 103: |
|
|
4028 | case 104: |
|
|
4029 | case 105: |
|
|
4030 | case 106: |
|
|
4031 | case 107: |
|
|
4032 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
|
|
4033 | break; |
|
|
4034 | #endif |
|
|
4035 | } |
|
|
4036 | } |
|
|
4037 | } |
|
|
4038 | |
3209 | void |
4039 | void |
3210 | rxvt_process_sgr_mode(pR_ unsigned int nargs, const int *arg) |
4040 | rxvt_term::set_cursor_style (int style) |
3211 | { |
4041 | { |
3212 | unsigned int i; |
4042 | if (!IN_RANGE_INC (style, 0, 6)) |
3213 | short rendset; |
4043 | return; |
3214 | int rendstyle; |
|
|
3215 | |
4044 | |
3216 | if (nargs == 0) { |
4045 | if (style == 0) |
3217 | rxvt_scr_rendition(aR_ 0, ~RS_None); |
4046 | style = 1; |
3218 | return; |
|
|
3219 | } |
|
|
3220 | for (i = 0; i < nargs; i++) { |
|
|
3221 | rendset = -1; |
|
|
3222 | switch (arg[i]) { |
|
|
3223 | case 0: |
|
|
3224 | rendset = 0, rendstyle = ~RS_None; |
|
|
3225 | break; |
|
|
3226 | case 1: |
|
|
3227 | rendset = 1, rendstyle = RS_Bold; |
|
|
3228 | break; |
|
|
3229 | case 4: |
|
|
3230 | rendset = 1, rendstyle = RS_Uline; |
|
|
3231 | break; |
|
|
3232 | case 5: |
|
|
3233 | rendset = 1, rendstyle = RS_Blink; |
|
|
3234 | break; |
|
|
3235 | case 7: |
|
|
3236 | rendset = 1, rendstyle = RS_RVid; |
|
|
3237 | break; |
|
|
3238 | case 22: |
|
|
3239 | rendset = 0, rendstyle = RS_Bold; |
|
|
3240 | break; |
|
|
3241 | case 24: |
|
|
3242 | rendset = 0, rendstyle = RS_Uline; |
|
|
3243 | break; |
|
|
3244 | case 25: |
|
|
3245 | rendset = 0, rendstyle = RS_Blink; |
|
|
3246 | break; |
|
|
3247 | case 27: |
|
|
3248 | rendset = 0, rendstyle = RS_RVid; |
|
|
3249 | break; |
|
|
3250 | } |
|
|
3251 | if (rendset != -1) { |
|
|
3252 | rxvt_scr_rendition(aR_ rendset, rendstyle); |
|
|
3253 | continue; /* for(;i;) */ |
|
|
3254 | } |
|
|
3255 | |
4047 | |
3256 | switch (arg[i]) { |
4048 | cursor_type = (style - 1) / 2; |
3257 | case 30: |
4049 | set_option (Opt_cursorUnderline, cursor_type == 1); |
3258 | case 31: /* set fg color */ |
|
|
3259 | case 32: |
|
|
3260 | case 33: |
|
|
3261 | case 34: |
|
|
3262 | case 35: |
|
|
3263 | case 36: |
|
|
3264 | case 37: |
|
|
3265 | rxvt_scr_color(aR_ (unsigned int)(minCOLOR + (arg[i] - 30)), |
|
|
3266 | Color_fg); |
|
|
3267 | break; |
|
|
3268 | #ifdef TTY_256COLOR |
|
|
3269 | case 38: |
|
|
3270 | if (nargs > i + 2 && arg[i + 1] == 5) { |
|
|
3271 | rxvt_scr_color(aR_ (unsigned int)(minCOLOR + arg[i + 2]), |
|
|
3272 | Color_fg); |
|
|
3273 | i += 2; |
|
|
3274 | } |
|
|
3275 | break; |
|
|
3276 | #endif |
|
|
3277 | case 39: /* default fg */ |
|
|
3278 | rxvt_scr_color(aR_ Color_fg, Color_fg); |
|
|
3279 | break; |
|
|
3280 | |
4050 | |
3281 | case 40: |
4051 | #ifdef CURSOR_BLINK |
3282 | case 41: /* set bg color */ |
4052 | set_option (Opt_cursorBlink, style & 1); |
3283 | case 42: |
4053 | cursor_blink_reset (); |
3284 | case 43: |
|
|
3285 | case 44: |
|
|
3286 | case 45: |
|
|
3287 | case 46: |
|
|
3288 | case 47: |
|
|
3289 | rxvt_scr_color(aR_ (unsigned int)(minCOLOR + (arg[i] - 40)), |
|
|
3290 | Color_bg); |
|
|
3291 | break; |
|
|
3292 | #ifdef TTY_256COLOR |
|
|
3293 | case 48: |
|
|
3294 | if (nargs > i + 2 && arg[i + 1] == 5) { |
|
|
3295 | rxvt_scr_color(aR_ (unsigned int)(minCOLOR + arg[i + 2]), |
|
|
3296 | Color_bg); |
|
|
3297 | i += 2; |
|
|
3298 | } |
|
|
3299 | break; |
|
|
3300 | #endif |
4054 | #endif |
3301 | case 49: /* default bg */ |
|
|
3302 | rxvt_scr_color(aR_ Color_bg, Color_bg); |
|
|
3303 | break; |
|
|
3304 | |
4055 | |
3305 | #ifndef NO_BRIGHTCOLOR |
4056 | want_refresh = 1; |
3306 | case 90: |
|
|
3307 | case 91: /* set bright fg color */ |
|
|
3308 | case 92: |
|
|
3309 | case 93: |
|
|
3310 | case 94: |
|
|
3311 | case 95: |
|
|
3312 | case 96: |
|
|
3313 | case 97: |
|
|
3314 | rxvt_scr_color(aR_ (unsigned int)(minBrightCOLOR + (arg[i] - 90)), |
|
|
3315 | Color_fg); |
|
|
3316 | break; |
|
|
3317 | case 100: |
|
|
3318 | case 101: /* set bright bg color */ |
|
|
3319 | case 102: |
|
|
3320 | case 103: |
|
|
3321 | case 104: |
|
|
3322 | case 105: |
|
|
3323 | case 106: |
|
|
3324 | case 107: |
|
|
3325 | rxvt_scr_color(aR_ (unsigned int)(minBrightCOLOR + (arg[i] - 100)), |
|
|
3326 | Color_bg); |
|
|
3327 | break; |
|
|
3328 | #endif |
|
|
3329 | } |
|
|
3330 | } |
|
|
3331 | } |
4057 | } |
3332 | /*}}} */ |
4058 | /*}}} */ |
3333 | |
4059 | |
3334 | /*{{{ process Rob Nation's own graphics mode sequences */ |
|
|
3335 | /* INTPROTO */ |
|
|
3336 | void |
|
|
3337 | rxvt_process_graphics(pR) |
|
|
3338 | { |
|
|
3339 | unsigned char ch, cmd = rxvt_cmd_getc(aR); |
|
|
3340 | |
|
|
3341 | #ifndef RXVT_GRAPHICS |
|
|
3342 | if (cmd == 'Q') { /* query graphics */ |
|
|
3343 | R->tt_printf("\033G0\n"); /* no graphics */ |
|
|
3344 | return; |
|
|
3345 | } |
|
|
3346 | /* swallow other graphics sequences until terminating ':' */ |
|
|
3347 | do |
|
|
3348 | ch = rxvt_cmd_getc(aR); |
|
|
3349 | while (ch != ':'); |
|
|
3350 | #else |
|
|
3351 | unsigned int nargs; |
|
|
3352 | int args[NGRX_PTS]; |
|
|
3353 | unsigned char *text = NULL; |
|
|
3354 | |
|
|
3355 | if (cmd == 'Q') { /* query graphics */ |
|
|
3356 | R->tt_printf("\033G1\n"); /* yes, graphics (color) */ |
|
|
3357 | return; |
|
|
3358 | } |
|
|
3359 | for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1;) { |
|
|
3360 | int neg; |
|
|
3361 | |
|
|
3362 | ch = rxvt_cmd_getc(aR); |
|
|
3363 | neg = (ch == '-'); |
|
|
3364 | if (neg || ch == '+') |
|
|
3365 | ch = rxvt_cmd_getc(aR); |
|
|
3366 | |
|
|
3367 | for (args[nargs] = 0; isdigit(ch); ch = rxvt_cmd_getc(aR)) |
|
|
3368 | args[nargs] = args[nargs] * 10 + (ch - '0'); |
|
|
3369 | if (neg) |
|
|
3370 | args[nargs] = -args[nargs]; |
|
|
3371 | |
|
|
3372 | nargs++; |
|
|
3373 | args[nargs] = 0; |
|
|
3374 | if (ch != ';') |
|
|
3375 | break; |
|
|
3376 | } |
|
|
3377 | |
|
|
3378 | if ((cmd == 'T') && (nargs >= 5)) { |
|
|
3379 | int i, len = args[4]; |
|
|
3380 | |
|
|
3381 | text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char)); |
|
|
3382 | |
|
|
3383 | if (text != NULL) { |
|
|
3384 | for (i = 0; i < len; i++) |
|
|
3385 | text[i] = rxvt_cmd_getc(aR); |
|
|
3386 | text[len] = '\0'; |
|
|
3387 | } |
|
|
3388 | } |
|
|
3389 | rxvt_Gr_do_graphics(aR_ cmd, nargs, args, text); |
|
|
3390 | #endif |
|
|
3391 | } |
|
|
3392 | /*}}} */ |
|
|
3393 | |
|
|
3394 | /* ------------------------------------------------------------------------- */ |
4060 | /* ---------------------------------------------------------------------- */ |
|
|
4061 | /* Write data to the pty as typed by the user, pasted with the mouse, |
|
|
4062 | * or generated by us in response to a query ESC sequence. |
|
|
4063 | */ |
3395 | |
4064 | |
3396 | /* |
4065 | /* |
3397 | * Send printf() formatted output to the command. |
4066 | * Send printf () formatted output to the command. |
3398 | * Only use for small amounts of data. |
4067 | * Only use for small amounts of data. |
3399 | */ |
4068 | */ |
3400 | void |
4069 | void |
3401 | rxvt_term::tt_printf (const char *fmt,...) |
4070 | rxvt_term::tt_printf (const char *fmt,...) |
3402 | { |
4071 | { |
3403 | va_list arg_ptr; |
4072 | va_list arg_ptr; |
3404 | unsigned char buf[256]; |
4073 | char buf[256]; |
3405 | |
4074 | |
3406 | va_start (arg_ptr, fmt); |
4075 | va_start (arg_ptr, fmt); |
3407 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4076 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
3408 | va_end (arg_ptr); |
4077 | va_end (arg_ptr); |
3409 | tt_write (buf, STRLEN (buf)); |
4078 | tt_write (buf, strlen (buf)); |
3410 | } |
4079 | } |
3411 | |
4080 | |
3412 | /* ---------------------------------------------------------------------- */ |
|
|
3413 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4081 | /* Write data to the pty as typed by the user. */ |
3414 | * or generated by us in response to a query ESC sequence. |
|
|
3415 | */ |
|
|
3416 | void |
4082 | void |
3417 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4083 | rxvt_term::tt_write_user_input (const char *data, unsigned int len) |
3418 | { |
4084 | { |
3419 | enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT |
4085 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4086 | return; |
3420 | |
4087 | |
3421 | if (len) |
4088 | if (option (Opt_scrollTtyKeypress)) |
|
|
4089 | if (view_start) |
3422 | { |
4090 | { |
|
|
4091 | view_start = 0; |
|
|
4092 | want_refresh = 1; |
|
|
4093 | } |
|
|
4094 | |
|
|
4095 | tt_write_ (data, len); |
|
|
4096 | } |
|
|
4097 | |
|
|
4098 | void |
|
|
4099 | rxvt_term::tt_write (const char *data, unsigned int len) |
|
|
4100 | { |
|
|
4101 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4102 | return; |
|
|
4103 | |
|
|
4104 | tt_write_ (data, len); |
|
|
4105 | } |
|
|
4106 | |
|
|
4107 | static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4108 | |
|
|
4109 | void |
|
|
4110 | rxvt_term::tt_write_ (const char *data, unsigned int len) |
|
|
4111 | { |
|
|
4112 | if (pty->pty < 0) |
|
|
4113 | return; |
|
|
4114 | |
|
|
4115 | if (v_buflen == 0) |
|
|
4116 | { |
|
|
4117 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4118 | |
|
|
4119 | max_it (written, 0); |
|
|
4120 | |
|
|
4121 | if (written == len) |
|
|
4122 | return; |
|
|
4123 | |
|
|
4124 | data += written; |
|
|
4125 | len -= written; |
|
|
4126 | } |
|
|
4127 | |
|
|
4128 | v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len); |
|
|
4129 | |
|
|
4130 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4131 | v_buflen += len; |
|
|
4132 | |
|
|
4133 | pty_ev.set (ev::READ | ev::WRITE); |
|
|
4134 | } |
|
|
4135 | |
|
|
4136 | void rxvt_term::pty_write () |
|
|
4137 | { |
|
|
4138 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4139 | |
|
|
4140 | if (written > 0) |
|
|
4141 | { |
|
|
4142 | v_buflen -= written; |
|
|
4143 | |
3423 | if (v_buflen == 0) |
4144 | if (v_buflen == 0) |
3424 | { |
4145 | { |
3425 | int written = write (cmd_fd, data, min (MAX_PTY_WRITE, len)); |
|
|
3426 | if (written == len) |
|
|
3427 | return; |
|
|
3428 | |
|
|
3429 | data += written; |
|
|
3430 | len -= written; |
|
|
3431 | } |
|
|
3432 | |
|
|
3433 | |
|
|
3434 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
3435 | |
|
|
3436 | memcpy (v_buffer + v_buflen, data, len); |
|
|
3437 | v_buflen += len; |
|
|
3438 | } |
|
|
3439 | |
|
|
3440 | for (;;) |
|
|
3441 | { |
|
|
3442 | int written = write (cmd_fd, v_buffer, min (MAX_PTY_WRITE, v_buflen)); |
|
|
3443 | |
|
|
3444 | if (written > 0) |
|
|
3445 | { |
|
|
3446 | v_buflen -= written; |
|
|
3447 | |
|
|
3448 | if (v_buflen == 0) |
|
|
3449 | { |
|
|
3450 | free (v_buffer); |
4146 | free (v_buffer); |
3451 | v_buffer = 0; |
4147 | v_buffer = 0; |
3452 | v_buflen = 0; |
|
|
3453 | |
4148 | |
3454 | pty_ev.set (EVENT_READ); |
4149 | pty_ev.set (ev::READ); |
3455 | return; |
|
|
3456 | } |
|
|
3457 | |
|
|
3458 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
3459 | } |
|
|
3460 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
3461 | // original code just ignores this... |
|
|
3462 | destroy (); |
|
|
3463 | else |
|
|
3464 | { |
|
|
3465 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
3466 | return; |
4150 | return; |
3467 | } |
4151 | } |
|
|
4152 | |
|
|
4153 | memmove (v_buffer, v_buffer + written, v_buflen); |
3468 | } |
4154 | } |
|
|
4155 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4156 | pty_ev.set (ev::READ); |
3469 | } |
4157 | } |
3470 | |
4158 | |
3471 | /*----------------------- end-of-file (C source) -----------------------*/ |
4159 | /*----------------------- end-of-file (C source) -----------------------*/ |
3472 | |
4160 | |