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