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