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