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