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