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