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