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