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