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,2015 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; |
978 | int end_row = row + nrow; |
971 | int end_row = row + nrow; |
979 | |
972 | |
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
973 | while (row > top_row && ROW (row - 1).is_longer ()) |
981 | --row; |
974 | --row; |
982 | |
975 | |
983 | do |
976 | do |
984 | { |
977 | { |
985 | int start_row = row; |
978 | int start_row = row; |
… | |
… | |
1005 | break; |
998 | break; |
1006 | } |
999 | } |
1007 | } |
1000 | } |
1008 | while (l->is_longer () && row < end_row); |
1001 | while (l->is_longer () && row < end_row); |
1009 | } |
1002 | } |
1010 | while (++row < end_row); |
1003 | while (row < end_row); |
1011 | } |
1004 | } |
1012 | |
1005 | |
1013 | scr_refresh (refresh_type); |
1006 | scr_refresh (); |
1014 | scrollbar_show (1); |
1007 | scrollBar.show (1); |
1015 | #ifdef USE_XIM |
1008 | #if USE_XIM |
1016 | IMSendSpot (); |
1009 | im_send_spot (); |
1017 | #endif |
1010 | #endif |
1018 | } |
1011 | } |
1019 | |
1012 | |
1020 | display->flush (); |
1013 | display->flush (); |
1021 | } |
1014 | } |
1022 | |
1015 | |
|
|
1016 | /* checks whether a refresh is requested and starts the refresh timer */ |
1023 | void |
1017 | void |
1024 | rxvt_term::check_cb (check_watcher &w) |
1018 | rxvt_term::refresh_check () |
1025 | { |
1019 | { |
1026 | SET_R (this); |
1020 | if (want_refresh && !flush_ev.is_active ()) |
1027 | SET_LOCALE (locale); |
1021 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
1028 | |
1022 | |
1029 | display->flush (); |
1023 | display->flush (); |
1030 | |
|
|
1031 | if (want_refresh && !flush_ev.active) |
|
|
1032 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
|
|
1033 | } |
1024 | } |
1034 | |
1025 | |
1035 | void |
1026 | void |
1036 | rxvt_term::flush_cb (time_watcher &w) |
1027 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1037 | { |
1028 | { |
1038 | SET_R (this); |
1029 | make_current (); |
1039 | SET_LOCALE (locale); |
|
|
1040 | |
1030 | |
1041 | refresh_limit = 1; |
|
|
1042 | refresh_count = 0; |
1031 | refresh_count = 0; |
1043 | flush (); |
1032 | flush (); |
1044 | } |
1033 | } |
1045 | |
1034 | |
1046 | #ifdef CURSOR_BLINK |
1035 | #ifdef CURSOR_BLINK |
1047 | void |
1036 | void |
|
|
1037 | rxvt_term::cursor_blink_reset () |
|
|
1038 | { |
|
|
1039 | if (!focus) |
|
|
1040 | return; |
|
|
1041 | |
|
|
1042 | if (hidden_cursor) |
|
|
1043 | { |
|
|
1044 | hidden_cursor = 0; |
|
|
1045 | want_refresh = 1; |
|
|
1046 | } |
|
|
1047 | |
|
|
1048 | if (option (Opt_cursorBlink) || (priv_modes & PrivMode_BlinkingCursor)) |
|
|
1049 | cursor_blink_ev.again (); |
|
|
1050 | else |
|
|
1051 | cursor_blink_ev.stop (); |
|
|
1052 | } |
|
|
1053 | |
|
|
1054 | void |
1048 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1055 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1049 | { |
1056 | { |
1050 | hidden_cursor = !hidden_cursor; |
1057 | hidden_cursor = !hidden_cursor; |
1051 | want_refresh = 1; |
1058 | want_refresh = 1; |
1052 | |
1059 | refresh_check (); |
1053 | w.start (w.at + BLINK_INTERVAL); |
|
|
1054 | } |
1060 | } |
1055 | #endif |
1061 | #endif |
1056 | |
1062 | |
1057 | #ifdef TEXT_BLINK |
1063 | #ifdef TEXT_BLINK |
1058 | void |
1064 | void |
1059 | rxvt_term::text_blink_cb (time_watcher &w) |
1065 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1060 | { |
1066 | { |
1061 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1067 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1062 | { |
1068 | { |
1063 | hidden_text = !hidden_text; |
1069 | hidden_text = !hidden_text; |
1064 | want_refresh = 1; |
1070 | want_refresh = 1; |
1065 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1071 | refresh_check (); |
1066 | } |
1072 | } |
|
|
1073 | else |
|
|
1074 | w.stop (); |
1067 | } |
1075 | } |
1068 | #endif |
1076 | #endif |
1069 | |
1077 | |
1070 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1078 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1071 | void |
1079 | void |
1072 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1080 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1073 | { |
1081 | { |
1074 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1082 | if ((scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) |
1075 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1083 | && scr_page (scrollBar.state == SB_STATE_UP ? UP : DN, 1)) |
1076 | { |
1084 | { |
1077 | refresh_type |= SMOOTH_REFRESH; |
|
|
1078 | want_refresh = 1; |
1085 | want_refresh = 1; |
1079 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1086 | refresh_check (); |
1080 | } |
1087 | } |
|
|
1088 | else |
|
|
1089 | w.stop (); |
1081 | } |
1090 | } |
1082 | #endif |
1091 | #endif |
1083 | |
1092 | |
1084 | #ifdef SELECTION_SCROLLING |
1093 | #ifdef SELECTION_SCROLLING |
1085 | void |
1094 | void |
1086 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1095 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1087 | { |
1096 | { |
1088 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1097 | if (scr_page (scroll_selection_lines)) |
1089 | { |
1098 | { |
1090 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1099 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1091 | refresh_type |= SMOOTH_REFRESH; |
|
|
1092 | want_refresh = 1; |
1100 | want_refresh = 1; |
1093 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1101 | refresh_check (); |
1094 | } |
1102 | } |
|
|
1103 | else |
|
|
1104 | w.stop (); |
1095 | } |
1105 | } |
1096 | #endif |
1106 | #endif |
1097 | |
1107 | |
1098 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1108 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1099 | void |
1109 | void |
1100 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1110 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1101 | { |
1111 | { |
1102 | if (mouse_slip_wheel_speed == 0 |
1112 | if (scr_page (mouse_slip_wheel_speed)) |
1103 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
1104 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
1105 | { |
1113 | { |
1106 | if (view_start == nsaved || |
|
|
1107 | view_start == 0) |
|
|
1108 | mouse_slip_wheel_speed = 0; |
|
|
1109 | |
|
|
1110 | refresh_type |= SMOOTH_REFRESH; |
|
|
1111 | want_refresh = 1; |
1114 | want_refresh = 1; |
1112 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1115 | refresh_check (); |
|
|
1116 | } |
|
|
1117 | |
|
|
1118 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
1113 | } |
1119 | { |
|
|
1120 | mouse_slip_wheel_speed = 0; |
|
|
1121 | w.stop (); |
|
|
1122 | } |
1114 | } |
1123 | } |
1115 | #endif |
1124 | #endif |
1116 | |
1125 | |
1117 | #if HAVE_SCHED_YIELD |
1126 | #if LINUX_YIELD_HACK |
1118 | static struct event_handler |
1127 | static struct event_handler |
1119 | { |
1128 | { |
1120 | check_watcher cw_yield; |
1129 | ev::prepare yield_ev; |
1121 | |
1130 | |
1122 | void yield (check_watcher &w) |
1131 | void yield_cb (ev::prepare &w, int revents) |
1123 | { |
1132 | { |
1124 | sched_yield (); |
1133 | // this should really be sched_yield(), but the linux guys thought |
|
|
1134 | // that giving a process calling sched_yield () less cpu time than |
|
|
1135 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1136 | // allowed by the sus... as is returning ENOSYS. |
|
|
1137 | // since the linux guys additionally thought that breaking the only |
|
|
1138 | // known workaround against their unusable sched_yield hack is cool, |
|
|
1139 | // we just nanosleep a bit and hope for the best. |
|
|
1140 | |
|
|
1141 | struct timespec ts = { 0, 1000 }; |
|
|
1142 | nanosleep (&ts, 0); |
|
|
1143 | |
1125 | w.stop (); |
1144 | w.stop (); |
1126 | } |
1145 | } |
1127 | |
1146 | |
1128 | event_handler () |
1147 | event_handler () |
1129 | : cw_yield (this, &event_handler::yield) |
1148 | : yield_ev (this, &event_handler::yield_cb) |
1130 | { |
1149 | { |
1131 | } |
1150 | } |
1132 | } event_handler; |
1151 | } event_handler; |
1133 | #endif |
1152 | #endif |
1134 | |
1153 | |
|
|
1154 | /* make sure all the cmd data is at beginning of cmdbuf */ |
|
|
1155 | void |
|
|
1156 | rxvt_term::cmdbuf_reify () |
|
|
1157 | { |
|
|
1158 | if (cmdbuf_ptr == cmdbuf_base) |
|
|
1159 | return; |
|
|
1160 | |
|
|
1161 | ssize_t used = cmdbuf_endp - cmdbuf_ptr; |
|
|
1162 | |
|
|
1163 | memmove (cmdbuf_base, cmdbuf_ptr, used); |
|
|
1164 | cmdbuf_ptr = cmdbuf_base; |
|
|
1165 | cmdbuf_endp = cmdbuf_ptr + used; |
|
|
1166 | |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | #if defined (KEYSYM_RESOURCE) |
|
|
1170 | void |
|
|
1171 | rxvt_term::cmdbuf_append (const char *str, size_t count) |
|
|
1172 | { |
|
|
1173 | cmdbuf_reify (); |
|
|
1174 | |
|
|
1175 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
|
|
1176 | |
|
|
1177 | if (count > avail) |
|
|
1178 | return; |
|
|
1179 | |
|
|
1180 | memcpy (cmdbuf_endp, str, count); |
|
|
1181 | cmdbuf_endp += count; |
|
|
1182 | |
|
|
1183 | cmd_parse (); |
|
|
1184 | } |
|
|
1185 | #endif |
|
|
1186 | |
1135 | bool |
1187 | bool |
1136 | rxvt_term::pty_fill () |
1188 | rxvt_term::pty_fill () |
1137 | { |
1189 | { |
1138 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1190 | cmdbuf_reify (); |
1139 | |
1191 | |
1140 | if (CBUFSIZ == n) |
1192 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
1141 | { |
1193 | |
1142 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1194 | if (!avail) |
1143 | n = 0; |
|
|
1144 | } |
1195 | { |
1145 | |
1196 | // normally this indicates a "too long" command sequence - just drop the data we have |
1146 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
|
|
1147 | cmdbuf_ptr = cmdbuf_base; |
1197 | cmdbuf_ptr = cmdbuf_base; |
1148 | cmdbuf_endp = cmdbuf_ptr + n; |
1198 | cmdbuf_endp = cmdbuf_ptr; |
|
|
1199 | avail = CBUFSIZ; |
|
|
1200 | } |
1149 | |
1201 | |
1150 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1202 | ssize_t r = read (pty->pty, cmdbuf_endp, avail); |
1151 | |
1203 | |
1152 | if (r > 0) |
1204 | if (r > 0) |
1153 | { |
1205 | { |
1154 | cmdbuf_endp += r; |
1206 | cmdbuf_endp += r; |
1155 | return true; |
1207 | return true; |
1156 | } |
1208 | } |
1157 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1209 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1158 | { |
1210 | { |
1159 | #if HAVE_SCHED_YIELD |
1211 | #if LINUX_YIELD_HACK |
1160 | if (display->is_local) |
1212 | if (display->is_local) |
1161 | event_handler.cw_yield.start (); |
1213 | event_handler.yield_ev.start (); |
1162 | #endif |
1214 | #endif |
1163 | } |
1215 | } |
1164 | else |
1216 | else |
1165 | { |
1217 | { |
1166 | pty_ev.stop (); |
1218 | pty_ev.stop (); |
1167 | |
1219 | |
1168 | if (!OPTION (Opt_hold)) |
1220 | if (!option (Opt_hold)) |
1169 | destroy (); |
1221 | destroy (); |
1170 | } |
1222 | } |
1171 | |
1223 | |
1172 | return false; |
1224 | return false; |
1173 | } |
1225 | } |
1174 | |
1226 | |
1175 | void |
1227 | void |
1176 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1228 | rxvt_term::pty_cb (ev::io &w, int revents) |
1177 | { |
1229 | { |
1178 | SET_R (this); |
1230 | make_current (); |
1179 | SET_LOCALE (locale); |
|
|
1180 | |
1231 | |
1181 | if (revents & EVENT_READ) |
1232 | if (revents & ev::READ) |
1182 | // loop, but don't allow a single term to monopolize us |
1233 | // loop, but don't allow a single term to monopolize us |
1183 | while (pty_fill ()) |
1234 | for (int i = CBUFCNT; i-- && pty_fill (); ) |
1184 | if (cmd_parse ()) |
1235 | cmd_parse (); |
1185 | break; |
|
|
1186 | |
1236 | |
1187 | if (revents & EVENT_WRITE) |
1237 | if (revents & ev::WRITE) |
1188 | pty_write (); |
1238 | pty_write (); |
1189 | } |
|
|
1190 | |
1239 | |
1191 | void |
1240 | refresh_check (); |
|
|
1241 | } |
|
|
1242 | |
|
|
1243 | void ecb_cold |
1192 | rxvt_term::pointer_unblank () |
1244 | rxvt_term::pointer_unblank () |
1193 | { |
1245 | { |
1194 | XDefineCursor (display->display, vt, TermWin_cursor); |
1246 | XDefineCursor (dpy, vt, TermWin_cursor); |
1195 | recolour_cursor (); |
1247 | recolor_cursor (); |
1196 | |
1248 | |
1197 | #ifdef POINTER_BLANK |
1249 | #ifdef POINTER_BLANK |
1198 | hidden_pointer = 0; |
1250 | hidden_pointer = 0; |
1199 | |
1251 | |
1200 | if (OPTION (Opt_pointerBlank)) |
1252 | if (option (Opt_pointerBlank)) |
1201 | pointer_ev.start (NOW + pointerBlankDelay); |
1253 | pointer_ev.start (pointerBlankDelay); |
1202 | #endif |
1254 | #endif |
1203 | } |
1255 | } |
1204 | |
1256 | |
1205 | #ifdef POINTER_BLANK |
1257 | #ifdef POINTER_BLANK |
1206 | void |
1258 | void ecb_cold |
1207 | rxvt_term::pointer_blank () |
1259 | rxvt_term::pointer_blank () |
1208 | { |
1260 | { |
1209 | if (!OPTION (Opt_pointerBlank)) |
1261 | if (!option (Opt_pointerBlank)) |
1210 | return; |
1262 | return; |
1211 | |
1263 | |
1212 | XDefineCursor (display->display, vt, display->blank_cursor); |
1264 | XDefineCursor (dpy, vt, display->blank_cursor); |
1213 | XFlush (display->display); |
1265 | XFlush (dpy); |
1214 | |
1266 | |
1215 | hidden_pointer = 1; |
1267 | hidden_pointer = 1; |
1216 | } |
1268 | } |
1217 | |
1269 | |
1218 | void |
1270 | void ecb_cold |
1219 | rxvt_term::pointer_cb (time_watcher &w) |
1271 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1220 | { |
1272 | { |
1221 | SET_R (this); |
1273 | make_current (); |
1222 | SET_LOCALE (locale); |
|
|
1223 | |
1274 | |
1224 | pointer_blank (); |
1275 | pointer_blank (); |
1225 | } |
1276 | } |
1226 | #endif |
1277 | #endif |
1227 | |
1278 | |
1228 | void |
1279 | void |
1229 | rxvt_term::mouse_report (XButtonEvent &ev) |
1280 | rxvt_term::mouse_report (XButtonEvent &ev) |
1230 | { |
1281 | { |
1231 | int button_number, key_state = 0; |
1282 | int button_number, key_state = 0; |
1232 | int x, y; |
1283 | int x, y; |
|
|
1284 | int code = 32; |
1233 | |
1285 | |
1234 | x = ev.x; |
1286 | x = Pixel2Col (ev.x) + 1; |
1235 | y = ev.y; |
1287 | y = Pixel2Row (ev.y) + 1; |
1236 | pixel_position (&x, &y); |
1288 | |
|
|
1289 | if (ev.type == MotionNotify) |
|
|
1290 | { |
|
|
1291 | if (x == mouse_row && y == mouse_col) |
|
|
1292 | return; |
|
|
1293 | |
|
|
1294 | mouse_row = x; |
|
|
1295 | mouse_col = y; |
|
|
1296 | code += 32; |
|
|
1297 | } |
1237 | |
1298 | |
1238 | if (MEvent.button == AnyButton) |
1299 | if (MEvent.button == AnyButton) |
1239 | button_number = 3; |
1300 | button_number = 3; |
1240 | else |
1301 | else |
1241 | { |
1302 | { |
1242 | button_number = MEvent.button - Button1; |
1303 | button_number = MEvent.button - Button1; |
1243 | /* add 0x3D for wheel events, like xterm does */ |
1304 | /* add 0x3D for wheel events, like xterm does */ |
1244 | if (button_number >= 3) |
1305 | if (button_number >= 3) |
1245 | button_number += (64 - 3); |
1306 | button_number += 64 - 3; |
1246 | } |
1307 | } |
1247 | |
1308 | |
1248 | if (priv_modes & PrivMode_MouseX10) |
1309 | if (priv_modes & PrivMode_MouseX10) |
1249 | { |
1310 | { |
1250 | /* |
1311 | /* |
… | |
… | |
1282 | fputc ('A', stderr); |
1343 | fputc ('A', stderr); |
1283 | if (key_state & 32) |
1344 | if (key_state & 32) |
1284 | fputc ('2', stderr); |
1345 | fputc ('2', stderr); |
1285 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1346 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1286 | button_number, |
1347 | button_number, |
1287 | x + 1, |
1348 | x, |
1288 | y + 1); |
1349 | y); |
1289 | #endif |
1350 | #endif |
1290 | |
1351 | |
|
|
1352 | #if ENABLE_FRILLS |
|
|
1353 | if (priv_modes & PrivMode_ExtMouseRight) |
|
|
1354 | tt_printf ("\033[%d;%d;%dM", |
|
|
1355 | code + button_number + key_state, |
|
|
1356 | x, |
|
|
1357 | y); |
|
|
1358 | else if (priv_modes & PrivMode_ExtModeMouse) |
|
|
1359 | tt_printf ("\033[M%c%lc%lc", |
|
|
1360 | code + button_number + key_state, |
|
|
1361 | wint_t (32 + x), |
|
|
1362 | wint_t (32 + y)); |
|
|
1363 | else |
|
|
1364 | #endif |
1291 | tt_printf ("\033[M%c%c%c", |
1365 | tt_printf ("\033[M%c%c%c", |
1292 | (32 + button_number + key_state), |
1366 | code + button_number + key_state, |
1293 | (32 + x + 1), |
1367 | 32 + x, |
1294 | (32 + y + 1)); |
1368 | 32 + y); |
1295 | } |
1369 | } |
1296 | |
|
|
1297 | #ifdef USING_W11LIB |
|
|
1298 | void |
|
|
1299 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1300 | { |
|
|
1301 | rxvt_t *r = rxvt_get_r (); |
|
|
1302 | |
|
|
1303 | x_cb (*ev); |
|
|
1304 | } |
|
|
1305 | #endif |
|
|
1306 | |
1370 | |
1307 | /*{{{ process an X event */ |
1371 | /*{{{ process an X event */ |
1308 | void |
1372 | void ecb_hot |
1309 | rxvt_term::x_cb (XEvent &ev) |
1373 | rxvt_term::x_cb (XEvent &ev) |
1310 | { |
1374 | { |
1311 | dDisp; |
1375 | make_current (); |
1312 | |
1376 | |
1313 | SET_R (this); |
1377 | dLocal (Display *, dpy); |
1314 | SET_LOCALE (locale); |
|
|
1315 | |
1378 | |
|
|
1379 | if (ev.xany.window == vt |
|
|
1380 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1381 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1382 | return; |
|
|
1383 | |
|
|
1384 | // for XQueryPointer |
1316 | Window unused_root, unused_child; |
1385 | Window unused_root, unused_child; |
1317 | int unused_root_x, unused_root_y; |
1386 | int unused_root_x, unused_root_y; |
1318 | unsigned int unused_mask; |
1387 | unsigned int unused_mask; |
1319 | |
1388 | |
1320 | switch (ev.type) |
1389 | switch (ev.type) |
1321 | { |
1390 | { |
1322 | case KeyPress: |
1391 | case KeyPress: |
1323 | #if ISO_14755 |
1392 | key_press (ev.xkey); |
1324 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1325 | #endif |
|
|
1326 | lookup_key (ev.xkey); |
|
|
1327 | |
|
|
1328 | break; |
1393 | break; |
1329 | |
1394 | |
1330 | case KeyRelease: |
1395 | case KeyRelease: |
1331 | { |
1396 | key_release (ev.xkey); |
1332 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1333 | KeySym ks; |
|
|
1334 | |
|
|
1335 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1336 | #endif |
|
|
1337 | |
|
|
1338 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1339 | // ISO 14755 support |
|
|
1340 | if (iso14755buf) |
|
|
1341 | if (iso14755buf & ISO_14755_52) |
|
|
1342 | { |
|
|
1343 | # if ENABLE_OVERLAY |
|
|
1344 | scr_overlay_off (); |
|
|
1345 | # endif |
|
|
1346 | # if ISO_14755 |
|
|
1347 | // iso14755 part 5.2 handling: release time |
|
|
1348 | // first: controls |
|
|
1349 | if ((ev.xkey.state & ControlMask) |
|
|
1350 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1351 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1352 | { |
|
|
1353 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1354 | commit_iso14755 (); |
|
|
1355 | goto skip_switch; |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1359 | if (i[0] == ks) |
|
|
1360 | { |
|
|
1361 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1362 | commit_iso14755 (); |
|
|
1363 | goto skip_switch; |
|
|
1364 | } |
|
|
1365 | |
|
|
1366 | scr_bell (); |
|
|
1367 | # endif |
|
|
1368 | iso14755buf = 0; |
|
|
1369 | break; |
|
|
1370 | } |
|
|
1371 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1372 | { |
|
|
1373 | # if ENABLE_OVERLAY |
|
|
1374 | scr_overlay_off (); |
|
|
1375 | # endif |
|
|
1376 | if (iso14755buf & ISO_14755_51) |
|
|
1377 | commit_iso14755 (); |
|
|
1378 | #if ISO_14755 |
|
|
1379 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1380 | { |
|
|
1381 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1382 | |
|
|
1383 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1384 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1385 | } |
|
|
1386 | # endif |
|
|
1387 | else |
|
|
1388 | iso14755buf = 0; |
|
|
1389 | } |
|
|
1390 | #endif |
|
|
1391 | |
|
|
1392 | if (ev.xany.window == vt |
|
|
1393 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
1394 | break; |
|
|
1395 | |
|
|
1396 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1397 | if (!(ev.xkey.state & ControlMask)) |
|
|
1398 | slip_wheel_ev.stop (); |
|
|
1399 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1400 | mouse_slip_wheel_speed = 0; |
|
|
1401 | #endif |
|
|
1402 | break; |
1397 | break; |
1403 | } |
|
|
1404 | |
1398 | |
1405 | case ButtonPress: |
1399 | case ButtonPress: |
1406 | button_press (ev.xbutton); |
1400 | button_press (ev.xbutton); |
1407 | break; |
1401 | break; |
1408 | |
1402 | |
… | |
… | |
1410 | button_release (ev.xbutton); |
1404 | button_release (ev.xbutton); |
1411 | break; |
1405 | break; |
1412 | |
1406 | |
1413 | case ClientMessage: |
1407 | case ClientMessage: |
1414 | if (ev.xclient.format == 32 |
1408 | if (ev.xclient.format == 32 |
1415 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1409 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1416 | { |
1410 | { |
|
|
1411 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1412 | { |
|
|
1413 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1414 | { |
1417 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1415 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1416 | { |
|
|
1417 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1418 | destroy (); |
1418 | destroy (); |
|
|
1419 | } |
1419 | #if ENABLE_EWMH |
1420 | #if ENABLE_EWMH |
1420 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1421 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1421 | XSendEvent (disp, ev.xclient.window = display->root, |
1422 | XSendEvent (dpy, ev.xclient.window = display->root, |
1422 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1423 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1423 | &ev); |
1424 | &ev); |
|
|
1425 | #endif |
|
|
1426 | } |
|
|
1427 | } |
|
|
1428 | #if ENABLE_XEMBED |
|
|
1429 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1430 | { |
|
|
1431 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1432 | focus_in (); |
|
|
1433 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1434 | focus_out (); |
|
|
1435 | } |
1424 | #endif |
1436 | #endif |
1425 | } |
1437 | } |
1426 | #if ENABLE_XEMBED |
|
|
1427 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1428 | { |
|
|
1429 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1430 | focus_in (); |
|
|
1431 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1432 | focus_out (); |
|
|
1433 | } |
|
|
1434 | #endif |
|
|
1435 | #ifdef OFFIX_DND |
|
|
1436 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1437 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1438 | && (ev.xclient.data.l[0] == DndFile |
|
|
1439 | || ev.xclient.data.l[0] == DndDir |
|
|
1440 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1441 | { |
|
|
1442 | /* Get Dnd data */ |
|
|
1443 | Atom ActualType; |
|
|
1444 | int ActualFormat; |
|
|
1445 | unsigned char *data; |
|
|
1446 | unsigned long Size, RemainingBytes; |
|
|
1447 | |
|
|
1448 | XGetWindowProperty (disp, display->root, |
|
|
1449 | xa[XA_DNDSELECTION], |
|
|
1450 | 0L, 1000000L, |
|
|
1451 | False, AnyPropertyType, |
|
|
1452 | &ActualType, &ActualFormat, |
|
|
1453 | &Size, &RemainingBytes, |
|
|
1454 | &data); |
|
|
1455 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1456 | XFree (data); |
|
|
1457 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1458 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1459 | } |
|
|
1460 | #endif /* OFFIX_DND */ |
|
|
1461 | break; |
|
|
1462 | |
|
|
1463 | case MappingNotify: |
|
|
1464 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1465 | break; |
1438 | break; |
1466 | |
1439 | |
1467 | /* |
1440 | /* |
1468 | * XXX: this is not the _current_ arrangement |
1441 | * XXX: this is not the _current_ arrangement |
1469 | * Here's my conclusion: |
1442 | * Here's my conclusion: |
… | |
… | |
1488 | break; |
1461 | break; |
1489 | } |
1462 | } |
1490 | break; |
1463 | break; |
1491 | |
1464 | |
1492 | case FocusIn: |
1465 | case FocusIn: |
|
|
1466 | if (ev.xfocus.detail != NotifyInferior |
|
|
1467 | && ev.xfocus.detail != NotifyPointer |
|
|
1468 | && ev.xfocus.mode != NotifyGrab) |
1493 | focus_in (); |
1469 | focus_in (); |
1494 | break; |
1470 | break; |
1495 | |
1471 | |
1496 | case FocusOut: |
1472 | case FocusOut: |
|
|
1473 | if (ev.xfocus.detail != NotifyInferior |
|
|
1474 | && ev.xfocus.detail != NotifyPointer |
|
|
1475 | && ev.xfocus.mode != NotifyGrab) |
1497 | focus_out (); |
1476 | focus_out (); |
1498 | break; |
1477 | break; |
1499 | |
1478 | |
1500 | case ConfigureNotify: |
1479 | case ConfigureNotify: |
1501 | if (ev.xconfigure.window == parent[0]) |
1480 | if (ev.xconfigure.window == parent) |
1502 | { |
1481 | { |
1503 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1482 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1504 | ; |
1483 | ; |
|
|
1484 | |
|
|
1485 | bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE); |
|
|
1486 | |
|
|
1487 | if (want_position_change) |
|
|
1488 | { |
|
|
1489 | int x, y; |
|
|
1490 | |
|
|
1491 | if (ev.xconfigure.send_event) |
|
|
1492 | { |
|
|
1493 | x = ev.xconfigure.x; |
|
|
1494 | y = ev.xconfigure.y; |
|
|
1495 | } |
|
|
1496 | else |
|
|
1497 | get_window_origin (x, y); |
|
|
1498 | |
|
|
1499 | if (x != parent_x || y != parent_y) |
|
|
1500 | { |
|
|
1501 | parent_x = x; |
|
|
1502 | parent_y = y; |
|
|
1503 | HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END)); |
|
|
1504 | } |
|
|
1505 | } |
1505 | |
1506 | |
1506 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1507 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1507 | { |
1508 | { |
1508 | seen_resize = 1; |
1509 | seen_resize = 1; |
1509 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1510 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1510 | } |
1511 | } |
1511 | |
1512 | |
1512 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1513 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1513 | if (OPTION (Opt_transparent)) |
|
|
1514 | check_our_parents (); |
|
|
1515 | #endif |
|
|
1516 | } |
1514 | } |
1517 | break; |
1515 | break; |
1518 | |
1516 | |
1519 | case PropertyNotify: |
1517 | case PropertyNotify: |
1520 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1518 | HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1521 | && ev.xproperty.state == PropertyNewValue) |
|
|
1522 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
|
|
1523 | |
|
|
1524 | break; |
1519 | break; |
1525 | |
1520 | |
1526 | case SelectionClear: |
1521 | case SelectionClear: |
1527 | selection_clear (); |
1522 | selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]); |
1528 | break; |
|
|
1529 | |
|
|
1530 | case SelectionNotify: |
|
|
1531 | if (selection_wait == Sel_normal) |
|
|
1532 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
|
|
1533 | break; |
1523 | break; |
1534 | |
1524 | |
1535 | case SelectionRequest: |
1525 | case SelectionRequest: |
1536 | selection_send (ev.xselectionrequest); |
1526 | selection_send (ev.xselectionrequest); |
1537 | break; |
1527 | break; |
1538 | |
1528 | |
1539 | case MapNotify: |
1529 | case MapNotify: |
1540 | mapped = 1; |
1530 | mapped = 1; |
1541 | #ifdef TEXT_BLINK |
1531 | #ifdef TEXT_BLINK |
1542 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1532 | text_blink_ev.start (); |
1543 | #endif |
1533 | #endif |
1544 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1534 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1545 | break; |
1535 | break; |
1546 | |
1536 | |
1547 | case UnmapNotify: |
1537 | case UnmapNotify: |
… | |
… | |
1549 | #ifdef TEXT_BLINK |
1539 | #ifdef TEXT_BLINK |
1550 | text_blink_ev.stop (); |
1540 | text_blink_ev.stop (); |
1551 | #endif |
1541 | #endif |
1552 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1542 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1553 | break; |
1543 | break; |
1554 | |
|
|
1555 | #ifdef TRANSPARENT |
|
|
1556 | case ReparentNotify: |
|
|
1557 | rootwin_cb (ev); |
|
|
1558 | break; |
|
|
1559 | #endif /* TRANSPARENT */ |
|
|
1560 | |
1544 | |
1561 | case GraphicsExpose: |
1545 | case GraphicsExpose: |
1562 | case Expose: |
1546 | case Expose: |
1563 | if (ev.xany.window == vt) |
1547 | if (ev.xany.window == vt) |
1564 | { |
1548 | { |
1565 | do |
1549 | do |
|
|
1550 | { |
1566 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1567 | ev.xexpose.width, ev.xexpose.height, False); |
1552 | ev.xexpose.width, ev.xexpose.height, false); |
|
|
1553 | } |
1568 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1554 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1569 | |
1555 | |
1570 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1556 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1571 | |
1557 | |
1572 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1558 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1559 | { |
1573 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1574 | ev.xexpose.width, ev.xexpose.height, False); |
1561 | ev.xexpose.width, ev.xexpose.height, false); |
|
|
1562 | } |
1575 | |
1563 | |
1576 | scr_refresh (refresh_type); |
1564 | want_refresh = 1; |
1577 | } |
1565 | } |
1578 | else |
1566 | else |
1579 | { |
1567 | { |
1580 | XEvent unused_event; |
1568 | XEvent unused_event; |
1581 | |
1569 | |
1582 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1570 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1583 | ; |
1571 | ; |
1584 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1572 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1585 | ; |
1573 | ; |
1586 | |
1574 | |
1587 | if (isScrollbarWindow (ev.xany.window)) |
1575 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1588 | { |
1576 | { |
1589 | scrollBar.setIdle (); |
1577 | scrollBar.state = SB_STATE_IDLE; |
1590 | scrollbar_show (0); |
1578 | scrollBar.show (0); |
1591 | } |
1579 | } |
1592 | #ifdef MENUBAR |
|
|
1593 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1594 | menubar_expose (); |
|
|
1595 | #endif |
|
|
1596 | |
|
|
1597 | #ifdef TRANSPARENT |
|
|
1598 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1599 | XClearWindow (disp, ev.xany.window); |
|
|
1600 | #endif |
|
|
1601 | } |
1580 | } |
1602 | break; |
1581 | break; |
1603 | |
1582 | |
1604 | case MotionNotify: |
1583 | case MotionNotify: |
1605 | #ifdef POINTER_BLANK |
1584 | #ifdef POINTER_BLANK |
1606 | if (hidden_pointer) |
1585 | if (hidden_pointer) |
1607 | pointer_unblank (); |
1586 | pointer_unblank (); |
1608 | #endif |
1587 | #endif |
1609 | #if MENUBAR |
1588 | if (!bypass_keystate |
1610 | if (isMenuBarWindow (ev.xany.window)) |
1589 | && ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
1611 | { |
1590 | || priv_modes & PrivMode_MouseAnyEvent)) |
1612 | menubar_control (ev.xbutton); |
1591 | mouse_report (ev.xbutton); |
1613 | break; |
|
|
1614 | } |
|
|
1615 | #endif |
|
|
1616 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1592 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1617 | break; |
1593 | break; |
1618 | |
1594 | |
1619 | if (ev.xany.window == vt) |
1595 | if (ev.xany.window == vt) |
1620 | { |
1596 | { |
|
|
1597 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1621 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1598 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1622 | ; // nop |
1599 | ; // nop |
1623 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1600 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1624 | { |
1601 | { |
1625 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1602 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1626 | ; |
1603 | ; |
1627 | |
1604 | |
1628 | XQueryPointer (disp, vt, |
1605 | XQueryPointer (dpy, vt, |
1629 | &unused_root, &unused_child, |
1606 | &unused_root, &unused_child, |
1630 | &unused_root_x, &unused_root_y, |
1607 | &unused_root_x, &unused_root_y, |
1631 | &ev.xbutton.x, &ev.xbutton.y, |
1608 | &ev.xbutton.x, &ev.xbutton.y, |
1632 | &ev.xbutton.state); |
1609 | &ev.xbutton.state); |
1633 | #ifdef MOUSE_THRESHOLD |
1610 | #ifdef MOUSE_THRESHOLD |
1634 | /* deal with a `jumpy' mouse */ |
1611 | /* deal with a `jumpy' mouse */ |
1635 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1612 | if (ev.xmotion.time - MEvent.time > MOUSE_THRESHOLD) |
|
|
1613 | #endif |
1636 | { |
1614 | { |
1637 | #endif |
|
|
1638 | #if ISO_14755 |
1615 | #if ISO_14755 |
1639 | // 5.4 |
1616 | // 5.4 |
1640 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1617 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1641 | { |
1618 | { |
1642 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1619 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
… | |
… | |
1648 | |
1625 | |
1649 | #ifdef SELECTION_SCROLLING |
1626 | #ifdef SELECTION_SCROLLING |
1650 | if (ev.xbutton.y < int_bwidth |
1627 | if (ev.xbutton.y < int_bwidth |
1651 | || Pixel2Row (ev.xbutton.y) > (nrow-1)) |
1628 | || Pixel2Row (ev.xbutton.y) > (nrow-1)) |
1652 | { |
1629 | { |
|
|
1630 | page_dirn scroll_selection_dir; |
1653 | int dist; |
1631 | int dist; |
1654 | |
1632 | |
1655 | /* don't clobber the current delay if we are |
1633 | /* don't clobber the current delay if we are |
1656 | * already in the middle of scrolling. |
1634 | * already in the middle of scrolling. |
1657 | */ |
1635 | */ |
1658 | if (!sel_scroll_ev.active) |
1636 | if (!sel_scroll_ev.is_active ()) |
1659 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1637 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1660 | |
1638 | |
1661 | /* save the event params so we can highlight |
1639 | /* save the event params so we can highlight |
1662 | * the selection in the pending-scroll loop |
1640 | * the selection in the pending-scroll loop |
1663 | */ |
1641 | */ |
1664 | selection_save_x = ev.xbutton.x; |
1642 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1672 | dist = int_bwidth - ev.xbutton.y; |
1650 | dist = int_bwidth - ev.xbutton.y; |
1673 | } |
1651 | } |
1674 | else |
1652 | else |
1675 | { |
1653 | { |
1676 | scroll_selection_dir = DN; |
1654 | scroll_selection_dir = DN; |
1677 | dist = ev.xbutton.y - (int_bwidth + height); |
1655 | dist = ev.xbutton.y - (int_bwidth + vt_height); |
1678 | } |
1656 | } |
1679 | |
1657 | |
1680 | scroll_selection_lines = Pixel2Height (dist) |
1658 | scroll_selection_lines = Pixel2Height (dist) |
1681 | / SELECTION_SCROLL_LINE_SPEEDUP |
1659 | / SELECTION_SCROLL_LINE_SPEEDUP |
1682 | + 1; |
1660 | + 1; |
1683 | min_it (scroll_selection_lines, |
1661 | min_it (scroll_selection_lines, |
1684 | SELECTION_SCROLL_MAX_LINES); |
1662 | SELECTION_SCROLL_MAX_LINES); |
|
|
1663 | scroll_selection_lines *= scroll_selection_dir; |
1685 | } |
1664 | } |
1686 | else |
1665 | else |
1687 | { |
1666 | { |
1688 | /* we are within the text window, so we |
1667 | /* we are within the text window, so we |
1689 | * shouldn't be scrolling |
1668 | * shouldn't be scrolling |
1690 | */ |
1669 | */ |
1691 | if (sel_scroll_ev.active) |
|
|
1692 | sel_scroll_ev.stop(); |
1670 | sel_scroll_ev.stop(); |
1693 | } |
1671 | } |
1694 | #endif |
1672 | #endif |
1695 | #ifdef MOUSE_THRESHOLD |
|
|
1696 | } |
1673 | } |
1697 | #endif |
|
|
1698 | } |
1674 | } |
1699 | } |
1675 | } |
1700 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1676 | else if (scrollBar.state == SB_STATE_MOTION && ev.xany.window == scrollBar.win) |
1701 | { |
1677 | { |
1702 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1678 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1703 | MotionNotify, &ev)) |
1679 | MotionNotify, &ev)) |
1704 | ; |
1680 | ; |
1705 | |
1681 | |
1706 | XQueryPointer (disp, scrollBar.win, |
1682 | XQueryPointer (dpy, scrollBar.win, |
1707 | &unused_root, &unused_child, |
1683 | &unused_root, &unused_child, |
1708 | &unused_root_x, &unused_root_y, |
1684 | &unused_root_x, &unused_root_y, |
1709 | &ev.xbutton.x, &ev.xbutton.y, |
1685 | &ev.xbutton.x, &ev.xbutton.y, |
1710 | &unused_mask); |
1686 | &unused_mask); |
1711 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1687 | scr_move_to (scrollBar.position (ev.xbutton.y) - csrO, |
1712 | scrollbar_size ()); |
1688 | scrollBar.size ()); |
1713 | scr_refresh (refresh_type); |
|
|
1714 | refresh_limit = 0; |
1689 | want_refresh = 1; |
1715 | scrollbar_show (1); |
1690 | scrollBar.show (1); |
1716 | } |
1691 | } |
1717 | break; |
1692 | break; |
1718 | } |
1693 | } |
1719 | |
1694 | |
1720 | skip_switch: ; |
|
|
1721 | |
|
|
1722 | #if defined(CURSOR_BLINK) |
1695 | #if defined(CURSOR_BLINK) |
1723 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1696 | if (ev.type == KeyPress) |
1724 | { |
1697 | cursor_blink_reset (); |
1725 | if (hidden_cursor) |
|
|
1726 | { |
|
|
1727 | hidden_cursor = 0; |
|
|
1728 | want_refresh = 1; |
|
|
1729 | } |
|
|
1730 | |
|
|
1731 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1732 | } |
|
|
1733 | #endif |
1698 | #endif |
1734 | |
1699 | |
1735 | #if defined(POINTER_BLANK) |
1700 | #if defined(POINTER_BLANK) |
1736 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1701 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1737 | { |
1702 | { |
1738 | if (ev.type == MotionNotify |
1703 | if (ev.type == MotionNotify |
1739 | || ev.type == ButtonPress |
1704 | || ev.type == ButtonPress |
1740 | || ev.type == ButtonRelease) |
1705 | || ev.type == ButtonRelease) |
1741 | if (hidden_pointer) |
1706 | if (hidden_pointer) |
… | |
… | |
1743 | |
1708 | |
1744 | if (ev.type == KeyPress && hidden_pointer == 0) |
1709 | if (ev.type == KeyPress && hidden_pointer == 0) |
1745 | pointer_blank (); |
1710 | pointer_blank (); |
1746 | } |
1711 | } |
1747 | #endif |
1712 | #endif |
1748 | } |
|
|
1749 | |
1713 | |
1750 | void |
1714 | refresh_check (); |
|
|
1715 | } |
|
|
1716 | |
|
|
1717 | #if ENABLE_FRILLS |
|
|
1718 | void ecb_cold |
|
|
1719 | rxvt_term::set_urgency (bool enable) |
|
|
1720 | { |
|
|
1721 | if (enable == urgency_hint) |
|
|
1722 | return; |
|
|
1723 | |
|
|
1724 | if (XWMHints *h = XGetWMHints (dpy, parent)) |
|
|
1725 | { |
|
|
1726 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1727 | XSetWMHints (dpy, parent, h); |
|
|
1728 | urgency_hint = enable; |
|
|
1729 | XFree (h); |
|
|
1730 | } |
|
|
1731 | } |
|
|
1732 | #endif |
|
|
1733 | |
|
|
1734 | void ecb_cold |
1751 | rxvt_term::focus_in () |
1735 | rxvt_term::focus_in () |
1752 | { |
1736 | { |
1753 | if (!focus) |
1737 | if (!focus) |
1754 | { |
1738 | { |
1755 | focus = 1; |
1739 | focus = 1; |
1756 | want_refresh = 1; |
1740 | want_refresh = 1; |
1757 | |
1741 | |
1758 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1759 | |
|
|
1760 | #if USE_XIM |
1742 | #if USE_XIM |
1761 | if (Input_Context != NULL) |
1743 | if (Input_Context != NULL) |
1762 | { |
1744 | { |
1763 | IMSetStatusPosition (); |
1745 | im_set_position (); |
1764 | XSetICFocus (Input_Context); |
1746 | XSetICFocus (Input_Context); |
1765 | } |
1747 | } |
1766 | #endif |
1748 | #endif |
1767 | #if CURSOR_BLINK |
1749 | #if CURSOR_BLINK |
1768 | if (OPTION (Opt_cursorBlink)) |
1750 | if (option (Opt_cursorBlink)) |
1769 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1751 | cursor_blink_ev.again (); |
1770 | #endif |
1752 | #endif |
1771 | #if OFF_FOCUS_FADING |
1753 | #if OFF_FOCUS_FADING |
1772 | if (rs[Rs_fade]) |
1754 | if (rs[Rs_fade]) |
1773 | { |
1755 | { |
1774 | pix_colors = pix_colors_focused; |
1756 | pix_colors = pix_colors_focused; |
1775 | scr_recolour (); |
1757 | scr_recolor (); |
1776 | } |
1758 | } |
1777 | #endif |
1759 | #endif |
1778 | } |
1760 | #if ENABLE_FRILLS |
1779 | } |
1761 | if (option (Opt_urgentOnBell)) |
|
|
1762 | set_urgency (0); |
1780 | |
1763 | |
1781 | void |
1764 | if (priv_modes & PrivMode_FocusEvent) |
|
|
1765 | tt_printf ("\x1b[I"); |
|
|
1766 | #endif |
|
|
1767 | |
|
|
1768 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1769 | } |
|
|
1770 | } |
|
|
1771 | |
|
|
1772 | void ecb_cold |
1782 | rxvt_term::focus_out () |
1773 | rxvt_term::focus_out () |
1783 | { |
1774 | { |
1784 | if (focus) |
1775 | if (focus) |
1785 | { |
1776 | { |
1786 | focus = 0; |
1777 | focus = 0; |
1787 | want_refresh = 1; |
1778 | want_refresh = 1; |
1788 | |
1779 | |
1789 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1780 | #if ENABLE_FRILLS |
|
|
1781 | if (option (Opt_urgentOnBell)) |
|
|
1782 | set_urgency (0); |
1790 | |
1783 | |
|
|
1784 | if (priv_modes & PrivMode_FocusEvent) |
|
|
1785 | tt_printf ("\x1b[O"); |
|
|
1786 | #endif |
1791 | #if ENABLE_FRILLS || ISO_14755 |
1787 | #if ENABLE_FRILLS || ISO_14755 |
1792 | if (iso14755buf) |
1788 | if (iso14755buf) |
1793 | { |
1789 | { |
1794 | iso14755buf = 0; |
1790 | iso14755buf = 0; |
1795 | # if ENABLE_OVERLAY |
1791 | # if ISO_14755 |
1796 | scr_overlay_off (); |
1792 | scr_overlay_off (); |
1797 | # endif |
1793 | # endif |
1798 | } |
1794 | } |
1799 | #endif |
1795 | #endif |
1800 | #if USE_XIM |
1796 | #if USE_XIM |
1801 | if (Input_Context != NULL) |
1797 | if (Input_Context != NULL) |
1802 | XUnsetICFocus (Input_Context); |
1798 | XUnsetICFocus (Input_Context); |
1803 | #endif |
1799 | #endif |
1804 | #if CURSOR_BLINK |
1800 | #if CURSOR_BLINK |
1805 | if (OPTION (Opt_cursorBlink)) |
1801 | if (option (Opt_cursorBlink)) |
1806 | cursor_blink_ev.stop (); |
1802 | cursor_blink_ev.stop (); |
|
|
1803 | |
1807 | hidden_cursor = 0; |
1804 | hidden_cursor = 0; |
1808 | #endif |
1805 | #endif |
1809 | #if OFF_FOCUS_FADING |
1806 | #if OFF_FOCUS_FADING |
1810 | if (rs[Rs_fade]) |
1807 | if (rs[Rs_fade]) |
1811 | { |
1808 | { |
1812 | pix_colors = pix_colors_unfocused; |
1809 | pix_colors = pix_colors_unfocused; |
1813 | scr_recolour (); |
1810 | scr_recolor (); |
1814 | } |
1811 | } |
1815 | #endif |
1812 | #endif |
|
|
1813 | |
|
|
1814 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1815 | } |
|
|
1816 | } |
|
|
1817 | |
|
|
1818 | void ecb_cold |
|
|
1819 | rxvt_term::update_fade_color (unsigned int idx, bool first_time) |
|
|
1820 | { |
|
|
1821 | #if OFF_FOCUS_FADING |
|
|
1822 | if (rs[Rs_fade]) |
1816 | } |
1823 | { |
1817 | } |
1824 | if (!first_time) |
|
|
1825 | pix_colors_focused [idx].free (this); |
1818 | |
1826 | |
1819 | #if TRANSPARENT |
1827 | rgba c; |
1820 | void |
1828 | pix_colors [Color_fade].get (c); |
|
|
1829 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1830 | } |
|
|
1831 | #endif |
|
|
1832 | } |
|
|
1833 | |
|
|
1834 | #if ENABLE_PERL |
|
|
1835 | void ecb_hot |
1821 | rxvt_term::rootwin_cb (XEvent &ev) |
1836 | rxvt_term::rootwin_cb (XEvent &ev) |
1822 | { |
1837 | { |
1823 | SET_R (this); |
1838 | make_current (); |
1824 | SET_LOCALE (locale); |
1839 | |
|
|
1840 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1841 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1842 | return; |
1825 | |
1843 | |
1826 | switch (ev.type) |
1844 | switch (ev.type) |
1827 | { |
1845 | { |
1828 | case PropertyNotify: |
1846 | case PropertyNotify: |
1829 | /* |
1847 | /* |
1830 | * if user used some Esetroot compatible prog to set the root bg, |
1848 | * if user used some Esetroot compatible prog to set the root bg, |
1831 | * use the property to determine the pixmap. We use it later on. |
1849 | * use the property to determine the pixmap. We use it later on. |
1832 | */ |
1850 | */ |
1833 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1851 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1834 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1852 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1835 | return; |
1853 | { |
|
|
1854 | HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END)); |
|
|
1855 | } |
1836 | |
1856 | |
1837 | /* FALLTHROUGH */ |
|
|
1838 | case ReparentNotify: |
|
|
1839 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1840 | want_refresh = want_full_refresh = 1; |
|
|
1841 | break; |
1857 | break; |
1842 | } |
1858 | } |
|
|
1859 | |
|
|
1860 | refresh_check (); |
1843 | } |
1861 | } |
1844 | #endif |
1862 | #endif |
1845 | |
1863 | |
1846 | void |
1864 | void |
1847 | rxvt_term::button_press (XButtonEvent &ev) |
1865 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1856 | /* |
1874 | /* |
1857 | * VT window processing of button press |
1875 | * VT window processing of button press |
1858 | */ |
1876 | */ |
1859 | if (ev.window == vt) |
1877 | if (ev.window == vt) |
1860 | { |
1878 | { |
|
|
1879 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1880 | return; |
|
|
1881 | |
1861 | #if ISO_14755 |
1882 | #if ISO_14755 |
1862 | // 5.4 |
1883 | // 5.4 |
1863 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1884 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1864 | { |
1885 | { |
1865 | iso14755_54 (ev.x, ev.y); |
1886 | iso14755_54 (ev.x, ev.y); |
1866 | return; |
1887 | return; |
1867 | } |
1888 | } |
1868 | #endif |
1889 | #endif |
1869 | |
1890 | |
1870 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1891 | clickintime = ev.time - MEvent.time < multiClickTime; |
1871 | |
1892 | |
1872 | if (reportmode) |
1893 | if (reportmode) |
1873 | { |
1894 | { |
1874 | /* mouse report from vt window */ |
1895 | /* mouse report from vt window */ |
1875 | /* save the xbutton state (for ButtonRelease) */ |
1896 | /* save the xbutton state (for ButtonRelease) */ |
1876 | MEvent.state = ev.state; |
1897 | MEvent.state = ev.state; |
1877 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1898 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1878 | if (ev.button == MEvent.button && clickintime) |
1899 | if (ev.button == MEvent.button && clickintime) |
1879 | { |
1900 | { |
1880 | /* same button, within alloted time */ |
1901 | /* same button, within allowed time */ |
1881 | MEvent.clicks++; |
1902 | MEvent.clicks++; |
1882 | |
1903 | |
1883 | if (MEvent.clicks > 1) |
1904 | if (MEvent.clicks > 1) |
1884 | { |
1905 | { |
1885 | /* only report double clicks */ |
1906 | /* only report double clicks */ |
… | |
… | |
1899 | mouse_report (ev); |
1920 | mouse_report (ev); |
1900 | } |
1921 | } |
1901 | #else |
1922 | #else |
1902 | MEvent.button = ev.button; |
1923 | MEvent.button = ev.button; |
1903 | mouse_report (ev); |
1924 | mouse_report (ev); |
1904 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1925 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1905 | |
1926 | |
1906 | } |
1927 | } |
1907 | else |
1928 | else |
1908 | { |
1929 | { |
1909 | if (ev.button != MEvent.button) |
1930 | if (ev.button != MEvent.button) |
1910 | MEvent.clicks = 0; |
1931 | MEvent.clicks = 0; |
1911 | |
1932 | |
1912 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1913 | switch (ev.button) |
1933 | switch (ev.button) |
1914 | { |
1934 | { |
1915 | case Button1: |
1935 | case Button1: |
1916 | /* allow meta + click to select rectangular areas */ |
1936 | /* allow meta + click to select rectangular areas */ |
1917 | /* should be done in screen.C */ |
1937 | /* should be done in screen.C */ |
1918 | #if ENABLE_FRILLS |
1938 | #if ENABLE_FRILLS |
1919 | selection.rect = !!(ev.state & ModMetaMask); |
1939 | selection.rect = !!(ev.state & ModMetaMask); |
1920 | #else |
1940 | #else |
1921 | selection.rect = false; |
1941 | selection.rect = false; |
1922 | #endif |
1942 | #endif |
1923 | |
1943 | |
1924 | /* allow shift+left click to extend selection */ |
1944 | /* allow shift+left click to extend selection */ |
1925 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1945 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1926 | { |
1946 | { |
1927 | if (MEvent.button == Button1 && clickintime) |
1947 | if (MEvent.button == Button1 && clickintime) |
1928 | selection_rotate (ev.x, ev.y); |
1948 | selection_rotate (ev.x, ev.y); |
1929 | else |
1949 | else |
1930 | selection_extend (ev.x, ev.y, 1); |
1950 | selection_extend (ev.x, ev.y, 1); |
1931 | } |
1951 | } |
1932 | else |
1952 | else |
1933 | { |
1953 | { |
1934 | if (MEvent.button == Button1 && clickintime) |
1954 | if (MEvent.button == Button1 && clickintime) |
1935 | MEvent.clicks++; |
1955 | MEvent.clicks++; |
1936 | else |
1956 | else |
1937 | MEvent.clicks = 1; |
1957 | MEvent.clicks = 1; |
1938 | |
1958 | |
1939 | selection_click (MEvent.clicks, ev.x, ev.y); |
1959 | selection_click (MEvent.clicks, ev.x, ev.y); |
1940 | } |
1960 | } |
1941 | |
1961 | |
1942 | MEvent.button = Button1; |
1962 | MEvent.button = Button1; |
1943 | break; |
1963 | break; |
1944 | |
1964 | |
1945 | case Button3: |
1965 | case Button3: |
1946 | if (MEvent.button == Button3 && clickintime) |
1966 | if (MEvent.button == Button3 && clickintime) |
1947 | selection_rotate (ev.x, ev.y); |
1967 | selection_rotate (ev.x, ev.y); |
1948 | else |
1968 | else |
1949 | selection_extend (ev.x, ev.y, 1); |
1969 | selection_extend (ev.x, ev.y, 1); |
1950 | |
1970 | |
1951 | MEvent.button = Button3; |
1971 | MEvent.button = Button3; |
1952 | break; |
1972 | break; |
1953 | } |
1973 | } |
1954 | } |
1974 | } |
1955 | |
1975 | |
1956 | MEvent.time = ev.time; |
1976 | MEvent.time = ev.time; |
1957 | return; |
1977 | return; |
1958 | } |
1978 | } |
1959 | |
1979 | |
1960 | /* |
1980 | /* |
1961 | * Scrollbar window processing of button press |
1981 | * Scrollbar window processing of button press |
1962 | */ |
1982 | */ |
1963 | if (isScrollbarWindow (ev.window)) |
1983 | if (scrollBar.state && ev.window == scrollBar.win) |
1964 | { |
1984 | { |
1965 | scrollBar.setIdle (); |
1985 | page_dirn direction = NO_DIR; |
|
|
1986 | |
|
|
1987 | if (scrollBar.upButton (ev.y)) |
|
|
1988 | direction = UP; /* up */ |
|
|
1989 | else if (scrollBar.dnButton (ev.y)) |
|
|
1990 | direction = DN; /* down */ |
|
|
1991 | |
|
|
1992 | scrollBar.state = SB_STATE_IDLE; |
1966 | /* |
1993 | /* |
1967 | * Rxvt-style scrollbar: |
1994 | * Rxvt-style scrollbar: |
1968 | * move up if mouse is above slider |
1995 | * move up if mouse is above slider |
1969 | * move dn if mouse is below slider |
1996 | * move dn if mouse is below slider |
1970 | * |
1997 | * |
… | |
… | |
1979 | /* |
2006 | /* |
1980 | * Mouse report disabled scrollbar: |
2007 | * Mouse report disabled scrollbar: |
1981 | * arrow buttons - send up/down |
2008 | * arrow buttons - send up/down |
1982 | * click on scrollbar - send pageup/down |
2009 | * click on scrollbar - send pageup/down |
1983 | */ |
2010 | */ |
1984 | if ((scrollBar.style == R_SB_NEXT |
2011 | if (direction == UP) |
1985 | && scrollbarnext_upButton (ev.y)) |
|
|
1986 | || (scrollBar.style == R_SB_RXVT |
|
|
1987 | && scrollbarrxvt_upButton (ev.y))) |
|
|
1988 | tt_printf ("\033[A"); |
2012 | tt_printf ("\033[A"); |
1989 | else if ((scrollBar.style == R_SB_NEXT |
2013 | else if (direction == DN) |
1990 | && scrollbarnext_dnButton (ev.y)) |
|
|
1991 | || (scrollBar.style == R_SB_RXVT |
|
|
1992 | && scrollbarrxvt_dnButton (ev.y))) |
|
|
1993 | tt_printf ("\033[B"); |
2014 | tt_printf ("\033[B"); |
1994 | else |
2015 | else |
1995 | switch (ev.button) |
2016 | switch (ev.button) |
1996 | { |
2017 | { |
1997 | case Button2: |
2018 | case Button2: |
… | |
… | |
2004 | tt_printf ("\033[5~"); |
2025 | tt_printf ("\033[5~"); |
2005 | break; |
2026 | break; |
2006 | } |
2027 | } |
2007 | } |
2028 | } |
2008 | else |
2029 | else |
2009 | #endif /* NO_SCROLLBAR_REPORT */ |
2030 | #endif /* NO_SCROLLBAR_REPORT */ |
2010 | |
|
|
2011 | { |
|
|
2012 | char upordown = 0; |
|
|
2013 | |
|
|
2014 | if (scrollBar.style == R_SB_NEXT) |
|
|
2015 | { |
2031 | { |
2016 | if (scrollbarnext_upButton (ev.y)) |
2032 | if (direction != NO_DIR) |
2017 | upordown = -1; /* up */ |
|
|
2018 | else if (scrollbarnext_dnButton (ev.y)) |
|
|
2019 | upordown = 1; /* down */ |
|
|
2020 | } |
|
|
2021 | else if (scrollBar.style == R_SB_RXVT) |
|
|
2022 | { |
|
|
2023 | if (scrollbarrxvt_upButton (ev.y)) |
|
|
2024 | upordown = -1; /* up */ |
|
|
2025 | else if (scrollbarrxvt_dnButton (ev.y)) |
|
|
2026 | upordown = 1; /* down */ |
|
|
2027 | } |
|
|
2028 | if (upordown) |
|
|
2029 | { |
2033 | { |
2030 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
2034 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2035 | if (!cont_scroll_ev.is_active ()) |
2031 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
2036 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2032 | #endif |
2037 | #endif |
2033 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
2038 | if (scr_page (direction, 1)) |
2034 | { |
2039 | { |
2035 | if (upordown < 0) |
2040 | if (direction == UP) |
2036 | scrollBar.setUp (); |
2041 | scrollBar.state = SB_STATE_UP; |
2037 | else |
2042 | else |
2038 | scrollBar.setDn (); |
2043 | scrollBar.state = SB_STATE_DOWN; |
2039 | } |
2044 | } |
2040 | } |
2045 | } |
2041 | else |
2046 | else |
2042 | switch (ev.button) |
2047 | switch (ev.button) |
2043 | { |
2048 | { |
2044 | case Button2: |
2049 | case Button2: |
2045 | switch (scrollbar_align) |
2050 | switch (scrollBar.align) |
2046 | { |
2051 | { |
2047 | case R_SB_ALIGN_TOP: |
2052 | case SB_ALIGN_TOP: |
2048 | csrO = 0; |
2053 | csrO = 0; |
2049 | break; |
2054 | break; |
2050 | case R_SB_ALIGN_CENTRE: |
2055 | case SB_ALIGN_CENTRE: |
2051 | csrO = (scrollBar.bot - scrollBar.top) / 2; |
2056 | csrO = (scrollBar.bot - scrollBar.top) / 2; |
2052 | break; |
2057 | break; |
2053 | case R_SB_ALIGN_BOTTOM: |
2058 | case SB_ALIGN_BOTTOM: |
2054 | csrO = scrollBar.bot - scrollBar.top; |
2059 | csrO = scrollBar.bot - scrollBar.top; |
2055 | break; |
2060 | break; |
2056 | } |
2061 | } |
2057 | |
2062 | |
2058 | if (scrollBar.style == R_SB_XTERM |
2063 | if (scrollBar.style == SB_STYLE_XTERM |
2059 | || scrollbar_above_slider (ev.y) |
2064 | || scrollBar.above_slider (ev.y) |
2060 | || scrollbar_below_slider (ev.y)) |
2065 | || scrollBar.below_slider (ev.y)) |
2061 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2066 | scr_move_to (scrollBar.position (ev.y) - csrO, scrollBar.size ()); |
2062 | |
2067 | |
2063 | scrollBar.setMotion (); |
2068 | scrollBar.state = SB_STATE_MOTION; |
2064 | break; |
2069 | break; |
2065 | |
2070 | |
2066 | case Button1: |
2071 | case Button1: |
2067 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
2072 | if (scrollBar.align == SB_ALIGN_CENTRE) |
2068 | csrO = ev.y - scrollBar.top; |
2073 | csrO = ev.y - scrollBar.top; |
2069 | /* FALLTHROUGH */ |
2074 | /* FALLTHROUGH */ |
2070 | |
2075 | |
2071 | case Button3: |
2076 | case Button3: |
2072 | if (scrollBar.style != R_SB_XTERM) |
2077 | if (scrollBar.style != SB_STYLE_XTERM) |
2073 | { |
2078 | { |
2074 | if (scrollbar_above_slider (ev.y)) |
2079 | if (scrollBar.above_slider (ev.y)) |
2075 | # ifdef RXVT_SCROLL_FULL |
2080 | # ifdef RXVT_SCROLL_FULL |
2076 | scr_page (UP, nrow - 1); |
2081 | scr_page (UP, nrow - 1); |
2077 | # else |
2082 | # else |
2078 | scr_page (UP, nrow / 4); |
2083 | scr_page (UP, nrow / 4); |
2079 | # endif |
2084 | # endif |
2080 | else if (scrollbar_below_slider (ev.y)) |
2085 | else if (scrollBar.below_slider (ev.y)) |
2081 | # ifdef RXVT_SCROLL_FULL |
2086 | # ifdef RXVT_SCROLL_FULL |
2082 | scr_page (DN, nrow - 1); |
2087 | scr_page (DN, nrow - 1); |
2083 | # else |
2088 | # else |
2084 | scr_page (DN, nrow / 4); |
2089 | scr_page (DN, nrow / 4); |
2085 | # endif |
2090 | # endif |
2086 | else |
2091 | else |
2087 | scrollBar.setMotion (); |
2092 | scrollBar.state = SB_STATE_MOTION; |
2088 | } |
2093 | } |
2089 | else |
2094 | else |
2090 | { |
2095 | { |
2091 | scr_page ((ev.button == Button1 ? DN : UP), |
2096 | scr_page ((ev.button == Button1 ? DN : UP), |
2092 | (nrow |
2097 | (nrow |
2093 | * scrollbar_position (ev.y) |
2098 | * scrollBar.position (ev.y) |
2094 | / scrollbar_size ())); |
2099 | / scrollBar.size ())); |
2095 | } |
2100 | } |
2096 | |
2101 | |
2097 | break; |
2102 | break; |
2098 | } |
2103 | } |
2099 | } |
2104 | } |
2100 | |
2105 | |
2101 | return; |
2106 | return; |
2102 | } |
2107 | } |
2103 | |
|
|
2104 | #if MENUBAR |
|
|
2105 | /* |
|
|
2106 | * Menubar window processing of button press |
|
|
2107 | */ |
|
|
2108 | if (isMenuBarWindow (ev.window)) |
|
|
2109 | menubar_control (ev); |
|
|
2110 | #endif |
|
|
2111 | } |
2108 | } |
2112 | |
2109 | |
2113 | void |
2110 | void |
2114 | rxvt_term::button_release (XButtonEvent &ev) |
2111 | rxvt_term::button_release (XButtonEvent &ev) |
2115 | { |
2112 | { |
… | |
… | |
2117 | |
2114 | |
2118 | csrO = 0; /* reset csr Offset */ |
2115 | csrO = 0; /* reset csr Offset */ |
2119 | if (!bypass_keystate) |
2116 | if (!bypass_keystate) |
2120 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2117 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2121 | |
2118 | |
2122 | if (scrollbar_isUpDn ()) |
2119 | if (scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) |
2123 | { |
2120 | { |
2124 | scrollBar.setIdle (); |
2121 | scrollBar.state = SB_STATE_IDLE; |
2125 | scrollbar_show (0); |
2122 | scrollBar.show (0); |
2126 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2127 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2128 | #endif |
|
|
2129 | } |
2123 | } |
2130 | |
2124 | |
2131 | #ifdef SELECTION_SCROLLING |
2125 | #ifdef SELECTION_SCROLLING |
2132 | if (sel_scroll_ev.active) |
|
|
2133 | sel_scroll_ev.stop(); |
2126 | sel_scroll_ev.stop(); |
2134 | #endif |
2127 | #endif |
2135 | |
2128 | |
2136 | if (ev.window == vt) |
2129 | if (ev.window == vt) |
2137 | { |
2130 | { |
|
|
2131 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2132 | return; |
|
|
2133 | |
2138 | #if ISO_14755 |
2134 | #if ISO_14755 |
2139 | // 5.4 |
2135 | // 5.4 |
2140 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2136 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2141 | return; |
2137 | return; |
2142 | #endif |
2138 | #endif |
|
|
2139 | |
2143 | if (reportmode) |
2140 | if (reportmode) |
2144 | { |
2141 | { |
2145 | /* mouse report from vt window */ |
2142 | /* mouse report from vt window */ |
2146 | /* don't report release of wheel "buttons" */ |
2143 | /* don't report release of wheel "buttons" */ |
2147 | if (ev.button >= 4) |
2144 | if (ev.button >= 4) |
… | |
… | |
2149 | #ifdef MOUSE_REPORT_DOUBLECLICK |
2146 | #ifdef MOUSE_REPORT_DOUBLECLICK |
2150 | /* only report the release of 'slow' single clicks */ |
2147 | /* only report the release of 'slow' single clicks */ |
2151 | if (MEvent.button != AnyButton |
2148 | if (MEvent.button != AnyButton |
2152 | && (ev.button != MEvent.button |
2149 | && (ev.button != MEvent.button |
2153 | || (ev.time - MEvent.time |
2150 | || (ev.time - MEvent.time |
2154 | > MULTICLICK_TIME / 2))) |
2151 | > multiClickTime / 2))) |
2155 | { |
2152 | { |
2156 | MEvent.clicks = 0; |
2153 | MEvent.clicks = 0; |
2157 | MEvent.button = AnyButton; |
2154 | MEvent.button = AnyButton; |
2158 | mouse_report (ev); |
2155 | mouse_report (ev); |
2159 | } |
2156 | } |
2160 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2157 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2161 | MEvent.button = AnyButton; |
2158 | MEvent.button = AnyButton; |
2162 | mouse_report (ev); |
2159 | mouse_report (ev); |
2163 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2160 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2164 | return; |
2161 | return; |
2165 | } |
2162 | } |
2166 | |
2163 | |
2167 | /* |
2164 | /* |
2168 | * dumb hack to compensate for the failure of click-and-drag |
2165 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2171 | if (priv_modes & PrivMode_mouse_report |
2168 | if (priv_modes & PrivMode_mouse_report |
2172 | && bypass_keystate |
2169 | && bypass_keystate |
2173 | && ev.button == Button1 && MEvent.clicks <= 1) |
2170 | && ev.button == Button1 && MEvent.clicks <= 1) |
2174 | selection_extend (ev.x, ev.y, 0); |
2171 | selection_extend (ev.x, ev.y, 0); |
2175 | |
2172 | |
2176 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2177 | return; |
|
|
2178 | |
|
|
2179 | switch (ev.button) |
2173 | switch (ev.button) |
2180 | { |
2174 | { |
2181 | case Button1: |
2175 | case Button1: |
2182 | case Button3: |
2176 | case Button3: |
2183 | selection_make (ev.time); |
2177 | selection_make (ev.time); |
2184 | break; |
2178 | break; |
|
|
2179 | |
2185 | case Button2: |
2180 | case Button2: |
2186 | selection_request (ev.time, ev.x, ev.y); |
2181 | if (IN_RANGE_EXC (ev.x, 0, vt_width) && IN_RANGE_EXC (ev.y, 0, vt_height)) // inside window? |
|
|
2182 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2187 | break; |
2183 | break; |
|
|
2184 | |
2188 | #ifdef MOUSE_WHEEL |
2185 | #ifdef MOUSE_WHEEL |
2189 | case Button4: |
2186 | case Button4: |
2190 | case Button5: |
2187 | case Button5: |
2191 | { |
2188 | { |
2192 | int i; |
2189 | int lines; |
2193 | page_dirn v; |
2190 | page_dirn dirn; |
2194 | |
2191 | |
2195 | v = ev.button == Button4 ? UP : DN; |
2192 | dirn = ev.button == Button4 ? UP : DN; |
2196 | |
2193 | |
2197 | if (ev.state & ShiftMask) |
2194 | if (ev.state & ShiftMask) |
2198 | i = 1; |
2195 | lines = 1; |
2199 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2196 | else if (option (Opt_mouseWheelScrollPage)) |
2200 | i = nrow - 1; |
2197 | lines = nrow - 1; |
2201 | else |
2198 | else |
2202 | i = 5; |
2199 | lines = 5; |
2203 | |
2200 | |
2204 | # ifdef MOUSE_SLIP_WHEELING |
2201 | # ifdef MOUSE_SLIP_WHEELING |
2205 | if (ev.state & ControlMask) |
2202 | if (ev.state & ControlMask) |
2206 | { |
2203 | { |
2207 | mouse_slip_wheel_speed += v ? -1 : 1; |
2204 | mouse_slip_wheel_speed += dirn; |
2208 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2205 | clamp_it (mouse_slip_wheel_speed, -nrow, nrow); |
2209 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
|
|
2210 | |
2206 | |
2211 | if (slip_wheel_ev.at < NOW) |
2207 | if (!slip_wheel_ev.is_active ()) |
2212 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2208 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2213 | |
|
|
2214 | slip_wheel_ev.start (); |
|
|
2215 | } |
2209 | } |
2216 | else |
2210 | else |
|
|
2211 | # endif |
2217 | { |
2212 | { |
2218 | # endif |
|
|
2219 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2220 | scr_page (v, i); |
2213 | scr_page (dirn, lines); |
2221 | scr_refresh (SMOOTH_REFRESH); |
|
|
2222 | scrollbar_show (1); |
2214 | scrollBar.show (1); |
2223 | # else |
|
|
2224 | while (i--) |
|
|
2225 | { |
|
|
2226 | scr_page (v, 1); |
|
|
2227 | scr_refresh (SMOOTH_REFRESH); |
|
|
2228 | scrollbar_show (1); |
|
|
2229 | } |
|
|
2230 | # endif |
|
|
2231 | # ifdef MOUSE_SLIP_WHEELING |
|
|
2232 | } |
2215 | } |
2233 | #endif |
|
|
2234 | } |
2216 | } |
2235 | break; |
2217 | break; |
2236 | #endif |
2218 | #endif |
2237 | } |
2219 | } |
2238 | } |
2220 | } |
2239 | #ifdef MENUBAR |
|
|
2240 | else if (isMenuBarWindow (ev.window)) |
|
|
2241 | menubar_control (ev); |
|
|
2242 | #endif |
|
|
2243 | } |
2221 | } |
2244 | |
|
|
2245 | #ifdef TRANSPARENT |
|
|
2246 | #if TINTING |
|
|
2247 | /* taken from aterm-0.4.2 */ |
|
|
2248 | |
|
|
2249 | typedef uint32_t RUINT32T; |
|
|
2250 | |
|
|
2251 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2252 | { |
|
|
2253 | int sh_r, sh_g, sh_b; |
|
|
2254 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2255 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2256 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2257 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2258 | int i; |
|
|
2259 | |
|
|
2260 | Visual *visual = display->visual; |
|
|
2261 | |
|
|
2262 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2263 | |
|
|
2264 | /* for convenience */ |
|
|
2265 | mask_r = visual->red_mask; |
|
|
2266 | mask_g = visual->green_mask; |
|
|
2267 | mask_b = visual->blue_mask; |
|
|
2268 | |
|
|
2269 | /* boring lookup table pre-initialization */ |
|
|
2270 | switch (srcImage->bits_per_pixel) { |
|
|
2271 | case 15: |
|
|
2272 | if ((mask_r != 0x7c00) || |
|
|
2273 | (mask_g != 0x03e0) || |
|
|
2274 | (mask_b != 0x001f)) |
|
|
2275 | return; |
|
|
2276 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2277 | lookup_r = lookup; |
|
|
2278 | lookup_g = lookup+32; |
|
|
2279 | lookup_b = lookup+32+32; |
|
|
2280 | sh_r = 10; |
|
|
2281 | sh_g = 5; |
|
|
2282 | sh_b = 0; |
|
|
2283 | break; |
|
|
2284 | case 16: |
|
|
2285 | if ((mask_r != 0xf800) || |
|
|
2286 | (mask_g != 0x07e0) || |
|
|
2287 | (mask_b != 0x001f)) |
|
|
2288 | return; |
|
|
2289 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2290 | lookup_r = lookup; |
|
|
2291 | lookup_g = lookup+32; |
|
|
2292 | lookup_b = lookup+32+64; |
|
|
2293 | sh_r = 11; |
|
|
2294 | sh_g = 5; |
|
|
2295 | sh_b = 0; |
|
|
2296 | break; |
|
|
2297 | case 24: |
|
|
2298 | if ((mask_r != 0xff0000) || |
|
|
2299 | (mask_g != 0x00ff00) || |
|
|
2300 | (mask_b != 0x0000ff)) |
|
|
2301 | return; |
|
|
2302 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2303 | lookup_r = lookup; |
|
|
2304 | lookup_g = lookup+256; |
|
|
2305 | lookup_b = lookup+256+256; |
|
|
2306 | sh_r = 16; |
|
|
2307 | sh_g = 8; |
|
|
2308 | sh_b = 0; |
|
|
2309 | break; |
|
|
2310 | case 32: |
|
|
2311 | if ((mask_r != 0xff0000) || |
|
|
2312 | (mask_g != 0x00ff00) || |
|
|
2313 | (mask_b != 0x0000ff)) |
|
|
2314 | return; |
|
|
2315 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2316 | lookup_r = lookup; |
|
|
2317 | lookup_g = lookup+256; |
|
|
2318 | lookup_b = lookup+256+256; |
|
|
2319 | sh_r = 16; |
|
|
2320 | sh_g = 8; |
|
|
2321 | sh_b = 0; |
|
|
2322 | break; |
|
|
2323 | default: |
|
|
2324 | return; /* we do not support this color depth */ |
|
|
2325 | } |
|
|
2326 | |
|
|
2327 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2328 | if (shade < 0) { |
|
|
2329 | shade = -shade; |
|
|
2330 | if (shade < 0) shade = 0; |
|
|
2331 | if (shade > 100) shade = 100; |
|
|
2332 | |
|
|
2333 | lower_lim_r = 65535-rm; |
|
|
2334 | lower_lim_g = 65535-gm; |
|
|
2335 | lower_lim_b = 65535-bm; |
|
|
2336 | |
|
|
2337 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2338 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2339 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2340 | |
|
|
2341 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2342 | } else { |
|
|
2343 | if (shade < 0) shade = 0; |
|
|
2344 | if (shade > 100) shade = 100; |
|
|
2345 | |
|
|
2346 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2347 | |
|
|
2348 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2349 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2350 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2351 | } |
|
|
2352 | |
|
|
2353 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2354 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2355 | { |
|
|
2356 | unsigned int tmp; |
|
|
2357 | |
|
|
2358 | tmp = lower_lim_r; |
|
|
2359 | lower_lim_r = lower_lim_b; |
|
|
2360 | lower_lim_b = tmp; |
|
|
2361 | |
|
|
2362 | tmp = upper_lim_r; |
|
|
2363 | upper_lim_r = upper_lim_b; |
|
|
2364 | upper_lim_b = tmp; |
|
|
2365 | } |
|
|
2366 | |
|
|
2367 | /* fill our lookup tables */ |
|
|
2368 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2369 | { |
|
|
2370 | RUINT32T tmp; |
|
|
2371 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2372 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2373 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2374 | } |
|
|
2375 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2376 | { |
|
|
2377 | RUINT32T tmp; |
|
|
2378 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2379 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2380 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2381 | } |
|
|
2382 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2383 | { |
|
|
2384 | RUINT32T tmp; |
|
|
2385 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2386 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2387 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2388 | } |
|
|
2389 | |
|
|
2390 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2391 | switch (srcImage->bits_per_pixel) |
|
|
2392 | { |
|
|
2393 | case 15: |
|
|
2394 | { |
|
|
2395 | unsigned short *p1, *pf, *p, *pl; |
|
|
2396 | p1 = (unsigned short *) srcImage->data; |
|
|
2397 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2398 | while (p1 < pf) |
|
|
2399 | { |
|
|
2400 | p = p1; |
|
|
2401 | pl = p1 + srcImage->width; |
|
|
2402 | for (; p < pl; p++) |
|
|
2403 | { |
|
|
2404 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2405 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2406 | lookup_b[(*p & 0x001f)]; |
|
|
2407 | } |
|
|
2408 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2409 | } |
|
|
2410 | break; |
|
|
2411 | } |
|
|
2412 | case 16: |
|
|
2413 | { |
|
|
2414 | unsigned short *p1, *pf, *p, *pl; |
|
|
2415 | p1 = (unsigned short *) srcImage->data; |
|
|
2416 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2417 | while (p1 < pf) |
|
|
2418 | { |
|
|
2419 | p = p1; |
|
|
2420 | pl = p1 + srcImage->width; |
|
|
2421 | for (; p < pl; p++) |
|
|
2422 | { |
|
|
2423 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2424 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2425 | lookup_b[(*p & 0x001f)]; |
|
|
2426 | } |
|
|
2427 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2428 | } |
|
|
2429 | break; |
|
|
2430 | } |
|
|
2431 | case 24: |
|
|
2432 | { |
|
|
2433 | unsigned char *p1, *pf, *p, *pl; |
|
|
2434 | p1 = (unsigned char *) srcImage->data; |
|
|
2435 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2436 | while (p1 < pf) |
|
|
2437 | { |
|
|
2438 | p = p1; |
|
|
2439 | pl = p1 + srcImage->width * 3; |
|
|
2440 | for (; p < pl; p += 3) |
|
|
2441 | { |
|
|
2442 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2443 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2444 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2445 | } |
|
|
2446 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2447 | } |
|
|
2448 | break; |
|
|
2449 | } |
|
|
2450 | case 32: |
|
|
2451 | { |
|
|
2452 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2453 | p1 = (RUINT32T *) srcImage->data; |
|
|
2454 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2455 | |
|
|
2456 | while (p1 < pf) |
|
|
2457 | { |
|
|
2458 | p = p1; |
|
|
2459 | pl = p1 + srcImage->width; |
|
|
2460 | for (; p < pl; p++) |
|
|
2461 | { |
|
|
2462 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2463 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2464 | lookup_b[(*p & 0x0000ff)] | |
|
|
2465 | (*p & ~0xffffff); |
|
|
2466 | } |
|
|
2467 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2468 | } |
|
|
2469 | break; |
|
|
2470 | } |
|
|
2471 | } |
|
|
2472 | |
|
|
2473 | free (lookup); |
|
|
2474 | } |
|
|
2475 | #endif |
|
|
2476 | |
|
|
2477 | /* |
|
|
2478 | * Check our parents are still who we think they are. |
|
|
2479 | * Do transparency updates if required |
|
|
2480 | */ |
|
|
2481 | int |
|
|
2482 | rxvt_term::check_our_parents () |
|
|
2483 | { |
|
|
2484 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2485 | unsigned long nitems, bytes_after; |
|
|
2486 | Atom atype; |
|
|
2487 | unsigned char *prop = NULL; |
|
|
2488 | Window root, oldp, *list; |
|
|
2489 | Pixmap rootpixmap = None; |
|
|
2490 | XWindowAttributes wattr, wrootattr; |
|
|
2491 | dDisp; |
|
|
2492 | |
|
|
2493 | pchanged = 0; |
|
|
2494 | |
|
|
2495 | if (!OPTION (Opt_transparent)) |
|
|
2496 | return pchanged; /* Don't try any more */ |
|
|
2497 | |
|
|
2498 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2499 | rootdepth = wrootattr.depth; |
|
|
2500 | |
|
|
2501 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2502 | |
|
|
2503 | if (rootdepth != wattr.depth) |
|
|
2504 | { |
|
|
2505 | if (am_transparent) |
|
|
2506 | { |
|
|
2507 | pchanged = 1; |
|
|
2508 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2509 | am_transparent = am_pixmap_trans = 0; |
|
|
2510 | } |
|
|
2511 | |
|
|
2512 | return pchanged; /* Don't try any more */ |
|
|
2513 | } |
|
|
2514 | |
|
|
2515 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2516 | XSync (disp, False); |
|
|
2517 | |
|
|
2518 | /* |
|
|
2519 | * Make the frame window set by the window manager have |
|
|
2520 | * the root background. Some window managers put multiple nested frame |
|
|
2521 | * windows for each client, so we have to take care about that. |
|
|
2522 | */ |
|
|
2523 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2524 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2525 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2526 | &nitems, &bytes_after, &prop) == Success); |
|
|
2527 | |
|
|
2528 | if (!i || prop == NULL) |
|
|
2529 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2530 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2531 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2532 | &nitems, &bytes_after, &prop) == Success); |
|
|
2533 | |
|
|
2534 | if (!i || prop == NULL |
|
|
2535 | #if TINTING |
|
|
2536 | || !rs[Rs_color + Color_tint] |
|
|
2537 | #endif |
|
|
2538 | ) |
|
|
2539 | have_pixmap = 0; |
|
|
2540 | else |
|
|
2541 | { |
|
|
2542 | have_pixmap = 1; |
|
|
2543 | rootpixmap = *(Pixmap *)prop; |
|
|
2544 | XFree (prop); |
|
|
2545 | } |
|
|
2546 | |
|
|
2547 | if (have_pixmap) |
|
|
2548 | { |
|
|
2549 | /* |
|
|
2550 | * Copy display->root pixmap transparency |
|
|
2551 | */ |
|
|
2552 | int sx, sy, nx, ny; |
|
|
2553 | unsigned int nw, nh; |
|
|
2554 | Window cr; |
|
|
2555 | XImage *image; |
|
|
2556 | GC gc; |
|
|
2557 | XGCValues gcvalue; |
|
|
2558 | |
|
|
2559 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2560 | 0, 0, &sx, &sy, &cr); |
|
|
2561 | nw = (unsigned int)szHint.width; |
|
|
2562 | nh = (unsigned int)szHint.height; |
|
|
2563 | nx = ny = 0; |
|
|
2564 | |
|
|
2565 | if (sx < 0) |
|
|
2566 | { |
|
|
2567 | nw += sx; |
|
|
2568 | nx = -sx; |
|
|
2569 | sx = 0; |
|
|
2570 | } |
|
|
2571 | |
|
|
2572 | if (sy < 0) |
|
|
2573 | { |
|
|
2574 | nh += sy; |
|
|
2575 | ny = -sy; |
|
|
2576 | sy = 0; |
|
|
2577 | } |
|
|
2578 | |
|
|
2579 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2580 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2581 | |
|
|
2582 | XSync (disp, False); |
|
|
2583 | allowedxerror = -1; |
|
|
2584 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2585 | |
|
|
2586 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2587 | /* XXX: may need a delay here? */ |
|
|
2588 | allowedxerror = 0; |
|
|
2589 | |
|
|
2590 | if (image == NULL) |
|
|
2591 | { |
|
|
2592 | if (am_transparent && am_pixmap_trans) |
|
|
2593 | { |
|
|
2594 | pchanged = 1; |
|
|
2595 | if (pixmap != None) |
|
|
2596 | { |
|
|
2597 | XFreePixmap (disp, pixmap); |
|
|
2598 | pixmap = None; |
|
|
2599 | } |
|
|
2600 | } |
|
|
2601 | |
|
|
2602 | am_pixmap_trans = 0; |
|
|
2603 | } |
|
|
2604 | else |
|
|
2605 | { |
|
|
2606 | if (pixmap != None) |
|
|
2607 | XFreePixmap (disp, pixmap); |
|
|
2608 | |
|
|
2609 | #if TINTING |
|
|
2610 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2611 | { |
|
|
2612 | unsigned short rm, gm, bm; |
|
|
2613 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2614 | |
|
|
2615 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2616 | |
|
|
2617 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2618 | } |
|
|
2619 | #endif |
|
|
2620 | |
|
|
2621 | pixmap = XCreatePixmap (disp, vt, |
|
|
2622 | szHint.width, szHint.height, image->depth); |
|
|
2623 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2624 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2625 | nx, ny, image->width, image->height); |
|
|
2626 | XFreeGC (disp, gc); |
|
|
2627 | XDestroyImage (image); |
|
|
2628 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2629 | XClearWindow (disp, parent[0]); |
|
|
2630 | |
|
|
2631 | if (!am_transparent || !am_pixmap_trans) |
|
|
2632 | pchanged = 1; |
|
|
2633 | |
|
|
2634 | am_transparent = am_pixmap_trans = 1; |
|
|
2635 | } |
|
|
2636 | } |
|
|
2637 | |
|
|
2638 | if (am_pixmap_trans) |
|
|
2639 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2640 | else |
|
|
2641 | { |
|
|
2642 | unsigned int n; |
|
|
2643 | /* |
|
|
2644 | * InheritPixmap transparency |
|
|
2645 | */ |
|
|
2646 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2647 | { |
|
|
2648 | oldp = parent[i]; |
|
|
2649 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2650 | &parent[i], &list, &n); |
|
|
2651 | XFree (list); |
|
|
2652 | |
|
|
2653 | if (parent[i] == display->root) |
|
|
2654 | { |
|
|
2655 | if (oldp != None) |
|
|
2656 | pchanged = 1; |
|
|
2657 | |
|
|
2658 | break; |
|
|
2659 | } |
|
|
2660 | |
|
|
2661 | if (oldp != parent[i]) |
|
|
2662 | pchanged = 1; |
|
|
2663 | } |
|
|
2664 | |
|
|
2665 | n = 0; |
|
|
2666 | |
|
|
2667 | if (pchanged) |
|
|
2668 | { |
|
|
2669 | for (; n < (unsigned int)i; n++) |
|
|
2670 | { |
|
|
2671 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2672 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2673 | { |
|
|
2674 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2675 | break; |
|
|
2676 | } |
|
|
2677 | } |
|
|
2678 | } |
|
|
2679 | |
|
|
2680 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2681 | { |
|
|
2682 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2683 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2684 | am_transparent = 0; |
|
|
2685 | /* XXX: also turn off Opt_transparent? */ |
|
|
2686 | } |
|
|
2687 | else |
|
|
2688 | { |
|
|
2689 | #if WAIT_FOR_WM |
|
|
2690 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2691 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2692 | sleep (1); |
|
|
2693 | #endif |
|
|
2694 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2695 | { |
|
|
2696 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2697 | XClearWindow (disp, parent[n]); |
|
|
2698 | } |
|
|
2699 | |
|
|
2700 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2701 | am_transparent = 1; |
|
|
2702 | } |
|
|
2703 | |
|
|
2704 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2705 | parent[i] = None; |
|
|
2706 | } |
|
|
2707 | |
|
|
2708 | if (scrollBar.win) |
|
|
2709 | { |
|
|
2710 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2711 | scrollBar.setIdle (); |
|
|
2712 | scrollbar_show (0); |
|
|
2713 | } |
|
|
2714 | |
|
|
2715 | if (am_transparent) |
|
|
2716 | { |
|
|
2717 | want_refresh = want_full_refresh = 1; |
|
|
2718 | if (am_pixmap_trans) |
|
|
2719 | flush (); |
|
|
2720 | } |
|
|
2721 | |
|
|
2722 | return pchanged; |
|
|
2723 | } |
|
|
2724 | #endif |
|
|
2725 | |
2222 | |
2726 | /*}}} */ |
2223 | /*}}} */ |
2727 | |
2224 | |
2728 | bool |
2225 | void ecb_hot |
2729 | rxvt_term::cmd_parse () |
2226 | rxvt_term::cmd_parse () |
2730 | { |
2227 | { |
2731 | bool flag = false; |
|
|
2732 | wchar_t ch = NOCHAR; |
2228 | wchar_t ch = NOCHAR; |
2733 | char *seq_begin; // remember start of esc-sequence here |
2229 | char *seq_begin; // remember start of esc-sequence here |
2734 | |
2230 | |
2735 | for (;;) |
2231 | for (;;) |
2736 | { |
2232 | { |
2737 | if (ch == NOCHAR) |
2233 | if (ecb_unlikely (ch == NOCHAR)) |
2738 | { |
2234 | { |
2739 | seq_begin = cmdbuf_ptr; |
2235 | seq_begin = cmdbuf_ptr; |
2740 | ch = next_char (); |
2236 | ch = next_char (); |
2741 | |
2237 | |
2742 | if (ch == NOCHAR) |
2238 | if (ch == NOCHAR) |
2743 | break; |
2239 | break; |
2744 | } |
2240 | } |
2745 | |
2241 | |
2746 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2242 | if (ecb_likely (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
2747 | { |
2243 | { |
2748 | if (!seen_input) |
2244 | if (ecb_unlikely (!seen_input)) |
2749 | { |
2245 | { |
2750 | seen_input = 1; |
2246 | seen_input = 1; |
2751 | // many badly-written programs (e.g. jed) contain a race condition: |
2247 | // many badly-written programs (e.g. jed) contain a race condition: |
2752 | // they first read the screensize and then install a SIGWINCH handler. |
2248 | // they first read the screensize and then install a SIGWINCH handler. |
2753 | // some window managers resize the window early, and these programs |
2249 | // some window managers resize the window early, and these programs |
… | |
… | |
2766 | wchar_t *str = buf; |
2262 | wchar_t *str = buf; |
2767 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2263 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2768 | |
2264 | |
2769 | for (;;) |
2265 | for (;;) |
2770 | { |
2266 | { |
2771 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2267 | if (ecb_unlikely (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
2772 | break; |
2268 | break; |
2773 | |
2269 | |
2774 | *str++ = ch; |
2270 | *str++ = ch; |
2775 | |
2271 | |
2776 | if (ch == C0_LF || str >= eol) |
2272 | if (ecb_unlikely (ch == C0_LF || str >= eol)) |
2777 | { |
2273 | { |
2778 | if (ch == C0_LF) |
2274 | if (ch == C0_LF) |
2779 | nlines++; |
2275 | nlines++; |
2780 | |
2276 | |
2781 | refresh_count++; |
2277 | refresh_count++; |
2782 | |
2278 | |
2783 | if (!OPTION (Opt_jumpScroll) |
2279 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2784 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2785 | { |
2280 | { |
2786 | refreshnow = true; |
|
|
2787 | refresh_count = 0; |
2281 | refresh_count = 0; |
|
|
2282 | |
|
|
2283 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2284 | { |
|
|
2285 | refreshnow = true; |
2788 | ch = NOCHAR; |
2286 | ch = NOCHAR; |
2789 | break; |
2287 | break; |
|
|
2288 | } |
2790 | } |
2289 | } |
2791 | |
2290 | |
2792 | // scr_add_lines only works for nlines <= nrow - 1. |
2291 | // scr_add_lines only works for nlines <= nrow - 1. |
2793 | if (nlines >= nrow - 1) |
2292 | if (nlines >= nrow - 1) |
2794 | { |
2293 | { |
|
|
2294 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2795 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2295 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2796 | scr_add_lines (buf, str - buf, nlines); |
2296 | scr_add_lines (buf, str - buf, nlines); |
2797 | |
2297 | |
2798 | nlines = 0; |
2298 | nlines = 0; |
2799 | str = buf; |
2299 | str = buf; |
2800 | eol = str + min (ncol, UBUFSIZ); |
2300 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2815 | |
2315 | |
2816 | seq_begin = cmdbuf_ptr; |
2316 | seq_begin = cmdbuf_ptr; |
2817 | ch = next_char (); |
2317 | ch = next_char (); |
2818 | } |
2318 | } |
2819 | |
2319 | |
|
|
2320 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2820 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2321 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2821 | scr_add_lines (buf, str - buf, nlines); |
2322 | scr_add_lines (buf, str - buf, nlines); |
2822 | |
2323 | |
2823 | /* |
2324 | /* |
2824 | * If there have been a lot of new lines, then update the screen |
2325 | * If there have been a lot of new lines, then update the screen |
2825 | * What the heck I'll cheat and only refresh less than every page-full. |
2326 | * What the heck we'll cheat and only refresh less than every page-full. |
2826 | * the number of pages between refreshes is refresh_limit, which |
2327 | * if skipScroll is enabled. |
2827 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2828 | */ |
2328 | */ |
2829 | if (refreshnow) |
2329 | if (refreshnow) |
2830 | { |
2330 | { |
2831 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2832 | refresh_limit++; |
|
|
2833 | else |
|
|
2834 | { |
|
|
2835 | flag = true; |
|
|
2836 | scr_refresh (refresh_type); |
2331 | scr_refresh (); |
2837 | flush_ev.stop (); |
2332 | want_refresh = 1; |
2838 | } |
|
|
2839 | } |
2333 | } |
2840 | |
|
|
2841 | } |
2334 | } |
2842 | else |
2335 | else |
2843 | { |
2336 | { |
2844 | try |
2337 | try |
2845 | { |
2338 | { |
… | |
… | |
2853 | } |
2346 | } |
2854 | |
2347 | |
2855 | ch = NOCHAR; |
2348 | ch = NOCHAR; |
2856 | } |
2349 | } |
2857 | } |
2350 | } |
2858 | |
|
|
2859 | return flag; |
|
|
2860 | } |
2351 | } |
2861 | |
2352 | |
2862 | // read the next character |
2353 | // read the next character |
2863 | wchar_t |
2354 | wchar_t ecb_hot |
2864 | rxvt_term::next_char () |
2355 | rxvt_term::next_char () NOTHROW |
2865 | { |
2356 | { |
2866 | while (cmdbuf_ptr < cmdbuf_endp) |
2357 | while (cmdbuf_ptr < cmdbuf_endp) |
2867 | { |
2358 | { |
2868 | // assume 7-bit to be ascii ALWAYS |
2359 | // assume 7-bit to be ascii ALWAYS |
2869 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2360 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2870 | return *cmdbuf_ptr++; |
2361 | return *cmdbuf_ptr++; |
2871 | |
2362 | |
2872 | wchar_t wc; |
2363 | wchar_t wc; |
2873 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2364 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2874 | |
2365 | |
… | |
… | |
2878 | cmdbuf_ptr = cmdbuf_endp; |
2369 | cmdbuf_ptr = cmdbuf_endp; |
2879 | break; |
2370 | break; |
2880 | } |
2371 | } |
2881 | |
2372 | |
2882 | if (len == (size_t)-1) |
2373 | if (len == (size_t)-1) |
|
|
2374 | { |
|
|
2375 | mbstate.reset (); // reset now undefined conversion state |
|
|
2376 | // a -1 might indicate that a previous incomplete char is invalid (previous return -2) |
|
|
2377 | // in which case we "erroneously" return the next byte which might be valid. |
2883 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2378 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
2379 | } |
2884 | |
2380 | |
2885 | // assume wchar == unicode |
2381 | // assume wchar == unicode |
2886 | cmdbuf_ptr += len; |
2382 | cmdbuf_ptr += len; |
2887 | return wc & UNICODE_MASK; |
2383 | return wc & UNICODE_MASK; |
2888 | } |
2384 | } |
2889 | |
2385 | |
2890 | return NOCHAR; |
2386 | return NOCHAR; |
2891 | } |
2387 | } |
2892 | |
2388 | |
2893 | // read the next octet |
2389 | // read the next octet |
2894 | uint32_t |
2390 | uint32_t ecb_hot |
2895 | rxvt_term::next_octet () |
2391 | rxvt_term::next_octet () NOTHROW |
2896 | { |
2392 | { |
2897 | return cmdbuf_ptr < cmdbuf_endp |
2393 | return cmdbuf_ptr < cmdbuf_endp |
2898 | ? (unsigned char)*cmdbuf_ptr++ |
2394 | ? (unsigned char)*cmdbuf_ptr++ |
2899 | : NOCHAR; |
2395 | : NOCHAR; |
2900 | } |
2396 | } |
2901 | |
2397 | |
2902 | /* rxvt_cmd_getc () - Return next input character */ |
2398 | static class out_of_input out_of_input; |
2903 | /* |
2399 | |
2904 | * Return the next input character after first passing any keyboard input |
2400 | wchar_t ecb_hot |
2905 | * to the command. |
2401 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2906 | */ |
|
|
2907 | wchar_t |
|
|
2908 | rxvt_term::cmd_getc () |
|
|
2909 | { |
2402 | { |
2910 | wchar_t c = next_char (); |
2403 | wchar_t c = next_char (); |
2911 | |
2404 | |
2912 | if (c == NOCHAR) |
2405 | if (c == NOCHAR) |
2913 | throw out_of_input; |
2406 | throw out_of_input; |
2914 | |
2407 | |
2915 | return c; |
2408 | return c; |
2916 | } |
2409 | } |
2917 | |
2410 | |
2918 | uint32_t |
2411 | uint32_t ecb_hot |
2919 | rxvt_term::cmd_get8 () |
2412 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2920 | { |
2413 | { |
2921 | uint32_t c = next_octet (); |
2414 | uint32_t c = next_octet (); |
2922 | |
2415 | |
2923 | if (c == NOCHAR) |
2416 | if (c == NOCHAR) |
2924 | throw out_of_input; |
2417 | throw out_of_input; |
… | |
… | |
2927 | } |
2420 | } |
2928 | |
2421 | |
2929 | /*{{{ print pipe */ |
2422 | /*{{{ print pipe */ |
2930 | /*----------------------------------------------------------------------*/ |
2423 | /*----------------------------------------------------------------------*/ |
2931 | #ifdef PRINTPIPE |
2424 | #ifdef PRINTPIPE |
2932 | FILE * |
2425 | FILE * ecb_cold |
2933 | rxvt_term::popen_printer () |
2426 | rxvt_term::popen_printer () |
2934 | { |
2427 | { |
2935 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2428 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2936 | |
2429 | |
2937 | if (stream == NULL) |
2430 | if (stream == NULL) |
2938 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2431 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2939 | |
2432 | |
2940 | return stream; |
2433 | return stream; |
2941 | } |
2434 | } |
2942 | |
2435 | |
2943 | int |
2436 | int ecb_cold |
2944 | rxvt_term::pclose_printer (FILE *stream) |
2437 | rxvt_term::pclose_printer (FILE *stream) |
2945 | { |
2438 | { |
2946 | fflush (stream); |
2439 | fflush (stream); |
2947 | return pclose (stream); |
2440 | return pclose (stream); |
2948 | } |
2441 | } |
2949 | |
2442 | |
2950 | /* |
2443 | /* |
2951 | * simulate attached vt100 printer |
2444 | * simulate attached vt100 printer |
2952 | */ |
2445 | */ |
2953 | void |
2446 | void ecb_cold |
2954 | rxvt_term::process_print_pipe () |
2447 | rxvt_term::process_print_pipe () |
2955 | { |
2448 | { |
2956 | int done; |
2449 | FILE *fd = popen_printer (); |
2957 | FILE *fd; |
|
|
2958 | |
2450 | |
2959 | if ((fd = popen_printer ()) == NULL) |
2451 | if (!fd) |
2960 | return; |
2452 | return; |
2961 | |
2453 | |
2962 | /* |
2454 | /* |
2963 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2455 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2964 | * is received. |
2456 | * is received. |
2965 | */ |
2457 | */ |
2966 | for (done = 0; !done;) |
2458 | for (int done = 0; !done; ) |
2967 | { |
2459 | { |
2968 | unsigned char buf[8]; |
2460 | unsigned char buf[8]; |
2969 | unicode_t ch; |
2461 | unicode_t ch; |
2970 | unsigned int i, len; |
2462 | unsigned int i, len; |
2971 | |
2463 | |
… | |
… | |
2990 | { |
2482 | { |
2991 | if ((buf[len++] = cmd_getc ()) == 'i') |
2483 | if ((buf[len++] = cmd_getc ()) == 'i') |
2992 | break; /* done = 1 */ |
2484 | break; /* done = 1 */ |
2993 | } |
2485 | } |
2994 | } |
2486 | } |
2995 | |
2487 | |
2996 | for (i = 0; i < len; i++) |
2488 | for (i = 0; i < len; i++) |
2997 | if (putc (buf[i], fd) == EOF) |
2489 | if (putc (buf[i], fd) == EOF) |
2998 | { |
2490 | { |
2999 | done = 1; |
2491 | done = 1; |
3000 | break; |
2492 | break; |
… | |
… | |
3002 | } |
2494 | } |
3003 | } |
2495 | } |
3004 | |
2496 | |
3005 | pclose_printer (fd); |
2497 | pclose_printer (fd); |
3006 | } |
2498 | } |
3007 | #endif /* PRINTPIPE */ |
2499 | #endif /* PRINTPIPE */ |
3008 | /*}}} */ |
2500 | /*}}} */ |
3009 | |
2501 | |
3010 | /* *INDENT-OFF* */ |
|
|
3011 | enum { |
2502 | enum { |
3012 | C1_40 = 0x40, |
2503 | C1_40 = 0x40, |
3013 | C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, |
2504 | C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, |
3014 | C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, |
2505 | C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, |
3015 | C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, |
2506 | C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, |
3016 | C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC, |
2507 | C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC, |
3017 | }; |
2508 | }; |
3018 | /* *INDENT-ON* */ |
|
|
3019 | |
2509 | |
3020 | /*{{{ process non-printing single characters */ |
2510 | /*{{{ process non-printing single characters */ |
3021 | void |
2511 | void ecb_hot |
3022 | rxvt_term::process_nonprinting (unicode_t ch) |
2512 | rxvt_term::process_nonprinting (unicode_t ch) |
3023 | { |
2513 | { |
3024 | switch (ch) |
2514 | switch (ch) |
3025 | { |
2515 | { |
3026 | case C0_ESC: |
2516 | case C0_ESC: |
… | |
… | |
3056 | scr_charset_choose (0); |
2546 | scr_charset_choose (0); |
3057 | break; |
2547 | break; |
3058 | |
2548 | |
3059 | #ifdef EIGHT_BIT_CONTROLS |
2549 | #ifdef EIGHT_BIT_CONTROLS |
3060 | // 8-bit controls |
2550 | // 8-bit controls |
3061 | case 0x90: /* DCS */ |
2551 | case 0x90: /* DCS */ |
3062 | process_dcs_seq (); |
2552 | process_dcs_seq (); |
3063 | break; |
2553 | break; |
3064 | case 0x9b: /* CSI */ |
2554 | case 0x9b: /* CSI */ |
3065 | process_csi_seq (); |
2555 | process_csi_seq (); |
3066 | break; |
2556 | break; |
3067 | case 0x9d: /* CSI */ |
2557 | case 0x9d: /* OSC */ |
3068 | process_osc_seq (); |
2558 | process_osc_seq (); |
3069 | break; |
2559 | break; |
3070 | #endif |
2560 | #endif |
3071 | } |
2561 | } |
3072 | } |
2562 | } |
3073 | /*}}} */ |
2563 | /*}}} */ |
3074 | |
2564 | |
3075 | |
2565 | |
3076 | /*{{{ process VT52 escape sequences */ |
2566 | /*{{{ process VT52 escape sequences */ |
3077 | void |
2567 | void ecb_cold |
3078 | rxvt_term::process_escape_vt52 (unicode_t ch) |
2568 | rxvt_term::process_escape_vt52 (unicode_t ch) |
3079 | { |
2569 | { |
3080 | int row, col; |
2570 | int row, col; |
3081 | |
2571 | |
3082 | switch (ch) |
2572 | switch (ch) |
… | |
… | |
3116 | break; |
2606 | break; |
3117 | case 'Z': /* identify the terminal type */ |
2607 | case 'Z': /* identify the terminal type */ |
3118 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2608 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
3119 | break; |
2609 | break; |
3120 | case '<': /* turn off VT52 mode */ |
2610 | case '<': /* turn off VT52 mode */ |
3121 | PrivMode (0, PrivMode_vt52); |
2611 | priv_modes &= ~PrivMode_vt52; |
3122 | break; |
2612 | break; |
3123 | case 'F': /* use special graphics character set */ |
2613 | case 'F': /* use special graphics character set */ |
3124 | case 'G': /* use regular character set */ |
2614 | case 'G': /* use regular character set */ |
3125 | /* unimplemented */ |
2615 | /* unimplemented */ |
3126 | break; |
2616 | break; |
… | |
… | |
3132 | } |
2622 | } |
3133 | /*}}} */ |
2623 | /*}}} */ |
3134 | |
2624 | |
3135 | |
2625 | |
3136 | /*{{{ process escape sequences */ |
2626 | /*{{{ process escape sequences */ |
3137 | void |
2627 | void ecb_hot |
3138 | rxvt_term::process_escape_seq () |
2628 | rxvt_term::process_escape_seq () |
3139 | { |
2629 | { |
3140 | unicode_t ch = cmd_getc (); |
2630 | unicode_t ch = cmd_getc (); |
3141 | |
2631 | |
3142 | if (priv_modes & PrivMode_vt52) |
2632 | if (priv_modes & PrivMode_vt52) |
… | |
… | |
3145 | return; |
2635 | return; |
3146 | } |
2636 | } |
3147 | |
2637 | |
3148 | switch (ch) |
2638 | switch (ch) |
3149 | { |
2639 | { |
3150 | /* case 1: do_tek_mode (); break; */ |
|
|
3151 | case '#': |
2640 | case '#': |
3152 | if (cmd_getc () == '8') |
2641 | if (cmd_getc () == '8') |
3153 | scr_E (); |
2642 | scr_E (); |
3154 | break; |
2643 | break; |
3155 | case '(': |
2644 | case '(': |
… | |
… | |
3162 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2651 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3163 | break; |
2652 | break; |
3164 | case '+': |
2653 | case '+': |
3165 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2654 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3166 | break; |
2655 | break; |
3167 | #if ENABLE_FRILLS |
2656 | #if !ENABLE_MINIMAL |
3168 | case '6': |
2657 | case '6': |
3169 | scr_backindex (); |
2658 | scr_backindex (); |
3170 | break; |
2659 | break; |
3171 | #endif |
2660 | #endif |
3172 | case '7': |
2661 | case '7': |
3173 | scr_cursor (SAVE); |
2662 | scr_cursor (SAVE); |
3174 | break; |
2663 | break; |
3175 | case '8': |
2664 | case '8': |
3176 | scr_cursor (RESTORE); |
2665 | scr_cursor (RESTORE); |
3177 | break; |
2666 | break; |
3178 | #if ENABLE_FRILLS |
2667 | #if !ENABLE_MINIMAL |
3179 | case '9': |
2668 | case '9': |
3180 | scr_forwardindex (); |
2669 | scr_forwardindex (); |
3181 | break; |
2670 | break; |
3182 | #endif |
2671 | #endif |
|
|
2672 | // DECPAM/DECPNM |
3183 | case '=': |
2673 | case '=': |
|
|
2674 | priv_modes |= PrivMode_aplKP; |
|
|
2675 | break; |
3184 | case '>': |
2676 | case '>': |
3185 | PrivMode ((ch == '='), PrivMode_aplKP); |
2677 | priv_modes &= ~PrivMode_aplKP; |
3186 | break; |
2678 | break; |
3187 | |
2679 | |
3188 | case C1_40: |
2680 | case C1_40: |
3189 | cmd_getc (); |
2681 | cmd_getc (); |
3190 | break; |
2682 | break; |
… | |
… | |
3194 | |
2686 | |
3195 | /* 8.3.87: NEXT LINE */ |
2687 | /* 8.3.87: NEXT LINE */ |
3196 | case C1_NEL: /* ESC E */ |
2688 | case C1_NEL: /* ESC E */ |
3197 | { |
2689 | { |
3198 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
2690 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3199 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
2691 | scr_add_lines (nlcr, ecb_array_length (nlcr), 1); |
3200 | } |
2692 | } |
3201 | break; |
2693 | break; |
3202 | |
2694 | |
3203 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2695 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3204 | case C1_ESA: /* ESC G */ |
2696 | case C1_ESA: /* ESC G */ |
3205 | process_graphics (); |
2697 | // used by original rxvt for rob nations own graphics mode |
|
|
2698 | if (cmd_getc () == 'Q') |
|
|
2699 | tt_printf ("\033G0\012"); /* query graphics - no graphics */ |
3206 | break; |
2700 | break; |
3207 | |
2701 | |
3208 | /* 8.3.63: CHARACTER TABULATION SET */ |
2702 | /* 8.3.63: CHARACTER TABULATION SET */ |
3209 | case C1_HTS: /* ESC H */ |
2703 | case C1_HTS: /* ESC H */ |
3210 | scr_set_tab (1); |
2704 | scr_set_tab (1); |
… | |
… | |
3214 | case C1_RI: /* ESC M */ |
2708 | case C1_RI: /* ESC M */ |
3215 | scr_index (DN); |
2709 | scr_index (DN); |
3216 | break; |
2710 | break; |
3217 | |
2711 | |
3218 | /* 8.3.142: SINGLE-SHIFT TWO */ |
2712 | /* 8.3.142: SINGLE-SHIFT TWO */ |
3219 | /*case C1_SS2: scr_single_shift (2); break; */ |
2713 | /* case C1_SS2: break; */ |
3220 | |
2714 | |
3221 | /* 8.3.143: SINGLE-SHIFT THREE */ |
2715 | /* 8.3.143: SINGLE-SHIFT THREE */ |
3222 | /*case C1_SS3: scr_single_shift (3); break; */ |
2716 | /* case C1_SS3: break; */ |
3223 | |
2717 | |
3224 | /* 8.3.27: DEVICE CONTROL STRING */ |
2718 | /* 8.3.27: DEVICE CONTROL STRING */ |
3225 | case C1_DCS: /* ESC P */ |
2719 | case C1_DCS: /* ESC P */ |
3226 | process_dcs_seq (); |
2720 | process_dcs_seq (); |
3227 | break; |
2721 | break; |
… | |
… | |
3229 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2723 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3230 | case C1_SCI: /* ESC Z */ |
2724 | case C1_SCI: /* ESC Z */ |
3231 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2725 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3232 | break; /* steal obsolete ESC [ c */ |
2726 | break; /* steal obsolete ESC [ c */ |
3233 | |
2727 | |
3234 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2728 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
3235 | case C1_CSI: /* ESC [ */ |
2729 | case C1_CSI: /* ESC [ */ |
3236 | process_csi_seq (); |
2730 | process_csi_seq (); |
3237 | break; |
2731 | break; |
3238 | |
2732 | |
3239 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2733 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
3240 | case C1_OSC: /* ESC ] */ |
2734 | case C1_OSC: /* ESC ] */ |
3241 | process_osc_seq (); |
2735 | process_osc_seq (); |
3242 | break; |
2736 | break; |
3243 | |
2737 | |
3244 | /* 8.3.106: RESET TO INITIAL STATE */ |
2738 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
3245 | case 'c': |
2739 | case 'c': |
3246 | mbstate.reset (); |
2740 | mbstate.reset (); |
3247 | scr_poweron (); |
2741 | scr_poweron (); |
3248 | scrollbar_show (1); |
2742 | scrollBar.show (1); |
3249 | break; |
2743 | break; |
3250 | |
2744 | |
3251 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2745 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
3252 | case 'n': |
2746 | case 'n': |
3253 | scr_charset_choose (2); |
2747 | scr_charset_choose (2); |
… | |
… | |
3260 | } |
2754 | } |
3261 | } |
2755 | } |
3262 | /*}}} */ |
2756 | /*}}} */ |
3263 | |
2757 | |
3264 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2758 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
3265 | /* *INDENT-OFF* */ |
|
|
3266 | enum { |
2759 | enum { |
3267 | CSI_ICH = 0x40, |
2760 | CSI_ICH = 0x40, |
3268 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2761 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
3269 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2762 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
3270 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2763 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
… | |
… | |
3273 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2766 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
3274 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2767 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
3275 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2768 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
3276 | }; |
2769 | }; |
3277 | |
2770 | |
3278 | #define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ |
2771 | #define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \ |
3279 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2772 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
3280 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2773 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
3281 | #define get_byte_array_bit(array, bit) \ |
2774 | #define get_byte_array_bit(array, bit) \ |
3282 | (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) |
2775 | (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7)))) |
3283 | |
2776 | |
3284 | const unsigned char csi_defaults[] = |
2777 | static const unsigned char csi_defaults[] = |
3285 | { |
2778 | { |
3286 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2779 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
3287 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2780 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
3288 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2781 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
3289 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
2782 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
3290 | make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ |
2783 | make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ |
3291 | make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ |
2784 | make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ |
3292 | make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ |
2785 | make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ |
3293 | make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ |
2786 | make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ |
3294 | }; |
2787 | }; |
3295 | /* *INDENT-ON* */ |
|
|
3296 | |
2788 | |
3297 | void |
2789 | void ecb_hot |
3298 | rxvt_term::process_csi_seq () |
2790 | rxvt_term::process_csi_seq () |
3299 | { |
2791 | { |
3300 | unicode_t ch, priv, i; |
2792 | unicode_t ch, priv, prev_ch, i; |
3301 | unsigned int nargs, p; |
2793 | unsigned int nargs, p; |
3302 | int n, ndef; |
2794 | int n, ndef; |
3303 | int arg[ESC_ARGS]; |
2795 | int arg[ESC_ARGS] = { }; |
3304 | |
2796 | |
3305 | for (nargs = ESC_ARGS; nargs > 0;) |
2797 | nargs = 0; |
3306 | arg[--nargs] = 0; |
|
|
3307 | |
2798 | |
3308 | priv = 0; |
2799 | priv = 0; |
3309 | ch = cmd_getc (); |
2800 | ch = cmd_getc (); |
3310 | if (ch >= '<' && ch <= '?') |
2801 | if ((ch >= '<' && ch <= '?') || ch == '!') |
|
|
2802 | { |
3311 | { /* '<' '=' '>' '?' */ |
2803 | /* '<' '=' '>' '?' '!' */ |
3312 | priv = ch; |
2804 | priv = ch; |
3313 | ch = cmd_getc (); |
2805 | ch = cmd_getc (); |
3314 | } |
2806 | } |
3315 | |
2807 | |
|
|
2808 | prev_ch = 0; |
3316 | /* read any numerical arguments */ |
2809 | /* read any numerical arguments */ |
3317 | for (n = -1; ch < CSI_ICH; ) |
2810 | for (n = -1; ch < CSI_ICH; ) |
3318 | { |
2811 | { |
3319 | if (isdigit (ch)) |
2812 | if (isdigit (ch)) |
3320 | { |
2813 | { |
… | |
… | |
3330 | n = -1; |
2823 | n = -1; |
3331 | } |
2824 | } |
3332 | else if (IS_CONTROL (ch)) |
2825 | else if (IS_CONTROL (ch)) |
3333 | process_nonprinting (ch); |
2826 | process_nonprinting (ch); |
3334 | |
2827 | |
|
|
2828 | prev_ch = ch; |
3335 | ch = cmd_getc (); |
2829 | ch = cmd_getc (); |
3336 | } |
2830 | } |
3337 | |
2831 | |
3338 | if (ch > CSI_7F) |
2832 | if (ch > CSI_7F) |
3339 | return; |
2833 | return; |
… | |
… | |
3345 | ndef = get_byte_array_bit (csi_defaults, i); |
2839 | ndef = get_byte_array_bit (csi_defaults, i); |
3346 | for (p = 0; p < nargs; p++) |
2840 | for (p = 0; p < nargs; p++) |
3347 | if (arg[p] == -1) |
2841 | if (arg[p] == -1) |
3348 | arg[p] = ndef; |
2842 | arg[p] = ndef; |
3349 | |
2843 | |
3350 | #ifdef DEBUG_CMD |
|
|
3351 | fprintf (stderr, "CSI "); |
|
|
3352 | for (p = 0; p < nargs; p++) |
|
|
3353 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3354 | fprintf (stderr, "%c\n", ch); |
|
|
3355 | #endif |
|
|
3356 | |
|
|
3357 | /* |
2844 | /* |
3358 | * private mode handling |
2845 | * private mode handling |
3359 | */ |
2846 | */ |
3360 | if (priv) |
2847 | if (priv) |
3361 | { |
2848 | { |
3362 | switch (priv) |
2849 | switch (priv) |
3363 | { |
2850 | { |
3364 | case '>': |
2851 | case '>': |
3365 | if (ch == CSI_DA) /* secondary device attributes */ |
2852 | if (ch == CSI_DA) /* secondary device attributes */ |
3366 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2853 | { |
|
|
2854 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2855 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2856 | // |
|
|
2857 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2858 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
|
|
2859 | // versions. |
|
|
2860 | // |
|
|
2861 | tt_printf ("\033[>%d;95;0c", 'U'); |
|
|
2862 | } |
3367 | break; |
2863 | break; |
|
|
2864 | |
3368 | case '?': |
2865 | case '?': |
3369 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2866 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3370 | process_terminal_mode (ch, priv, nargs, arg); |
2867 | process_terminal_mode (ch, priv, nargs, arg); |
3371 | break; |
2868 | break; |
|
|
2869 | |
|
|
2870 | case '!': |
|
|
2871 | if (ch == CSI_70) |
|
|
2872 | { |
|
|
2873 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2874 | scr_soft_reset (); |
|
|
2875 | |
|
|
2876 | static const int pm_h[] = { 7, 25 }; |
|
|
2877 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; |
|
|
2878 | |
|
|
2879 | process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h); |
|
|
2880 | process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l); |
3372 | } |
2881 | } |
|
|
2882 | break; |
|
|
2883 | } |
|
|
2884 | |
3373 | return; |
2885 | return; |
3374 | } |
2886 | } |
3375 | |
2887 | |
3376 | switch (ch) |
2888 | switch (ch) |
3377 | { |
2889 | { |
… | |
… | |
3391 | } |
2903 | } |
3392 | break; |
2904 | break; |
3393 | #endif |
2905 | #endif |
3394 | |
2906 | |
3395 | case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ |
2907 | case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ |
3396 | case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ |
2908 | case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ |
3397 | arg[0] = -arg[0]; |
2909 | arg[0] = -arg[0]; |
3398 | /* FALLTHROUGH */ |
2910 | /* FALLTHROUGH */ |
3399 | case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ |
2911 | case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ |
3400 | case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ |
2912 | case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ |
3401 | scr_gotorc (arg[0], 0, RELATIVE); |
2913 | scr_gotorc (arg[0], 0, RELATIVE); |
3402 | break; |
2914 | break; |
3403 | |
2915 | |
3404 | case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ |
2916 | case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ |
3405 | case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ |
2917 | case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ |
… | |
… | |
3497 | break; |
3009 | break; |
3498 | case 6: /* CPR requested */ |
3010 | case 6: /* CPR requested */ |
3499 | scr_report_position (); |
3011 | scr_report_position (); |
3500 | break; |
3012 | break; |
3501 | case 7: /* unofficial extension */ |
3013 | case 7: /* unofficial extension */ |
3502 | if (OPTION (Opt_insecure)) |
3014 | if (option (Opt_insecure)) |
3503 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3015 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3504 | break; |
3016 | break; |
3505 | case 8: /* unofficial extension */ |
3017 | case 8: /* unofficial extension */ |
3506 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3018 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3507 | break; |
3019 | break; |
… | |
… | |
3555 | scr_insert_mode (1); |
3067 | scr_insert_mode (1); |
3556 | else if (arg[0] == 20) |
3068 | else if (arg[0] == 20) |
3557 | priv_modes |= PrivMode_LFNL; |
3069 | priv_modes |= PrivMode_LFNL; |
3558 | break; |
3070 | break; |
3559 | |
3071 | |
|
|
3072 | case CSI_71: // DECSCUSR: set cursor style |
|
|
3073 | if (prev_ch == ' ') |
|
|
3074 | set_cursor_style (arg[0]); |
|
|
3075 | break; |
|
|
3076 | |
3560 | /* |
3077 | /* |
3561 | * PRIVATE USE beyond this point. All CSI_7? sequences here |
3078 | * PRIVATE USE beyond this point. All CSI_7? sequences here |
3562 | */ |
3079 | */ |
3563 | case CSI_72: /* DECSTBM: set top and bottom margins */ |
3080 | case CSI_72: /* DECSTBM: set top and bottom margins */ |
3564 | if (nargs == 1) |
3081 | if (nargs == 1) |
… | |
… | |
3574 | break; |
3091 | break; |
3575 | case CSI_75: |
3092 | case CSI_75: |
3576 | scr_cursor (RESTORE); |
3093 | scr_cursor (RESTORE); |
3577 | break; |
3094 | break; |
3578 | |
3095 | |
3579 | #if ENABLE_FRILLS |
3096 | #if !ENABLE_MINIMAL |
3580 | case CSI_74: |
3097 | case CSI_74: |
3581 | process_window_ops (arg, nargs); |
3098 | process_window_ops (arg, nargs); |
3582 | break; |
3099 | break; |
3583 | #endif |
3100 | #endif |
3584 | |
3101 | |
… | |
… | |
3591 | break; |
3108 | break; |
3592 | } |
3109 | } |
3593 | } |
3110 | } |
3594 | /*}}} */ |
3111 | /*}}} */ |
3595 | |
3112 | |
3596 | #if ENABLE_FRILLS |
3113 | #if !ENABLE_MINIMAL |
3597 | /* ARGSUSED */ |
|
|
3598 | void |
3114 | void |
3599 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3115 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3600 | { |
3116 | { |
3601 | int x, y; |
3117 | int x, y; |
3602 | XWindowAttributes wattr; |
3118 | XWindowAttributes wattr; |
3603 | Window wdummy; |
3119 | Window wdummy; |
3604 | dDisp; |
3120 | |
|
|
3121 | dLocal (Display *, dpy); |
3605 | |
3122 | |
3606 | if (nargs == 0) |
3123 | if (nargs == 0) |
3607 | return; |
3124 | return; |
3608 | |
3125 | |
3609 | switch (args[0]) |
3126 | switch (args[0]) |
3610 | { |
3127 | { |
3611 | /* |
3128 | /* |
3612 | * commands |
3129 | * commands |
3613 | */ |
3130 | */ |
3614 | case 1: /* deiconify window */ |
3131 | case 1: /* deiconify window */ |
3615 | XMapWindow (disp, parent[0]); |
3132 | XMapWindow (dpy, parent); |
3616 | break; |
3133 | break; |
3617 | case 2: /* iconify window */ |
3134 | case 2: /* iconify window */ |
3618 | XIconifyWindow (disp, parent[0], display->screen); |
3135 | XIconifyWindow (dpy, parent, display->screen); |
3619 | break; |
3136 | break; |
3620 | case 3: /* set position (pixels) */ |
3137 | case 3: /* set position (pixels) */ |
3621 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3138 | XMoveWindow (dpy, parent, args[1], args[2]); |
3622 | break; |
3139 | break; |
3623 | case 4: /* set size (pixels) */ |
3140 | case 4: /* set size (pixels) */ |
3624 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3141 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3625 | break; |
3142 | break; |
3626 | case 5: /* raise window */ |
3143 | case 5: /* raise window */ |
3627 | XRaiseWindow (disp, parent[0]); |
3144 | XRaiseWindow (dpy, parent); |
3628 | break; |
3145 | break; |
3629 | case 6: /* lower window */ |
3146 | case 6: /* lower window */ |
3630 | XLowerWindow (disp, parent[0]); |
3147 | XLowerWindow (dpy, parent); |
3631 | break; |
3148 | break; |
3632 | case 7: /* refresh window */ |
3149 | case 7: /* refresh window */ |
3633 | scr_touch (true); |
3150 | scr_touch (true); |
3634 | break; |
3151 | break; |
3635 | case 8: /* set size (chars) */ |
3152 | case 8: /* set size (chars) */ |
… | |
… | |
3638 | break; |
3155 | break; |
3639 | |
3156 | |
3640 | //case 9: NYI, TODO, restore maximized window or maximize window |
3157 | //case 9: NYI, TODO, restore maximized window or maximize window |
3641 | default: |
3158 | default: |
3642 | if (args[0] >= 24) /* set height (chars) */ |
3159 | if (args[0] >= 24) /* set height (chars) */ |
3643 | set_widthheight ((unsigned int)width, |
3160 | set_widthheight ((unsigned int)vt_width, |
3644 | (unsigned int) (args[1] * fheight)); |
3161 | (unsigned int) (args[1] * fheight)); |
3645 | break; |
3162 | break; |
3646 | |
|
|
3647 | |
3163 | |
3648 | /* |
3164 | /* |
3649 | * reports - some output format copied from XTerm |
3165 | * reports - some output format copied from XTerm |
3650 | */ |
3166 | */ |
3651 | case 11: /* report window state */ |
3167 | case 11: /* report window state */ |
3652 | XGetWindowAttributes (disp, parent[0], &wattr); |
3168 | XGetWindowAttributes (dpy, parent, &wattr); |
3653 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3169 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3654 | break; |
3170 | break; |
3655 | case 13: /* report window position */ |
3171 | case 13: /* report window position */ |
3656 | XGetWindowAttributes (disp, parent[0], &wattr); |
3172 | XGetWindowAttributes (dpy, parent, &wattr); |
3657 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3173 | XTranslateCoordinates (dpy, parent, wattr.root, |
3658 | -wattr.border_width, -wattr.border_width, |
3174 | -wattr.border_width, -wattr.border_width, |
3659 | &x, &y, &wdummy); |
3175 | &x, &y, &wdummy); |
3660 | tt_printf ("\033[3;%d;%dt", x, y); |
3176 | tt_printf ("\033[3;%d;%dt", x, y); |
3661 | break; |
3177 | break; |
3662 | case 14: /* report window size (pixels) */ |
3178 | case 14: /* report window size (pixels) */ |
3663 | XGetWindowAttributes (disp, parent[0], &wattr); |
3179 | XGetWindowAttributes (dpy, parent, &wattr); |
3664 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3180 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3665 | break; |
3181 | break; |
3666 | case 18: /* report text area size (chars) */ |
3182 | case 18: /* report text area size (chars) */ |
3667 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3183 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3668 | break; |
3184 | break; |
… | |
… | |
3670 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3186 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3671 | break; |
3187 | break; |
3672 | case 20: /* report icon label */ |
3188 | case 20: /* report icon label */ |
3673 | { |
3189 | { |
3674 | char *s; |
3190 | char *s; |
3675 | XGetIconName (disp, parent[0], &s); |
3191 | XGetIconName (dpy, parent, &s); |
3676 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3192 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3677 | XFree (s); |
3193 | XFree (s); |
3678 | } |
3194 | } |
3679 | break; |
3195 | break; |
3680 | case 21: /* report window title */ |
3196 | case 21: /* report window title */ |
3681 | { |
3197 | { |
3682 | char *s; |
3198 | char *s; |
3683 | XFetchName (disp, parent[0], &s); |
3199 | XFetchName (dpy, parent, &s); |
3684 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3200 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3685 | XFree (s); |
3201 | XFree (s); |
3686 | } |
3202 | } |
3687 | break; |
3203 | break; |
3688 | } |
3204 | } |
3689 | } |
3205 | } |
… | |
… | |
3698 | rxvt_term::get_to_st (unicode_t &ends_how) |
3214 | rxvt_term::get_to_st (unicode_t &ends_how) |
3699 | { |
3215 | { |
3700 | unicode_t ch; |
3216 | unicode_t ch; |
3701 | bool seen_esc = false; |
3217 | bool seen_esc = false; |
3702 | unsigned int n = 0; |
3218 | unsigned int n = 0; |
3703 | wchar_t string[STRING_MAX]; |
3219 | wchar_t string[CBUFSIZ]; |
3704 | |
3220 | |
3705 | while ((ch = cmd_getc ()) != NOCHAR) |
3221 | while ((ch = cmd_getc ()) != NOCHAR) |
3706 | { |
3222 | { |
3707 | if (seen_esc) |
3223 | if (seen_esc) |
3708 | { |
3224 | { |
… | |
… | |
3716 | seen_esc = true; |
3232 | seen_esc = true; |
3717 | continue; |
3233 | continue; |
3718 | } |
3234 | } |
3719 | else if (ch == C0_BEL || ch == CHAR_ST) |
3235 | else if (ch == C0_BEL || ch == CHAR_ST) |
3720 | break; |
3236 | break; |
|
|
3237 | else if (ch == C0_SYN) |
|
|
3238 | ch = cmd_get8 (); |
3721 | else if (ch < 0x20) |
3239 | else if (ch < 0x20) |
3722 | return NULL; /* other control character - exit */ |
3240 | return NULL; /* other control character - exit */ |
3723 | |
3241 | |
3724 | seen_esc = false; |
3242 | seen_esc = false; |
3725 | |
3243 | |
3726 | if (n >= STRING_MAX - 1) |
3244 | if (n >= sizeof (string) - 1) |
3727 | // stop at some sane length |
3245 | // stop at some sane length |
3728 | return NULL; |
3246 | return NULL; |
3729 | |
3247 | |
3730 | if (ch == C0_SYN) |
|
|
3731 | string[n++] = cmd_get8 (); |
|
|
3732 | else |
|
|
3733 | string[n++] = ch; |
3248 | string[n++] = ch; |
3734 | } |
3249 | } |
3735 | |
3250 | |
3736 | string[n++] = '\0'; |
3251 | string[n++] = '\0'; |
3737 | |
3252 | |
3738 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3253 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3745 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3260 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3746 | */ |
3261 | */ |
3747 | void |
3262 | void |
3748 | rxvt_term::process_dcs_seq () |
3263 | rxvt_term::process_dcs_seq () |
3749 | { |
3264 | { |
3750 | char *s; |
|
|
3751 | unicode_t eh; |
|
|
3752 | |
|
|
3753 | /* |
3265 | /* |
3754 | * Not handled yet |
3266 | * Not handled yet |
3755 | */ |
3267 | */ |
|
|
3268 | |
|
|
3269 | unicode_t eh; |
3756 | s = get_to_st (eh); |
3270 | char *s = get_to_st (eh); |
3757 | if (s) |
3271 | if (s) |
3758 | free (s); |
3272 | free (s); |
3759 | |
3273 | |
3760 | return; |
3274 | return; |
3761 | } |
3275 | } |
… | |
… | |
3765 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3279 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3766 | */ |
3280 | */ |
3767 | void |
3281 | void |
3768 | rxvt_term::process_osc_seq () |
3282 | rxvt_term::process_osc_seq () |
3769 | { |
3283 | { |
3770 | unicode_t ch, eh; |
|
|
3771 | int arg; |
3284 | int arg; |
3772 | |
3285 | |
3773 | ch = cmd_getc (); |
3286 | unicode_t ch = cmd_getc (); |
3774 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3287 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3775 | arg = arg * 10 + (ch - '0'); |
3288 | arg = arg * 10 + (ch - '0'); |
3776 | |
3289 | |
3777 | if (ch == ';') |
3290 | if (ch == ';') |
3778 | { |
3291 | { |
|
|
3292 | unicode_t eh; |
3779 | char *s = get_to_st (eh); |
3293 | char *s = get_to_st (eh); |
3780 | |
3294 | |
3781 | if (s) |
3295 | if (s) |
3782 | { |
3296 | { |
3783 | process_xterm_seq (arg, s, eh); |
3297 | process_xterm_seq (arg, s, eh); |
3784 | free (s); |
3298 | free (s); |
3785 | } |
3299 | } |
3786 | } |
3300 | } |
3787 | } |
3301 | } |
3788 | |
3302 | |
|
|
3303 | static unsigned int |
|
|
3304 | colorcube_index (unsigned int idx_r, |
|
|
3305 | unsigned int idx_g, |
|
|
3306 | unsigned int idx_b) |
|
|
3307 | { |
|
|
3308 | assert (idx_r < Red_levels); |
|
|
3309 | assert (idx_g < Green_levels); |
|
|
3310 | assert (idx_b < Blue_levels); |
|
|
3311 | |
|
|
3312 | return idx_r * Blue_levels * Green_levels + |
|
|
3313 | idx_g * Blue_levels + |
|
|
3314 | idx_b; |
|
|
3315 | } |
|
|
3316 | |
|
|
3317 | /* |
|
|
3318 | * Find the nearest color slot in the hidden color cube, |
|
|
3319 | * adapt its value to the 32bit RGBA color. |
|
|
3320 | */ |
|
|
3321 | unsigned int |
|
|
3322 | rxvt_term::map_rgb24_color (unsigned int r, unsigned int g, unsigned int b, unsigned int a) |
|
|
3323 | { |
|
|
3324 | r &= 0xff; |
|
|
3325 | g &= 0xff; |
|
|
3326 | b &= 0xff; |
|
|
3327 | a &= 0xff; |
|
|
3328 | |
|
|
3329 | uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; |
|
|
3330 | |
|
|
3331 | unsigned int idx_r = r * (Red_levels - 1) / 0xff; |
|
|
3332 | unsigned int idx_g = g * (Green_levels - 1) / 0xff; |
|
|
3333 | unsigned int idx_b = b * (Blue_levels - 1) / 0xff; |
|
|
3334 | unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); |
|
|
3335 | |
|
|
3336 | /* we allow one of the 6 directly neighbouring colours */ |
|
|
3337 | /* to replace the current color, if they not used recently */ |
|
|
3338 | static const signed char dxyz[][3] = { |
|
|
3339 | 0, 0, 0, |
|
|
3340 | 0, 0, +1, |
|
|
3341 | 0, 0, -1, |
|
|
3342 | 0, +1, 0, |
|
|
3343 | 0, -1, 0, |
|
|
3344 | +1, 0, 0, |
|
|
3345 | -1, 0, 0, |
|
|
3346 | }; |
|
|
3347 | |
|
|
3348 | for (int n = 0; n < ecb_array_length (dxyz); ++n) |
|
|
3349 | { |
|
|
3350 | int r = idx_r + dxyz[n][0]; |
|
|
3351 | int g = idx_g + dxyz[n][1]; |
|
|
3352 | int b = idx_b + dxyz[n][2]; |
|
|
3353 | |
|
|
3354 | if (!IN_RANGE_EXC (r, 0, Red_levels )) continue; |
|
|
3355 | if (!IN_RANGE_EXC (g, 0, Green_levels)) continue; |
|
|
3356 | if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue; |
|
|
3357 | |
|
|
3358 | unsigned int index = colorcube_index (r, g, b); |
|
|
3359 | |
|
|
3360 | if (rgb24_color[index] == color) |
|
|
3361 | { |
|
|
3362 | rgb24_seqno[index] = ++rgb24_sequence; |
|
|
3363 | return index + minTermCOLOR24; |
|
|
3364 | } |
|
|
3365 | |
|
|
3366 | // minor issue: could update index 0 few more times |
|
|
3367 | if ((rgb24_seqno[index] | rgb24_color[index]) == 0) |
|
|
3368 | { |
|
|
3369 | idx = index; |
|
|
3370 | goto update; |
|
|
3371 | } |
|
|
3372 | |
|
|
3373 | // like (rgb24_seqno[idx] > rgb24_seqno[index]) |
|
|
3374 | // but also handles wrap around values good enough |
|
|
3375 | if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff) |
|
|
3376 | idx = index; |
|
|
3377 | } |
|
|
3378 | |
|
|
3379 | update: |
|
|
3380 | rgb24_color[idx] = color; |
|
|
3381 | rgb24_seqno[idx] = ++rgb24_sequence; |
|
|
3382 | |
|
|
3383 | idx += minTermCOLOR24; |
|
|
3384 | pix_colors_focused [idx].free (this); |
|
|
3385 | pix_colors_focused [idx].set (this, rgba (r * 0x0101, g * 0x0101, b * 0x0101, a * 0x0101)); |
|
|
3386 | update_fade_color (idx, false); |
|
|
3387 | |
|
|
3388 | return idx; |
|
|
3389 | } |
|
|
3390 | |
3789 | void |
3391 | void |
3790 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3392 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3791 | { |
3393 | { |
3792 | if (str[0] == '?' && !str[1]) |
3394 | if (str[0] == '?' && !str[1]) |
3793 | { |
3395 | { |
3794 | unsigned short r, g, b; |
3396 | rgba c; |
3795 | pix_colors_focused[color].get (display, r, g, b); |
3397 | pix_colors_focused[color].get (c); |
|
|
3398 | |
|
|
3399 | #if XFT |
|
|
3400 | if (c.a != rgba::MAX_CC) |
|
|
3401 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.r, c.g, c.b, c.a, resp); |
|
|
3402 | else |
|
|
3403 | #endif |
3796 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3404 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3797 | } |
3405 | } |
3798 | else |
3406 | else |
3799 | set_window_color (color, str); |
3407 | set_window_color (color, str); |
3800 | } |
3408 | } |
3801 | |
3409 | |
3802 | /* |
3410 | /* |
3803 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3411 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3804 | */ |
3412 | */ |
3805 | void |
3413 | void |
3806 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3414 | rxvt_term::process_xterm_seq (int op, char *str, char resp) |
3807 | { |
3415 | { |
3808 | int changed = 0; |
|
|
3809 | int color; |
3416 | int color; |
3810 | char *buf, *name; |
3417 | char *buf, *name; |
3811 | bool query = str[0] == '?' && !str[1]; |
3418 | bool query = str[0] == '?' && !str[1]; |
3812 | int saveop = op; |
3419 | int saveop = op; |
3813 | dDisp; |
3420 | |
|
|
3421 | dLocal (Display *, dpy); |
3814 | |
3422 | |
3815 | assert (str != NULL); |
3423 | assert (str != NULL); |
|
|
3424 | |
|
|
3425 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3426 | return; |
|
|
3427 | |
3816 | switch (op) |
3428 | switch (op) |
3817 | { |
3429 | { |
3818 | case XTerm_name: |
3430 | case XTerm_name: |
3819 | set_title (str); |
3431 | set_title (str); |
3820 | /* FALLTHROUGH */ |
3432 | /* FALLTHROUGH */ |
… | |
… | |
3834 | unsigned long bytes_after; |
3446 | unsigned long bytes_after; |
3835 | unsigned char *value = 0; |
3447 | unsigned char *value = 0; |
3836 | const char *str = ""; |
3448 | const char *str = ""; |
3837 | |
3449 | |
3838 | if (prop |
3450 | if (prop |
3839 | && XGetWindowProperty (disp, parent[0], |
3451 | && XGetWindowProperty (dpy, parent, |
3840 | prop, 0, 1<<16, 0, AnyPropertyType, |
3452 | prop, 0, 1<<16, 0, AnyPropertyType, |
3841 | &actual_type, &actual_format, |
3453 | &actual_type, &actual_format, |
3842 | &nitems, &bytes_after, &value) == Success |
3454 | &nitems, &bytes_after, &value) == Success |
3843 | && actual_type != None |
3455 | && actual_type != None |
3844 | && actual_format == 8) |
3456 | && actual_format == 8) |
3845 | str = (const char *)(value); |
3457 | str = (const char *)(value); |
3846 | |
3458 | |
3847 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3459 | tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp); |
3848 | |
3460 | |
3849 | XFree (value); |
3461 | XFree (value); |
3850 | } |
3462 | } |
3851 | else |
3463 | else |
3852 | { |
3464 | { |
3853 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3465 | char *eq = strchr (str, '='); |
3854 | |
3466 | |
3855 | if (eq) |
3467 | if (eq) |
3856 | { |
3468 | { |
3857 | *eq = 0; |
3469 | *eq = 0; |
3858 | set_utf8_property (display->atom (str), eq + 1); |
3470 | set_utf8_property (display->atom (str), eq + 1); |
3859 | } |
3471 | } |
3860 | else |
3472 | else |
3861 | XDeleteProperty (disp, parent[0], |
3473 | XDeleteProperty (dpy, parent, |
3862 | display->atom (str)); |
3474 | display->atom (str)); |
3863 | } |
3475 | } |
3864 | break; |
3476 | break; |
3865 | |
3477 | |
3866 | case XTerm_Color: |
3478 | case XTerm_Color: |
… | |
… | |
3868 | { |
3480 | { |
3869 | if ((name = strchr (buf, ';')) == NULL) |
3481 | if ((name = strchr (buf, ';')) == NULL) |
3870 | break; |
3482 | break; |
3871 | |
3483 | |
3872 | *name++ = '\0'; |
3484 | *name++ = '\0'; |
3873 | color = atoi (buf); |
3485 | color = atoi (buf) + minCOLOR; |
3874 | |
3486 | |
3875 | if (color < 0 || color >= TOTAL_COLORS) |
3487 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3876 | break; |
3488 | break; |
3877 | |
3489 | |
3878 | if ((buf = strchr (name, ';')) != NULL) |
3490 | if ((buf = strchr (name, ';')) != NULL) |
3879 | *buf++ = '\0'; |
3491 | *buf++ = '\0'; |
3880 | |
3492 | |
3881 | if (name[0] == '?' && !name[1]) |
3493 | process_color_seq (op, color, name, resp); |
3882 | { |
|
|
3883 | unsigned short r, g, b; |
|
|
3884 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3885 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3886 | } |
|
|
3887 | else |
|
|
3888 | set_window_color (color + minCOLOR, name); |
|
|
3889 | } |
3494 | } |
3890 | break; |
3495 | break; |
|
|
3496 | case Rxvt_restoreFG: |
3891 | case XTerm_Color00: |
3497 | case XTerm_Color00: |
3892 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3498 | process_color_seq (op, Color_fg, str, resp); |
3893 | break; |
3499 | break; |
|
|
3500 | case Rxvt_restoreBG: |
3894 | case XTerm_Color01: |
3501 | case XTerm_Color01: |
3895 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3502 | process_color_seq (op, Color_bg, str, resp); |
3896 | break; |
3503 | break; |
3897 | #ifndef NO_CURSORCOLOR |
3504 | #ifndef NO_CURSORCOLOR |
3898 | case XTerm_Color_cursor: |
3505 | case XTerm_Color_cursor: |
3899 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3506 | process_color_seq (op, Color_cursor, str, resp); |
3900 | break; |
3507 | break; |
3901 | #endif |
3508 | #endif |
3902 | case XTerm_Color_pointer_fg: |
3509 | case XTerm_Color_pointer_fg: |
3903 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3510 | process_color_seq (op, Color_pointer_fg, str, resp); |
3904 | break; |
3511 | break; |
3905 | case XTerm_Color_pointer_bg: |
3512 | case XTerm_Color_pointer_bg: |
3906 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3513 | process_color_seq (op, Color_pointer_bg, str, resp); |
3907 | break; |
3514 | break; |
|
|
3515 | #ifdef OPTION_HC |
|
|
3516 | case XTerm_Color_HC: |
|
|
3517 | process_color_seq (op, Color_HC, str, resp); |
|
|
3518 | break; |
|
|
3519 | case XTerm_Color_HTC: |
|
|
3520 | process_color_seq (op, Color_HTC, str, resp); |
|
|
3521 | break; |
|
|
3522 | #endif |
3908 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3523 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3909 | case XTerm_Color_BD: |
3524 | case URxvt_Color_BD: |
3910 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3525 | process_color_seq (op, Color_BD, str, resp); |
3911 | break; |
3526 | break; |
3912 | case XTerm_Color_UL: |
3527 | case URxvt_Color_UL: |
3913 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3528 | process_color_seq (op, Color_UL, str, resp); |
3914 | break; |
|
|
3915 | case XTerm_Color_RV: |
|
|
3916 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3917 | break; |
3529 | break; |
3918 | case URxvt_Color_IT: |
3530 | case URxvt_Color_IT: |
3919 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3531 | process_color_seq (op, Color_IT, str, resp); |
3920 | break; |
3532 | break; |
3921 | #endif |
3533 | #endif |
3922 | #if TRANSPARENT && TINTING |
|
|
3923 | case URxvt_Color_tint: |
3534 | case URxvt_Color_border: |
3924 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3535 | process_color_seq (op, Color_border, str, resp); |
3925 | check_our_parents (); |
|
|
3926 | if (am_transparent) |
|
|
3927 | want_full_refresh = want_refresh = 1; |
|
|
3928 | break; |
|
|
3929 | #endif |
|
|
3930 | |
|
|
3931 | case XTerm_Pixmap: |
|
|
3932 | if (*str != ';') |
|
|
3933 | { |
|
|
3934 | #if XPM_BACKGROUND |
|
|
3935 | scale_pixmap (""); /* reset to default scaling */ |
|
|
3936 | set_bgPixmap (str); /* change pixmap */ |
|
|
3937 | #endif |
|
|
3938 | scr_touch (true); |
|
|
3939 | } |
|
|
3940 | while ((str = strchr (str, ';')) != NULL) |
|
|
3941 | { |
|
|
3942 | str++; |
|
|
3943 | #if XPM_BACKGROUND |
|
|
3944 | changed += scale_pixmap (str); |
|
|
3945 | #endif |
|
|
3946 | } |
|
|
3947 | |
|
|
3948 | if (changed) |
|
|
3949 | { |
|
|
3950 | #ifdef XPM_BACKGROUND |
|
|
3951 | resize_pixmap (); |
|
|
3952 | #endif |
|
|
3953 | scr_touch (true); |
|
|
3954 | } |
|
|
3955 | break; |
|
|
3956 | |
|
|
3957 | case XTerm_restoreFG: |
|
|
3958 | set_window_color (Color_fg, str); |
|
|
3959 | break; |
|
|
3960 | case XTerm_restoreBG: |
|
|
3961 | set_window_color (Color_bg, str); |
|
|
3962 | break; |
3536 | break; |
3963 | |
3537 | |
3964 | case XTerm_logfile: |
3538 | case XTerm_logfile: |
3965 | // TODO, when secure mode? |
3539 | // TODO, when secure mode? |
3966 | break; |
3540 | break; |
3967 | |
3541 | |
3968 | #ifdef MENUBAR |
|
|
3969 | case URxvt_Menu: |
|
|
3970 | if (OPTION (Opt_insecure)) |
|
|
3971 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3972 | break; |
|
|
3973 | #endif |
|
|
3974 | #if 0 |
3542 | #if 0 |
3975 | case XTerm_dumpscreen: /* no error notices */ |
3543 | case Rxvt_dumpscreen: /* no error notices */ |
3976 | { |
3544 | { |
3977 | int fd; |
3545 | int fd; |
3978 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3546 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3979 | { |
3547 | { |
3980 | scr_dump (fd); |
3548 | scr_dump (fd); |
… | |
… | |
3991 | case URxvt_italicFont: |
3559 | case URxvt_italicFont: |
3992 | case URxvt_boldItalicFont: |
3560 | case URxvt_boldItalicFont: |
3993 | #endif |
3561 | #endif |
3994 | if (query) |
3562 | if (query) |
3995 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3563 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3996 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3564 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3997 | ? fontset[op - URxvt_font]->fontdesc : "", |
3565 | ? fontset[op - URxvt_font]->fontdesc : "", |
3998 | resp); |
3566 | resp); |
3999 | else |
3567 | else |
4000 | { |
3568 | { |
4001 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3569 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
4004 | allocated.push_back ((void *)res); |
3572 | allocated.push_back ((void *)res); |
4005 | set_fonts (); |
3573 | set_fonts (); |
4006 | } |
3574 | } |
4007 | break; |
3575 | break; |
4008 | |
3576 | |
4009 | #if ENABLE_FRILLS |
3577 | case URxvt_version: |
|
|
3578 | if (query) |
|
|
3579 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3580 | op, |
|
|
3581 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3582 | resp); |
|
|
3583 | break; |
|
|
3584 | |
|
|
3585 | #if !ENABLE_MINIMAL |
4010 | case URxvt_locale: |
3586 | case URxvt_locale: |
4011 | if (query) |
3587 | if (query) |
4012 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3588 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
4013 | else |
3589 | else |
4014 | { |
3590 | { |
4015 | set_locale (str); |
3591 | set_locale (str); |
4016 | pty.set_utf8_mode (enc_utf8); |
3592 | pty->set_utf8_mode (enc_utf8); |
4017 | init_xlocale (); |
3593 | init_xlocale (); |
4018 | } |
3594 | } |
4019 | break; |
3595 | break; |
4020 | |
3596 | |
4021 | case URxvt_view_up: |
3597 | case URxvt_view_up: |
… | |
… | |
4032 | break; |
3608 | break; |
4033 | #endif |
3609 | #endif |
4034 | |
3610 | |
4035 | #if ENABLE_PERL |
3611 | #if ENABLE_PERL |
4036 | case URxvt_perl: |
3612 | case URxvt_perl: |
4037 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3613 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
4038 | ; // no responses yet |
|
|
4039 | break; |
3614 | break; |
4040 | #endif |
3615 | #endif |
4041 | } |
3616 | } |
4042 | } |
3617 | } |
4043 | /*----------------------------------------------------------------------*/ |
3618 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4050 | * 's' = save |
3625 | * 's' = save |
4051 | * 'r' = restore |
3626 | * 'r' = restore |
4052 | * 't' = toggle |
3627 | * 't' = toggle |
4053 | * so no need for fancy checking |
3628 | * so no need for fancy checking |
4054 | */ |
3629 | */ |
4055 | int |
3630 | int ecb_cold |
4056 | rxvt_term::privcases (int mode, unsigned long bit) |
3631 | rxvt_term::privcases (int mode, unsigned long bit) |
4057 | { |
3632 | { |
4058 | int state; |
3633 | int state; |
4059 | |
3634 | |
4060 | if (mode == 's') |
3635 | if (mode == 's') |
4061 | { |
3636 | { |
4062 | SavedModes |= (priv_modes & bit); |
3637 | if (priv_modes & bit) |
|
|
3638 | SavedModes |= bit; |
|
|
3639 | else |
|
|
3640 | SavedModes &= ~bit; |
4063 | return -1; |
3641 | return -1; |
4064 | } |
3642 | } |
4065 | else |
3643 | else |
4066 | { |
3644 | { |
4067 | if (mode == 'r') |
3645 | if (mode == 'r') |
4068 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3646 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
4069 | else |
3647 | else |
4070 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3648 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
4071 | PrivMode (state, bit); |
3649 | |
|
|
3650 | if (state) |
|
|
3651 | priv_modes |= bit; |
|
|
3652 | else |
|
|
3653 | priv_modes &= ~bit; |
4072 | } |
3654 | } |
4073 | |
3655 | |
4074 | return state; |
3656 | return state; |
4075 | } |
3657 | } |
4076 | |
3658 | |
4077 | /* we're not using priv _yet_ */ |
3659 | /* we're not using priv _yet_ */ |
4078 | void |
3660 | void |
4079 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3661 | rxvt_term::process_terminal_mode (int mode, int priv ecb_unused, unsigned int nargs, const int *arg) |
4080 | { |
3662 | { |
4081 | unsigned int i, j; |
3663 | unsigned int i, j; |
4082 | int state; |
3664 | int state; |
4083 | |
3665 | |
4084 | static const struct |
3666 | static const struct |
4085 | { |
3667 | { |
4086 | const int argval; |
3668 | const int argval; |
4087 | const unsigned long bit; |
3669 | const unsigned long bit; |
4088 | } |
|
|
4089 | |
|
|
4090 | argtopriv[] = { |
3670 | } argtopriv[] = { |
4091 | { 1, PrivMode_aplCUR }, |
3671 | { 1, PrivMode_aplCUR }, // DECCKM |
4092 | { 2, PrivMode_vt52 }, |
3672 | { 2, PrivMode_vt52 }, // DECANM |
4093 | { 3, PrivMode_132 }, |
3673 | { 3, PrivMode_132 }, // DECCOLM |
4094 | { 4, PrivMode_smoothScroll }, |
3674 | { 4, PrivMode_smoothScroll }, // DECSCLM |
4095 | { 5, PrivMode_rVideo }, |
3675 | { 5, PrivMode_rVideo }, // DECSCNM |
4096 | { 6, PrivMode_relOrigin }, |
3676 | { 6, PrivMode_relOrigin }, // DECOM |
4097 | { 7, PrivMode_Autowrap }, |
3677 | { 7, PrivMode_Autowrap }, // DECAWM |
4098 | // 8, bi-directional support mode |
3678 | // 8, auto-repeat keys // DECARM |
4099 | { 9, PrivMode_MouseX10 }, |
3679 | { 9, PrivMode_MouseX10 }, |
4100 | #ifdef menuBar_esc |
|
|
4101 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4102 | #endif |
|
|
4103 | // 18, 19 printing-related |
|
|
4104 | { 25, PrivMode_VisibleCursor }, |
3680 | { 12, PrivMode_BlinkingCursor }, |
|
|
3681 | // 18 end FF to printer after print screen |
|
|
3682 | // 19 Print screen prints full screen/scroll region |
|
|
3683 | { 25, PrivMode_VisibleCursor }, // DECTCEM cnorm/cvvis/civis |
4105 | #ifdef scrollBar_esc |
3684 | #ifdef scrollBar_esc |
4106 | { scrollBar_esc, PrivMode_scrollBar }, |
3685 | { scrollBar_esc, PrivMode_scrollBar }, |
4107 | #endif |
3686 | #endif |
4108 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3687 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
|
|
3688 | // 38, tektronix mode // DECTEK |
4109 | { 40, PrivMode_132OK }, |
3689 | { 40, PrivMode_132OK }, |
4110 | // 41 xterm more fixes NYI |
3690 | // 41 xterm more fixes NYI |
4111 | // 45 margin bell NYI |
3691 | // 45 margin bell NYI |
4112 | // 46 start logging |
3692 | // 46 start logging |
4113 | { 47, PrivMode_Screen }, |
3693 | { 47, PrivMode_Screen }, |
4114 | { 66, PrivMode_aplKP }, |
3694 | { 66, PrivMode_aplKP }, // DECNKM |
4115 | #ifndef NO_BACKSPACE_KEY |
3695 | #ifndef NO_BACKSPACE_KEY |
4116 | { 67, PrivMode_BackSpace }, |
3696 | { 67, PrivMode_BackSpace }, // DECBKM |
4117 | #endif |
3697 | #endif |
4118 | { 1000, PrivMode_MouseX11 }, |
3698 | { 1000, PrivMode_MouseX11 }, |
4119 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3699 | { 1002, PrivMode_MouseBtnEvent }, |
4120 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3700 | { 1003, PrivMode_MouseAnyEvent }, |
4121 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
3701 | #if ENABLE_FRILLS |
|
|
3702 | { 1004, PrivMode_FocusEvent }, |
|
|
3703 | { 1005, PrivMode_ExtModeMouse }, |
|
|
3704 | #endif |
4122 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3705 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
4123 | { 1011, PrivMode_Keypress }, // rxvt extension |
3706 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3707 | #if ENABLE_FRILLS |
|
|
3708 | { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 |
|
|
3709 | #endif |
4124 | // 1035 enable modifiers for alt, numlock NYI |
3710 | // 1035 enable modifiers for alt, numlock NYI |
4125 | // 1036 send ESC for meta keys NYI |
3711 | // 1036 send ESC for meta keys NYI |
4126 | // 1037 send DEL for keypad delete NYI |
3712 | // 1037 send DEL for keypad delete NYI |
4127 | { 1047, PrivMode_Screen }, |
3713 | { 1047, PrivMode_Screen }, |
4128 | // 1048 save and restore cursor |
3714 | // 1048 save and restore cursor, implemented in code |
4129 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3715 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
4130 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3716 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3717 | { 2004, PrivMode_BracketPaste }, |
4131 | }; |
3718 | }; |
4132 | |
3719 | |
4133 | if (nargs == 0) |
3720 | if (nargs == 0) |
4134 | return; |
3721 | return; |
4135 | |
3722 | |
… | |
… | |
4142 | for (i = 0; i < nargs; i++) |
3729 | for (i = 0; i < nargs; i++) |
4143 | { |
3730 | { |
4144 | state = -1; |
3731 | state = -1; |
4145 | |
3732 | |
4146 | /* basic handling */ |
3733 | /* basic handling */ |
4147 | for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) |
3734 | for (j = 0; j < ecb_array_length (argtopriv); j++) |
4148 | if (argtopriv[j].argval == arg[i]) |
3735 | if (argtopriv[j].argval == arg[i]) |
4149 | { |
3736 | { |
4150 | state = privcases (mode, argtopriv[j].bit); |
3737 | state = privcases (mode, argtopriv[j].bit); |
4151 | break; |
3738 | break; |
4152 | } |
3739 | } |
… | |
… | |
4160 | |
3747 | |
4161 | scr_touch (true); |
3748 | scr_touch (true); |
4162 | break; |
3749 | break; |
4163 | #endif |
3750 | #endif |
4164 | case 1048: /* alternative cursor save */ |
3751 | case 1048: /* alternative cursor save */ |
4165 | case 1049: |
|
|
4166 | if (OPTION (Opt_secondaryScreen)) |
3752 | if (option (Opt_secondaryScreen)) |
4167 | if (mode == 0) |
3753 | if (mode == 0) |
4168 | scr_cursor (RESTORE); |
3754 | scr_cursor (RESTORE); |
4169 | else if (mode == 1) |
3755 | else if (mode == 1) |
4170 | scr_cursor (SAVE); |
3756 | scr_cursor (SAVE); |
4171 | break; |
3757 | break; |
… | |
… | |
4179 | case 2: /* VT52 mode */ |
3765 | case 2: /* VT52 mode */ |
4180 | /* oddball mode. should be set regardless of set/reset |
3766 | /* oddball mode. should be set regardless of set/reset |
4181 | * parameter. Return from VT52 mode with an ESC < from |
3767 | * parameter. Return from VT52 mode with an ESC < from |
4182 | * within VT52 mode |
3768 | * within VT52 mode |
4183 | */ |
3769 | */ |
4184 | PrivMode (1, PrivMode_vt52); |
3770 | priv_modes |= PrivMode_vt52; |
4185 | break; |
3771 | break; |
4186 | case 3: /* 80/132 */ |
3772 | case 3: /* 80/132 */ |
4187 | if (priv_modes & PrivMode_132OK) |
3773 | if (priv_modes & PrivMode_132OK) |
4188 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3774 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
4189 | break; |
3775 | break; |
4190 | case 4: /* smooth scrolling */ |
3776 | case 4: /* smooth scrolling */ |
4191 | set_option (Opt_jumpScroll, !state); |
3777 | set_option (Opt_jumpScroll, !state); |
4192 | break; |
3778 | break; |
4193 | case 5: /* reverse video */ |
3779 | case 5: /* reverse video */ |
… | |
… | |
4200 | scr_autowrap (state); |
3786 | scr_autowrap (state); |
4201 | break; |
3787 | break; |
4202 | /* case 8: - auto repeat, can't do on a per window basis */ |
3788 | /* case 8: - auto repeat, can't do on a per window basis */ |
4203 | case 9: /* X10 mouse reporting */ |
3789 | case 9: /* X10 mouse reporting */ |
4204 | if (state) /* orthogonal */ |
3790 | if (state) /* orthogonal */ |
4205 | priv_modes &= ~PrivMode_MouseX11; |
3791 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4206 | break; |
3792 | break; |
4207 | #ifdef menuBar_esc |
|
|
4208 | case menuBar_esc: |
|
|
4209 | #ifdef MENUBAR |
|
|
4210 | map_menuBar (state); |
|
|
4211 | #endif |
|
|
4212 | break; |
|
|
4213 | #endif |
|
|
4214 | #ifdef scrollBar_esc |
3793 | #ifdef scrollBar_esc |
4215 | case scrollBar_esc: |
3794 | case scrollBar_esc: |
4216 | if (scrollbar_mapping (state)) |
3795 | scrollBar.map (state); |
4217 | { |
|
|
4218 | resize_all_windows (0, 0, 0); |
3796 | resize_all_windows (0, 0, 0); |
4219 | scr_touch (true); |
3797 | scr_touch (true); |
4220 | } |
3798 | break; |
|
|
3799 | #endif |
|
|
3800 | #ifdef CURSOR_BLINK |
|
|
3801 | case 12: |
|
|
3802 | cursor_blink_reset (); |
4221 | break; |
3803 | break; |
4222 | #endif |
3804 | #endif |
4223 | case 25: /* visible/invisible cursor */ |
3805 | case 25: /* visible/invisible cursor */ |
4224 | scr_cursor_visible (state); |
3806 | scr_cursor_visible (state); |
4225 | break; |
3807 | break; |
… | |
… | |
4230 | break; |
3812 | break; |
4231 | /* case 66: - application key pad */ |
3813 | /* case 66: - application key pad */ |
4232 | /* case 67: - backspace key */ |
3814 | /* case 67: - backspace key */ |
4233 | case 1000: /* X11 mouse reporting */ |
3815 | case 1000: /* X11 mouse reporting */ |
4234 | if (state) /* orthogonal */ |
3816 | if (state) /* orthogonal */ |
4235 | priv_modes &= ~PrivMode_MouseX10; |
3817 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4236 | break; |
3818 | break; |
4237 | #if 0 |
|
|
4238 | case 1001: |
3819 | case 1002: |
4239 | break; /* X11 mouse highlighting */ |
3820 | case 1003: |
4240 | #endif |
3821 | if (state) |
|
|
3822 | { |
|
|
3823 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3824 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3825 | mouse_row = mouse_col = 0; |
|
|
3826 | vt_emask_mouse = PointerMotionMask; |
|
|
3827 | } |
|
|
3828 | else |
|
|
3829 | vt_emask_mouse = NoEventMask; |
|
|
3830 | |
|
|
3831 | vt_select_input (); |
|
|
3832 | break; |
4241 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3833 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4242 | set_option (Opt_scrollTtyOutput, !state); |
3834 | set_option (Opt_scrollTtyOutput, !state); |
4243 | break; |
3835 | break; |
4244 | case 1011: /* scroll to bottom on key press */ |
3836 | case 1011: /* scroll to bottom on key press */ |
4245 | set_option (Opt_scrollTtyKeypress, state); |
3837 | set_option (Opt_scrollTtyKeypress, state); |
4246 | break; |
3838 | break; |
4247 | case 1047: /* secondary screen w/ clearing last */ |
3839 | case 1047: /* secondary screen w/ clearing last */ |
4248 | if (OPTION (Opt_secondaryScreen)) |
3840 | if (option (Opt_secondaryScreen)) |
4249 | if (current_screen != PRIMARY) |
3841 | if (!state) |
4250 | scr_erase_screen (2); |
3842 | scr_erase_screen (2); |
|
|
3843 | |
4251 | scr_change_screen (state); |
3844 | scr_change_screen (state); |
4252 | break; |
3845 | break; |
4253 | case 1049: /* secondary screen w/ clearing first */ |
3846 | case 1049: /* secondary screen w/ clearing first */ |
|
|
3847 | if (option (Opt_secondaryScreen)) |
|
|
3848 | if (state) |
|
|
3849 | scr_cursor (SAVE); |
|
|
3850 | |
4254 | scr_change_screen (state); |
3851 | scr_change_screen (state); |
|
|
3852 | |
4255 | if (OPTION (Opt_secondaryScreen)) |
3853 | if (option (Opt_secondaryScreen)) |
4256 | if (current_screen != PRIMARY) |
3854 | if (state) |
4257 | scr_erase_screen (2); |
3855 | scr_erase_screen (2); |
|
|
3856 | else |
|
|
3857 | scr_cursor (RESTORE); |
4258 | break; |
3858 | break; |
4259 | default: |
3859 | default: |
4260 | break; |
3860 | break; |
4261 | } |
3861 | } |
4262 | } |
3862 | } |
4263 | } |
3863 | } |
4264 | /*}}} */ |
3864 | /*}}} */ |
4265 | |
3865 | |
4266 | /*{{{ process sgr sequences */ |
3866 | /*{{{ process sgr sequences */ |
4267 | void |
3867 | void ecb_hot |
4268 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
3868 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
4269 | { |
3869 | { |
4270 | unsigned int i; |
3870 | unsigned int i; |
4271 | short rendset; |
3871 | short rendset; |
4272 | int rendstyle; |
3872 | int rendstyle; |
… | |
… | |
4314 | //case 19: // ninth alt font |
3914 | //case 19: // ninth alt font |
4315 | //case 20: // gothic |
3915 | //case 20: // gothic |
4316 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
3916 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
4317 | rendset = 0, rendstyle = RS_Bold; |
3917 | rendset = 0, rendstyle = RS_Bold; |
4318 | break; |
3918 | break; |
4319 | case 22: // normal intensity |
3919 | case 22: // bold off (vt220) |
4320 | rendset = 0, rendstyle = RS_Bold; |
3920 | rendset = 0, rendstyle = RS_Bold; |
4321 | break; |
3921 | break; |
4322 | case 23: // disable italic |
3922 | case 23: // disable italic |
4323 | rendset = 0, rendstyle = RS_Italic; |
3923 | rendset = 0, rendstyle = RS_Italic; |
4324 | break; |
3924 | break; |
4325 | case 24: |
3925 | case 24: // underline off (vt220) |
4326 | rendset = 0, rendstyle = RS_Uline; |
3926 | rendset = 0, rendstyle = RS_Uline; |
4327 | break; |
3927 | break; |
4328 | case 25: |
3928 | case 25: // blink off (vt220) |
4329 | rendset = 0, rendstyle = RS_Blink; |
3929 | rendset = 0, rendstyle = RS_Blink; |
4330 | break; |
3930 | break; |
4331 | case 26: // variable spacing (iso 8613) |
3931 | case 26: // variable spacing (iso 8613) |
4332 | rendset = 0, rendstyle = RS_Blink; |
3932 | rendset = 0, rendstyle = RS_Blink; |
4333 | break; |
3933 | break; |
4334 | case 27: |
3934 | case 27: // reverse off (vt220) |
4335 | rendset = 0, rendstyle = RS_RVid; |
3935 | rendset = 0, rendstyle = RS_RVid; |
4336 | break; |
3936 | break; |
4337 | //case 28: // visible. NYI |
3937 | //case 28: // visible. NYI |
4338 | //case 29: // not crossed-out |
3938 | //case 29: // not crossed-out |
4339 | } |
3939 | } |
… | |
… | |
4354 | case 35: |
3954 | case 35: |
4355 | case 36: |
3955 | case 36: |
4356 | case 37: |
3956 | case 37: |
4357 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
3957 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4358 | break; |
3958 | break; |
4359 | case 38: // set fg color, ISO 8613-6 |
|
|
4360 | if (nargs > i + 2 && arg[i + 1] == 5) |
|
|
4361 | { |
|
|
4362 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
|
|
4363 | i += 2; |
|
|
4364 | } |
|
|
4365 | break; |
|
|
4366 | case 39: /* default fg */ |
3959 | case 39: /* default fg */ |
4367 | scr_color (Color_fg, Color_fg); |
3960 | scr_color (Color_fg, Color_fg); |
4368 | break; |
3961 | break; |
4369 | |
3962 | |
4370 | case 40: |
3963 | case 40: |
… | |
… | |
4375 | case 45: |
3968 | case 45: |
4376 | case 46: |
3969 | case 46: |
4377 | case 47: |
3970 | case 47: |
4378 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
3971 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4379 | break; |
3972 | break; |
4380 | case 48: // set bg color, ISO 8613-6 |
|
|
4381 | if (nargs > i + 2 && arg[i + 1] == 5) |
|
|
4382 | { |
|
|
4383 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
|
|
4384 | i += 2; |
|
|
4385 | } |
|
|
4386 | break; |
|
|
4387 | case 49: /* default bg */ |
3973 | case 49: /* default bg */ |
4388 | scr_color (Color_bg, Color_bg); |
3974 | scr_color (Color_bg, Color_bg); |
4389 | break; |
3975 | break; |
4390 | |
3976 | |
|
|
3977 | case 38: // set fg color, ISO 8613-6 |
|
|
3978 | case 48: // set bg color, ISO 8613-6 |
|
|
3979 | { |
|
|
3980 | unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; |
|
|
3981 | unsigned int idx; |
|
|
3982 | |
|
|
3983 | if (nargs > i + 2 && arg[i + 1] == 5) |
|
|
3984 | { |
|
|
3985 | idx = minCOLOR + arg[i + 2]; |
|
|
3986 | i += 2; |
|
|
3987 | |
|
|
3988 | scr_color (idx, fgbg); |
|
|
3989 | } |
|
|
3990 | else if (nargs > i + 4 && arg[i + 1] == 2) |
|
|
3991 | { |
|
|
3992 | unsigned int r = arg[i + 2]; |
|
|
3993 | unsigned int g = arg[i + 3]; |
|
|
3994 | unsigned int b = arg[i + 4]; |
|
|
3995 | unsigned int a = 0xff; |
|
|
3996 | |
|
|
3997 | idx = map_rgb24_color (r, g, b, a); |
|
|
3998 | |
|
|
3999 | i += 4; |
|
|
4000 | |
|
|
4001 | scr_color (idx, fgbg); |
|
|
4002 | } |
|
|
4003 | } |
|
|
4004 | break; |
|
|
4005 | |
4391 | //case 50: // not variable spacing |
4006 | //case 50: // not variable spacing |
4392 | |
4007 | |
4393 | #if ENABLE_FRILLS |
4008 | #if !ENABLE_MINIMAL |
4394 | case 90: |
4009 | case 90: |
4395 | case 91: /* set bright fg color */ |
4010 | case 91: /* set bright fg color */ |
4396 | case 92: |
4011 | case 92: |
4397 | case 93: |
4012 | case 93: |
4398 | case 94: |
4013 | case 94: |
… | |
… | |
4413 | break; |
4028 | break; |
4414 | #endif |
4029 | #endif |
4415 | } |
4030 | } |
4416 | } |
4031 | } |
4417 | } |
4032 | } |
|
|
4033 | |
|
|
4034 | void |
|
|
4035 | rxvt_term::set_cursor_style (int style) |
|
|
4036 | { |
|
|
4037 | if (!IN_RANGE_INC (style, 0, 6)) |
|
|
4038 | return; |
|
|
4039 | |
|
|
4040 | if (style == 0) |
|
|
4041 | style = 1; |
|
|
4042 | |
|
|
4043 | cursor_type = (style - 1) / 2; |
|
|
4044 | set_option (Opt_cursorUnderline, cursor_type == 1); |
|
|
4045 | |
|
|
4046 | #ifdef CURSOR_BLINK |
|
|
4047 | set_option (Opt_cursorBlink, style & 1); |
|
|
4048 | cursor_blink_reset (); |
|
|
4049 | #endif |
|
|
4050 | |
|
|
4051 | want_refresh = 1; |
|
|
4052 | } |
4418 | /*}}} */ |
4053 | /*}}} */ |
4419 | |
4054 | |
4420 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
|
|
4421 | void |
|
|
4422 | rxvt_term::process_graphics () |
|
|
4423 | { |
|
|
4424 | unicode_t ch, cmd = cmd_getc (); |
|
|
4425 | |
|
|
4426 | if (cmd == 'Q') |
|
|
4427 | { /* query graphics */ |
|
|
4428 | tt_printf ("\033G0\012"); /* no graphics */ |
|
|
4429 | return; |
|
|
4430 | } |
|
|
4431 | /* swallow other graphics sequences until terminating ':' */ |
|
|
4432 | do |
|
|
4433 | ch = cmd_getc (); |
|
|
4434 | while (ch != ':'); |
|
|
4435 | } |
|
|
4436 | /*}}} */ |
|
|
4437 | |
|
|
4438 | /* ------------------------------------------------------------------------- */ |
4055 | /* ---------------------------------------------------------------------- */ |
|
|
4056 | /* Write data to the pty as typed by the user, pasted with the mouse, |
|
|
4057 | * or generated by us in response to a query ESC sequence. |
|
|
4058 | */ |
4439 | |
4059 | |
4440 | /* |
4060 | /* |
4441 | * Send printf () formatted output to the command. |
4061 | * Send printf () formatted output to the command. |
4442 | * Only use for small amounts of data. |
4062 | * Only use for small amounts of data. |
4443 | */ |
4063 | */ |
… | |
… | |
4451 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4071 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4452 | va_end (arg_ptr); |
4072 | va_end (arg_ptr); |
4453 | tt_write (buf, strlen (buf)); |
4073 | tt_write (buf, strlen (buf)); |
4454 | } |
4074 | } |
4455 | |
4075 | |
4456 | /* ---------------------------------------------------------------------- */ |
|
|
4457 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4076 | /* Write data to the pty as typed by the user. */ |
4458 | * or generated by us in response to a query ESC sequence. |
4077 | void |
4459 | */ |
4078 | rxvt_term::tt_write_user_input (const char *data, unsigned int len) |
4460 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4079 | { |
|
|
4080 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4081 | return; |
|
|
4082 | |
|
|
4083 | if (option (Opt_scrollTtyKeypress)) |
|
|
4084 | if (view_start) |
|
|
4085 | { |
|
|
4086 | view_start = 0; |
|
|
4087 | want_refresh = 1; |
|
|
4088 | } |
|
|
4089 | |
|
|
4090 | tt_write_ (data, len); |
|
|
4091 | } |
4461 | |
4092 | |
4462 | void |
4093 | void |
4463 | rxvt_term::tt_write (const char *data, unsigned int len) |
4094 | rxvt_term::tt_write (const char *data, unsigned int len) |
4464 | { |
4095 | { |
4465 | if (pty.pty < 0) |
4096 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4466 | return; |
4097 | return; |
4467 | |
4098 | |
|
|
4099 | tt_write_ (data, len); |
|
|
4100 | } |
|
|
4101 | |
|
|
4102 | static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4103 | |
|
|
4104 | void |
|
|
4105 | rxvt_term::tt_write_ (const char *data, unsigned int len) |
|
|
4106 | { |
|
|
4107 | if (pty->pty < 0) |
|
|
4108 | return; |
|
|
4109 | |
4468 | if (v_buflen == 0) |
4110 | if (v_buflen == 0) |
4469 | { |
4111 | { |
4470 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4112 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4471 | |
4113 | |
|
|
4114 | max_it (written, 0); |
|
|
4115 | |
4472 | if ((unsigned int)written == len) |
4116 | if (written == len) |
4473 | return; |
4117 | return; |
4474 | |
4118 | |
4475 | data += written; |
4119 | data += written; |
4476 | len -= written; |
4120 | len -= written; |
4477 | } |
4121 | } |
4478 | |
4122 | |
4479 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4123 | v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len); |
4480 | |
4124 | |
4481 | memcpy (v_buffer + v_buflen, data, len); |
4125 | memcpy (v_buffer + v_buflen, data, len); |
4482 | v_buflen += len; |
4126 | v_buflen += len; |
4483 | |
4127 | |
4484 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4128 | pty_ev.set (ev::READ | ev::WRITE); |
4485 | } |
4129 | } |
4486 | |
4130 | |
4487 | void rxvt_term::pty_write () |
4131 | void rxvt_term::pty_write () |
4488 | { |
4132 | { |
4489 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4133 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4490 | |
4134 | |
4491 | if (written > 0) |
4135 | if (written > 0) |
4492 | { |
4136 | { |
4493 | v_buflen -= written; |
4137 | v_buflen -= written; |
4494 | |
4138 | |
4495 | if (v_buflen == 0) |
4139 | if (v_buflen == 0) |
4496 | { |
4140 | { |
4497 | free (v_buffer); |
4141 | free (v_buffer); |
4498 | v_buffer = 0; |
4142 | v_buffer = 0; |
4499 | v_buflen = 0; |
|
|
4500 | |
4143 | |
4501 | pty_ev.set (EVENT_READ); |
4144 | pty_ev.set (ev::READ); |
4502 | return; |
4145 | return; |
4503 | } |
4146 | } |
4504 | |
4147 | |
4505 | memmove (v_buffer, v_buffer + written, v_buflen); |
4148 | memmove (v_buffer, v_buffer + written, v_buflen); |
4506 | } |
4149 | } |
4507 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4150 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4508 | pty_ev.set (EVENT_READ); |
4151 | pty_ev.set (ev::READ); |
4509 | } |
4152 | } |
4510 | |
4153 | |
4511 | /*----------------------- end-of-file (C source) -----------------------*/ |
4154 | /*----------------------- end-of-file (C source) -----------------------*/ |
4512 | |
4155 | |