1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * 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> |
… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
|
|
31 | * Copyright (c) 2007 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 2 of the License, or |
35 | * (at your option) any later version. |
36 | * (at your option) any later version. |
… | |
… | |
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 | |
53 | #ifdef KEYSYM_RESOURCE |
55 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
56 | # include "keyboard.h" |
55 | #endif |
57 | #endif |
56 | |
58 | |
57 | #include <csignal> |
59 | #include <csignal> |
58 | |
60 | |
|
|
61 | #if LINUX_YIELD_HACK |
|
|
62 | # include <ctime> |
|
|
63 | #endif |
|
|
64 | |
59 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
60 | |
66 | |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | |
|
|
63 | // exception thrown when the command parser runs out of input data |
|
|
64 | class out_of_input { } out_of_input; |
|
|
65 | |
68 | |
66 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
67 | |
70 | |
68 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
69 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
93 | XK_Shift_L, 0x21e7, |
96 | XK_Shift_L, 0x21e7, |
94 | XK_Shift_R, 0x21e7, |
97 | XK_Shift_R, 0x21e7, |
95 | |
98 | |
96 | XK_Shift_Lock, 0x21eb, |
99 | XK_Shift_Lock, 0x21eb, |
97 | XK_ISO_Lock, 0x21eb, |
100 | XK_ISO_Lock, 0x21eb, |
98 | XK_ISO_Lock, 0x21eb, |
|
|
99 | XK_Caps_Lock, 0x21ec, |
101 | XK_Caps_Lock, 0x21ec, |
100 | XK_Num_Lock, 0x21ed, |
102 | XK_Num_Lock, 0x21ed, |
101 | XK_ISO_Level3_Shift, 0x21ee, |
103 | XK_ISO_Level3_Shift, 0x21ee, |
102 | XK_ISO_Level3_Lock, 0x21ef, |
104 | XK_ISO_Level3_Lock, 0x21ef, |
103 | XK_ISO_Group_Lock, 0x21f0, |
105 | XK_ISO_Group_Lock, 0x21f0, |
… | |
… | |
141 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | return; |
144 | return; |
143 | |
145 | |
144 | for (;;) |
146 | for (;;) |
145 | { |
147 | { |
146 | const line_t &l = ROW(-view_start); |
148 | const line_t &l = ROW(y + view_start); |
147 | |
149 | |
148 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
149 | |
151 | |
150 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
151 | { |
153 | { |
152 | iso14755_51 (l.t[x], l.r[x]); |
154 | iso14755_51 (l.t[x], l.r[x], x, y); |
153 | iso14755buf = ISO_14755_54; |
155 | iso14755buf = ISO_14755_54; |
154 | break; |
156 | break; |
155 | } |
157 | } |
156 | |
158 | |
157 | x--; |
159 | x--; |
158 | } |
160 | } |
159 | } |
161 | } |
160 | #endif |
|
|
161 | |
162 | |
162 | #if ENABLE_OVERLAY |
|
|
163 | void |
163 | void |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
165 | { |
165 | { |
166 | rxvt_fontset *fs = FONTSET (r); |
166 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
169 | int len; |
170 | |
170 | |
171 | fname = rxvt_utf8towcs (f->name); |
171 | fname = rxvt_utf8towcs (f->name); |
172 | |
172 | |
173 | #if ENABLE_COMBINING |
173 | # if ENABLE_COMBINING |
174 | if (IS_COMPOSE (ch)) |
174 | if (IS_COMPOSE (ch)) |
175 | { |
175 | { |
176 | len = rxvt_composite.expand (ch, 0); |
176 | len = rxvt_composite.expand (ch, 0); |
177 | alloc = chr = new wchar_t[len]; |
177 | alloc = chr = new wchar_t[len]; |
178 | rxvt_composite.expand (ch, chr); |
178 | rxvt_composite.expand (ch, chr); |
179 | } |
179 | } |
180 | else |
180 | else |
181 | #endif |
181 | # endif |
182 | { |
182 | { |
183 | ch2 = ch; |
183 | ch2 = ch; |
184 | |
184 | |
185 | alloc = 0; |
185 | alloc = 0; |
186 | chr = &ch2; |
186 | chr = &ch2; |
187 | len = 1; |
187 | len = 1; |
188 | } |
188 | } |
189 | |
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 | |
190 | int width = wcswidth (fname, wcslen (fname)); |
202 | int width = wcswidth (fname, wcslen (fname)); |
191 | |
203 | |
192 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
204 | max_it (width, 8+5); // for char + hex |
|
|
205 | max_it (width, strlen (attr)); |
|
|
206 | |
|
|
207 | if (y >= 0) |
|
|
208 | { |
|
|
209 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
|
|
210 | x = 0; |
|
|
211 | } |
|
|
212 | |
|
|
213 | scr_overlay_new (x, y, width, len + 2); |
193 | |
214 | |
194 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
215 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
195 | |
216 | |
196 | for (int y = 0; y < len; y++) |
217 | for (int y = 0; y < len; y++) |
197 | { |
218 | { |
… | |
… | |
200 | ch = *chr++; |
221 | ch = *chr++; |
201 | |
222 | |
202 | sprintf (buf, "%8x", ch); |
223 | sprintf (buf, "%8x", ch); |
203 | scr_overlay_set (0, y, buf); |
224 | scr_overlay_set (0, y, buf); |
204 | scr_overlay_set (9, y, '='); |
225 | scr_overlay_set (9, y, '='); |
205 | #if !UNICODE3 |
226 | # if !UNICODE_3 |
206 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
207 | ch = 0xfffd; |
228 | ch = 0xfffd; |
208 | #endif |
229 | # endif |
209 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
210 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
211 | } |
234 | } |
212 | |
235 | |
|
|
236 | // { |
|
|
237 | // char buf[4+4+3+1]; |
|
|
238 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
239 | // scr_overlay_set (0, 0, buf); |
|
|
240 | // } |
|
|
241 | scr_overlay_set (0, len , attr); |
213 | scr_overlay_set (0, len, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
214 | |
243 | |
215 | free (fname); |
244 | free (fname); |
216 | |
245 | |
217 | #if ENABLE_COMBINING |
246 | # if ENABLE_COMBINING |
218 | if (alloc) |
247 | if (alloc) |
219 | delete [] alloc; |
248 | delete [] alloc; |
220 | #endif |
249 | # endif |
221 | } |
250 | } |
222 | #endif |
251 | #endif |
223 | |
252 | |
224 | void |
253 | void |
225 | rxvt_term::commit_iso14755 () |
254 | rxvt_term::commit_iso14755 () |
… | |
… | |
242 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
243 | len = 1; |
272 | len = 1; |
244 | } |
273 | } |
245 | |
274 | |
246 | if (len > 0) |
275 | if (len > 0) |
247 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
248 | else |
277 | else |
249 | scr_bell (); |
278 | scr_bell (); |
250 | } |
279 | } |
251 | |
280 | |
252 | iso14755buf = 0; |
281 | iso14755buf = 0; |
253 | } |
282 | } |
254 | |
283 | |
255 | int |
284 | static int |
256 | rxvt_term::hex_keyval (XKeyEvent &ev) |
285 | hex_keyval (XKeyEvent &ev) |
257 | { |
286 | { |
258 | // check wether this event corresponds to a hex digit |
287 | // check wether this event corresponds to a hex digit |
259 | // if the modifiers had not been pressed. |
288 | // if the modifiers had not been pressed. |
260 | for (int index = 0; index < 8; index++) |
289 | for (int index = 0; index < 8; index++) |
261 | { |
290 | { |
… | |
… | |
269 | |
298 | |
270 | return -1; |
299 | return -1; |
271 | } |
300 | } |
272 | #endif |
301 | #endif |
273 | |
302 | |
274 | /*{{{ Convert the keypress event into a string */ |
303 | static inline KeySym |
|
|
304 | translate_keypad (KeySym keysym, bool kp) |
|
|
305 | { |
|
|
306 | #ifdef XK_KP_Home |
|
|
307 | static const KeySym keypadtrans[] = { |
|
|
308 | XK_KP_7, // XK_KP_Home |
|
|
309 | XK_KP_4, // XK_KP_Left |
|
|
310 | XK_KP_8, // XK_KP_Up |
|
|
311 | XK_KP_6, // XK_KP_Right |
|
|
312 | XK_KP_2, // XK_KP_Down |
|
|
313 | # ifndef UNSHIFTED_SCROLLKEYS |
|
|
314 | XK_KP_9, // XK_KP_Prior |
|
|
315 | XK_KP_3, // XK_KP_Next |
|
|
316 | # else |
|
|
317 | XK_Prior, |
|
|
318 | XK_Next, |
|
|
319 | # endif |
|
|
320 | XK_KP_1, // XK_KP_End |
|
|
321 | XK_KP_5, // XK_KP_Begin |
|
|
322 | }; |
|
|
323 | |
|
|
324 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
325 | { |
|
|
326 | unsigned int index = keysym - XK_KP_Home; |
|
|
327 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
328 | } |
|
|
329 | else if (keysym == XK_KP_Insert) |
|
|
330 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
331 | # ifndef NO_DELETE_KEY |
|
|
332 | else if (keysym == XK_KP_Delete) |
|
|
333 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
334 | # endif |
|
|
335 | #endif |
|
|
336 | return keysym; |
|
|
337 | } |
|
|
338 | |
|
|
339 | static inline int |
|
|
340 | map_function_key (KeySym keysym) |
|
|
341 | { |
|
|
342 | int param = 0; |
|
|
343 | |
|
|
344 | if (IN_RANGE_INC (keysym, XK_F1, XK_F35)) |
|
|
345 | { |
|
|
346 | param = 11 + keysym - XK_F1; |
|
|
347 | if (keysym >= XK_F17) |
|
|
348 | param += 4; |
|
|
349 | else if (keysym >= XK_F15) |
|
|
350 | param += 3; |
|
|
351 | else if (keysym >= XK_F11) |
|
|
352 | param += 2; |
|
|
353 | else if (keysym >= XK_F6) |
|
|
354 | param += 1; |
|
|
355 | } |
|
|
356 | else |
|
|
357 | switch (keysym) |
|
|
358 | { |
|
|
359 | case XK_Find: |
|
|
360 | param = 1; |
|
|
361 | break; |
|
|
362 | case XK_Insert: |
|
|
363 | param = 2; |
|
|
364 | break; |
|
|
365 | #ifdef DXK_Remove |
|
|
366 | case DXK_Remove: |
|
|
367 | #endif |
|
|
368 | case XK_Execute: |
|
|
369 | param = 3; |
|
|
370 | break; |
|
|
371 | case XK_Select: |
|
|
372 | param = 4; |
|
|
373 | break; |
|
|
374 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
375 | case XK_Prior: |
|
|
376 | param = 5; |
|
|
377 | break; |
|
|
378 | case XK_Next: |
|
|
379 | param = 6; |
|
|
380 | break; |
|
|
381 | case XK_Home: |
|
|
382 | param = 7; |
|
|
383 | break; |
|
|
384 | case XK_End: |
|
|
385 | param = 8; |
|
|
386 | break; |
|
|
387 | #endif |
|
|
388 | case XK_Help: |
|
|
389 | param = 28; |
|
|
390 | break; |
|
|
391 | case XK_Menu: |
|
|
392 | param = 29; |
|
|
393 | break; |
|
|
394 | } |
|
|
395 | return param; |
|
|
396 | } |
|
|
397 | |
275 | void |
398 | void |
276 | rxvt_term::lookup_key (XKeyEvent &ev) |
399 | rxvt_term::key_press (XKeyEvent &ev) |
277 | { |
400 | { |
278 | int ctrl, meta, shft, len; |
401 | int ctrl, meta, shft, len; |
279 | unsigned int newlen; |
|
|
280 | KeySym keysym; |
402 | KeySym keysym; |
281 | #ifdef DEBUG_CMD |
|
|
282 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
283 | #endif |
|
|
284 | int valid_keysym; |
403 | int valid_keysym; |
285 | unsigned char kbuf[KBUFSZ]; |
404 | char kbuf[KBUFSZ]; |
|
|
405 | |
|
|
406 | #if ISO_14755 |
|
|
407 | if (iso14755buf & ISO_14755_52) |
|
|
408 | return; |
|
|
409 | #endif |
286 | |
410 | |
287 | /* |
411 | /* |
288 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
412 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
289 | * escape sequence to toggle the Keypad. |
413 | * escape sequence to toggle the Keypad. |
290 | * |
414 | * |
… | |
… | |
295 | meta = ev.state & ModMetaMask; |
419 | meta = ev.state & ModMetaMask; |
296 | |
420 | |
297 | if (numlock_state || (ev.state & ModNumLockMask)) |
421 | if (numlock_state || (ev.state & ModNumLockMask)) |
298 | { |
422 | { |
299 | numlock_state = (ev.state & ModNumLockMask); |
423 | numlock_state = (ev.state & ModNumLockMask); |
300 | PrivMode ((!numlock_state), PrivMode_aplKP); |
424 | set_privmode (PrivMode_aplKP, !numlock_state); |
301 | } |
425 | } |
302 | |
426 | |
303 | kbuf[0] = 0; |
427 | kbuf[0] = 0; |
304 | |
428 | |
305 | #ifdef USE_XIM |
429 | #ifdef USE_XIM |
… | |
… | |
308 | Status status_return; |
432 | Status status_return; |
309 | |
433 | |
310 | #if 0 |
434 | #if 0 |
311 | #ifdef X_HAVE_UTF8_STRING |
435 | #ifdef X_HAVE_UTF8_STRING |
312 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
436 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
313 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
437 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
314 | KBUFSZ, &keysym, &status_return); |
438 | KBUFSZ, &keysym, &status_return); |
315 | else |
439 | else |
316 | #endif |
440 | #endif |
317 | #endif |
441 | #endif |
318 | { |
442 | { |
… | |
… | |
355 | || status_return == XLookupBoth; |
479 | || status_return == XLookupBoth; |
356 | } |
480 | } |
357 | else |
481 | else |
358 | #endif |
482 | #endif |
359 | { |
483 | { |
360 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
484 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
361 | valid_keysym = keysym != NoSymbol; |
485 | valid_keysym = keysym != NoSymbol; |
362 | } |
486 | } |
363 | |
487 | |
364 | if (valid_keysym) |
488 | if (valid_keysym) |
365 | { |
489 | { |
… | |
… | |
417 | scr_move_to (0, 1); |
541 | scr_move_to (0, 1); |
418 | return; |
542 | return; |
419 | } |
543 | } |
420 | else if (keysym == XK_End) |
544 | else if (keysym == XK_End) |
421 | { |
545 | { |
422 | scr_move_to (1, 0); |
546 | scr_move_to (1, 1); |
423 | return; |
547 | return; |
424 | } |
548 | } |
425 | } |
549 | } |
426 | #endif |
550 | #endif |
427 | } |
551 | } |
… | |
… | |
438 | { |
562 | { |
439 | switch (keysym) |
563 | switch (keysym) |
440 | { |
564 | { |
441 | /* normal XTerm key bindings */ |
565 | /* normal XTerm key bindings */ |
442 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
566 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
443 | selection_request (ev.time, 0, 0); |
567 | selection_request (ev.time); |
444 | return; |
568 | return; |
445 | #if TODO |
569 | #if TODO |
446 | /* rxvt extras */ |
570 | /* rxvt extras */ |
447 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
571 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
448 | change_font (FONT_UP); |
572 | change_font (FONT_UP); |
… | |
… | |
467 | { |
591 | { |
468 | commit_iso14755 (); |
592 | commit_iso14755 (); |
469 | iso14755buf = ISO_14755_51; |
593 | iso14755buf = ISO_14755_51; |
470 | # if ISO_14755 |
594 | # if ISO_14755 |
471 | iso14755_51 (0); |
595 | iso14755_51 (0); |
|
|
596 | # endif |
|
|
597 | return; |
|
|
598 | } |
|
|
599 | else if (keysym == XK_BackSpace) |
|
|
600 | { |
|
|
601 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
602 | # if ISO_14755 |
|
|
603 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
472 | # endif |
604 | # endif |
473 | return; |
605 | return; |
474 | } |
606 | } |
475 | else if ((hv = hex_keyval (ev)) >= 0) |
607 | else if ((hv = hex_keyval (ev)) >= 0) |
476 | { |
608 | { |
… | |
… | |
481 | # endif |
613 | # endif |
482 | return; |
614 | return; |
483 | } |
615 | } |
484 | else |
616 | else |
485 | { |
617 | { |
486 | # if ENABLE_OVERLAY |
618 | # if ISO_14755 |
487 | scr_overlay_off (); |
619 | scr_overlay_off (); |
488 | # endif |
620 | # endif |
489 | iso14755buf = 0; |
621 | iso14755buf = 0; |
490 | } |
622 | } |
491 | } |
623 | } |
492 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
624 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
493 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
625 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
494 | if (!(iso14755buf & ISO_14755_STARTED)) |
626 | if (!(iso14755buf & ISO_14755_STARTED)) |
495 | { |
627 | { |
496 | iso14755buf |= ISO_14755_STARTED; |
628 | iso14755buf |= ISO_14755_STARTED; |
497 | # if ENABLE_OVERLAY |
629 | # if ISO_14755 |
498 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
630 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
499 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
631 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
500 | # endif |
632 | # endif |
501 | } |
633 | } |
502 | #endif |
634 | #endif |
503 | |
635 | |
504 | #ifdef PRINTPIPE |
636 | #ifdef PRINTPIPE |
505 | if (keysym == XK_Print) |
637 | if (keysym == XK_Print) |
506 | { |
638 | { |
507 | scr_printscreen (ctrl | shft); |
639 | scr_printscreen (ctrl | shft); |
508 | return; |
640 | return; |
509 | } |
641 | } |
510 | #endif |
642 | #endif |
511 | |
643 | |
512 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
644 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
513 | { |
645 | { |
|
|
646 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
|
|
647 | unsigned int newlen = 1; |
|
|
648 | |
|
|
649 | switch (translate_keypad (keysym, kp)) |
514 | { |
650 | { |
|
|
651 | #ifndef NO_BACKSPACE_KEY |
|
|
652 | case XK_BackSpace: |
|
|
653 | if (priv_modes & PrivMode_HaveBackSpace) |
|
|
654 | { |
|
|
655 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
656 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
657 | kbuf[1] = '\0'; |
|
|
658 | } |
|
|
659 | else |
|
|
660 | strcpy (kbuf, rs[Rs_backspace_key]); |
|
|
661 | break; |
|
|
662 | #endif |
|
|
663 | #ifndef NO_DELETE_KEY |
|
|
664 | case XK_Delete: |
|
|
665 | strcpy (kbuf, rs[Rs_delete_key]); |
|
|
666 | break; |
|
|
667 | #endif |
|
|
668 | case XK_Tab: |
|
|
669 | if (shft) |
|
|
670 | strcpy (kbuf, "\033[Z"); |
|
|
671 | else |
|
|
672 | { |
|
|
673 | #ifdef CTRL_TAB_MAKES_META |
|
|
674 | if (ctrl) |
|
|
675 | meta = 1; |
|
|
676 | #endif |
|
|
677 | #ifdef MOD4_TAB_MAKES_META |
|
|
678 | if (ev.state & Mod4Mask) |
|
|
679 | meta = 1; |
|
|
680 | #endif |
515 | newlen = 1; |
681 | newlen = 0; |
516 | switch (keysym) |
682 | } |
|
|
683 | break; |
|
|
684 | |
|
|
685 | case XK_Up: /* "\033[A" */ |
|
|
686 | case XK_Down: /* "\033[B" */ |
|
|
687 | case XK_Right: /* "\033[C" */ |
|
|
688 | case XK_Left: /* "\033[D" */ |
|
|
689 | strcpy (kbuf, "\033[Z"); |
|
|
690 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
691 | /* do Shift first */ |
|
|
692 | if (shft) |
|
|
693 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
694 | else if (ctrl) |
|
|
695 | { |
|
|
696 | kbuf[1] = 'O'; |
|
|
697 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
698 | } |
|
|
699 | else if (priv_modes & PrivMode_aplCUR) |
|
|
700 | kbuf[1] = 'O'; |
|
|
701 | break; |
|
|
702 | |
|
|
703 | case XK_KP_Enter: |
|
|
704 | /* allow shift to override */ |
|
|
705 | if (kp) |
|
|
706 | { |
|
|
707 | strcpy (kbuf, "\033OM"); |
|
|
708 | break; |
|
|
709 | } |
|
|
710 | |
|
|
711 | /* FALLTHROUGH */ |
|
|
712 | |
|
|
713 | case XK_Return: |
|
|
714 | if (priv_modes & PrivMode_LFNL) |
|
|
715 | { |
|
|
716 | kbuf[0] = '\015'; |
|
|
717 | kbuf[1] = '\012'; |
|
|
718 | kbuf[2] = '\0'; |
|
|
719 | } |
|
|
720 | else |
|
|
721 | { |
|
|
722 | kbuf[0] = '\015'; |
|
|
723 | kbuf[1] = '\0'; |
|
|
724 | } |
|
|
725 | break; |
|
|
726 | |
|
|
727 | case XK_KP_F1: /* "\033OP" */ |
|
|
728 | case XK_KP_F2: /* "\033OQ" */ |
|
|
729 | case XK_KP_F3: /* "\033OR" */ |
|
|
730 | case XK_KP_F4: /* "\033OS" */ |
|
|
731 | strcpy (kbuf, "\033OP"); |
|
|
732 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
733 | break; |
|
|
734 | |
|
|
735 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
736 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
737 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
738 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
739 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
740 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
741 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
742 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
743 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
744 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
745 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
746 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
747 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
748 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
749 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
750 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
751 | /* allow shift to override */ |
|
|
752 | if (kp) |
|
|
753 | { |
|
|
754 | strcpy (kbuf, "\033Oj"); |
|
|
755 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
756 | } |
|
|
757 | else |
|
|
758 | { |
|
|
759 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
760 | kbuf[1] = '\0'; |
|
|
761 | } |
|
|
762 | break; |
|
|
763 | |
|
|
764 | default: |
517 | { |
765 | { |
518 | #ifndef NO_BACKSPACE_KEY |
766 | int param = map_function_key (keysym); |
519 | case XK_BackSpace: |
767 | if (param > 0) |
520 | if (priv_modes & PrivMode_HaveBackSpace) |
768 | sprintf (kbuf,"\033[%d~", param); |
521 | { |
|
|
522 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
523 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
524 | kbuf[1] = '\0'; |
|
|
525 | } |
|
|
526 | else |
769 | else |
527 | strcpy (kbuf, key_backspace); |
|
|
528 | break; |
|
|
529 | #endif |
|
|
530 | #ifndef NO_DELETE_KEY |
|
|
531 | # ifdef XK_KP_Prior |
|
|
532 | case XK_KP_Delete: |
|
|
533 | /* allow shift to override */ |
|
|
534 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
535 | { |
|
|
536 | strcpy (kbuf, "\033On"); |
|
|
537 | break; |
|
|
538 | } |
|
|
539 | /* FALLTHROUGH */ |
|
|
540 | # endif |
|
|
541 | case XK_Delete: |
|
|
542 | strcpy (kbuf, key_delete); |
|
|
543 | break; |
|
|
544 | #endif |
|
|
545 | case XK_Tab: |
|
|
546 | if (shft) |
|
|
547 | strcpy (kbuf, "\033[Z"); |
|
|
548 | else |
|
|
549 | { |
|
|
550 | #ifdef CTRL_TAB_MAKES_META |
|
|
551 | if (ctrl) |
|
|
552 | meta = 1; |
|
|
553 | #endif |
|
|
554 | #ifdef MOD4_TAB_MAKES_META |
|
|
555 | if (ev.state & Mod4Mask) |
|
|
556 | meta = 1; |
|
|
557 | #endif |
|
|
558 | newlen = 0; |
|
|
559 | } |
|
|
560 | break; |
|
|
561 | |
|
|
562 | #ifdef XK_KP_Left |
|
|
563 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
564 | case XK_KP_Down: /* \033Or or standard */ |
|
|
565 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
566 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
567 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
568 | { |
|
|
569 | strcpy (kbuf, "\033OZ"); |
|
|
570 | kbuf[2] = "txvr"[keysym - XK_KP_Left]; |
|
|
571 | break; |
|
|
572 | } |
|
|
573 | else |
|
|
574 | /* translate to std. cursor key */ |
|
|
575 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
576 | /* FALLTHROUGH */ |
|
|
577 | #endif |
|
|
578 | case XK_Up: /* "\033[A" */ |
|
|
579 | case XK_Down: /* "\033[B" */ |
|
|
580 | case XK_Right: /* "\033[C" */ |
|
|
581 | case XK_Left: /* "\033[D" */ |
|
|
582 | strcpy (kbuf, "\033[Z"); |
|
|
583 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
584 | /* do Shift first */ |
|
|
585 | if (shft) |
|
|
586 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
587 | else if (ctrl) |
|
|
588 | { |
|
|
589 | kbuf[1] = 'O'; |
|
|
590 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
591 | } |
|
|
592 | else if (priv_modes & PrivMode_aplCUR) |
|
|
593 | kbuf[1] = 'O'; |
|
|
594 | break; |
|
|
595 | |
|
|
596 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
597 | # ifdef XK_KP_Prior |
|
|
598 | case XK_KP_Prior: |
|
|
599 | /* allow shift to override */ |
|
|
600 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
601 | { |
|
|
602 | strcpy (kbuf, "\033Oy"); |
|
|
603 | break; |
|
|
604 | } |
|
|
605 | /* FALLTHROUGH */ |
|
|
606 | # endif |
|
|
607 | case XK_Prior: |
|
|
608 | strcpy (kbuf, "\033[5~"); |
|
|
609 | break; |
|
|
610 | # ifdef XK_KP_Next |
|
|
611 | case XK_KP_Next: |
|
|
612 | /* allow shift to override */ |
|
|
613 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
614 | { |
|
|
615 | strcpy (kbuf, "\033Os"); |
|
|
616 | break; |
|
|
617 | } |
|
|
618 | /* FALLTHROUGH */ |
|
|
619 | # endif |
|
|
620 | case XK_Next: |
|
|
621 | strcpy (kbuf, "\033[6~"); |
|
|
622 | break; |
|
|
623 | #endif |
|
|
624 | case XK_KP_Enter: |
|
|
625 | /* allow shift to override */ |
|
|
626 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
627 | { |
|
|
628 | strcpy (kbuf, "\033OM"); |
|
|
629 | break; |
|
|
630 | } |
|
|
631 | |
|
|
632 | /* FALLTHROUGH */ |
|
|
633 | |
|
|
634 | case XK_Return: |
|
|
635 | if (priv_modes & PrivMode_LFNL) |
|
|
636 | { |
|
|
637 | kbuf[0] = '\015'; |
|
|
638 | kbuf[1] = '\012'; |
|
|
639 | kbuf[2] = '\0'; |
|
|
640 | } |
|
|
641 | else |
|
|
642 | { |
|
|
643 | kbuf[0] = '\015'; |
|
|
644 | kbuf[1] = '\0'; |
|
|
645 | } |
|
|
646 | break; |
|
|
647 | |
|
|
648 | #ifdef XK_KP_Begin |
|
|
649 | case XK_KP_Begin: |
|
|
650 | strcpy (kbuf, "\033Ou"); |
|
|
651 | break; |
|
|
652 | |
|
|
653 | #endif |
|
|
654 | case XK_KP_F1: /* "\033OP" */ |
|
|
655 | case XK_KP_F2: /* "\033OQ" */ |
|
|
656 | case XK_KP_F3: /* "\033OR" */ |
|
|
657 | case XK_KP_F4: /* "\033OS" */ |
|
|
658 | strcpy (kbuf, "\033OP"); |
|
|
659 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
660 | break; |
|
|
661 | |
|
|
662 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
663 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
664 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
665 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
666 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
667 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
668 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
669 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
670 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
671 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
672 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
673 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
674 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
675 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
676 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
677 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
678 | /* allow shift to override */ |
|
|
679 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
680 | { |
|
|
681 | strcpy (kbuf, "\033Oj"); |
|
|
682 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
683 | } |
|
|
684 | else |
|
|
685 | { |
|
|
686 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
687 | kbuf[1] = '\0'; |
|
|
688 | } |
|
|
689 | break; |
|
|
690 | |
|
|
691 | case XK_Find: |
|
|
692 | strcpy (kbuf, "\033[1~"); |
|
|
693 | break; |
|
|
694 | |
|
|
695 | #ifdef XK_KP_End |
|
|
696 | case XK_KP_Insert: |
|
|
697 | /* allow shift to override */ |
|
|
698 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
699 | { |
|
|
700 | strcpy (kbuf, "\033Op"); |
|
|
701 | break; |
|
|
702 | } |
|
|
703 | /* FALLTHROUGH */ |
|
|
704 | #endif |
|
|
705 | case XK_Insert: |
|
|
706 | strcpy (kbuf, "\033[2~"); |
|
|
707 | break; |
|
|
708 | #ifdef DXK_Remove /* support for DEC remove like key */ |
|
|
709 | case DXK_Remove: |
|
|
710 | /* FALLTHROUGH */ |
|
|
711 | #endif |
|
|
712 | case XK_Execute: |
|
|
713 | strcpy (kbuf, "\033[3~"); |
|
|
714 | break; |
|
|
715 | case XK_Select: |
|
|
716 | strcpy (kbuf, "\033[4~"); |
|
|
717 | break; |
|
|
718 | #ifdef XK_KP_End |
|
|
719 | case XK_KP_End: |
|
|
720 | /* allow shift to override */ |
|
|
721 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
722 | { |
|
|
723 | strcpy (kbuf, "\033Oq"); |
|
|
724 | break; |
|
|
725 | } |
|
|
726 | /* FALLTHROUGH */ |
|
|
727 | #endif |
|
|
728 | case XK_End: |
|
|
729 | strcpy (kbuf, KS_END); |
|
|
730 | break; |
|
|
731 | #ifdef XK_KP_Home |
|
|
732 | case XK_KP_Home: |
|
|
733 | /* allow shift to override */ |
|
|
734 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
735 | { |
|
|
736 | strcpy (kbuf, "\033Ow"); |
|
|
737 | break; |
|
|
738 | } |
|
|
739 | /* FALLTHROUGH */ |
|
|
740 | #endif |
|
|
741 | case XK_Home: |
|
|
742 | strcpy (kbuf, KS_HOME); |
|
|
743 | break; |
|
|
744 | |
|
|
745 | #define FKEY(n, fkey) \ |
|
|
746 | sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) |
|
|
747 | |
|
|
748 | case XK_F1: /* "\033[11~" */ |
|
|
749 | case XK_F2: /* "\033[12~" */ |
|
|
750 | case XK_F3: /* "\033[13~" */ |
|
|
751 | case XK_F4: /* "\033[14~" */ |
|
|
752 | case XK_F5: /* "\033[15~" */ |
|
|
753 | FKEY (11, XK_F1); |
|
|
754 | break; |
|
|
755 | case XK_F6: /* "\033[17~" */ |
|
|
756 | case XK_F7: /* "\033[18~" */ |
|
|
757 | case XK_F8: /* "\033[19~" */ |
|
|
758 | case XK_F9: /* "\033[20~" */ |
|
|
759 | case XK_F10: /* "\033[21~" */ |
|
|
760 | FKEY (17, XK_F6); |
|
|
761 | break; |
|
|
762 | case XK_F11: /* "\033[23~" */ |
|
|
763 | case XK_F12: /* "\033[24~" */ |
|
|
764 | case XK_F13: /* "\033[25~" */ |
|
|
765 | case XK_F14: /* "\033[26~" */ |
|
|
766 | FKEY (23, XK_F11); |
|
|
767 | break; |
|
|
768 | case XK_F15: /* "\033[28~" */ |
|
|
769 | case XK_F16: /* "\033[29~" */ |
|
|
770 | FKEY (28, XK_F15); |
|
|
771 | break; |
|
|
772 | case XK_Help: /* "\033[28~" */ |
|
|
773 | FKEY (28, XK_Help); |
|
|
774 | break; |
|
|
775 | case XK_Menu: /* "\033[29~" */ |
|
|
776 | FKEY (29, XK_Menu); |
|
|
777 | break; |
|
|
778 | case XK_F17: /* "\033[31~" */ |
|
|
779 | case XK_F18: /* "\033[32~" */ |
|
|
780 | case XK_F19: /* "\033[33~" */ |
|
|
781 | case XK_F20: /* "\033[34~" */ |
|
|
782 | case XK_F21: /* "\033[35~" */ |
|
|
783 | case XK_F22: /* "\033[36~" */ |
|
|
784 | case XK_F23: /* "\033[37~" */ |
|
|
785 | case XK_F24: /* "\033[38~" */ |
|
|
786 | case XK_F25: /* "\033[39~" */ |
|
|
787 | case XK_F26: /* "\033[40~" */ |
|
|
788 | case XK_F27: /* "\033[41~" */ |
|
|
789 | case XK_F28: /* "\033[42~" */ |
|
|
790 | case XK_F29: /* "\033[43~" */ |
|
|
791 | case XK_F30: /* "\033[44~" */ |
|
|
792 | case XK_F31: /* "\033[45~" */ |
|
|
793 | case XK_F32: /* "\033[46~" */ |
|
|
794 | case XK_F33: /* "\033[47~" */ |
|
|
795 | case XK_F34: /* "\033[48~" */ |
|
|
796 | case XK_F35: /* "\033[49~" */ |
|
|
797 | FKEY (31, XK_F17); |
|
|
798 | break; |
|
|
799 | #undef FKEY |
|
|
800 | default: |
|
|
801 | newlen = 0; |
770 | newlen = 0; |
802 | break; |
|
|
803 | } |
771 | } |
804 | |
772 | break; |
805 | if (newlen) |
|
|
806 | len = strlen (kbuf); |
|
|
807 | } |
773 | } |
|
|
774 | |
|
|
775 | if (newlen) |
|
|
776 | len = strlen (kbuf); |
808 | |
777 | |
809 | /* |
778 | /* |
810 | * Pass meta for all function keys, if 'meta' option set |
779 | * Pass meta for all function keys, if 'meta' option set |
811 | */ |
780 | */ |
812 | #ifdef META8_OPTION |
781 | #ifdef META8_OPTION |
… | |
… | |
829 | { |
798 | { |
830 | #ifdef META8_OPTION |
799 | #ifdef META8_OPTION |
831 | /* set 8-bit on */ |
800 | /* set 8-bit on */ |
832 | if (meta && (meta_char == 0x80)) |
801 | if (meta && (meta_char == 0x80)) |
833 | { |
802 | { |
834 | unsigned char *ch; |
803 | char *ch; |
835 | |
804 | |
836 | for (ch = kbuf; ch < kbuf + len; ch++) |
805 | for (ch = kbuf; ch < kbuf + len; ch++) |
837 | *ch |= 0x80; |
806 | *ch |= 0x80; |
838 | |
807 | |
839 | meta = 0; |
808 | meta = 0; |
… | |
… | |
841 | #endif |
810 | #endif |
842 | /* nil */ ; |
811 | /* nil */ ; |
843 | } |
812 | } |
844 | } |
813 | } |
845 | |
814 | |
|
|
815 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
816 | return; |
|
|
817 | |
846 | if (len <= 0) |
818 | if (len <= 0) |
847 | return; /* not mapped */ |
819 | return; /* not mapped */ |
848 | |
820 | |
849 | if (options & Opt_scrollTtyKeypress) |
821 | if (option (Opt_scrollTtyKeypress)) |
850 | if (view_start) |
822 | if (view_start) |
851 | { |
823 | { |
852 | view_start = 0; |
824 | view_start = 0; |
853 | want_refresh = 1; |
825 | want_refresh = 1; |
854 | } |
826 | } |
… | |
… | |
872 | #ifdef META8_OPTION |
844 | #ifdef META8_OPTION |
873 | && meta_char == C0_ESC |
845 | && meta_char == C0_ESC |
874 | #endif |
846 | #endif |
875 | ) |
847 | ) |
876 | { |
848 | { |
877 | const unsigned char ch = C0_ESC; |
849 | const char ch = C0_ESC; |
878 | tt_write (&ch, 1); |
850 | tt_write (&ch, 1); |
879 | } |
851 | } |
880 | |
852 | |
881 | #if defined(DEBUG_CMD) |
|
|
882 | /* Display keyboard buffer contents */ |
|
|
883 | unsigned char *p; |
|
|
884 | int i; |
|
|
885 | |
|
|
886 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
887 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
888 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
889 | fprintf (stderr, "'\n"); |
|
|
890 | #endif /* DEBUG_CMD */ |
|
|
891 | tt_write (kbuf, (unsigned int)len); |
853 | tt_write (kbuf, (unsigned int)len); |
892 | } |
854 | } |
893 | /*}}} */ |
|
|
894 | |
855 | |
|
|
856 | void |
|
|
857 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
858 | { |
|
|
859 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
860 | KeySym keysym; |
|
|
861 | |
|
|
862 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
863 | #endif |
|
|
864 | |
|
|
865 | #if ENABLE_FRILLS || ISO_14755 |
|
|
866 | // ISO 14755 support |
|
|
867 | if (iso14755buf) |
|
|
868 | if (iso14755buf & ISO_14755_52) |
|
|
869 | { |
|
|
870 | # if ISO_14755 |
|
|
871 | scr_overlay_off (); |
|
|
872 | # endif |
|
|
873 | # if ISO_14755 |
|
|
874 | // iso14755 part 5.2 handling: release time |
|
|
875 | // first: controls |
|
|
876 | if ((ev.state & ControlMask) |
|
|
877 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
878 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
879 | { |
|
|
880 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
881 | commit_iso14755 (); |
|
|
882 | |
|
|
883 | return; |
|
|
884 | } |
|
|
885 | |
|
|
886 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
887 | if (i[0] == keysym) |
|
|
888 | { |
|
|
889 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
890 | commit_iso14755 (); |
|
|
891 | |
|
|
892 | return; |
|
|
893 | } |
|
|
894 | |
|
|
895 | scr_bell (); |
|
|
896 | # endif |
|
|
897 | iso14755buf = 0; |
|
|
898 | |
|
|
899 | return; |
|
|
900 | } |
|
|
901 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
902 | { |
|
|
903 | # if ISO_14755 |
|
|
904 | scr_overlay_off (); |
|
|
905 | # endif |
|
|
906 | if (iso14755buf & ISO_14755_51) |
|
|
907 | commit_iso14755 (); |
|
|
908 | #if ISO_14755 |
|
|
909 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
910 | { |
|
|
911 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
912 | |
|
|
913 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
914 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
915 | } |
|
|
916 | # endif |
|
|
917 | else |
|
|
918 | iso14755buf = 0; |
|
|
919 | } |
|
|
920 | #endif |
|
|
921 | |
|
|
922 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
923 | return; |
|
|
924 | |
|
|
925 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
926 | if (!(ev.state & ControlMask)) |
|
|
927 | slip_wheel_ev.stop (); |
|
|
928 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
929 | mouse_slip_wheel_speed = 0; |
|
|
930 | #endif |
|
|
931 | } |
|
|
932 | |
895 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
933 | #if defined (KEYSYM_RESOURCE) |
896 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
897 | /* attempt to `write' count to the input buffer */ |
|
|
898 | unsigned int |
934 | unsigned int |
899 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
935 | rxvt_term::cmd_write (const char *str, unsigned int count) |
900 | { |
936 | { |
901 | unsigned int n, s; |
937 | unsigned int n, s; |
902 | |
938 | |
903 | n = cmdbuf_ptr - cmdbuf_base; |
939 | n = cmdbuf_ptr - cmdbuf_base; |
904 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
940 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
930 | void |
966 | void |
931 | rxvt_term::flush () |
967 | rxvt_term::flush () |
932 | { |
968 | { |
933 | flush_ev.stop (); |
969 | flush_ev.stop (); |
934 | |
970 | |
935 | #ifdef TRANSPARENT |
971 | #ifdef HAVE_BG_PIXMAP |
936 | if (want_full_refresh) |
972 | if (bgPixmap.check_clearChanged ()) |
937 | { |
973 | { |
938 | want_full_refresh = 0; |
974 | // scr_clear (true); This needs to be researched further! |
939 | scr_clear (); |
|
|
940 | scr_touch (false); |
975 | scr_touch (false); |
941 | } |
976 | } |
942 | #endif |
977 | #endif |
943 | |
978 | |
944 | if (want_refresh) |
979 | if (want_refresh) |
945 | { |
980 | { |
|
|
981 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
982 | { |
|
|
983 | int row = view_start; |
|
|
984 | int end_row = row + nrow; |
|
|
985 | |
|
|
986 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
987 | --row; |
|
|
988 | |
|
|
989 | do |
|
|
990 | { |
|
|
991 | int start_row = row; |
|
|
992 | line_t *l; |
|
|
993 | |
|
|
994 | do |
|
|
995 | { |
|
|
996 | l = &ROW (row++); |
|
|
997 | |
|
|
998 | if (!(l->f & LINE_FILTERED)) |
|
|
999 | { |
|
|
1000 | // line not filtered, mark it as filtered |
|
|
1001 | l->f |= LINE_FILTERED; |
|
|
1002 | while (l->is_longer ()) |
|
|
1003 | { |
|
|
1004 | l = &ROW (row++); |
|
|
1005 | l->f |= LINE_FILTERED; |
|
|
1006 | } |
|
|
1007 | |
|
|
1008 | // and filter it |
|
|
1009 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1010 | |
|
|
1011 | break; |
|
|
1012 | } |
|
|
1013 | } |
|
|
1014 | while (l->is_longer () && row < end_row); |
|
|
1015 | } |
|
|
1016 | while (row < end_row); |
|
|
1017 | } |
|
|
1018 | |
946 | scr_refresh (refresh_type); |
1019 | scr_refresh (); |
947 | scrollbar_show (1); |
1020 | scrollbar_show (1); |
948 | #ifdef USE_XIM |
1021 | #ifdef USE_XIM |
949 | IMSendSpot (); |
1022 | IMSendSpot (); |
950 | #endif |
1023 | #endif |
951 | } |
1024 | } |
952 | |
1025 | |
953 | display->flush (); |
1026 | display->flush (); |
954 | } |
1027 | } |
955 | |
1028 | |
|
|
1029 | /* checks wether a refresh is requested and starts the refresh timer */ |
956 | void |
1030 | void |
957 | rxvt_term::check_cb (check_watcher &w) |
1031 | rxvt_term::refresh_check () |
958 | { |
1032 | { |
959 | SET_R (this); |
1033 | if (want_refresh && !flush_ev.is_active ()) |
960 | SET_LOCALE (locale); |
1034 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
961 | |
1035 | |
962 | display->flush (); |
1036 | display->flush (); |
963 | |
|
|
964 | if (want_refresh && !flush_ev.active) |
|
|
965 | flush_ev.start (NOW + 0.01); |
|
|
966 | } |
1037 | } |
967 | |
1038 | |
968 | void |
1039 | void |
969 | rxvt_term::flush_cb (time_watcher &w) |
1040 | rxvt_term::flush_cb (ev::timer &w, int revents) |
970 | { |
1041 | { |
971 | SET_R (this); |
1042 | make_current (); |
972 | SET_LOCALE (locale); |
|
|
973 | |
1043 | |
974 | refresh_limit = 1; |
|
|
975 | refresh_count = 0; |
1044 | refresh_count = 0; |
976 | flush (); |
1045 | flush (); |
977 | } |
1046 | } |
978 | |
1047 | |
979 | #ifdef CURSOR_BLINK |
1048 | #ifdef CURSOR_BLINK |
980 | void |
1049 | void |
981 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1050 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
982 | { |
1051 | { |
983 | hidden_cursor = !hidden_cursor; |
1052 | hidden_cursor = !hidden_cursor; |
984 | want_refresh = 1; |
1053 | want_refresh = 1; |
985 | |
1054 | refresh_check (); |
986 | w.start (w.at + BLINK_INTERVAL); |
|
|
987 | } |
1055 | } |
988 | #endif |
1056 | #endif |
989 | |
1057 | |
990 | #ifdef TEXT_BLINK |
1058 | #ifdef TEXT_BLINK |
991 | void |
1059 | void |
992 | rxvt_term::text_blink_cb (time_watcher &w) |
1060 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
993 | { |
1061 | { |
994 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1062 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
995 | { |
1063 | { |
996 | hidden_text = !hidden_text; |
1064 | hidden_text = !hidden_text; |
997 | want_refresh = 1; |
1065 | want_refresh = 1; |
998 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1066 | refresh_check (); |
999 | } |
1067 | } |
|
|
1068 | else |
|
|
1069 | w.stop (); |
1000 | } |
1070 | } |
1001 | #endif |
1071 | #endif |
1002 | |
1072 | |
1003 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1073 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1004 | void |
1074 | void |
1005 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1075 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1006 | { |
1076 | { |
1007 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1077 | if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
1008 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1078 | && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) |
1009 | { |
1079 | { |
1010 | refresh_type |= SMOOTH_REFRESH; |
|
|
1011 | want_refresh = 1; |
1080 | want_refresh = 1; |
1012 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1081 | refresh_check (); |
1013 | } |
1082 | } |
|
|
1083 | else |
|
|
1084 | w.stop (); |
1014 | } |
1085 | } |
1015 | #endif |
1086 | #endif |
1016 | |
1087 | |
1017 | #ifdef SELECTION_SCROLLING |
1088 | #ifdef SELECTION_SCROLLING |
1018 | void |
1089 | void |
1019 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1090 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1020 | { |
1091 | { |
1021 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1092 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1022 | { |
1093 | { |
1023 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1094 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1024 | refresh_type |= SMOOTH_REFRESH; |
|
|
1025 | want_refresh = 1; |
1095 | want_refresh = 1; |
1026 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1096 | refresh_check (); |
1027 | } |
1097 | } |
|
|
1098 | else |
|
|
1099 | w.stop (); |
1028 | } |
1100 | } |
1029 | #endif |
1101 | #endif |
1030 | |
1102 | |
1031 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1103 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1032 | void |
1104 | void |
1033 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1105 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1034 | { |
1106 | { |
1035 | if (mouse_slip_wheel_speed == 0 |
1107 | if (scr_changeview (view_start - mouse_slip_wheel_speed)) |
1036 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
1037 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
1038 | { |
1108 | { |
1039 | if (view_start == nsaved || |
|
|
1040 | view_start == 0) |
|
|
1041 | mouse_slip_wheel_speed = 0; |
|
|
1042 | |
|
|
1043 | refresh_type |= SMOOTH_REFRESH; |
|
|
1044 | want_refresh = 1; |
1109 | want_refresh = 1; |
1045 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1110 | refresh_check (); |
|
|
1111 | } |
|
|
1112 | |
|
|
1113 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
1046 | } |
1114 | { |
|
|
1115 | mouse_slip_wheel_speed = 0; |
|
|
1116 | w.stop (); |
|
|
1117 | } |
1047 | } |
1118 | } |
|
|
1119 | #endif |
|
|
1120 | |
|
|
1121 | #if LINUX_YIELD_HACK |
|
|
1122 | static struct event_handler |
|
|
1123 | { |
|
|
1124 | ev::prepare yield_ev; |
|
|
1125 | |
|
|
1126 | void yield_cb (ev::prepare &w, int revents) |
|
|
1127 | { |
|
|
1128 | // this should really be sched_yield(), but the linux guys thought |
|
|
1129 | // that giving a process calling sched_yield () less cpu time than |
|
|
1130 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1131 | // allowed by the sus... as is returning ENOSYS. |
|
|
1132 | |
|
|
1133 | struct timespec ts = { 0, 0 }; |
|
|
1134 | nanosleep (&ts, 0); |
|
|
1135 | |
|
|
1136 | w.stop (); |
|
|
1137 | } |
|
|
1138 | |
|
|
1139 | event_handler () |
|
|
1140 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1141 | { |
|
|
1142 | } |
|
|
1143 | } event_handler; |
1048 | #endif |
1144 | #endif |
1049 | |
1145 | |
1050 | bool |
1146 | bool |
1051 | rxvt_term::pty_fill () |
1147 | rxvt_term::pty_fill () |
1052 | { |
1148 | { |
1053 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1149 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1054 | |
1150 | |
1055 | if (CBUFSIZ == n) |
1151 | if (CBUFSIZ == n) |
1056 | { |
1152 | { |
1057 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1153 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1058 | n = 0; |
1154 | n = 0; |
1059 | } |
1155 | } |
1060 | |
1156 | |
1061 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1157 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1062 | cmdbuf_ptr = cmdbuf_base; |
1158 | cmdbuf_ptr = cmdbuf_base; |
1063 | cmdbuf_endp = cmdbuf_ptr + n; |
1159 | cmdbuf_endp = cmdbuf_ptr + n; |
1064 | |
1160 | |
1065 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1161 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1066 | |
1162 | |
1067 | if (n > 0) |
1163 | if (r > 0) |
1068 | { |
1164 | { |
1069 | cmdbuf_endp += n; |
1165 | cmdbuf_endp += r; |
1070 | return true; |
1166 | return true; |
1071 | } |
1167 | } |
1072 | else if (n < 0 && errno != EAGAIN) |
1168 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1169 | { |
|
|
1170 | #if LINUX_YIELD_HACK |
|
|
1171 | if (display->is_local) |
|
|
1172 | event_handler.yield_ev.start (); |
|
|
1173 | #endif |
|
|
1174 | } |
|
|
1175 | else |
|
|
1176 | { |
|
|
1177 | pty_ev.stop (); |
|
|
1178 | |
|
|
1179 | if (!option (Opt_hold)) |
1073 | destroy (); |
1180 | destroy (); |
1074 | |
1181 | } |
|
|
1182 | |
1075 | return false; |
1183 | return false; |
1076 | } |
1184 | } |
1077 | |
1185 | |
1078 | void |
1186 | void |
1079 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1187 | rxvt_term::pty_cb (ev::io &w, int revents) |
1080 | { |
1188 | { |
1081 | SET_R (this); |
1189 | make_current (); |
1082 | SET_LOCALE (locale); |
|
|
1083 | |
1190 | |
1084 | if (revents & EVENT_READ) |
1191 | if (revents & ev::READ) |
1085 | // loop, but don't allow a single term to monopolize us |
1192 | // loop, but don't allow a single term to monopolize us |
1086 | while (pty_fill ()) |
1193 | while (pty_fill ()) |
1087 | if (cmd_parse ()) |
1194 | if (cmd_parse ()) |
1088 | break; |
1195 | break; |
1089 | |
1196 | |
1090 | if (revents & EVENT_WRITE) |
1197 | if (revents & ev::WRITE) |
1091 | pty_write (); |
1198 | pty_write (); |
|
|
1199 | |
|
|
1200 | refresh_check (); |
1092 | } |
1201 | } |
1093 | |
1202 | |
1094 | void |
1203 | void |
1095 | rxvt_term::pointer_unblank () |
1204 | rxvt_term::pointer_unblank () |
1096 | { |
1205 | { |
1097 | XDefineCursor (display->display, vt, TermWin_cursor); |
1206 | XDefineCursor (dpy, vt, TermWin_cursor); |
1098 | recolour_cursor (); |
1207 | recolour_cursor (); |
1099 | |
1208 | |
1100 | #ifdef POINTER_BLANK |
1209 | #ifdef POINTER_BLANK |
1101 | hidden_pointer = 0; |
1210 | hidden_pointer = 0; |
1102 | |
1211 | |
1103 | if (options & Opt_pointerBlank) |
1212 | if (option (Opt_pointerBlank)) |
1104 | pointer_ev.start (NOW + pointerBlankDelay); |
1213 | pointer_ev.start (pointerBlankDelay); |
1105 | #endif |
1214 | #endif |
1106 | } |
1215 | } |
1107 | |
1216 | |
1108 | #ifdef POINTER_BLANK |
1217 | #ifdef POINTER_BLANK |
1109 | void |
1218 | void |
1110 | rxvt_term::pointer_blank () |
1219 | rxvt_term::pointer_blank () |
1111 | { |
1220 | { |
1112 | if (! (options & Opt_pointerBlank)) |
1221 | if (!option (Opt_pointerBlank)) |
1113 | return; |
1222 | return; |
1114 | |
1223 | |
1115 | XDefineCursor (display->display, vt, display->blank_cursor); |
1224 | XDefineCursor (dpy, vt, display->blank_cursor); |
1116 | XFlush (display->display); |
1225 | XFlush (dpy); |
1117 | |
1226 | |
1118 | hidden_pointer = 1; |
1227 | hidden_pointer = 1; |
1119 | } |
1228 | } |
1120 | |
1229 | |
1121 | void |
1230 | void |
1122 | rxvt_term::pointer_cb (time_watcher &w) |
1231 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1123 | { |
1232 | { |
1124 | SET_R (this); |
1233 | make_current (); |
1125 | SET_LOCALE (locale); |
|
|
1126 | |
1234 | |
1127 | pointer_blank (); |
1235 | pointer_blank (); |
1128 | } |
1236 | } |
1129 | #endif |
1237 | #endif |
1130 | |
1238 | |
1131 | void |
1239 | void |
1132 | rxvt_term::mouse_report (XButtonEvent &ev) |
1240 | rxvt_term::mouse_report (XButtonEvent &ev) |
1133 | { |
1241 | { |
1134 | int button_number, key_state = 0; |
1242 | int button_number, key_state = 0; |
1135 | int x, y; |
1243 | int x, y; |
|
|
1244 | int code = 32; |
1136 | |
1245 | |
1137 | x = ev.x; |
1246 | x = Pixel2Col (ev.x); |
1138 | y = ev.y; |
1247 | y = Pixel2Row (ev.y); |
1139 | pixel_position (&x, &y); |
1248 | if (ev.type == MotionNotify) |
|
|
1249 | { |
|
|
1250 | if (x == mouse_row && y == mouse_col) |
|
|
1251 | return; |
|
|
1252 | mouse_row = x; |
|
|
1253 | mouse_col = y; |
|
|
1254 | code += 32; |
|
|
1255 | } |
1140 | |
1256 | |
1141 | if (MEvent.button == AnyButton) |
1257 | if (MEvent.button == AnyButton) |
1142 | button_number = 3; |
1258 | button_number = 3; |
1143 | else |
1259 | else |
1144 | { |
1260 | { |
… | |
… | |
1190 | x + 1, |
1306 | x + 1, |
1191 | y + 1); |
1307 | y + 1); |
1192 | #endif |
1308 | #endif |
1193 | |
1309 | |
1194 | tt_printf ("\033[M%c%c%c", |
1310 | tt_printf ("\033[M%c%c%c", |
1195 | (32 + button_number + key_state), |
1311 | (code + button_number + key_state), |
1196 | (32 + x + 1), |
1312 | (32 + x + 1), |
1197 | (32 + y + 1)); |
1313 | (32 + y + 1)); |
1198 | } |
1314 | } |
1199 | |
|
|
1200 | #ifdef USING_W11LIB |
|
|
1201 | void |
|
|
1202 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1203 | { |
|
|
1204 | rxvt_t *r = rxvt_get_r (); |
|
|
1205 | |
|
|
1206 | x_cb (*ev); |
|
|
1207 | } |
|
|
1208 | #endif |
|
|
1209 | |
1315 | |
1210 | /*{{{ process an X event */ |
1316 | /*{{{ process an X event */ |
1211 | void |
1317 | void |
1212 | rxvt_term::x_cb (XEvent &ev) |
1318 | rxvt_term::x_cb (XEvent &ev) |
1213 | { |
1319 | { |
1214 | dDisp; |
1320 | make_current (); |
1215 | |
1321 | |
1216 | SET_R (this); |
1322 | dLocal (Display *, dpy); |
1217 | SET_LOCALE (locale); |
|
|
1218 | |
1323 | |
1219 | #if defined(CURSOR_BLINK) |
1324 | if (ev.xany.window == vt |
1220 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1325 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1221 | { |
1326 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1222 | if (hidden_cursor) |
1327 | return; |
1223 | { |
|
|
1224 | hidden_cursor = 0; |
|
|
1225 | want_refresh = 1; |
|
|
1226 | } |
|
|
1227 | |
1328 | |
1228 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1329 | // for XQueryPointer |
1229 | } |
|
|
1230 | #endif |
|
|
1231 | |
|
|
1232 | #if defined(POINTER_BLANK) |
|
|
1233 | if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1234 | { |
|
|
1235 | if (ev.type == MotionNotify |
|
|
1236 | || ev.type == ButtonPress |
|
|
1237 | || ev.type == ButtonRelease) |
|
|
1238 | if (hidden_pointer) |
|
|
1239 | pointer_unblank (); |
|
|
1240 | |
|
|
1241 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1242 | pointer_blank (); |
|
|
1243 | } |
|
|
1244 | #endif |
|
|
1245 | |
|
|
1246 | Window unused_root, unused_child; |
1330 | Window unused_root, unused_child; |
1247 | int unused_root_x, unused_root_y; |
1331 | int unused_root_x, unused_root_y; |
1248 | unsigned int unused_mask; |
1332 | unsigned int unused_mask; |
1249 | |
1333 | |
1250 | switch (ev.type) |
1334 | switch (ev.type) |
1251 | { |
1335 | { |
1252 | case KeyPress: |
1336 | case KeyPress: |
1253 | #if ISO_14755 |
1337 | key_press (ev.xkey); |
1254 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1255 | #endif |
|
|
1256 | lookup_key (ev.xkey); |
|
|
1257 | |
|
|
1258 | break; |
1338 | break; |
1259 | |
1339 | |
1260 | case KeyRelease: |
1340 | case KeyRelease: |
1261 | { |
1341 | key_release (ev.xkey); |
1262 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1263 | KeySym ks; |
|
|
1264 | |
|
|
1265 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1266 | #endif |
|
|
1267 | |
|
|
1268 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1269 | // ISO 14755 support |
|
|
1270 | if (iso14755buf) |
|
|
1271 | if (iso14755buf & ISO_14755_52) |
|
|
1272 | { |
|
|
1273 | # if ENABLE_OVERLAY |
|
|
1274 | scr_overlay_off (); |
|
|
1275 | # endif |
|
|
1276 | # if ISO_14755 |
|
|
1277 | // iso14755 part 5.2 handling: release time |
|
|
1278 | // first: controls |
|
|
1279 | if ((ev.xkey.state & ControlMask) |
|
|
1280 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1281 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1282 | { |
|
|
1283 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1284 | commit_iso14755 (); |
|
|
1285 | return; // case-break; |
|
|
1286 | } |
|
|
1287 | |
|
|
1288 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1289 | if (i[0] == ks) |
|
|
1290 | { |
|
|
1291 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1292 | commit_iso14755 (); |
|
|
1293 | return; // case-break; |
|
|
1294 | } |
|
|
1295 | |
|
|
1296 | scr_bell (); |
|
|
1297 | # endif |
|
|
1298 | iso14755buf = 0; |
|
|
1299 | break; |
|
|
1300 | } |
|
|
1301 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1302 | { |
|
|
1303 | # if ENABLE_OVERLAY |
|
|
1304 | scr_overlay_off (); |
|
|
1305 | # endif |
|
|
1306 | if (iso14755buf & ISO_14755_51) |
|
|
1307 | commit_iso14755 (); |
|
|
1308 | #if ISO_14755 |
|
|
1309 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1310 | { |
|
|
1311 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1312 | |
|
|
1313 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1314 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1315 | } |
|
|
1316 | # endif |
|
|
1317 | else |
|
|
1318 | iso14755buf = 0; |
|
|
1319 | } |
|
|
1320 | #endif |
|
|
1321 | |
|
|
1322 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1323 | if (!(ev.xkey.state & ControlMask)) |
|
|
1324 | slip_wheel_ev.stop (); |
|
|
1325 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1326 | mouse_slip_wheel_speed = 0; |
|
|
1327 | #endif |
|
|
1328 | break; |
1342 | break; |
1329 | } |
|
|
1330 | |
1343 | |
1331 | case ButtonPress: |
1344 | case ButtonPress: |
1332 | button_press (ev.xbutton); |
1345 | button_press (ev.xbutton); |
1333 | break; |
1346 | break; |
1334 | |
1347 | |
… | |
… | |
1336 | button_release (ev.xbutton); |
1349 | button_release (ev.xbutton); |
1337 | break; |
1350 | break; |
1338 | |
1351 | |
1339 | case ClientMessage: |
1352 | case ClientMessage: |
1340 | if (ev.xclient.format == 32 |
1353 | if (ev.xclient.format == 32 |
1341 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1354 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1342 | { |
1355 | { |
|
|
1356 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1357 | { |
|
|
1358 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1359 | { |
1343 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1360 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1361 | { |
|
|
1362 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1344 | destroy (); |
1363 | destroy (); |
|
|
1364 | } |
1345 | #if ENABLE_EWMH |
1365 | #if ENABLE_EWMH |
1346 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1366 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1347 | XSendEvent (disp, ev.xclient.window = display->root, |
1367 | XSendEvent (dpy, ev.xclient.window = display->root, |
1348 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1368 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1349 | &ev); |
1369 | &ev); |
|
|
1370 | #endif |
|
|
1371 | } |
|
|
1372 | } |
|
|
1373 | #if ENABLE_XEMBED |
|
|
1374 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1375 | { |
|
|
1376 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1377 | focus_in (); |
|
|
1378 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1379 | focus_out (); |
|
|
1380 | } |
1350 | #endif |
1381 | #endif |
1351 | } |
1382 | } |
1352 | #if ENABLE_XEMBED |
|
|
1353 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1354 | { |
|
|
1355 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1356 | focus_in (); |
|
|
1357 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1358 | focus_out (); |
|
|
1359 | } |
|
|
1360 | #endif |
|
|
1361 | #ifdef OFFIX_DND |
|
|
1362 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1363 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1364 | && (ev.xclient.data.l[0] == DndFile |
|
|
1365 | || ev.xclient.data.l[0] == DndDir |
|
|
1366 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1367 | { |
|
|
1368 | /* Get Dnd data */ |
|
|
1369 | Atom ActualType; |
|
|
1370 | int ActualFormat; |
|
|
1371 | unsigned char *data; |
|
|
1372 | unsigned long Size, RemainingBytes; |
|
|
1373 | |
|
|
1374 | XGetWindowProperty (disp, display->root, |
|
|
1375 | xa[XA_DNDSELECTION], |
|
|
1376 | 0L, 1000000L, |
|
|
1377 | False, AnyPropertyType, |
|
|
1378 | &ActualType, &ActualFormat, |
|
|
1379 | &Size, &RemainingBytes, |
|
|
1380 | &data); |
|
|
1381 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1382 | XFree (data); |
|
|
1383 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1384 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1385 | } |
|
|
1386 | #endif /* OFFIX_DND */ |
|
|
1387 | break; |
|
|
1388 | |
|
|
1389 | case MappingNotify: |
|
|
1390 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1391 | break; |
1383 | break; |
1392 | |
1384 | |
1393 | /* |
1385 | /* |
1394 | * XXX: this is not the _current_ arrangement |
1386 | * XXX: this is not the _current_ arrangement |
1395 | * Here's my conclusion: |
1387 | * Here's my conclusion: |
… | |
… | |
1414 | break; |
1406 | break; |
1415 | } |
1407 | } |
1416 | break; |
1408 | break; |
1417 | |
1409 | |
1418 | case FocusIn: |
1410 | case FocusIn: |
|
|
1411 | if (ev.xfocus.detail != NotifyInferior |
|
|
1412 | && ev.xfocus.detail != NotifyPointer |
|
|
1413 | && ev.xfocus.mode != NotifyGrab) |
1419 | focus_in (); |
1414 | focus_in (); |
1420 | break; |
1415 | break; |
1421 | |
1416 | |
1422 | case FocusOut: |
1417 | case FocusOut: |
|
|
1418 | if (ev.xfocus.detail != NotifyInferior |
|
|
1419 | && ev.xfocus.detail != NotifyPointer |
|
|
1420 | && ev.xfocus.mode != NotifyGrab) |
1423 | focus_out (); |
1421 | focus_out (); |
1424 | break; |
1422 | break; |
1425 | |
1423 | |
1426 | case ConfigureNotify: |
1424 | case ConfigureNotify: |
|
|
1425 | /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1426 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1427 | szHint.width, szHint.height);*/ |
1427 | if (ev.xconfigure.window == parent[0]) |
1428 | if (ev.xconfigure.window == parent[0]) |
1428 | { |
1429 | { |
1429 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1430 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1430 | ; |
1431 | ; |
1431 | |
1432 | |
1432 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1433 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1433 | { |
1434 | { |
1434 | seen_resize = 1; |
1435 | seen_resize = 1; |
1435 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1436 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1436 | } |
1437 | } |
1437 | |
1438 | else |
1438 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1439 | { |
1439 | if (options & Opt_transparent) |
1440 | #ifdef HAVE_BG_PIXMAP |
1440 | check_our_parents (); |
1441 | if (bgPixmap.window_position_sensitive ()) |
|
|
1442 | { |
|
|
1443 | if (mapped) |
|
|
1444 | update_background (); |
|
|
1445 | else |
|
|
1446 | bgPixmap.invalidate (); |
|
|
1447 | } |
1441 | #endif |
1448 | #endif |
|
|
1449 | } |
|
|
1450 | |
|
|
1451 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1442 | } |
1452 | } |
1443 | break; |
1453 | break; |
1444 | |
1454 | |
1445 | case PropertyNotify: |
1455 | case PropertyNotify: |
|
|
1456 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1446 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1457 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1447 | && ev.xproperty.state == PropertyNewValue) |
1458 | && ev.xproperty.state == PropertyNewValue) |
1448 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1459 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1449 | |
1460 | |
1450 | break; |
1461 | break; |
1451 | |
1462 | |
1452 | case SelectionClear: |
1463 | case SelectionClear: |
1453 | selection_clear (); |
1464 | selection_clear (); |
… | |
… | |
1458 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1469 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1459 | break; |
1470 | break; |
1460 | |
1471 | |
1461 | case SelectionRequest: |
1472 | case SelectionRequest: |
1462 | selection_send (ev.xselectionrequest); |
1473 | selection_send (ev.xselectionrequest); |
|
|
1474 | break; |
|
|
1475 | |
|
|
1476 | case MapNotify: |
|
|
1477 | #ifdef HAVE_BG_PIXMAP |
|
|
1478 | /* This is needed spcifically to fix the case of no window manager or a |
|
|
1479 | * non-reparenting window manager. In those cases we never get first |
|
|
1480 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
|
|
1481 | * care of multiplicity of ConfigureNotify events arriwing while WM does |
|
|
1482 | * reparenting. |
|
|
1483 | * We should not render background immidiately, as there could be several |
|
|
1484 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
|
|
1485 | * by scheduling background redraw as soon as we can, but giving a short |
|
|
1486 | * bit of time for ConfigureNotifies to arrive. |
|
|
1487 | * We should render background PRIOR to drawing any text, but AFTER all |
|
|
1488 | * of ConfigureNotifys for the best results. |
|
|
1489 | */ |
|
|
1490 | if (bgPixmap.flags & bgPixmap_t::isInvalid) |
|
|
1491 | update_background_ev.start (0.025); |
|
|
1492 | #endif |
|
|
1493 | mapped = 1; |
|
|
1494 | #ifdef TEXT_BLINK |
|
|
1495 | text_blink_ev.start (); |
|
|
1496 | #endif |
|
|
1497 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1463 | break; |
1498 | break; |
1464 | |
1499 | |
1465 | case UnmapNotify: |
1500 | case UnmapNotify: |
1466 | mapped = 0; |
1501 | mapped = 0; |
1467 | #ifdef TEXT_BLINK |
1502 | #ifdef TEXT_BLINK |
1468 | text_blink_ev.stop (); |
1503 | text_blink_ev.stop (); |
1469 | #endif |
1504 | #endif |
|
|
1505 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1470 | break; |
1506 | break; |
1471 | |
|
|
1472 | case MapNotify: |
|
|
1473 | mapped = 1; |
|
|
1474 | #ifdef TEXT_BLINK |
|
|
1475 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1476 | #endif |
|
|
1477 | break; |
|
|
1478 | |
|
|
1479 | #ifdef TRANSPARENT |
|
|
1480 | case ReparentNotify: |
|
|
1481 | rootwin_cb (ev); |
|
|
1482 | break; |
|
|
1483 | #endif /* TRANSPARENT */ |
|
|
1484 | |
1507 | |
1485 | case GraphicsExpose: |
1508 | case GraphicsExpose: |
1486 | case Expose: |
1509 | case Expose: |
1487 | if (ev.xany.window == vt) |
1510 | if (ev.xany.window == vt) |
1488 | { |
1511 | { |
1489 | do |
1512 | do |
|
|
1513 | { |
1490 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1514 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1491 | ev.xexpose.width, ev.xexpose.height, False); |
1515 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1516 | } |
1492 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1517 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1493 | |
1518 | |
1494 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1519 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1495 | |
1520 | |
1496 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1521 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1522 | { |
1497 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1498 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1525 | } |
1499 | |
1526 | |
1500 | scr_refresh (refresh_type); |
1527 | want_refresh = 1; |
1501 | } |
1528 | } |
1502 | else |
1529 | else |
1503 | { |
1530 | { |
1504 | XEvent unused_event; |
1531 | XEvent unused_event; |
1505 | |
1532 | |
1506 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1533 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1507 | ; |
1534 | ; |
1508 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1535 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1509 | ; |
1536 | ; |
1510 | |
1537 | |
1511 | if (isScrollbarWindow (ev.xany.window)) |
1538 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1512 | { |
1539 | { |
1513 | scrollBar.setIdle (); |
1540 | scrollBar.state = STATE_IDLE; |
1514 | scrollbar_show (0); |
1541 | scrollbar_show (0); |
1515 | } |
1542 | } |
1516 | #ifdef MENUBAR |
|
|
1517 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1518 | menubar_expose (); |
|
|
1519 | #endif |
|
|
1520 | |
|
|
1521 | #ifdef TRANSPARENT |
|
|
1522 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1523 | XClearWindow (disp, ev.xany.window); |
|
|
1524 | #endif |
|
|
1525 | } |
1543 | } |
1526 | break; |
1544 | break; |
1527 | |
1545 | |
1528 | case MotionNotify: |
1546 | case MotionNotify: |
1529 | #ifdef POINTER_BLANK |
1547 | #ifdef POINTER_BLANK |
1530 | if (hidden_pointer) |
1548 | if (hidden_pointer) |
1531 | pointer_unblank (); |
1549 | pointer_unblank (); |
1532 | #endif |
1550 | #endif |
1533 | #if MENUBAR |
1551 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
1534 | if (isMenuBarWindow (ev.xany.window)) |
1552 | || priv_modes & PrivMode_MouseAnyEvent) |
1535 | { |
|
|
1536 | menubar_control (ev.xbutton); |
1553 | mouse_report (ev.xbutton); |
1537 | break; |
|
|
1538 | } |
|
|
1539 | #endif |
|
|
1540 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1554 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1541 | break; |
1555 | break; |
1542 | |
1556 | |
1543 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1544 | { |
1558 | { |
|
|
1559 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1560 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1561 | ; // nop |
1545 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1562 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1546 | { |
1563 | { |
1547 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1564 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1548 | ; |
1565 | ; |
1549 | |
1566 | |
1550 | XQueryPointer (disp, vt, |
1567 | XQueryPointer (dpy, vt, |
1551 | &unused_root, &unused_child, |
1568 | &unused_root, &unused_child, |
1552 | &unused_root_x, &unused_root_y, |
1569 | &unused_root_x, &unused_root_y, |
1553 | &ev.xbutton.x, &ev.xbutton.y, |
1570 | &ev.xbutton.x, &ev.xbutton.y, |
1554 | &ev.xbutton.state); |
1571 | &ev.xbutton.state); |
1555 | #ifdef MOUSE_THRESHOLD |
1572 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1575 | int dist; |
1592 | int dist; |
1576 | |
1593 | |
1577 | /* don't clobber the current delay if we are |
1594 | /* don't clobber the current delay if we are |
1578 | * already in the middle of scrolling. |
1595 | * already in the middle of scrolling. |
1579 | */ |
1596 | */ |
1580 | if (!sel_scroll_ev.active) |
1597 | if (!sel_scroll_ev.is_active ()) |
1581 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1598 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1582 | |
1599 | |
1583 | /* save the event params so we can highlight |
1600 | /* save the event params so we can highlight |
1584 | * the selection in the pending-scroll loop |
1601 | * the selection in the pending-scroll loop |
1585 | */ |
1602 | */ |
1586 | selection_save_x = ev.xbutton.x; |
1603 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1600 | } |
1617 | } |
1601 | |
1618 | |
1602 | scroll_selection_lines = Pixel2Height (dist) |
1619 | scroll_selection_lines = Pixel2Height (dist) |
1603 | / SELECTION_SCROLL_LINE_SPEEDUP |
1620 | / SELECTION_SCROLL_LINE_SPEEDUP |
1604 | + 1; |
1621 | + 1; |
1605 | MIN_IT (scroll_selection_lines, |
1622 | min_it (scroll_selection_lines, |
1606 | SELECTION_SCROLL_MAX_LINES); |
1623 | SELECTION_SCROLL_MAX_LINES); |
1607 | } |
1624 | } |
1608 | else |
1625 | else |
1609 | { |
1626 | { |
1610 | /* we are within the text window, so we |
1627 | /* we are within the text window, so we |
1611 | * shouldn't be scrolling |
1628 | * shouldn't be scrolling |
1612 | */ |
1629 | */ |
1613 | if (sel_scroll_ev.active) |
|
|
1614 | sel_scroll_ev.stop(); |
1630 | sel_scroll_ev.stop(); |
1615 | } |
1631 | } |
1616 | #endif |
1632 | #endif |
1617 | #ifdef MOUSE_THRESHOLD |
1633 | #ifdef MOUSE_THRESHOLD |
1618 | } |
1634 | } |
1619 | #endif |
1635 | #endif |
1620 | } |
1636 | } |
1621 | } |
1637 | } |
1622 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1638 | else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) |
1623 | { |
1639 | { |
1624 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1640 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1625 | MotionNotify, &ev)) |
1641 | MotionNotify, &ev)) |
1626 | ; |
1642 | ; |
1627 | |
1643 | |
1628 | XQueryPointer (disp, scrollBar.win, |
1644 | XQueryPointer (dpy, scrollBar.win, |
1629 | &unused_root, &unused_child, |
1645 | &unused_root, &unused_child, |
1630 | &unused_root_x, &unused_root_y, |
1646 | &unused_root_x, &unused_root_y, |
1631 | &ev.xbutton.x, &ev.xbutton.y, |
1647 | &ev.xbutton.x, &ev.xbutton.y, |
1632 | &unused_mask); |
1648 | &unused_mask); |
1633 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1649 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1634 | scrollbar_size ()); |
1650 | scrollBar.size ()); |
1635 | scr_refresh (refresh_type); |
|
|
1636 | refresh_limit = 0; |
1651 | want_refresh = 1; |
1637 | scrollbar_show (1); |
1652 | scrollbar_show (1); |
1638 | } |
1653 | } |
1639 | break; |
1654 | break; |
1640 | } |
1655 | } |
|
|
1656 | |
|
|
1657 | #if defined(CURSOR_BLINK) |
|
|
1658 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1659 | { |
|
|
1660 | if (hidden_cursor) |
|
|
1661 | { |
|
|
1662 | hidden_cursor = 0; |
|
|
1663 | want_refresh = 1; |
|
|
1664 | } |
|
|
1665 | |
|
|
1666 | cursor_blink_ev.again (); |
|
|
1667 | } |
|
|
1668 | #endif |
|
|
1669 | |
|
|
1670 | #if defined(POINTER_BLANK) |
|
|
1671 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1672 | { |
|
|
1673 | if (ev.type == MotionNotify |
|
|
1674 | || ev.type == ButtonPress |
|
|
1675 | || ev.type == ButtonRelease) |
|
|
1676 | if (hidden_pointer) |
|
|
1677 | pointer_unblank (); |
|
|
1678 | |
|
|
1679 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1680 | pointer_blank (); |
|
|
1681 | } |
|
|
1682 | #endif |
|
|
1683 | |
|
|
1684 | refresh_check (); |
1641 | } |
1685 | } |
1642 | |
1686 | |
1643 | void |
1687 | void |
1644 | rxvt_term::focus_in () |
1688 | rxvt_term::focus_in () |
1645 | { |
1689 | { |
1646 | if (!focus) |
1690 | if (!focus) |
1647 | { |
1691 | { |
1648 | focus = 1; |
1692 | focus = 1; |
1649 | want_refresh = 1; |
1693 | want_refresh = 1; |
|
|
1694 | |
|
|
1695 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1696 | |
1650 | #if USE_XIM |
1697 | #if USE_XIM |
1651 | if (Input_Context != NULL) |
1698 | if (Input_Context != NULL) |
1652 | { |
1699 | { |
1653 | IMSetStatusPosition (); |
1700 | IMSetPosition (); |
1654 | XSetICFocus (Input_Context); |
1701 | XSetICFocus (Input_Context); |
1655 | } |
1702 | } |
1656 | #endif |
1703 | #endif |
1657 | #if CURSOR_BLINK |
1704 | #if CURSOR_BLINK |
1658 | if (options & Opt_cursorBlink) |
1705 | if (option (Opt_cursorBlink)) |
1659 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1706 | cursor_blink_ev.again (); |
1660 | #endif |
1707 | #endif |
1661 | #if OFF_FOCUS_FADING |
1708 | #if OFF_FOCUS_FADING |
1662 | if (rs[Rs_fade]) |
1709 | if (rs[Rs_fade]) |
1663 | { |
1710 | { |
1664 | pix_colors = pix_colors_focused; |
1711 | pix_colors = pix_colors_focused; |
1665 | scr_recolour (); |
1712 | scr_recolour (); |
1666 | } |
1713 | } |
1667 | #endif |
1714 | #endif |
|
|
1715 | #if ENABLE_FRILLS |
|
|
1716 | if (option (Opt_urgentOnBell)) |
|
|
1717 | { |
|
|
1718 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1719 | { |
|
|
1720 | h->flags &= ~XUrgencyHint; |
|
|
1721 | XSetWMHints (dpy, parent[0], h); |
|
|
1722 | } |
|
|
1723 | } |
|
|
1724 | #endif |
1668 | } |
1725 | } |
1669 | } |
1726 | } |
1670 | |
1727 | |
1671 | void |
1728 | void |
1672 | rxvt_term::focus_out () |
1729 | rxvt_term::focus_out () |
… | |
… | |
1674 | if (focus) |
1731 | if (focus) |
1675 | { |
1732 | { |
1676 | focus = 0; |
1733 | focus = 0; |
1677 | want_refresh = 1; |
1734 | want_refresh = 1; |
1678 | |
1735 | |
|
|
1736 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1737 | |
1679 | #if ENABLE_FRILLS || ISO_14755 |
1738 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1739 | if (iso14755buf) |
|
|
1740 | { |
1680 | iso14755buf = 0; |
1741 | iso14755buf = 0; |
1681 | #endif |
1742 | # if ISO_14755 |
1682 | #if ENABLE_OVERLAY |
|
|
1683 | scr_overlay_off (); |
1743 | scr_overlay_off (); |
|
|
1744 | # endif |
|
|
1745 | } |
1684 | #endif |
1746 | #endif |
1685 | #if USE_XIM |
1747 | #if USE_XIM |
1686 | if (Input_Context != NULL) |
1748 | if (Input_Context != NULL) |
1687 | XUnsetICFocus (Input_Context); |
1749 | XUnsetICFocus (Input_Context); |
1688 | #endif |
1750 | #endif |
1689 | #if CURSOR_BLINK |
1751 | #if CURSOR_BLINK |
1690 | if (options & Opt_cursorBlink) |
1752 | if (option (Opt_cursorBlink)) |
1691 | cursor_blink_ev.stop (); |
1753 | cursor_blink_ev.stop (); |
|
|
1754 | |
1692 | hidden_cursor = 0; |
1755 | hidden_cursor = 0; |
1693 | #endif |
1756 | #endif |
1694 | #if OFF_FOCUS_FADING |
1757 | #if OFF_FOCUS_FADING |
1695 | if (rs[Rs_fade]) |
1758 | if (rs[Rs_fade]) |
1696 | { |
1759 | { |
… | |
… | |
1699 | } |
1762 | } |
1700 | #endif |
1763 | #endif |
1701 | } |
1764 | } |
1702 | } |
1765 | } |
1703 | |
1766 | |
1704 | #if TRANSPARENT |
1767 | void |
|
|
1768 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1769 | { |
|
|
1770 | #if OFF_FOCUS_FADING |
|
|
1771 | if (rs[Rs_fade]) |
|
|
1772 | { |
|
|
1773 | rgba c; |
|
|
1774 | pix_colors [Color_fade].get (c); |
|
|
1775 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1776 | } |
|
|
1777 | #endif |
|
|
1778 | } |
|
|
1779 | |
|
|
1780 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1705 | void |
1781 | void |
1706 | rxvt_term::rootwin_cb (XEvent &ev) |
1782 | rxvt_term::rootwin_cb (XEvent &ev) |
1707 | { |
1783 | { |
1708 | SET_R (this); |
1784 | make_current (); |
1709 | SET_LOCALE (locale); |
|
|
1710 | |
1785 | |
|
|
1786 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1787 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1788 | return; |
|
|
1789 | |
|
|
1790 | # if ENABLE_TRANSPARENCY |
1711 | switch (ev.type) |
1791 | switch (ev.type) |
1712 | { |
1792 | { |
1713 | case PropertyNotify: |
1793 | case PropertyNotify: |
1714 | /* |
1794 | /* |
1715 | * if user used some Esetroot compatible prog to set the root bg, |
1795 | * if user used some Esetroot compatible prog to set the root bg, |
1716 | * use the property to determine the pixmap. We use it later on. |
1796 | * use the property to determine the pixmap. We use it later on. |
1717 | */ |
1797 | */ |
1718 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1798 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1719 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1799 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1720 | return; |
1800 | { |
|
|
1801 | bgPixmap.set_root_pixmap (); |
|
|
1802 | update_background (); |
|
|
1803 | } |
1721 | |
1804 | |
1722 | /* FALLTHROUGH */ |
|
|
1723 | case ReparentNotify: |
|
|
1724 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1725 | want_refresh = want_full_refresh = 1; |
|
|
1726 | break; |
1805 | break; |
1727 | } |
1806 | } |
|
|
1807 | # endif |
|
|
1808 | |
|
|
1809 | refresh_check (); |
1728 | } |
1810 | } |
1729 | #endif |
1811 | #endif |
1730 | |
1812 | |
1731 | void |
1813 | void |
1732 | rxvt_term::button_press (XButtonEvent &ev) |
1814 | rxvt_term::button_press (XButtonEvent &ev) |
1733 | { |
1815 | { |
1734 | int reportmode = 0, clickintime; |
1816 | int reportmode = 0, clickintime; |
1735 | |
1817 | |
1736 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1818 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1819 | |
1737 | if (!bypass_keystate) |
1820 | if (!bypass_keystate) |
1738 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1821 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1739 | |
1822 | |
1740 | /* |
1823 | /* |
1741 | * VT window processing of button press |
1824 | * VT window processing of button press |
1742 | */ |
1825 | */ |
1743 | if (ev.window == vt) |
1826 | if (ev.window == vt) |
1744 | { |
1827 | { |
|
|
1828 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1829 | return; |
|
|
1830 | |
1745 | #if ISO_14755 |
1831 | #if ISO_14755 |
1746 | // 5.4 |
1832 | // 5.4 |
1747 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1833 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1748 | { |
1834 | { |
1749 | iso14755_54 (ev.x, ev.y); |
1835 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1761 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1847 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1762 | if (ev.button == MEvent.button && clickintime) |
1848 | if (ev.button == MEvent.button && clickintime) |
1763 | { |
1849 | { |
1764 | /* same button, within alloted time */ |
1850 | /* same button, within alloted time */ |
1765 | MEvent.clicks++; |
1851 | MEvent.clicks++; |
|
|
1852 | |
1766 | if (MEvent.clicks > 1) |
1853 | if (MEvent.clicks > 1) |
1767 | { |
1854 | { |
1768 | /* only report double clicks */ |
1855 | /* only report double clicks */ |
1769 | MEvent.clicks = 2; |
1856 | MEvent.clicks = 2; |
1770 | mouse_report (ev); |
1857 | mouse_report (ev); |
… | |
… | |
1782 | mouse_report (ev); |
1869 | mouse_report (ev); |
1783 | } |
1870 | } |
1784 | #else |
1871 | #else |
1785 | MEvent.button = ev.button; |
1872 | MEvent.button = ev.button; |
1786 | mouse_report (ev); |
1873 | mouse_report (ev); |
1787 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1874 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1788 | |
1875 | |
1789 | } |
1876 | } |
1790 | else |
1877 | else |
1791 | { |
1878 | { |
1792 | if (ev.button != MEvent.button) |
1879 | if (ev.button != MEvent.button) |
… | |
… | |
1802 | #else |
1889 | #else |
1803 | selection.rect = false; |
1890 | selection.rect = false; |
1804 | #endif |
1891 | #endif |
1805 | |
1892 | |
1806 | /* allow shift+left click to extend selection */ |
1893 | /* allow shift+left click to extend selection */ |
1807 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1894 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1808 | { |
1895 | { |
1809 | if (MEvent.button == Button1 && clickintime) |
1896 | if (MEvent.button == Button1 && clickintime) |
1810 | selection_rotate (ev.x, ev.y); |
1897 | selection_rotate (ev.x, ev.y); |
1811 | else |
1898 | else |
1812 | selection_extend (ev.x, ev.y, 1); |
1899 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
1840 | } |
1927 | } |
1841 | |
1928 | |
1842 | /* |
1929 | /* |
1843 | * Scrollbar window processing of button press |
1930 | * Scrollbar window processing of button press |
1844 | */ |
1931 | */ |
1845 | if (isScrollbarWindow (ev.window)) |
1932 | if (scrollBar.state && ev.window == scrollBar.win) |
1846 | { |
1933 | { |
1847 | scrollBar.setIdle (); |
1934 | page_dirn direction = NO_DIR; |
|
|
1935 | |
|
|
1936 | if (scrollBar.upButton (ev.y)) |
|
|
1937 | direction = UP; /* up */ |
|
|
1938 | else if (scrollBar.dnButton (ev.y)) |
|
|
1939 | direction = DN; /* down */ |
|
|
1940 | |
|
|
1941 | scrollBar.state = STATE_IDLE; |
1848 | /* |
1942 | /* |
1849 | * Rxvt-style scrollbar: |
1943 | * Rxvt-style scrollbar: |
1850 | * move up if mouse is above slider |
1944 | * move up if mouse is above slider |
1851 | * move dn if mouse is below slider |
1945 | * move dn if mouse is below slider |
1852 | * |
1946 | * |
… | |
… | |
1861 | /* |
1955 | /* |
1862 | * Mouse report disabled scrollbar: |
1956 | * Mouse report disabled scrollbar: |
1863 | * arrow buttons - send up/down |
1957 | * arrow buttons - send up/down |
1864 | * click on scrollbar - send pageup/down |
1958 | * click on scrollbar - send pageup/down |
1865 | */ |
1959 | */ |
1866 | if ((scrollBar.style == R_SB_NEXT |
1960 | if (direction == UP) |
1867 | && scrollbarnext_upButton (ev.y)) |
|
|
1868 | || (scrollBar.style == R_SB_RXVT |
|
|
1869 | && scrollbarrxvt_upButton (ev.y))) |
|
|
1870 | tt_printf ("\033[A"); |
1961 | tt_printf ("\033[A"); |
1871 | else if ((scrollBar.style == R_SB_NEXT |
1962 | else if (direction == DN) |
1872 | && scrollbarnext_dnButton (ev.y)) |
|
|
1873 | || (scrollBar.style == R_SB_RXVT |
|
|
1874 | && scrollbarrxvt_dnButton (ev.y))) |
|
|
1875 | tt_printf ("\033[B"); |
1963 | tt_printf ("\033[B"); |
1876 | else |
1964 | else |
1877 | switch (ev.button) |
1965 | switch (ev.button) |
1878 | { |
1966 | { |
1879 | case Button2: |
1967 | case Button2: |
… | |
… | |
1886 | tt_printf ("\033[5~"); |
1974 | tt_printf ("\033[5~"); |
1887 | break; |
1975 | break; |
1888 | } |
1976 | } |
1889 | } |
1977 | } |
1890 | else |
1978 | else |
1891 | #endif /* NO_SCROLLBAR_REPORT */ |
1979 | #endif /* NO_SCROLLBAR_REPORT */ |
1892 | |
|
|
1893 | { |
|
|
1894 | char upordown = 0; |
|
|
1895 | |
|
|
1896 | if (scrollBar.style == R_SB_NEXT) |
|
|
1897 | { |
1980 | { |
1898 | if (scrollbarnext_upButton (ev.y)) |
1981 | if (direction != NO_DIR) |
1899 | upordown = -1; /* up */ |
|
|
1900 | else if (scrollbarnext_dnButton (ev.y)) |
|
|
1901 | upordown = 1; /* down */ |
|
|
1902 | } |
|
|
1903 | else if (scrollBar.style == R_SB_RXVT) |
|
|
1904 | { |
|
|
1905 | if (scrollbarrxvt_upButton (ev.y)) |
|
|
1906 | upordown = -1; /* up */ |
|
|
1907 | else if (scrollbarrxvt_dnButton (ev.y)) |
|
|
1908 | upordown = 1; /* down */ |
|
|
1909 | } |
|
|
1910 | if (upordown) |
|
|
1911 | { |
1982 | { |
1912 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1983 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1984 | if (!cont_scroll_ev.is_active ()) |
1913 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1985 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1914 | #endif |
1986 | #endif |
1915 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1987 | if (scr_page (direction, 1)) |
1916 | { |
1988 | { |
1917 | if (upordown < 0) |
1989 | if (direction == UP) |
1918 | scrollBar.setUp (); |
1990 | scrollBar.state = STATE_UP; |
1919 | else |
1991 | else |
1920 | scrollBar.setDn (); |
1992 | scrollBar.state = STATE_DOWN; |
1921 | } |
1993 | } |
1922 | } |
1994 | } |
1923 | else |
1995 | else |
1924 | switch (ev.button) |
1996 | switch (ev.button) |
1925 | { |
1997 | { |
1926 | case Button2: |
1998 | case Button2: |
1927 | switch (scrollbar_align) |
1999 | switch (scrollBar.align) |
1928 | { |
2000 | { |
1929 | case R_SB_ALIGN_TOP: |
2001 | case R_SB_ALIGN_TOP: |
1930 | csrO = 0; |
2002 | csrO = 0; |
1931 | break; |
2003 | break; |
1932 | case R_SB_ALIGN_CENTRE: |
2004 | case R_SB_ALIGN_CENTRE: |
… | |
… | |
1938 | } |
2010 | } |
1939 | |
2011 | |
1940 | if (scrollBar.style == R_SB_XTERM |
2012 | if (scrollBar.style == R_SB_XTERM |
1941 | || scrollbar_above_slider (ev.y) |
2013 | || scrollbar_above_slider (ev.y) |
1942 | || scrollbar_below_slider (ev.y)) |
2014 | || scrollbar_below_slider (ev.y)) |
1943 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2015 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ()); |
1944 | |
2016 | |
1945 | scrollBar.setMotion (); |
2017 | scrollBar.state = STATE_MOTION; |
1946 | break; |
2018 | break; |
1947 | |
2019 | |
1948 | case Button1: |
2020 | case Button1: |
1949 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
2021 | if (scrollBar.align == R_SB_ALIGN_CENTRE) |
1950 | csrO = ev.y - scrollBar.top; |
2022 | csrO = ev.y - scrollBar.top; |
1951 | /* FALLTHROUGH */ |
2023 | /* FALLTHROUGH */ |
1952 | |
2024 | |
1953 | case Button3: |
2025 | case Button3: |
1954 | if (scrollBar.style != R_SB_XTERM) |
2026 | if (scrollBar.style != R_SB_XTERM) |
… | |
… | |
1964 | scr_page (DN, nrow - 1); |
2036 | scr_page (DN, nrow - 1); |
1965 | # else |
2037 | # else |
1966 | scr_page (DN, nrow / 4); |
2038 | scr_page (DN, nrow / 4); |
1967 | # endif |
2039 | # endif |
1968 | else |
2040 | else |
1969 | scrollBar.setMotion (); |
2041 | scrollBar.state = STATE_MOTION; |
1970 | } |
2042 | } |
1971 | else |
2043 | else |
1972 | { |
2044 | { |
1973 | scr_page ((ev.button == Button1 ? DN : UP), |
2045 | scr_page ((ev.button == Button1 ? DN : UP), |
1974 | (nrow |
2046 | (nrow |
1975 | * scrollbar_position (ev.y) |
2047 | * scrollbar_position (ev.y) |
1976 | / scrollbar_size ())); |
2048 | / scrollBar.size ())); |
1977 | } |
2049 | } |
1978 | |
2050 | |
1979 | break; |
2051 | break; |
1980 | } |
2052 | } |
1981 | } |
2053 | } |
|
|
2054 | |
1982 | return; |
2055 | return; |
1983 | } |
2056 | } |
1984 | #if MENUBAR |
|
|
1985 | /* |
|
|
1986 | * Menubar window processing of button press |
|
|
1987 | */ |
|
|
1988 | if (isMenuBarWindow (ev.window)) |
|
|
1989 | menubar_control (ev); |
|
|
1990 | #endif |
|
|
1991 | } |
2057 | } |
1992 | |
2058 | |
1993 | void |
2059 | void |
1994 | rxvt_term::button_release (XButtonEvent &ev) |
2060 | rxvt_term::button_release (XButtonEvent &ev) |
1995 | { |
2061 | { |
… | |
… | |
1997 | |
2063 | |
1998 | csrO = 0; /* reset csr Offset */ |
2064 | csrO = 0; /* reset csr Offset */ |
1999 | if (!bypass_keystate) |
2065 | if (!bypass_keystate) |
2000 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2066 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2001 | |
2067 | |
2002 | if (scrollbar_isUpDn ()) |
2068 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2003 | { |
2069 | { |
2004 | scrollBar.setIdle (); |
2070 | scrollBar.state = STATE_IDLE; |
2005 | scrollbar_show (0); |
2071 | scrollbar_show (0); |
2006 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2007 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2008 | #endif |
|
|
2009 | } |
2072 | } |
2010 | |
2073 | |
2011 | #ifdef SELECTION_SCROLLING |
2074 | #ifdef SELECTION_SCROLLING |
2012 | if (sel_scroll_ev.active) |
|
|
2013 | sel_scroll_ev.stop(); |
2075 | sel_scroll_ev.stop(); |
2014 | #endif |
2076 | #endif |
2015 | |
2077 | |
2016 | if (ev.window == vt) |
2078 | if (ev.window == vt) |
2017 | { |
2079 | { |
|
|
2080 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2081 | return; |
|
|
2082 | |
2018 | #if ISO_14755 |
2083 | #if ISO_14755 |
2019 | // 5.4 |
2084 | // 5.4 |
2020 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2085 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2021 | return; |
2086 | return; |
2022 | #endif |
2087 | #endif |
|
|
2088 | |
2023 | if (reportmode) |
2089 | if (reportmode) |
2024 | { |
2090 | { |
2025 | /* mouse report from vt window */ |
2091 | /* mouse report from vt window */ |
2026 | /* don't report release of wheel "buttons" */ |
2092 | /* don't report release of wheel "buttons" */ |
2027 | if (ev.button >= 4) |
2093 | if (ev.button >= 4) |
… | |
… | |
2038 | mouse_report (ev); |
2104 | mouse_report (ev); |
2039 | } |
2105 | } |
2040 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2106 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2041 | MEvent.button = AnyButton; |
2107 | MEvent.button = AnyButton; |
2042 | mouse_report (ev); |
2108 | mouse_report (ev); |
2043 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2109 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2044 | return; |
2110 | return; |
2045 | } |
2111 | } |
2046 | |
2112 | |
2047 | /* |
2113 | /* |
2048 | * dumb hack to compensate for the failure of click-and-drag |
2114 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2057 | { |
2123 | { |
2058 | case Button1: |
2124 | case Button1: |
2059 | case Button3: |
2125 | case Button3: |
2060 | selection_make (ev.time); |
2126 | selection_make (ev.time); |
2061 | break; |
2127 | break; |
|
|
2128 | |
2062 | case Button2: |
2129 | case Button2: |
2063 | selection_request (ev.time, ev.x, ev.y); |
2130 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2131 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2064 | break; |
2132 | break; |
|
|
2133 | |
2065 | #ifdef MOUSE_WHEEL |
2134 | #ifdef MOUSE_WHEEL |
2066 | case Button4: |
2135 | case Button4: |
2067 | case Button5: |
2136 | case Button5: |
2068 | { |
2137 | { |
2069 | int i; |
2138 | int i; |
… | |
… | |
2071 | |
2140 | |
2072 | v = ev.button == Button4 ? UP : DN; |
2141 | v = ev.button == Button4 ? UP : DN; |
2073 | |
2142 | |
2074 | if (ev.state & ShiftMask) |
2143 | if (ev.state & ShiftMask) |
2075 | i = 1; |
2144 | i = 1; |
2076 | else if (options & Opt_mouseWheelScrollPage) |
2145 | else if (option (Opt_mouseWheelScrollPage)) |
2077 | i = nrow - 1; |
2146 | i = nrow - 1; |
2078 | else |
2147 | else |
2079 | i = 5; |
2148 | i = 5; |
2080 | |
2149 | |
2081 | # ifdef MOUSE_SLIP_WHEELING |
2150 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2083 | { |
2152 | { |
2084 | mouse_slip_wheel_speed += v ? -1 : 1; |
2153 | mouse_slip_wheel_speed += v ? -1 : 1; |
2085 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2154 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2086 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2155 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2087 | |
2156 | |
2088 | if (slip_wheel_ev.at < NOW) |
2157 | if (!slip_wheel_ev.is_active ()) |
2089 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2158 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2090 | |
|
|
2091 | slip_wheel_ev.start (); |
|
|
2092 | } |
2159 | } |
2093 | else |
2160 | else |
|
|
2161 | # endif |
2094 | { |
2162 | { |
2095 | # endif |
|
|
2096 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2097 | scr_page (v, i); |
2163 | scr_page (v, i); |
2098 | scr_refresh (SMOOTH_REFRESH); |
|
|
2099 | scrollbar_show (1); |
2164 | scrollbar_show (1); |
2100 | # else |
|
|
2101 | while (i--) |
|
|
2102 | { |
|
|
2103 | scr_page (v, 1); |
|
|
2104 | scr_refresh (SMOOTH_REFRESH); |
|
|
2105 | scrollbar_show (1); |
|
|
2106 | } |
|
|
2107 | # endif |
|
|
2108 | # ifdef MOUSE_SLIP_WHEELING |
|
|
2109 | } |
2165 | } |
2110 | #endif |
|
|
2111 | } |
2166 | } |
2112 | break; |
2167 | break; |
2113 | #endif |
2168 | #endif |
2114 | } |
2169 | } |
2115 | } |
2170 | } |
2116 | #ifdef MENUBAR |
|
|
2117 | else if (isMenuBarWindow (ev.window)) |
|
|
2118 | menubar_control (ev); |
|
|
2119 | #endif |
|
|
2120 | } |
2171 | } |
2121 | |
|
|
2122 | #ifdef TRANSPARENT |
|
|
2123 | #if TINTING |
|
|
2124 | /* taken from aterm-0.4.2 */ |
|
|
2125 | |
|
|
2126 | typedef uint32_t RUINT32T; |
|
|
2127 | |
|
|
2128 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2129 | { |
|
|
2130 | int sh_r, sh_g, sh_b; |
|
|
2131 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2132 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2133 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2134 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2135 | int i; |
|
|
2136 | |
|
|
2137 | Visual *visual = display->visual; |
|
|
2138 | |
|
|
2139 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2140 | |
|
|
2141 | /* for convenience */ |
|
|
2142 | mask_r = visual->red_mask; |
|
|
2143 | mask_g = visual->green_mask; |
|
|
2144 | mask_b = visual->blue_mask; |
|
|
2145 | |
|
|
2146 | /* boring lookup table pre-initialization */ |
|
|
2147 | switch (srcImage->bits_per_pixel) { |
|
|
2148 | case 15: |
|
|
2149 | if ((mask_r != 0x7c00) || |
|
|
2150 | (mask_g != 0x03e0) || |
|
|
2151 | (mask_b != 0x001f)) |
|
|
2152 | return; |
|
|
2153 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2154 | lookup_r = lookup; |
|
|
2155 | lookup_g = lookup+32; |
|
|
2156 | lookup_b = lookup+32+32; |
|
|
2157 | sh_r = 10; |
|
|
2158 | sh_g = 5; |
|
|
2159 | sh_b = 0; |
|
|
2160 | break; |
|
|
2161 | case 16: |
|
|
2162 | if ((mask_r != 0xf800) || |
|
|
2163 | (mask_g != 0x07e0) || |
|
|
2164 | (mask_b != 0x001f)) |
|
|
2165 | return; |
|
|
2166 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2167 | lookup_r = lookup; |
|
|
2168 | lookup_g = lookup+32; |
|
|
2169 | lookup_b = lookup+32+64; |
|
|
2170 | sh_r = 11; |
|
|
2171 | sh_g = 5; |
|
|
2172 | sh_b = 0; |
|
|
2173 | break; |
|
|
2174 | case 24: |
|
|
2175 | if ((mask_r != 0xff0000) || |
|
|
2176 | (mask_g != 0x00ff00) || |
|
|
2177 | (mask_b != 0x0000ff)) |
|
|
2178 | return; |
|
|
2179 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2180 | lookup_r = lookup; |
|
|
2181 | lookup_g = lookup+256; |
|
|
2182 | lookup_b = lookup+256+256; |
|
|
2183 | sh_r = 16; |
|
|
2184 | sh_g = 8; |
|
|
2185 | sh_b = 0; |
|
|
2186 | break; |
|
|
2187 | case 32: |
|
|
2188 | if ((mask_r != 0xff0000) || |
|
|
2189 | (mask_g != 0x00ff00) || |
|
|
2190 | (mask_b != 0x0000ff)) |
|
|
2191 | return; |
|
|
2192 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2193 | lookup_r = lookup; |
|
|
2194 | lookup_g = lookup+256; |
|
|
2195 | lookup_b = lookup+256+256; |
|
|
2196 | sh_r = 16; |
|
|
2197 | sh_g = 8; |
|
|
2198 | sh_b = 0; |
|
|
2199 | break; |
|
|
2200 | default: |
|
|
2201 | return; /* we do not support this color depth */ |
|
|
2202 | } |
|
|
2203 | |
|
|
2204 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2205 | if (shade < 0) { |
|
|
2206 | shade = -shade; |
|
|
2207 | if (shade < 0) shade = 0; |
|
|
2208 | if (shade > 100) shade = 100; |
|
|
2209 | |
|
|
2210 | lower_lim_r = 65535-rm; |
|
|
2211 | lower_lim_g = 65535-gm; |
|
|
2212 | lower_lim_b = 65535-bm; |
|
|
2213 | |
|
|
2214 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2215 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2216 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2217 | |
|
|
2218 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2219 | } else { |
|
|
2220 | if (shade < 0) shade = 0; |
|
|
2221 | if (shade > 100) shade = 100; |
|
|
2222 | |
|
|
2223 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2224 | |
|
|
2225 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2226 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2227 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2228 | } |
|
|
2229 | |
|
|
2230 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2231 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2232 | { |
|
|
2233 | unsigned int tmp; |
|
|
2234 | |
|
|
2235 | tmp = lower_lim_r; |
|
|
2236 | lower_lim_r = lower_lim_b; |
|
|
2237 | lower_lim_b = tmp; |
|
|
2238 | |
|
|
2239 | tmp = upper_lim_r; |
|
|
2240 | upper_lim_r = upper_lim_b; |
|
|
2241 | upper_lim_b = tmp; |
|
|
2242 | } |
|
|
2243 | |
|
|
2244 | /* fill our lookup tables */ |
|
|
2245 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2246 | { |
|
|
2247 | RUINT32T tmp; |
|
|
2248 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2249 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2250 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2251 | } |
|
|
2252 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2253 | { |
|
|
2254 | RUINT32T tmp; |
|
|
2255 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2256 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2257 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2258 | } |
|
|
2259 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2260 | { |
|
|
2261 | RUINT32T tmp; |
|
|
2262 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2263 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2264 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2265 | } |
|
|
2266 | |
|
|
2267 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2268 | switch (srcImage->bits_per_pixel) |
|
|
2269 | { |
|
|
2270 | case 15: |
|
|
2271 | { |
|
|
2272 | unsigned short *p1, *pf, *p, *pl; |
|
|
2273 | p1 = (unsigned short *) srcImage->data; |
|
|
2274 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2275 | while (p1 < pf) |
|
|
2276 | { |
|
|
2277 | p = p1; |
|
|
2278 | pl = p1 + srcImage->width; |
|
|
2279 | for (; p < pl; p++) |
|
|
2280 | { |
|
|
2281 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2282 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2283 | lookup_b[(*p & 0x001f)]; |
|
|
2284 | } |
|
|
2285 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2286 | } |
|
|
2287 | break; |
|
|
2288 | } |
|
|
2289 | case 16: |
|
|
2290 | { |
|
|
2291 | unsigned short *p1, *pf, *p, *pl; |
|
|
2292 | p1 = (unsigned short *) srcImage->data; |
|
|
2293 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2294 | while (p1 < pf) |
|
|
2295 | { |
|
|
2296 | p = p1; |
|
|
2297 | pl = p1 + srcImage->width; |
|
|
2298 | for (; p < pl; p++) |
|
|
2299 | { |
|
|
2300 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2301 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2302 | lookup_b[(*p & 0x001f)]; |
|
|
2303 | } |
|
|
2304 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2305 | } |
|
|
2306 | break; |
|
|
2307 | } |
|
|
2308 | case 24: |
|
|
2309 | { |
|
|
2310 | unsigned char *p1, *pf, *p, *pl; |
|
|
2311 | p1 = (unsigned char *) srcImage->data; |
|
|
2312 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2313 | while (p1 < pf) |
|
|
2314 | { |
|
|
2315 | p = p1; |
|
|
2316 | pl = p1 + srcImage->width * 3; |
|
|
2317 | for (; p < pl; p += 3) |
|
|
2318 | { |
|
|
2319 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2320 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2321 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2322 | } |
|
|
2323 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2324 | } |
|
|
2325 | break; |
|
|
2326 | } |
|
|
2327 | case 32: |
|
|
2328 | { |
|
|
2329 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2330 | p1 = (RUINT32T *) srcImage->data; |
|
|
2331 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2332 | |
|
|
2333 | while (p1 < pf) |
|
|
2334 | { |
|
|
2335 | p = p1; |
|
|
2336 | pl = p1 + srcImage->width; |
|
|
2337 | for (; p < pl; p++) |
|
|
2338 | { |
|
|
2339 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2340 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2341 | lookup_b[(*p & 0x0000ff)] | |
|
|
2342 | (*p & ~0xffffff); |
|
|
2343 | } |
|
|
2344 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2345 | } |
|
|
2346 | break; |
|
|
2347 | } |
|
|
2348 | } |
|
|
2349 | |
|
|
2350 | free (lookup); |
|
|
2351 | } |
|
|
2352 | #endif |
|
|
2353 | |
|
|
2354 | /* |
|
|
2355 | * Check our parents are still who we think they are. |
|
|
2356 | * Do transparency updates if required |
|
|
2357 | */ |
|
|
2358 | int |
|
|
2359 | rxvt_term::check_our_parents () |
|
|
2360 | { |
|
|
2361 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2362 | unsigned long nitems, bytes_after; |
|
|
2363 | Atom atype; |
|
|
2364 | unsigned char *prop = NULL; |
|
|
2365 | Window root, oldp, *list; |
|
|
2366 | Pixmap rootpixmap = None; |
|
|
2367 | XWindowAttributes wattr, wrootattr; |
|
|
2368 | dDisp; |
|
|
2369 | |
|
|
2370 | pchanged = 0; |
|
|
2371 | |
|
|
2372 | if (!(options & Opt_transparent)) |
|
|
2373 | return pchanged; /* Don't try any more */ |
|
|
2374 | |
|
|
2375 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2376 | rootdepth = wrootattr.depth; |
|
|
2377 | |
|
|
2378 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2379 | |
|
|
2380 | if (rootdepth != wattr.depth) |
|
|
2381 | { |
|
|
2382 | if (am_transparent) |
|
|
2383 | { |
|
|
2384 | pchanged = 1; |
|
|
2385 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2386 | am_transparent = am_pixmap_trans = 0; |
|
|
2387 | } |
|
|
2388 | |
|
|
2389 | return pchanged; /* Don't try any more */ |
|
|
2390 | } |
|
|
2391 | |
|
|
2392 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2393 | XSync (disp, False); |
|
|
2394 | |
|
|
2395 | /* |
|
|
2396 | * Make the frame window set by the window manager have |
|
|
2397 | * the root background. Some window managers put multiple nested frame |
|
|
2398 | * windows for each client, so we have to take care about that. |
|
|
2399 | */ |
|
|
2400 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2401 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2402 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2403 | &nitems, &bytes_after, &prop) == Success); |
|
|
2404 | |
|
|
2405 | if (!i || prop == NULL) |
|
|
2406 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2407 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2408 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2409 | &nitems, &bytes_after, &prop) == Success); |
|
|
2410 | |
|
|
2411 | if (!i || prop == NULL |
|
|
2412 | #if TINTING |
|
|
2413 | || !rs[Rs_color + Color_tint] |
|
|
2414 | #endif |
|
|
2415 | ) |
|
|
2416 | have_pixmap = 0; |
|
|
2417 | else |
|
|
2418 | { |
|
|
2419 | have_pixmap = 1; |
|
|
2420 | rootpixmap = *(Pixmap *)prop; |
|
|
2421 | XFree (prop); |
|
|
2422 | } |
|
|
2423 | |
|
|
2424 | if (have_pixmap) |
|
|
2425 | { |
|
|
2426 | /* |
|
|
2427 | * Copy display->root pixmap transparency |
|
|
2428 | */ |
|
|
2429 | int sx, sy, nx, ny; |
|
|
2430 | unsigned int nw, nh; |
|
|
2431 | Window cr; |
|
|
2432 | XImage *image; |
|
|
2433 | GC gc; |
|
|
2434 | XGCValues gcvalue; |
|
|
2435 | |
|
|
2436 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2437 | 0, 0, &sx, &sy, &cr); |
|
|
2438 | nw = (unsigned int)szHint.width; |
|
|
2439 | nh = (unsigned int)szHint.height; |
|
|
2440 | nx = ny = 0; |
|
|
2441 | |
|
|
2442 | if (sx < 0) |
|
|
2443 | { |
|
|
2444 | nw += sx; |
|
|
2445 | nx = -sx; |
|
|
2446 | sx = 0; |
|
|
2447 | } |
|
|
2448 | |
|
|
2449 | if (sy < 0) |
|
|
2450 | { |
|
|
2451 | nh += sy; |
|
|
2452 | ny = -sy; |
|
|
2453 | sy = 0; |
|
|
2454 | } |
|
|
2455 | |
|
|
2456 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2457 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2458 | |
|
|
2459 | XSync (disp, False); |
|
|
2460 | allowedxerror = -1; |
|
|
2461 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2462 | |
|
|
2463 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2464 | /* XXX: may need a delay here? */ |
|
|
2465 | allowedxerror = 0; |
|
|
2466 | |
|
|
2467 | if (image == NULL) |
|
|
2468 | { |
|
|
2469 | if (am_transparent && am_pixmap_trans) |
|
|
2470 | { |
|
|
2471 | pchanged = 1; |
|
|
2472 | if (pixmap != None) |
|
|
2473 | { |
|
|
2474 | XFreePixmap (disp, pixmap); |
|
|
2475 | pixmap = None; |
|
|
2476 | } |
|
|
2477 | } |
|
|
2478 | |
|
|
2479 | am_pixmap_trans = 0; |
|
|
2480 | } |
|
|
2481 | else |
|
|
2482 | { |
|
|
2483 | if (pixmap != None) |
|
|
2484 | XFreePixmap (disp, pixmap); |
|
|
2485 | |
|
|
2486 | #if TINTING |
|
|
2487 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2488 | { |
|
|
2489 | unsigned short rm, gm, bm; |
|
|
2490 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2491 | |
|
|
2492 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2493 | |
|
|
2494 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2495 | } |
|
|
2496 | #endif |
|
|
2497 | |
|
|
2498 | pixmap = XCreatePixmap (disp, vt, |
|
|
2499 | szHint.width, szHint.height, image->depth); |
|
|
2500 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2501 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2502 | nx, ny, image->width, image->height); |
|
|
2503 | XFreeGC (disp, gc); |
|
|
2504 | XDestroyImage (image); |
|
|
2505 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2506 | XClearWindow (disp, parent[0]); |
|
|
2507 | |
|
|
2508 | if (!am_transparent || !am_pixmap_trans) |
|
|
2509 | pchanged = 1; |
|
|
2510 | |
|
|
2511 | am_transparent = am_pixmap_trans = 1; |
|
|
2512 | } |
|
|
2513 | } |
|
|
2514 | |
|
|
2515 | if (am_pixmap_trans) |
|
|
2516 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2517 | else |
|
|
2518 | { |
|
|
2519 | unsigned int n; |
|
|
2520 | /* |
|
|
2521 | * InheritPixmap transparency |
|
|
2522 | */ |
|
|
2523 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2524 | { |
|
|
2525 | oldp = parent[i]; |
|
|
2526 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2527 | &parent[i], &list, &n); |
|
|
2528 | XFree (list); |
|
|
2529 | |
|
|
2530 | if (parent[i] == display->root) |
|
|
2531 | { |
|
|
2532 | if (oldp != None) |
|
|
2533 | pchanged = 1; |
|
|
2534 | |
|
|
2535 | break; |
|
|
2536 | } |
|
|
2537 | |
|
|
2538 | if (oldp != parent[i]) |
|
|
2539 | pchanged = 1; |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | n = 0; |
|
|
2543 | |
|
|
2544 | if (pchanged) |
|
|
2545 | { |
|
|
2546 | for (; n < (unsigned int)i; n++) |
|
|
2547 | { |
|
|
2548 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2549 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2550 | { |
|
|
2551 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2552 | break; |
|
|
2553 | } |
|
|
2554 | } |
|
|
2555 | } |
|
|
2556 | |
|
|
2557 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2558 | { |
|
|
2559 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2560 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2561 | am_transparent = 0; |
|
|
2562 | /* XXX: also turn off Opt_transparent? */ |
|
|
2563 | } |
|
|
2564 | else |
|
|
2565 | { |
|
|
2566 | #if WAIT_FOR_WM |
|
|
2567 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2568 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2569 | sleep (1); |
|
|
2570 | #endif |
|
|
2571 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2572 | { |
|
|
2573 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2574 | XClearWindow (disp, parent[n]); |
|
|
2575 | } |
|
|
2576 | |
|
|
2577 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2578 | am_transparent = 1; |
|
|
2579 | } |
|
|
2580 | |
|
|
2581 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2582 | parent[i] = None; |
|
|
2583 | } |
|
|
2584 | |
|
|
2585 | if (scrollBar.win) |
|
|
2586 | { |
|
|
2587 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2588 | scrollBar.setIdle (); |
|
|
2589 | scrollbar_show (0); |
|
|
2590 | } |
|
|
2591 | |
|
|
2592 | if (am_transparent) |
|
|
2593 | { |
|
|
2594 | want_refresh = want_full_refresh = 1; |
|
|
2595 | if (am_pixmap_trans) |
|
|
2596 | flush (); |
|
|
2597 | } |
|
|
2598 | |
|
|
2599 | return pchanged; |
|
|
2600 | } |
|
|
2601 | #endif |
|
|
2602 | |
2172 | |
2603 | /*}}} */ |
2173 | /*}}} */ |
2604 | |
2174 | |
2605 | bool |
2175 | bool |
2606 | rxvt_term::cmd_parse () |
2176 | rxvt_term::cmd_parse () |
2607 | { |
2177 | { |
2608 | bool flag = false; |
2178 | bool flag = false; |
2609 | unicode_t ch = NOCHAR; |
2179 | wchar_t ch = NOCHAR; |
2610 | unsigned char *seq_begin; // remember start of esc-sequence here |
2180 | char *seq_begin; // remember start of esc-sequence here |
2611 | |
2181 | |
2612 | for (;;) |
2182 | for (;;) |
2613 | { |
2183 | { |
2614 | if (ch == NOCHAR) |
2184 | if (ch == NOCHAR) |
2615 | { |
2185 | { |
2616 | seq_begin = cmdbuf_ptr; |
2186 | seq_begin = cmdbuf_ptr; |
2617 | ch = next_char (); |
2187 | ch = next_char (); |
2618 | } |
|
|
2619 | |
2188 | |
2620 | if (ch == NOCHAR) // TODO: improve |
2189 | if (ch == NOCHAR) |
2621 | break; |
2190 | break; |
|
|
2191 | } |
2622 | |
2192 | |
2623 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2193 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2624 | { |
2194 | { |
2625 | if (!seen_input) |
2195 | if (!seen_input) |
2626 | { |
2196 | { |
… | |
… | |
2635 | if (seen_resize && cmd_pid) |
2205 | if (seen_resize && cmd_pid) |
2636 | kill (-cmd_pid, SIGWINCH); |
2206 | kill (-cmd_pid, SIGWINCH); |
2637 | } |
2207 | } |
2638 | |
2208 | |
2639 | /* Read a text string from the input buffer */ |
2209 | /* Read a text string from the input buffer */ |
2640 | unicode_t buf[UBUFSIZ]; |
2210 | wchar_t buf[UBUFSIZ]; |
2641 | bool refreshnow = false; |
2211 | bool refreshnow = false; |
2642 | int nlines = 0; |
2212 | int nlines = 0; |
2643 | unicode_t *str = buf; |
2213 | wchar_t *str = buf; |
2644 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2214 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2645 | |
2215 | |
2646 | for (;;) |
2216 | for (;;) |
2647 | { |
2217 | { |
2648 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2218 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2649 | break; |
2219 | break; |
… | |
… | |
2655 | if (ch == C0_LF) |
2225 | if (ch == C0_LF) |
2656 | nlines++; |
2226 | nlines++; |
2657 | |
2227 | |
2658 | refresh_count++; |
2228 | refresh_count++; |
2659 | |
2229 | |
2660 | if (!(options & Opt_jumpScroll) |
2230 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2661 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2662 | { |
2231 | { |
|
|
2232 | refresh_count = 0; |
|
|
2233 | |
|
|
2234 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2235 | { |
2663 | refreshnow = true; |
2236 | refreshnow = true; |
2664 | ch = NOCHAR; |
2237 | ch = NOCHAR; |
2665 | break; |
2238 | break; |
|
|
2239 | } |
2666 | } |
2240 | } |
2667 | |
2241 | |
2668 | // scr_add_lines only works for nlines <= nrow - 1. |
2242 | // scr_add_lines only works for nlines <= nrow - 1. |
2669 | if (nlines >= nrow - 1) |
2243 | if (nlines >= nrow - 1) |
2670 | { |
2244 | { |
|
|
2245 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2246 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2671 | scr_add_lines (buf, nlines, str - buf); |
2247 | scr_add_lines (buf, str - buf, nlines); |
|
|
2248 | |
2672 | nlines = 0; |
2249 | nlines = 0; |
2673 | str = buf; |
2250 | str = buf; |
2674 | eol = str + min (ncol, UBUFSIZ); |
2251 | eol = str + min (ncol, UBUFSIZ); |
2675 | } |
2252 | } |
2676 | |
2253 | |
… | |
… | |
2689 | |
2266 | |
2690 | seq_begin = cmdbuf_ptr; |
2267 | seq_begin = cmdbuf_ptr; |
2691 | ch = next_char (); |
2268 | ch = next_char (); |
2692 | } |
2269 | } |
2693 | |
2270 | |
|
|
2271 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2272 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2694 | scr_add_lines (buf, nlines, str - buf); |
2273 | scr_add_lines (buf, str - buf, nlines); |
2695 | |
2274 | |
2696 | /* |
2275 | /* |
2697 | * If there have been a lot of new lines, then update the screen |
2276 | * If there have been a lot of new lines, then update the screen |
2698 | * What the heck I'll cheat and only refresh less than every page-full. |
2277 | * What the heck we'll cheat and only refresh less than every page-full. |
2699 | * the number of pages between refreshes is refresh_limit, which |
2278 | * if skipScroll is enabled. |
2700 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2701 | */ |
2279 | */ |
2702 | if (refreshnow) |
2280 | if (refreshnow) |
2703 | { |
2281 | { |
2704 | if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2705 | refresh_limit++; |
|
|
2706 | else |
|
|
2707 | { |
|
|
2708 | flag = true; |
2282 | flag = true; |
2709 | scr_refresh (refresh_type); |
2283 | scr_refresh (); |
2710 | } |
2284 | want_refresh = 1; |
2711 | } |
2285 | } |
2712 | |
2286 | |
2713 | } |
2287 | } |
2714 | else |
2288 | else |
2715 | { |
2289 | { |
… | |
… | |
2729 | } |
2303 | } |
2730 | |
2304 | |
2731 | return flag; |
2305 | return flag; |
2732 | } |
2306 | } |
2733 | |
2307 | |
2734 | // read the next octet |
|
|
2735 | unicode_t |
|
|
2736 | rxvt_term::next_octet () |
|
|
2737 | { |
|
|
2738 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2739 | ? *cmdbuf_ptr++ |
|
|
2740 | : NOCHAR; |
|
|
2741 | } |
|
|
2742 | |
|
|
2743 | // read the next character |
2308 | // read the next character |
2744 | unicode_t |
2309 | wchar_t |
2745 | rxvt_term::next_char () |
2310 | rxvt_term::next_char () NOTHROW |
2746 | { |
2311 | { |
2747 | while (cmdbuf_ptr < cmdbuf_endp) |
2312 | while (cmdbuf_ptr < cmdbuf_endp) |
2748 | { |
2313 | { |
2749 | // assume 7-bit to be ascii ALWAYS |
2314 | // assume 7-bit to be ascii ALWAYS |
2750 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2315 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2751 | return *cmdbuf_ptr++; |
2316 | return *cmdbuf_ptr++; |
2752 | |
2317 | |
2753 | wchar_t wc; |
2318 | wchar_t wc; |
2754 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2319 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2755 | |
2320 | |
2756 | if (len == (size_t)-2) |
2321 | if (len == (size_t)-2) |
2757 | { |
2322 | { |
2758 | // the mbstate stores incomplete sequences. didn't know this :/ |
2323 | // the mbstate stores incomplete sequences. didn't know this :/ |
2759 | cmdbuf_ptr = cmdbuf_endp; |
2324 | cmdbuf_ptr = cmdbuf_endp; |
2760 | break; |
2325 | break; |
2761 | } |
2326 | } |
2762 | |
2327 | |
2763 | if (len == (size_t)-1) |
2328 | if (len == (size_t)-1) |
2764 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2329 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2765 | |
2330 | |
2766 | // assume wchar == unicode |
2331 | // assume wchar == unicode |
2767 | cmdbuf_ptr += len; |
2332 | cmdbuf_ptr += len; |
2768 | return wc & UNICODE_MASK; |
2333 | return wc & UNICODE_MASK; |
2769 | } |
2334 | } |
2770 | |
2335 | |
2771 | return NOCHAR; |
2336 | return NOCHAR; |
2772 | } |
2337 | } |
|
|
2338 | |
|
|
2339 | // read the next octet |
|
|
2340 | uint32_t |
|
|
2341 | rxvt_term::next_octet () NOTHROW |
|
|
2342 | { |
|
|
2343 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2344 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2345 | : NOCHAR; |
|
|
2346 | } |
|
|
2347 | |
|
|
2348 | static class out_of_input out_of_input; |
2773 | |
2349 | |
2774 | /* rxvt_cmd_getc () - Return next input character */ |
2350 | /* rxvt_cmd_getc () - Return next input character */ |
2775 | /* |
2351 | /* |
2776 | * Return the next input character after first passing any keyboard input |
2352 | * Return the next input character after first passing any keyboard input |
2777 | * to the command. |
2353 | * to the command. |
2778 | */ |
2354 | */ |
2779 | unicode_t |
2355 | wchar_t |
2780 | rxvt_term::cmd_getc () |
2356 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2781 | { |
2357 | { |
2782 | unicode_t c = next_char (); |
2358 | wchar_t c = next_char (); |
2783 | |
2359 | |
2784 | if (c == NOCHAR) |
2360 | if (c == NOCHAR) |
2785 | throw out_of_input; |
2361 | throw out_of_input; |
2786 | |
2362 | |
2787 | return c; |
2363 | return c; |
2788 | } |
2364 | } |
2789 | |
2365 | |
2790 | unicode_t |
2366 | uint32_t |
2791 | rxvt_term::cmd_get8 () |
2367 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2792 | { |
2368 | { |
2793 | unicode_t c = next_octet (); |
2369 | uint32_t c = next_octet (); |
2794 | |
2370 | |
2795 | if (c == NOCHAR) |
2371 | if (c == NOCHAR) |
2796 | throw out_of_input; |
2372 | throw out_of_input; |
2797 | |
2373 | |
2798 | return c; |
2374 | return c; |
… | |
… | |
2862 | { |
2438 | { |
2863 | if ((buf[len++] = cmd_getc ()) == 'i') |
2439 | if ((buf[len++] = cmd_getc ()) == 'i') |
2864 | break; /* done = 1 */ |
2440 | break; /* done = 1 */ |
2865 | } |
2441 | } |
2866 | } |
2442 | } |
2867 | |
2443 | |
2868 | for (i = 0; i < len; i++) |
2444 | for (i = 0; i < len; i++) |
2869 | if (putc (buf[i], fd) == EOF) |
2445 | if (putc (buf[i], fd) == EOF) |
2870 | { |
2446 | { |
2871 | done = 1; |
2447 | done = 1; |
2872 | break; |
2448 | break; |
… | |
… | |
2874 | } |
2450 | } |
2875 | } |
2451 | } |
2876 | |
2452 | |
2877 | pclose_printer (fd); |
2453 | pclose_printer (fd); |
2878 | } |
2454 | } |
2879 | #endif /* PRINTPIPE */ |
2455 | #endif /* PRINTPIPE */ |
2880 | /*}}} */ |
2456 | /*}}} */ |
2881 | |
2457 | |
2882 | /* *INDENT-OFF* */ |
2458 | /* *INDENT-OFF* */ |
2883 | enum { |
2459 | enum { |
2884 | C1_40 = 0x40, |
2460 | C1_40 = 0x40, |
… | |
… | |
2898 | case C0_ESC: |
2474 | case C0_ESC: |
2899 | process_escape_seq (); |
2475 | process_escape_seq (); |
2900 | break; |
2476 | break; |
2901 | case C0_ENQ: /* terminal Status */ |
2477 | case C0_ENQ: /* terminal Status */ |
2902 | if (rs[Rs_answerbackstring]) |
2478 | if (rs[Rs_answerbackstring]) |
2903 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2479 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2904 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2905 | else |
2480 | else |
2906 | tt_write ((unsigned char *)VT100_ANS, |
2481 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2907 | (unsigned int)strlen (VT100_ANS)); |
|
|
2908 | break; |
2482 | break; |
2909 | case C0_BEL: /* bell */ |
2483 | case C0_BEL: /* bell */ |
2910 | scr_bell (); |
2484 | scr_bell (); |
2911 | break; |
2485 | break; |
2912 | case C0_BS: /* backspace */ |
2486 | case C0_BS: /* backspace */ |
… | |
… | |
2936 | process_dcs_seq (); |
2510 | process_dcs_seq (); |
2937 | break; |
2511 | break; |
2938 | case 0x9b: /* CSI */ |
2512 | case 0x9b: /* CSI */ |
2939 | process_csi_seq (); |
2513 | process_csi_seq (); |
2940 | break; |
2514 | break; |
2941 | case 0x9d: /* CSI */ |
2515 | case 0x9d: /* OSC */ |
2942 | process_osc_seq (); |
2516 | process_osc_seq (); |
2943 | break; |
2517 | break; |
2944 | #endif |
2518 | #endif |
2945 | } |
2519 | } |
2946 | } |
2520 | } |
… | |
… | |
2990 | break; |
2564 | break; |
2991 | case 'Z': /* identify the terminal type */ |
2565 | case 'Z': /* identify the terminal type */ |
2992 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2566 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2993 | break; |
2567 | break; |
2994 | case '<': /* turn off VT52 mode */ |
2568 | case '<': /* turn off VT52 mode */ |
2995 | PrivMode (0, PrivMode_vt52); |
2569 | set_privmode (PrivMode_vt52, 0); |
2996 | break; |
2570 | break; |
2997 | case 'F': /* use special graphics character set */ |
2571 | case 'F': /* use special graphics character set */ |
2998 | case 'G': /* use regular character set */ |
2572 | case 'G': /* use regular character set */ |
2999 | /* unimplemented */ |
2573 | /* unimplemented */ |
3000 | break; |
2574 | break; |
… | |
… | |
3036 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2610 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3037 | break; |
2611 | break; |
3038 | case '+': |
2612 | case '+': |
3039 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2613 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3040 | break; |
2614 | break; |
3041 | #if ENABLE_FRILLS |
2615 | #if !ENABLE_MINIMAL |
3042 | case '6': |
2616 | case '6': |
3043 | scr_backindex (); |
2617 | scr_backindex (); |
3044 | break; |
2618 | break; |
3045 | #endif |
2619 | #endif |
3046 | case '7': |
2620 | case '7': |
3047 | scr_cursor (SAVE); |
2621 | scr_cursor (SAVE); |
3048 | break; |
2622 | break; |
3049 | case '8': |
2623 | case '8': |
3050 | scr_cursor (RESTORE); |
2624 | scr_cursor (RESTORE); |
3051 | break; |
2625 | break; |
3052 | #if ENABLE_FRILLS |
2626 | #if !ENABLE_MINIMAL |
3053 | case '9': |
2627 | case '9': |
3054 | scr_forwardindex (); |
2628 | scr_forwardindex (); |
3055 | break; |
2629 | break; |
3056 | #endif |
2630 | #endif |
3057 | case '=': |
2631 | case '=': |
3058 | case '>': |
2632 | case '>': |
3059 | PrivMode ((ch == '='), PrivMode_aplKP); |
2633 | set_privmode (PrivMode_aplKP, ch == '='); |
3060 | break; |
2634 | break; |
3061 | |
2635 | |
3062 | case C1_40: |
2636 | case C1_40: |
3063 | cmd_getc (); |
2637 | cmd_getc (); |
3064 | break; |
2638 | break; |
… | |
… | |
3067 | break; |
2641 | break; |
3068 | |
2642 | |
3069 | /* 8.3.87: NEXT LINE */ |
2643 | /* 8.3.87: NEXT LINE */ |
3070 | case C1_NEL: /* ESC E */ |
2644 | case C1_NEL: /* ESC E */ |
3071 | { |
2645 | { |
3072 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2646 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3073 | scr_add_lines (nlcr, 1, 2); |
2647 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3074 | } |
2648 | } |
3075 | break; |
2649 | break; |
3076 | |
2650 | |
3077 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2651 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3078 | case C1_ESA: /* ESC G */ |
2652 | case C1_ESA: /* ESC G */ |
… | |
… | |
3100 | process_dcs_seq (); |
2674 | process_dcs_seq (); |
3101 | break; |
2675 | break; |
3102 | |
2676 | |
3103 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2677 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3104 | case C1_SCI: /* ESC Z */ |
2678 | case C1_SCI: /* ESC Z */ |
3105 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
2679 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3106 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3107 | break; /* steal obsolete ESC [ c */ |
2680 | break; /* steal obsolete ESC [ c */ |
3108 | |
2681 | |
3109 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2682 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3110 | case C1_CSI: /* ESC [ */ |
2683 | case C1_CSI: /* ESC [ */ |
3111 | process_csi_seq (); |
2684 | process_csi_seq (); |
… | |
… | |
3173 | rxvt_term::process_csi_seq () |
2746 | rxvt_term::process_csi_seq () |
3174 | { |
2747 | { |
3175 | unicode_t ch, priv, i; |
2748 | unicode_t ch, priv, i; |
3176 | unsigned int nargs, p; |
2749 | unsigned int nargs, p; |
3177 | int n, ndef; |
2750 | int n, ndef; |
3178 | int arg[ESC_ARGS]; |
2751 | int arg[ESC_ARGS] = { }; |
3179 | |
2752 | |
3180 | for (nargs = ESC_ARGS; nargs > 0;) |
2753 | nargs = 0; |
3181 | arg[--nargs] = 0; |
|
|
3182 | |
2754 | |
3183 | priv = 0; |
2755 | priv = 0; |
3184 | ch = cmd_getc (); |
2756 | ch = cmd_getc (); |
3185 | if (ch >= '<' && ch <= '?') |
2757 | if (ch >= '<' && ch <= '?') |
|
|
2758 | { |
3186 | { /* '<' '=' '>' '?' */ |
2759 | /* '<' '=' '>' '?' */ |
3187 | priv = ch; |
2760 | priv = ch; |
3188 | ch = cmd_getc (); |
2761 | ch = cmd_getc (); |
3189 | } |
2762 | } |
3190 | |
2763 | |
3191 | /* read any numerical arguments */ |
2764 | /* read any numerical arguments */ |
… | |
… | |
3220 | ndef = get_byte_array_bit (csi_defaults, i); |
2793 | ndef = get_byte_array_bit (csi_defaults, i); |
3221 | for (p = 0; p < nargs; p++) |
2794 | for (p = 0; p < nargs; p++) |
3222 | if (arg[p] == -1) |
2795 | if (arg[p] == -1) |
3223 | arg[p] = ndef; |
2796 | arg[p] = ndef; |
3224 | |
2797 | |
3225 | #ifdef DEBUG_CMD |
|
|
3226 | fprintf (stderr, "CSI "); |
|
|
3227 | for (p = 0; p < nargs; p++) |
|
|
3228 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3229 | fprintf (stderr, "%c\n", ch); |
|
|
3230 | #endif |
|
|
3231 | |
|
|
3232 | /* |
2798 | /* |
3233 | * private mode handling |
2799 | * private mode handling |
3234 | */ |
2800 | */ |
3235 | if (priv) |
2801 | if (priv) |
3236 | { |
2802 | { |
3237 | switch (priv) |
2803 | switch (priv) |
3238 | { |
2804 | { |
3239 | case '>': |
2805 | case '>': |
3240 | if (ch == CSI_DA) /* secondary device attributes */ |
2806 | if (ch == CSI_DA) /* secondary device attributes */ |
3241 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2807 | { |
|
|
2808 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2809 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2810 | // |
|
|
2811 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2812 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
|
|
2813 | // versions. |
|
|
2814 | // |
|
|
2815 | tt_printf ("\033[>%d;95;0c", 'U'); |
|
|
2816 | } |
3242 | break; |
2817 | break; |
|
|
2818 | |
3243 | case '?': |
2819 | case '?': |
3244 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2820 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3245 | process_terminal_mode (ch, priv, nargs, arg); |
2821 | process_terminal_mode (ch, priv, nargs, arg); |
3246 | break; |
2822 | break; |
3247 | } |
2823 | } |
… | |
… | |
3355 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
2931 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3356 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
2932 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3357 | break; |
2933 | break; |
3358 | |
2934 | |
3359 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
2935 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3360 | tt_write ((const unsigned char *)VT100_ANS, |
2936 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3361 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3362 | break; |
2937 | break; |
3363 | |
2938 | |
3364 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
2939 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3365 | process_sgr_mode (nargs, arg); |
2940 | process_sgr_mode (nargs, arg); |
3366 | break; |
2941 | break; |
… | |
… | |
3373 | break; |
2948 | break; |
3374 | case 6: /* CPR requested */ |
2949 | case 6: /* CPR requested */ |
3375 | scr_report_position (); |
2950 | scr_report_position (); |
3376 | break; |
2951 | break; |
3377 | case 7: /* unofficial extension */ |
2952 | case 7: /* unofficial extension */ |
3378 | if (options & Opt_insecure) |
2953 | if (option (Opt_insecure)) |
3379 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
2954 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3380 | break; |
2955 | break; |
3381 | case 8: /* unofficial extension */ |
2956 | case 8: /* unofficial extension */ |
3382 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2957 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3383 | break; |
2958 | break; |
… | |
… | |
3450 | break; |
3025 | break; |
3451 | case CSI_75: |
3026 | case CSI_75: |
3452 | scr_cursor (RESTORE); |
3027 | scr_cursor (RESTORE); |
3453 | break; |
3028 | break; |
3454 | |
3029 | |
3455 | #if ENABLE_FRILLS |
3030 | #if !ENABLE_MINIMAL |
3456 | case CSI_74: |
3031 | case CSI_74: |
3457 | process_window_ops (arg, nargs); |
3032 | process_window_ops (arg, nargs); |
3458 | break; |
3033 | break; |
3459 | #endif |
3034 | #endif |
3460 | |
3035 | |
… | |
… | |
3467 | break; |
3042 | break; |
3468 | } |
3043 | } |
3469 | } |
3044 | } |
3470 | /*}}} */ |
3045 | /*}}} */ |
3471 | |
3046 | |
3472 | #if ENABLE_FRILLS |
3047 | #if !ENABLE_MINIMAL |
3473 | /* ARGSUSED */ |
3048 | /* ARGSUSED */ |
3474 | void |
3049 | void |
3475 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3050 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3476 | { |
3051 | { |
3477 | int x, y; |
3052 | int x, y; |
3478 | XWindowAttributes wattr; |
3053 | XWindowAttributes wattr; |
3479 | Window wdummy; |
3054 | Window wdummy; |
3480 | dDisp; |
3055 | |
|
|
3056 | dLocal (Display *, dpy); |
3481 | |
3057 | |
3482 | if (nargs == 0) |
3058 | if (nargs == 0) |
3483 | return; |
3059 | return; |
3484 | |
3060 | |
3485 | switch (args[0]) |
3061 | switch (args[0]) |
3486 | { |
3062 | { |
3487 | /* |
3063 | /* |
3488 | * commands |
3064 | * commands |
3489 | */ |
3065 | */ |
3490 | case 1: /* deiconify window */ |
3066 | case 1: /* deiconify window */ |
3491 | XMapWindow (disp, parent[0]); |
3067 | XMapWindow (dpy, parent[0]); |
3492 | break; |
3068 | break; |
3493 | case 2: /* iconify window */ |
3069 | case 2: /* iconify window */ |
3494 | XIconifyWindow (disp, parent[0], display->screen); |
3070 | XIconifyWindow (dpy, parent[0], display->screen); |
3495 | break; |
3071 | break; |
3496 | case 3: /* set position (pixels) */ |
3072 | case 3: /* set position (pixels) */ |
3497 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3073 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3498 | break; |
3074 | break; |
3499 | case 4: /* set size (pixels) */ |
3075 | case 4: /* set size (pixels) */ |
3500 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3076 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3501 | break; |
3077 | break; |
3502 | case 5: /* raise window */ |
3078 | case 5: /* raise window */ |
3503 | XRaiseWindow (disp, parent[0]); |
3079 | XRaiseWindow (dpy, parent[0]); |
3504 | break; |
3080 | break; |
3505 | case 6: /* lower window */ |
3081 | case 6: /* lower window */ |
3506 | XLowerWindow (disp, parent[0]); |
3082 | XLowerWindow (dpy, parent[0]); |
3507 | break; |
3083 | break; |
3508 | case 7: /* refresh window */ |
3084 | case 7: /* refresh window */ |
3509 | scr_touch (true); |
3085 | scr_touch (true); |
3510 | break; |
3086 | break; |
3511 | case 8: /* set size (chars) */ |
3087 | case 8: /* set size (chars) */ |
… | |
… | |
3518 | if (args[0] >= 24) /* set height (chars) */ |
3094 | if (args[0] >= 24) /* set height (chars) */ |
3519 | set_widthheight ((unsigned int)width, |
3095 | set_widthheight ((unsigned int)width, |
3520 | (unsigned int) (args[1] * fheight)); |
3096 | (unsigned int) (args[1] * fheight)); |
3521 | break; |
3097 | break; |
3522 | |
3098 | |
3523 | |
|
|
3524 | /* |
3099 | /* |
3525 | * reports - some output format copied from XTerm |
3100 | * reports - some output format copied from XTerm |
3526 | */ |
3101 | */ |
3527 | case 11: /* report window state */ |
3102 | case 11: /* report window state */ |
3528 | XGetWindowAttributes (disp, parent[0], &wattr); |
3103 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3529 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3104 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3530 | break; |
3105 | break; |
3531 | case 13: /* report window position */ |
3106 | case 13: /* report window position */ |
3532 | XGetWindowAttributes (disp, parent[0], &wattr); |
3107 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3533 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3108 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3534 | -wattr.border_width, -wattr.border_width, |
3109 | -wattr.border_width, -wattr.border_width, |
3535 | &x, &y, &wdummy); |
3110 | &x, &y, &wdummy); |
3536 | tt_printf ("\033[3;%d;%dt", x, y); |
3111 | tt_printf ("\033[3;%d;%dt", x, y); |
3537 | break; |
3112 | break; |
3538 | case 14: /* report window size (pixels) */ |
3113 | case 14: /* report window size (pixels) */ |
3539 | XGetWindowAttributes (disp, parent[0], &wattr); |
3114 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3540 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3115 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3541 | break; |
3116 | break; |
3542 | case 18: /* report text area size (chars) */ |
3117 | case 18: /* report text area size (chars) */ |
3543 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3118 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3544 | break; |
3119 | break; |
… | |
… | |
3546 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3121 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3547 | break; |
3122 | break; |
3548 | case 20: /* report icon label */ |
3123 | case 20: /* report icon label */ |
3549 | { |
3124 | { |
3550 | char *s; |
3125 | char *s; |
3551 | XGetIconName (disp, parent[0], &s); |
3126 | XGetIconName (dpy, parent[0], &s); |
3552 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3127 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3553 | XFree (s); |
3128 | XFree (s); |
3554 | } |
3129 | } |
3555 | break; |
3130 | break; |
3556 | case 21: /* report window title */ |
3131 | case 21: /* report window title */ |
3557 | { |
3132 | { |
3558 | char *s; |
3133 | char *s; |
3559 | XFetchName (disp, parent[0], &s); |
3134 | XFetchName (dpy, parent[0], &s); |
3560 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3135 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3561 | XFree (s); |
3136 | XFree (s); |
3562 | } |
3137 | } |
3563 | break; |
3138 | break; |
3564 | } |
3139 | } |
3565 | } |
3140 | } |
… | |
… | |
3568 | /*----------------------------------------------------------------------*/ |
3143 | /*----------------------------------------------------------------------*/ |
3569 | /* |
3144 | /* |
3570 | * get input up until STRING TERMINATOR (or BEL) |
3145 | * get input up until STRING TERMINATOR (or BEL) |
3571 | * ends_how is terminator used. returned input must be free()'d |
3146 | * ends_how is terminator used. returned input must be free()'d |
3572 | */ |
3147 | */ |
3573 | unsigned char * |
3148 | char * |
3574 | rxvt_term::get_to_st (unicode_t &ends_how) |
3149 | rxvt_term::get_to_st (unicode_t &ends_how) |
3575 | { |
3150 | { |
3576 | unicode_t ch; |
3151 | unicode_t ch; |
3577 | bool seen_esc = false; |
3152 | bool seen_esc = false; |
3578 | unsigned int n = 0; |
3153 | unsigned int n = 0; |
… | |
… | |
3592 | seen_esc = true; |
3167 | seen_esc = true; |
3593 | continue; |
3168 | continue; |
3594 | } |
3169 | } |
3595 | else if (ch == C0_BEL || ch == CHAR_ST) |
3170 | else if (ch == C0_BEL || ch == CHAR_ST) |
3596 | break; |
3171 | break; |
|
|
3172 | else if (ch == C0_SYN) |
|
|
3173 | ch = cmd_get8 (); |
3597 | else if (ch < 0x20) |
3174 | else if (ch < 0x20) |
3598 | return NULL; /* other control character - exit */ |
3175 | return NULL; /* other control character - exit */ |
3599 | |
3176 | |
3600 | seen_esc = false; |
3177 | seen_esc = false; |
3601 | |
3178 | |
3602 | if (n >= STRING_MAX - 1) |
3179 | if (n >= STRING_MAX - 1) |
3603 | // stop at some sane length |
3180 | // stop at some sane length |
3604 | return NULL; |
3181 | return NULL; |
3605 | |
3182 | |
3606 | if (ch == C0_SYN) |
|
|
3607 | string[n++] = cmd_get8 (); |
|
|
3608 | else |
|
|
3609 | string[n++] = ch; |
3183 | string[n++] = ch; |
3610 | } |
3184 | } |
3611 | |
3185 | |
3612 | string[n++] = '\0'; |
3186 | string[n++] = '\0'; |
3613 | |
3187 | |
3614 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3188 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3615 | |
3189 | |
3616 | return (unsigned char *)rxvt_wcstombs (string); |
3190 | return rxvt_wcstombs (string); |
3617 | } |
3191 | } |
3618 | |
3192 | |
3619 | /*----------------------------------------------------------------------*/ |
3193 | /*----------------------------------------------------------------------*/ |
3620 | /* |
3194 | /* |
3621 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3195 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3622 | */ |
3196 | */ |
3623 | void |
3197 | void |
3624 | rxvt_term::process_dcs_seq () |
3198 | rxvt_term::process_dcs_seq () |
3625 | { |
3199 | { |
3626 | unsigned char *s; |
3200 | char *s; |
3627 | unicode_t eh; |
3201 | unicode_t eh; |
3628 | |
3202 | |
3629 | /* |
3203 | /* |
3630 | * Not handled yet |
3204 | * Not handled yet |
3631 | */ |
3205 | */ |
… | |
… | |
3650 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3224 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3651 | arg = arg * 10 + (ch - '0'); |
3225 | arg = arg * 10 + (ch - '0'); |
3652 | |
3226 | |
3653 | if (ch == ';') |
3227 | if (ch == ';') |
3654 | { |
3228 | { |
3655 | unsigned char *s = get_to_st (eh); |
3229 | char *s = get_to_st (eh); |
3656 | |
3230 | |
3657 | if (s) |
3231 | if (s) |
3658 | { |
3232 | { |
3659 | process_xterm_seq (arg, (char *)s, eh); |
3233 | process_xterm_seq (arg, s, eh); |
3660 | free (s); |
3234 | free (s); |
3661 | } |
3235 | } |
3662 | } |
3236 | } |
3663 | } |
3237 | } |
3664 | |
3238 | |
3665 | void |
3239 | void |
3666 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3240 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3667 | { |
3241 | { |
3668 | if (str[0] == '?' && !str[1]) |
3242 | if (str[0] == '?' && !str[1]) |
3669 | { |
3243 | { |
3670 | unsigned short r, g, b; |
3244 | rgba c; |
3671 | pix_colors_focused[color].get (display, r, g, b); |
3245 | pix_colors_focused[color].get (c); |
|
|
3246 | |
|
|
3247 | #if XFT |
|
|
3248 | if (c.a != rgba::MAX_CC) |
|
|
3249 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3250 | else |
|
|
3251 | #endif |
3672 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3252 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3673 | } |
3253 | } |
3674 | else |
3254 | else |
3675 | set_window_color (color, str); |
3255 | set_window_color (color, str); |
3676 | } |
3256 | } |
3677 | |
3257 | |
3678 | /* |
3258 | /* |
3679 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3259 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3680 | */ |
3260 | */ |
3681 | void |
3261 | void |
3682 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3262 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3683 | { |
3263 | { |
3684 | int changed = 0; |
|
|
3685 | int color; |
3264 | int color; |
3686 | char *buf, *name; |
3265 | char *buf, *name; |
3687 | bool query = str[0] == '?' && !str[1]; |
3266 | bool query = str[0] == '?' && !str[1]; |
3688 | int saveop = op; |
3267 | int saveop = op; |
3689 | dDisp; |
3268 | |
|
|
3269 | dLocal (Display *, dpy); |
3690 | |
3270 | |
3691 | assert (str != NULL); |
3271 | assert (str != NULL); |
|
|
3272 | |
|
|
3273 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3274 | return; |
|
|
3275 | |
3692 | switch (op) |
3276 | switch (op) |
3693 | { |
3277 | { |
3694 | case XTerm_name: |
3278 | case XTerm_name: |
3695 | set_title (str); |
3279 | set_title (str); |
3696 | /* FALLTHROUGH */ |
3280 | /* FALLTHROUGH */ |
… | |
… | |
3710 | unsigned long bytes_after; |
3294 | unsigned long bytes_after; |
3711 | unsigned char *value = 0; |
3295 | unsigned char *value = 0; |
3712 | const char *str = ""; |
3296 | const char *str = ""; |
3713 | |
3297 | |
3714 | if (prop |
3298 | if (prop |
3715 | && XGetWindowProperty (disp, parent[0], |
3299 | && XGetWindowProperty (dpy, parent[0], |
3716 | prop, 0, 1<<16, 0, AnyPropertyType, |
3300 | prop, 0, 1<<16, 0, AnyPropertyType, |
3717 | &actual_type, &actual_format, |
3301 | &actual_type, &actual_format, |
3718 | &nitems, &bytes_after, &value) == Success |
3302 | &nitems, &bytes_after, &value) == Success |
3719 | && actual_type != None |
3303 | && actual_type != None |
3720 | && actual_format == 8) |
3304 | && actual_format == 8) |
3721 | str = (const char *)(value); |
3305 | str = (const char *)(value); |
3722 | |
3306 | |
3723 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3307 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3724 | |
3308 | |
3725 | XFree (value); |
3309 | XFree (value); |
3726 | } |
3310 | } |
3727 | else |
3311 | else |
3728 | { |
3312 | { |
… | |
… | |
3732 | { |
3316 | { |
3733 | *eq = 0; |
3317 | *eq = 0; |
3734 | set_utf8_property (display->atom (str), eq + 1); |
3318 | set_utf8_property (display->atom (str), eq + 1); |
3735 | } |
3319 | } |
3736 | else |
3320 | else |
3737 | XDeleteProperty (disp, parent[0], |
3321 | XDeleteProperty (dpy, parent[0], |
3738 | display->atom (str)); |
3322 | display->atom (str)); |
3739 | } |
3323 | } |
3740 | break; |
3324 | break; |
3741 | |
3325 | |
3742 | case XTerm_Color: |
3326 | case XTerm_Color: |
… | |
… | |
3744 | { |
3328 | { |
3745 | if ((name = strchr (buf, ';')) == NULL) |
3329 | if ((name = strchr (buf, ';')) == NULL) |
3746 | break; |
3330 | break; |
3747 | |
3331 | |
3748 | *name++ = '\0'; |
3332 | *name++ = '\0'; |
3749 | color = atoi (buf); |
3333 | color = atoi (buf) + minCOLOR; |
3750 | |
3334 | |
3751 | if (color < 0 || color >= TOTAL_COLORS) |
3335 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3752 | break; |
3336 | break; |
3753 | |
3337 | |
3754 | if ((buf = strchr (name, ';')) != NULL) |
3338 | if ((buf = strchr (name, ';')) != NULL) |
3755 | *buf++ = '\0'; |
3339 | *buf++ = '\0'; |
3756 | |
3340 | |
3757 | if (name[0] == '?' && !name[1]) |
3341 | process_color_seq (op, color, name, resp); |
3758 | { |
|
|
3759 | unsigned short r, g, b; |
|
|
3760 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3761 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3762 | } |
|
|
3763 | else |
|
|
3764 | set_window_color (color + minCOLOR, name); |
|
|
3765 | } |
3342 | } |
3766 | break; |
3343 | break; |
|
|
3344 | case Rxvt_restoreFG: |
3767 | case XTerm_Color00: |
3345 | case XTerm_Color00: |
3768 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3346 | process_color_seq (op, Color_fg, str, resp); |
3769 | break; |
3347 | break; |
|
|
3348 | case Rxvt_restoreBG: |
3770 | case XTerm_Color01: |
3349 | case XTerm_Color01: |
3771 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3350 | process_color_seq (op, Color_bg, str, resp); |
3772 | break; |
3351 | break; |
3773 | #ifndef NO_CURSORCOLOR |
3352 | #ifndef NO_CURSORCOLOR |
3774 | case XTerm_Color_cursor: |
3353 | case XTerm_Color_cursor: |
3775 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3354 | process_color_seq (op, Color_cursor, str, resp); |
3776 | break; |
3355 | break; |
3777 | #endif |
3356 | #endif |
3778 | case XTerm_Color_pointer_fg: |
3357 | case XTerm_Color_pointer_fg: |
3779 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3358 | process_color_seq (op, Color_pointer_fg, str, resp); |
3780 | break; |
3359 | break; |
3781 | case XTerm_Color_pointer_bg: |
3360 | case XTerm_Color_pointer_bg: |
3782 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3361 | process_color_seq (op, Color_pointer_bg, str, resp); |
3783 | break; |
3362 | break; |
3784 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3363 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3785 | case XTerm_Color_BD: |
|
|
3786 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3787 | break; |
|
|
3788 | case XTerm_Color_UL: |
|
|
3789 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3790 | break; |
|
|
3791 | case XTerm_Color_RV: |
3364 | case XTerm_Color_RV: |
3792 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3365 | process_color_seq (op, Color_RV, str, resp); |
|
|
3366 | break; |
|
|
3367 | case Rxvt_Color_BD: |
|
|
3368 | case URxvt_Color_BD: |
|
|
3369 | process_color_seq (op, Color_BD, str, resp); |
|
|
3370 | break; |
|
|
3371 | case Rxvt_Color_UL: |
|
|
3372 | case URxvt_Color_UL: |
|
|
3373 | process_color_seq (op, Color_UL, str, resp); |
3793 | break; |
3374 | break; |
3794 | case URxvt_Color_IT: |
3375 | case URxvt_Color_IT: |
3795 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3376 | process_color_seq (op, Color_IT, str, resp); |
3796 | break; |
3377 | break; |
3797 | #endif |
3378 | #endif |
3798 | #if TRANSPARENT && TINTING |
3379 | #if ENABLE_TRANSPARENCY |
3799 | case URxvt_Color_tint: |
3380 | case URxvt_Color_tint: |
3800 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3381 | process_color_seq (op, Color_tint, str, resp); |
3801 | check_our_parents (); |
3382 | { |
3802 | if (am_transparent) |
3383 | bool changed = false; |
3803 | want_full_refresh = want_refresh = 1; |
|
|
3804 | break; |
|
|
3805 | #endif |
|
|
3806 | |
3384 | |
|
|
3385 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
3386 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
3387 | else |
|
|
3388 | changed = bgPixmap.unset_tint (); |
|
|
3389 | |
|
|
3390 | if (changed) |
|
|
3391 | update_background (); |
|
|
3392 | } |
|
|
3393 | |
|
|
3394 | break; |
|
|
3395 | #endif |
|
|
3396 | |
|
|
3397 | #if BG_IMAGE_FROM_FILE |
3807 | case XTerm_Pixmap: |
3398 | case Rxvt_Pixmap: |
3808 | if (*str != ';') |
3399 | if (!strcmp (str, "?")) |
3809 | { |
3400 | { |
3810 | #if XPM_BACKGROUND |
3401 | char str[256]; |
3811 | scale_pixmap (""); /* reset to default scaling */ |
3402 | |
3812 | set_bgPixmap (str); /* change pixmap */ |
3403 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3813 | #endif |
3404 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3814 | scr_touch (true); |
3405 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3406 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3815 | } |
3407 | } |
3816 | while ((str = strchr (str, ';')) != NULL) |
3408 | else |
3817 | { |
3409 | { |
|
|
3410 | int changed = 0; |
|
|
3411 | |
|
|
3412 | if (*str != ';') |
|
|
3413 | { |
|
|
3414 | /* reset to default scaling :*/ |
|
|
3415 | bgPixmap.unset_geometry (); |
|
|
3416 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3417 | changed++; |
|
|
3418 | str = strchr (str, ';'); |
|
|
3419 | if (str == NULL) |
|
|
3420 | bgPixmap.set_defaultGeometry (); |
|
|
3421 | } |
|
|
3422 | |
|
|
3423 | while (str) |
|
|
3424 | { |
3818 | str++; |
3425 | str++; |
3819 | #if XPM_BACKGROUND |
3426 | if (bgPixmap.set_geometry (str)) |
3820 | changed += scale_pixmap (str); |
3427 | changed++; |
3821 | #endif |
3428 | str = strchr (str, ';'); |
|
|
3429 | } |
|
|
3430 | |
|
|
3431 | if (changed) |
|
|
3432 | update_background (); |
3822 | } |
3433 | } |
3823 | |
|
|
3824 | if (changed) |
|
|
3825 | { |
|
|
3826 | #ifdef XPM_BACKGROUND |
|
|
3827 | resize_pixmap (); |
|
|
3828 | #endif |
|
|
3829 | scr_touch (true); |
|
|
3830 | } |
|
|
3831 | break; |
3434 | break; |
3832 | |
3435 | #endif |
3833 | case XTerm_restoreFG: |
|
|
3834 | set_window_color (Color_fg, str); |
|
|
3835 | break; |
|
|
3836 | case XTerm_restoreBG: |
|
|
3837 | set_window_color (Color_bg, str); |
|
|
3838 | break; |
|
|
3839 | |
3436 | |
3840 | case XTerm_logfile: |
3437 | case XTerm_logfile: |
3841 | // TODO, when secure mode? |
3438 | // TODO, when secure mode? |
3842 | break; |
3439 | break; |
3843 | |
3440 | |
3844 | #ifdef MENUBAR |
|
|
3845 | case URxvt_Menu: |
|
|
3846 | if (options & Opt_insecure) |
|
|
3847 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3848 | break; |
|
|
3849 | #endif |
|
|
3850 | #if 0 |
3441 | #if 0 |
3851 | case XTerm_dumpscreen: /* no error notices */ |
3442 | case Rxvt_dumpscreen: /* no error notices */ |
3852 | { |
3443 | { |
3853 | int fd; |
3444 | int fd; |
3854 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3445 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3855 | { |
3446 | { |
3856 | scr_dump (fd); |
3447 | scr_dump (fd); |
… | |
… | |
3867 | case URxvt_italicFont: |
3458 | case URxvt_italicFont: |
3868 | case URxvt_boldItalicFont: |
3459 | case URxvt_boldItalicFont: |
3869 | #endif |
3460 | #endif |
3870 | if (query) |
3461 | if (query) |
3871 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3462 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3872 | (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3463 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3873 | ? fontset[op - URxvt_font]->fontdesc : "", |
3464 | ? fontset[op - URxvt_font]->fontdesc : "", |
3874 | resp); |
3465 | resp); |
3875 | else |
3466 | else |
3876 | { |
3467 | { |
3877 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3468 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3880 | allocated.push_back ((void *)res); |
3471 | allocated.push_back ((void *)res); |
3881 | set_fonts (); |
3472 | set_fonts (); |
3882 | } |
3473 | } |
3883 | break; |
3474 | break; |
3884 | |
3475 | |
3885 | #if ENABLE_FRILLS |
3476 | case URxvt_version: |
|
|
3477 | if (query) |
|
|
3478 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3479 | op, |
|
|
3480 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3481 | resp); |
|
|
3482 | break; |
|
|
3483 | |
|
|
3484 | #if !ENABLE_MINIMAL |
3886 | case URxvt_locale: |
3485 | case URxvt_locale: |
3887 | if (query) |
3486 | if (query) |
3888 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
3487 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3889 | else |
3488 | else |
3890 | { |
3489 | { |
3891 | set_locale (str); |
3490 | set_locale (str); |
3892 | pty.set_utf8_mode (enc_utf8); |
3491 | pty->set_utf8_mode (enc_utf8); |
3893 | init_xlocale (); |
3492 | init_xlocale (); |
3894 | } |
3493 | } |
3895 | break; |
3494 | break; |
3896 | |
3495 | |
3897 | case URxvt_view_up: |
3496 | case URxvt_view_up: |
3898 | case URxvt_view_down: |
3497 | case URxvt_view_down: |
|
|
3498 | { |
3899 | int lines = atoi (str); |
3499 | int lines = atoi (str); |
3900 | |
3500 | |
3901 | if (lines) |
3501 | if (lines) |
3902 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3502 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3903 | else |
3503 | else |
3904 | { |
|
|
3905 | scr_erase_savelines (); |
3504 | scr_erase_savelines (); |
3906 | } |
3505 | } |
3907 | |
3506 | |
|
|
3507 | break; |
|
|
3508 | #endif |
|
|
3509 | |
|
|
3510 | #if ENABLE_PERL |
|
|
3511 | case URxvt_perl: |
|
|
3512 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
3513 | ; // no responses yet |
3908 | break; |
3514 | break; |
3909 | #endif |
3515 | #endif |
3910 | } |
3516 | } |
3911 | } |
3517 | } |
3912 | /*----------------------------------------------------------------------*/ |
3518 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3935 | { |
3541 | { |
3936 | if (mode == 'r') |
3542 | if (mode == 'r') |
3937 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3543 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3938 | else |
3544 | else |
3939 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3545 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3940 | PrivMode (state, bit); |
3546 | set_privmode (bit, state); |
3941 | } |
3547 | } |
3942 | |
3548 | |
3943 | return state; |
3549 | return state; |
3944 | } |
3550 | } |
3945 | |
3551 | |
3946 | /* we're not using priv _yet_ */ |
3552 | /* we're not using priv _yet_ */ |
3947 | void |
3553 | void |
3948 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3554 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3949 | { |
3555 | { |
3950 | unsigned int i, j; |
3556 | unsigned int i, j; |
3951 | int state; |
3557 | int state; |
3952 | |
3558 | |
3953 | static const struct |
3559 | static const struct |
3954 | { |
3560 | { |
3955 | const int argval; |
3561 | const int argval; |
3956 | const unsigned long bit; |
3562 | const unsigned long bit; |
3957 | } |
|
|
3958 | |
|
|
3959 | argtopriv[] = { |
3563 | } argtopriv[] = { |
3960 | { 1, PrivMode_aplCUR }, |
3564 | { 1, PrivMode_aplCUR }, |
3961 | { 2, PrivMode_vt52 }, |
3565 | { 2, PrivMode_vt52 }, |
3962 | { 3, PrivMode_132 }, |
3566 | { 3, PrivMode_132 }, |
3963 | { 4, PrivMode_smoothScroll }, |
3567 | { 4, PrivMode_smoothScroll }, |
3964 | { 5, PrivMode_rVideo }, |
3568 | { 5, PrivMode_rVideo }, |
3965 | { 6, PrivMode_relOrigin }, |
3569 | { 6, PrivMode_relOrigin }, |
3966 | { 7, PrivMode_Autowrap }, |
3570 | { 7, PrivMode_Autowrap }, |
3967 | // 8, bi-directional support mode |
3571 | // 8, bi-directional support mode |
3968 | { 9, PrivMode_MouseX10 }, |
3572 | { 9, PrivMode_MouseX10 }, |
3969 | #ifdef menuBar_esc |
|
|
3970 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3971 | #endif |
|
|
3972 | // 18, 19 printing-related |
3573 | // 18, 19 printing-related |
3973 | { 25, PrivMode_VisibleCursor }, |
3574 | { 25, PrivMode_VisibleCursor }, |
3974 | #ifdef scrollBar_esc |
3575 | #ifdef scrollBar_esc |
3975 | { scrollBar_esc, PrivMode_scrollBar }, |
3576 | { scrollBar_esc, PrivMode_scrollBar }, |
3976 | #endif |
3577 | #endif |
… | |
… | |
3983 | { 66, PrivMode_aplKP }, |
3584 | { 66, PrivMode_aplKP }, |
3984 | #ifndef NO_BACKSPACE_KEY |
3585 | #ifndef NO_BACKSPACE_KEY |
3985 | { 67, PrivMode_BackSpace }, |
3586 | { 67, PrivMode_BackSpace }, |
3986 | #endif |
3587 | #endif |
3987 | { 1000, PrivMode_MouseX11 }, |
3588 | { 1000, PrivMode_MouseX11 }, |
3988 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3589 | { 1002, PrivMode_MouseBtnEvent }, |
3989 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3590 | { 1003, PrivMode_MouseAnyEvent }, |
3990 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
|
|
3991 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3591 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3992 | { 1011, PrivMode_Keypress }, // rxvt extension |
3592 | { 1011, PrivMode_Keypress }, // rxvt extension |
3993 | // 1035 enable modifiers for alt, numlock NYI |
3593 | // 1035 enable modifiers for alt, numlock NYI |
3994 | // 1036 send ESC for meta keys NYI |
3594 | // 1036 send ESC for meta keys NYI |
3995 | // 1037 send DEL for keypad delete NYI |
3595 | // 1037 send DEL for keypad delete NYI |
3996 | { 1047, PrivMode_Screen }, |
3596 | { 1047, PrivMode_Screen }, |
3997 | // 1048 save and restore cursor |
3597 | // 1048 save and restore cursor |
3998 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3598 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3999 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3599 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3600 | { 2004, PrivMode_BracketPaste }, |
4000 | }; |
3601 | }; |
4001 | |
3602 | |
4002 | if (nargs == 0) |
3603 | if (nargs == 0) |
4003 | return; |
3604 | return; |
4004 | |
3605 | |
… | |
… | |
4021 | } |
3622 | } |
4022 | |
3623 | |
4023 | /* extra handling for values with state unkept */ |
3624 | /* extra handling for values with state unkept */ |
4024 | switch (arg[i]) |
3625 | switch (arg[i]) |
4025 | { |
3626 | { |
|
|
3627 | #if ENABLE_STYLES |
|
|
3628 | case 1021: |
|
|
3629 | set_option (Opt_intensityStyles, mode); |
|
|
3630 | |
|
|
3631 | scr_touch (true); |
|
|
3632 | break; |
|
|
3633 | #endif |
4026 | case 1048: /* alternative cursor save */ |
3634 | case 1048: /* alternative cursor save */ |
4027 | case 1049: |
3635 | case 1049: |
4028 | if (options & Opt_secondaryScreen) |
3636 | if (option (Opt_secondaryScreen)) |
4029 | if (mode == 0) |
3637 | if (mode == 0) |
4030 | scr_cursor (RESTORE); |
3638 | scr_cursor (RESTORE); |
4031 | else if (mode == 1) |
3639 | else if (mode == 1) |
4032 | scr_cursor (SAVE); |
3640 | scr_cursor (SAVE); |
4033 | break; |
3641 | break; |
… | |
… | |
4041 | case 2: /* VT52 mode */ |
3649 | case 2: /* VT52 mode */ |
4042 | /* oddball mode. should be set regardless of set/reset |
3650 | /* oddball mode. should be set regardless of set/reset |
4043 | * parameter. Return from VT52 mode with an ESC < from |
3651 | * parameter. Return from VT52 mode with an ESC < from |
4044 | * within VT52 mode |
3652 | * within VT52 mode |
4045 | */ |
3653 | */ |
4046 | PrivMode (1, PrivMode_vt52); |
3654 | set_privmode (PrivMode_vt52, 1); |
4047 | break; |
3655 | break; |
4048 | case 3: /* 80/132 */ |
3656 | case 3: /* 80/132 */ |
4049 | if (priv_modes & PrivMode_132OK) |
3657 | if (priv_modes & PrivMode_132OK) |
|
|
3658 | { |
|
|
3659 | scr_poweron (); |
4050 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3660 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
|
|
3661 | } |
4051 | break; |
3662 | break; |
4052 | case 4: /* smooth scrolling */ |
3663 | case 4: /* smooth scrolling */ |
4053 | if (state) |
|
|
4054 | options &= ~Opt_jumpScroll; |
|
|
4055 | else |
|
|
4056 | options |= Opt_jumpScroll; |
3664 | set_option (Opt_jumpScroll, !state); |
4057 | break; |
3665 | break; |
4058 | case 5: /* reverse video */ |
3666 | case 5: /* reverse video */ |
4059 | scr_rvideo_mode (state); |
3667 | scr_rvideo_mode (state); |
4060 | break; |
3668 | break; |
4061 | case 6: /* relative/absolute origins */ |
3669 | case 6: /* relative/absolute origins */ |
… | |
… | |
4065 | scr_autowrap (state); |
3673 | scr_autowrap (state); |
4066 | break; |
3674 | break; |
4067 | /* case 8: - auto repeat, can't do on a per window basis */ |
3675 | /* case 8: - auto repeat, can't do on a per window basis */ |
4068 | case 9: /* X10 mouse reporting */ |
3676 | case 9: /* X10 mouse reporting */ |
4069 | if (state) /* orthogonal */ |
3677 | if (state) /* orthogonal */ |
4070 | priv_modes &= ~PrivMode_MouseX11; |
3678 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4071 | break; |
3679 | break; |
4072 | #ifdef menuBar_esc |
|
|
4073 | case menuBar_esc: |
|
|
4074 | #ifdef MENUBAR |
|
|
4075 | map_menuBar (state); |
|
|
4076 | #endif |
|
|
4077 | break; |
|
|
4078 | #endif |
|
|
4079 | #ifdef scrollBar_esc |
3680 | #ifdef scrollBar_esc |
4080 | case scrollBar_esc: |
3681 | case scrollBar_esc: |
4081 | if (scrollbar_mapping (state)) |
3682 | if (scrollbar_mapping (state)) |
4082 | { |
3683 | { |
4083 | resize_all_windows (0, 0, 0); |
3684 | resize_all_windows (0, 0, 0); |
… | |
… | |
4095 | break; |
3696 | break; |
4096 | /* case 66: - application key pad */ |
3697 | /* case 66: - application key pad */ |
4097 | /* case 67: - backspace key */ |
3698 | /* case 67: - backspace key */ |
4098 | case 1000: /* X11 mouse reporting */ |
3699 | case 1000: /* X11 mouse reporting */ |
4099 | if (state) /* orthogonal */ |
3700 | if (state) /* orthogonal */ |
4100 | priv_modes &= ~PrivMode_MouseX10; |
3701 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4101 | break; |
3702 | break; |
4102 | #if 0 |
|
|
4103 | case 1001: |
3703 | case 1002: |
4104 | break; /* X11 mouse highlighting */ |
3704 | case 1003: |
4105 | #endif |
3705 | if (state) |
|
|
3706 | { |
|
|
3707 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3708 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3709 | vt_emask_mouse = PointerMotionMask; |
|
|
3710 | } |
|
|
3711 | else |
|
|
3712 | vt_emask_mouse = NoEventMask; |
|
|
3713 | vt_select_input (); |
|
|
3714 | break; |
4106 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3715 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4107 | if (state) |
|
|
4108 | options &= ~Opt_scrollTtyOutput; |
|
|
4109 | else |
|
|
4110 | options |= Opt_scrollTtyOutput; |
3716 | set_option (Opt_scrollTtyOutput, !state); |
4111 | break; |
3717 | break; |
4112 | case 1011: /* scroll to bottom on key press */ |
3718 | case 1011: /* scroll to bottom on key press */ |
4113 | if (state) |
|
|
4114 | options |= Opt_scrollTtyKeypress; |
3719 | set_option (Opt_scrollTtyKeypress, state); |
4115 | else |
|
|
4116 | options &= ~Opt_scrollTtyKeypress; |
|
|
4117 | break; |
3720 | break; |
4118 | case 1047: /* secondary screen w/ clearing last */ |
3721 | case 1047: /* secondary screen w/ clearing last */ |
4119 | if (options & Opt_secondaryScreen) |
3722 | if (option (Opt_secondaryScreen)) |
4120 | if (current_screen != PRIMARY) |
3723 | if (current_screen != PRIMARY) |
4121 | scr_erase_screen (2); |
3724 | scr_erase_screen (2); |
4122 | scr_change_screen (state); |
3725 | scr_change_screen (state); |
4123 | break; |
3726 | break; |
4124 | case 1049: /* secondary screen w/ clearing first */ |
3727 | case 1049: /* secondary screen w/ clearing first */ |
4125 | scr_change_screen (state); |
3728 | scr_change_screen (state); |
4126 | if (options & Opt_secondaryScreen) |
3729 | if (option (Opt_secondaryScreen)) |
4127 | if (current_screen != PRIMARY) |
3730 | if (current_screen != PRIMARY) |
4128 | scr_erase_screen (2); |
3731 | scr_erase_screen (2); |
4129 | break; |
3732 | break; |
4130 | default: |
3733 | default: |
4131 | break; |
3734 | break; |
… | |
… | |
4259 | scr_color (Color_bg, Color_bg); |
3862 | scr_color (Color_bg, Color_bg); |
4260 | break; |
3863 | break; |
4261 | |
3864 | |
4262 | //case 50: // not variable spacing |
3865 | //case 50: // not variable spacing |
4263 | |
3866 | |
4264 | #ifndef NO_BRIGHTCOLOR |
3867 | #if !ENABLE_MINIMAL |
4265 | case 90: |
3868 | case 90: |
4266 | case 91: /* set bright fg color */ |
3869 | case 91: /* set bright fg color */ |
4267 | case 92: |
3870 | case 92: |
4268 | case 93: |
3871 | case 93: |
4269 | case 94: |
3872 | case 94: |
… | |
… | |
4281 | case 106: |
3884 | case 106: |
4282 | case 107: |
3885 | case 107: |
4283 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
3886 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4284 | break; |
3887 | break; |
4285 | #endif |
3888 | #endif |
4286 | |
|
|
4287 | } |
3889 | } |
4288 | } |
3890 | } |
4289 | } |
3891 | } |
4290 | /*}}} */ |
3892 | /*}}} */ |
4291 | |
3893 | |
… | |
… | |
4294 | rxvt_term::process_graphics () |
3896 | rxvt_term::process_graphics () |
4295 | { |
3897 | { |
4296 | unicode_t ch, cmd = cmd_getc (); |
3898 | unicode_t ch, cmd = cmd_getc (); |
4297 | |
3899 | |
4298 | if (cmd == 'Q') |
3900 | if (cmd == 'Q') |
|
|
3901 | { |
4299 | { /* query graphics */ |
3902 | /* query graphics */ |
4300 | tt_printf ("\033G0\012"); /* no graphics */ |
3903 | tt_printf ("\033G0\012"); /* no graphics */ |
4301 | return; |
3904 | return; |
4302 | } |
3905 | } |
4303 | /* swallow other graphics sequences until terminating ':' */ |
3906 | /* swallow other graphics sequences until terminating ':' */ |
4304 | do |
3907 | do |
… | |
… | |
4315 | */ |
3918 | */ |
4316 | void |
3919 | void |
4317 | rxvt_term::tt_printf (const char *fmt,...) |
3920 | rxvt_term::tt_printf (const char *fmt,...) |
4318 | { |
3921 | { |
4319 | va_list arg_ptr; |
3922 | va_list arg_ptr; |
4320 | unsigned char buf[256]; |
3923 | char buf[256]; |
4321 | |
3924 | |
4322 | va_start (arg_ptr, fmt); |
3925 | va_start (arg_ptr, fmt); |
4323 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
3926 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4324 | va_end (arg_ptr); |
3927 | va_end (arg_ptr); |
4325 | tt_write (buf, strlen (buf)); |
3928 | tt_write (buf, strlen (buf)); |
… | |
… | |
4330 | * or generated by us in response to a query ESC sequence. |
3933 | * or generated by us in response to a query ESC sequence. |
4331 | */ |
3934 | */ |
4332 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3935 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4333 | |
3936 | |
4334 | void |
3937 | void |
4335 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
3938 | rxvt_term::tt_write (const char *data, unsigned int len) |
4336 | { |
3939 | { |
|
|
3940 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
3941 | return; |
|
|
3942 | |
|
|
3943 | if (pty->pty < 0) |
|
|
3944 | return; |
|
|
3945 | |
4337 | if (v_buflen == 0) |
3946 | if (v_buflen == 0) |
4338 | { |
3947 | { |
4339 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
3948 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4340 | |
3949 | |
4341 | if ((unsigned int)written == len) |
3950 | if ((unsigned int)written == len) |
4342 | return; |
3951 | return; |
4343 | |
3952 | |
4344 | data += written; |
3953 | data += written; |
4345 | len -= written; |
3954 | len -= written; |
4346 | } |
3955 | } |
4347 | |
3956 | |
4348 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
3957 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4349 | |
3958 | |
4350 | memcpy (v_buffer + v_buflen, data, len); |
3959 | memcpy (v_buffer + v_buflen, data, len); |
4351 | v_buflen += len; |
3960 | v_buflen += len; |
4352 | |
3961 | |
4353 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
3962 | pty_ev.set (ev::READ | ev::WRITE); |
4354 | } |
3963 | } |
4355 | |
3964 | |
4356 | void rxvt_term::pty_write () |
3965 | void rxvt_term::pty_write () |
4357 | { |
3966 | { |
4358 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
3967 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4359 | |
3968 | |
4360 | if (written > 0) |
3969 | if (written > 0) |
4361 | { |
3970 | { |
4362 | v_buflen -= written; |
3971 | v_buflen -= written; |
4363 | |
3972 | |
4364 | if (v_buflen == 0) |
3973 | if (v_buflen == 0) |
4365 | { |
3974 | { |
4366 | free (v_buffer); |
3975 | free (v_buffer); |
4367 | v_buffer = 0; |
3976 | v_buffer = 0; |
4368 | v_buflen = 0; |
|
|
4369 | |
3977 | |
4370 | pty_ev.set (EVENT_READ); |
3978 | pty_ev.set (ev::READ); |
4371 | return; |
3979 | return; |
4372 | } |
3980 | } |
4373 | |
3981 | |
4374 | memmove (v_buffer, v_buffer + written, v_buflen); |
3982 | memmove (v_buffer, v_buffer + written, v_buflen); |
4375 | } |
3983 | } |
4376 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
3984 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4377 | // original code just ignores this... |
3985 | pty_ev.set (ev::READ); |
4378 | destroy (); |
|
|
4379 | } |
3986 | } |
4380 | |
3987 | |
4381 | /*----------------------- end-of-file (C source) -----------------------*/ |
3988 | /*----------------------- end-of-file (C source) -----------------------*/ |
4382 | |
3989 | |