… | |
… | |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
8 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
8 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * - extensive modifications |
9 | * - extensive modifications |
|
|
10 | * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> |
|
|
11 | * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca> |
|
|
12 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
10 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
13 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
11 | * - extensive modifications |
14 | * - extensive modifications |
12 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
15 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
13 | * - QNX support |
16 | * - QNX support |
14 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
17 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
… | |
… | |
38 | |
41 | |
39 | #include <limits> |
42 | #include <limits> |
40 | |
43 | |
41 | #include <csignal> |
44 | #include <csignal> |
42 | |
45 | |
|
|
46 | #include <fcntl.h> |
|
|
47 | |
|
|
48 | #ifdef HAVE_XSETLOCALE |
|
|
49 | # define X_LOCALE |
|
|
50 | # include <X11/Xlocale.h> |
|
|
51 | #else |
|
|
52 | # ifdef HAVE_SETLOCALE |
|
|
53 | # include <clocale> |
|
|
54 | # endif |
|
|
55 | #endif |
|
|
56 | |
|
|
57 | #ifdef HAVE_NL_LANGINFO |
|
|
58 | # include <langinfo.h> |
|
|
59 | #endif |
|
|
60 | |
|
|
61 | #ifdef DISPLAY_IS_IP |
|
|
62 | /* On Solaris link with -lsocket and -lnsl */ |
|
|
63 | #include <sys/types.h> |
|
|
64 | #include <sys/socket.h> |
|
|
65 | |
|
|
66 | /* these next two are probably only on Sun (not Solaris) */ |
|
|
67 | #ifdef HAVE_SYS_SOCKIO_H |
|
|
68 | #include <sys/sockio.h> |
|
|
69 | #endif |
|
|
70 | #ifdef HAVE_SYS_BYTEORDER_H |
|
|
71 | #include <sys/byteorder.h> |
|
|
72 | #endif |
|
|
73 | |
|
|
74 | #include <netinet/in.h> |
|
|
75 | #include <arpa/inet.h> |
|
|
76 | #include <net/if.h> |
|
|
77 | #include <net/if_arp.h> |
|
|
78 | |
|
|
79 | static char * |
|
|
80 | rxvt_network_display (const char *display) |
|
|
81 | { |
|
|
82 | char buffer[1024], *rval = NULL; |
|
|
83 | struct ifconf ifc; |
|
|
84 | struct ifreq *ifr; |
|
|
85 | int i, skfd; |
|
|
86 | |
|
|
87 | if (display[0] != ':' && strncmp (display, "unix:", 5)) |
|
|
88 | return (char *) display; /* nothing to do */ |
|
|
89 | |
|
|
90 | ifc.ifc_len = sizeof (buffer); /* Get names of all ifaces */ |
|
|
91 | ifc.ifc_buf = buffer; |
|
|
92 | |
|
|
93 | if ((skfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) |
|
|
94 | { |
|
|
95 | perror ("socket"); |
|
|
96 | return NULL; |
|
|
97 | } |
|
|
98 | |
|
|
99 | if (ioctl (skfd, SIOCGIFCONF, &ifc) < 0) |
|
|
100 | { |
|
|
101 | perror ("SIOCGIFCONF"); |
|
|
102 | close (skfd); |
|
|
103 | return NULL; |
|
|
104 | } |
|
|
105 | |
|
|
106 | for (i = 0, ifr = ifc.ifc_req; |
|
|
107 | i < (ifc.ifc_len / sizeof (struct ifreq)); |
|
|
108 | i++, ifr++) |
|
|
109 | { |
|
|
110 | struct ifreq ifr2; |
|
|
111 | |
|
|
112 | strcpy (ifr2.ifr_name, ifr->ifr_name); |
|
|
113 | |
|
|
114 | if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) |
|
|
115 | { |
|
|
116 | unsigned long addr; |
|
|
117 | struct sockaddr_in *p_addr; |
|
|
118 | |
|
|
119 | p_addr = (struct sockaddr_in *) &ifr2.ifr_addr; |
|
|
120 | addr = htonl ((unsigned long)p_addr->sin_addr.s_addr); |
|
|
121 | |
|
|
122 | /* |
|
|
123 | * not "0.0.0.0" or "127.0.0.1" - so format the address |
|
|
124 | */ |
|
|
125 | if (addr && addr != 0x7F000001) |
|
|
126 | { |
|
|
127 | char *colon = strchr (display, ':'); |
|
|
128 | |
|
|
129 | if (colon == NULL) |
|
|
130 | colon = ":0.0"; |
|
|
131 | |
|
|
132 | rval = rxvt_malloc (strlen (colon) + 16); |
|
|
133 | sprintf (rval, "%d.%d.%d.%d%s", |
|
|
134 | (int) ((addr >> 030) & 0xFF), |
|
|
135 | (int) ((addr >> 020) & 0xFF), |
|
|
136 | (int) ((addr >> 010) & 0xFF), |
|
|
137 | (int) (addr & 0xFF), colon); |
|
|
138 | break; |
|
|
139 | } |
|
|
140 | } |
|
|
141 | } |
|
|
142 | |
|
|
143 | close (skfd); |
|
|
144 | |
|
|
145 | return rval; |
|
|
146 | } |
|
|
147 | #endif |
|
|
148 | |
43 | const char *const def_colorName[] = |
149 | const char *const def_colorName[] = |
44 | { |
150 | { |
45 | COLOR_FOREGROUND, |
151 | COLOR_FOREGROUND, |
46 | COLOR_BACKGROUND, |
152 | COLOR_BACKGROUND, |
47 | /* low-intensity colors */ |
153 | /* low-intensity colors */ |
… | |
… | |
50 | "rgb:00/cd/00", // 2: green (Green3) |
156 | "rgb:00/cd/00", // 2: green (Green3) |
51 | "rgb:cd/cd/00", // 3: yellow (Yellow3) |
157 | "rgb:cd/cd/00", // 3: yellow (Yellow3) |
52 | "rgb:00/00/cd", // 4: blue (Blue3) |
158 | "rgb:00/00/cd", // 4: blue (Blue3) |
53 | "rgb:cd/00/cd", // 5: magenta (Magenta3) |
159 | "rgb:cd/00/cd", // 5: magenta (Magenta3) |
54 | "rgb:00/cd/cd", // 6: cyan (Cyan3) |
160 | "rgb:00/cd/cd", // 6: cyan (Cyan3) |
55 | # ifdef XTERM_COLORS |
161 | # ifdef XTERM_COLORS |
56 | "rgb:e5/e5/e5", // 7: white (Grey90) |
162 | "rgb:e5/e5/e5", // 7: white (Grey90) |
57 | # else |
163 | # else |
58 | "rgb:fa/eb/d7", // 7: white (AntiqueWhite) |
164 | "rgb:fa/eb/d7", // 7: white (AntiqueWhite) |
59 | # endif |
165 | # endif |
60 | /* high-intensity colors */ |
166 | /* high-intensity colors */ |
61 | # ifdef XTERM_COLORS |
167 | # ifdef XTERM_COLORS |
62 | "rgb:4d/4d/4d", // 8: bright black (Grey30) |
168 | "rgb:4d/4d/4d", // 8: bright black (Grey30) |
… | |
… | |
146 | "rgb:e7/e7/e7", |
252 | "rgb:e7/e7/e7", |
147 | |
253 | |
148 | #ifndef NO_CURSORCOLOR |
254 | #ifndef NO_CURSORCOLOR |
149 | COLOR_CURSOR_BACKGROUND, |
255 | COLOR_CURSOR_BACKGROUND, |
150 | COLOR_CURSOR_FOREGROUND, |
256 | COLOR_CURSOR_FOREGROUND, |
151 | #endif /* ! NO_CURSORCOLOR */ |
257 | #endif /* ! NO_CURSORCOLOR */ |
152 | NULL, /* Color_pointer_fg */ |
258 | NULL, /* Color_pointer_fg */ |
153 | NULL, /* Color_pointer_bg */ |
259 | NULL, /* Color_pointer_bg */ |
154 | NULL, /* Color_border */ |
260 | NULL, /* Color_border */ |
155 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
261 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
156 | NULL, /* Color_BD */ |
262 | NULL, /* Color_BD */ |
157 | NULL, /* Color_IT */ |
263 | NULL, /* Color_IT */ |
158 | NULL, /* Color_UL */ |
264 | NULL, /* Color_UL */ |
159 | NULL, /* Color_RV */ |
265 | NULL, /* Color_RV */ |
160 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
266 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
161 | #if ENABLE_FRILLS |
267 | #if ENABLE_FRILLS |
162 | NULL, // Color_underline |
268 | NULL, // Color_underline |
163 | #endif |
269 | #endif |
164 | #ifdef OPTION_HC |
270 | #ifdef OPTION_HC |
165 | NULL, |
271 | NULL, |
166 | #endif |
272 | #endif |
167 | #ifdef KEEP_SCROLLCOLOR |
273 | #ifdef KEEP_SCROLLCOLOR |
168 | COLOR_SCROLLBAR, |
274 | COLOR_SCROLLBAR, |
169 | COLOR_SCROLLTROUGH, |
275 | COLOR_SCROLLTROUGH, |
170 | #endif /* KEEP_SCROLLCOLOR */ |
276 | #endif /* KEEP_SCROLLCOLOR */ |
171 | #if ENABLE_TRANSPARENCY |
277 | #if ENABLE_TRANSPARENCY |
172 | NULL, |
278 | NULL, |
173 | #endif |
279 | #endif |
174 | #if OFF_FOCUS_FADING |
280 | #if OFF_FOCUS_FADING |
175 | "rgb:00/00/00", |
281 | "rgb:00/00/00", |
176 | #endif |
282 | #endif |
177 | }; |
283 | }; |
178 | |
284 | |
179 | bool |
285 | void |
180 | rxvt_term::init_vars () |
286 | rxvt_term::init_vars () |
181 | { |
287 | { |
182 | pix_colors = // |
288 | pix_colors = // |
183 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
289 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
184 | #ifdef OFF_FOCUS_FADING |
290 | #ifdef OFF_FOCUS_FADING |
… | |
… | |
199 | numpix_colors = TOTAL_COLORS; |
305 | numpix_colors = TOTAL_COLORS; |
200 | |
306 | |
201 | refresh_type = SLOW_REFRESH; |
307 | refresh_type = SLOW_REFRESH; |
202 | |
308 | |
203 | oldcursor.row = oldcursor.col = -1; |
309 | oldcursor.row = oldcursor.col = -1; |
204 | #ifdef HAVE_BG_PIXMAP |
|
|
205 | #ifdef HAVE_AFTERIMAGE |
|
|
206 | bgPixmap.original_asim = NULL; |
|
|
207 | #endif |
|
|
208 | /* bgPixmap.w = bgPixmap.h = 0; */ |
|
|
209 | #ifdef XPM_BACKGROUND |
|
|
210 | bgPixmap.h_scale = bgPixmap.v_scale = 0; |
|
|
211 | bgPixmap.h_align = bgPixmap.v_align = 0; |
|
|
212 | #endif |
|
|
213 | bgPixmap.flags = 0; |
|
|
214 | bgPixmap.pixmap = None; |
|
|
215 | #endif |
|
|
216 | last_bot = last_state = -1; |
310 | last_bot = last_state = -1; |
217 | |
311 | |
218 | set_option (Opt_scrollBar); |
312 | set_option (Opt_scrollBar); |
219 | set_option (Opt_scrollTtyOutput); |
313 | set_option (Opt_scrollTtyOutput); |
220 | set_option (Opt_jumpScroll); |
314 | set_option (Opt_jumpScroll); |
… | |
… | |
222 | set_option (Opt_secondaryScreen); |
316 | set_option (Opt_secondaryScreen); |
223 | set_option (Opt_secondaryScroll); |
317 | set_option (Opt_secondaryScroll); |
224 | set_option (Opt_pastableTabs); |
318 | set_option (Opt_pastableTabs); |
225 | set_option (Opt_intensityStyles); |
319 | set_option (Opt_intensityStyles); |
226 | set_option (Opt_iso14755_52); |
320 | set_option (Opt_iso14755_52); |
227 | |
|
|
228 | return true; |
|
|
229 | } |
321 | } |
230 | |
322 | |
231 | void |
323 | void |
232 | rxvt_term::init_secondary () |
324 | rxvt_term::init_secondary () |
233 | { |
325 | { |
… | |
… | |
240 | if ((i = open ("/dev/null", O_RDONLY)) < 0) |
332 | if ((i = open ("/dev/null", O_RDONLY)) < 0) |
241 | { |
333 | { |
242 | /* TODO: BOO HISS */ |
334 | /* TODO: BOO HISS */ |
243 | dup2 (STDERR_FILENO, STDIN_FILENO); |
335 | dup2 (STDERR_FILENO, STDIN_FILENO); |
244 | } |
336 | } |
245 | else if (i > STDIN_FILENO) |
337 | else if (i != STDIN_FILENO) |
246 | { |
338 | { |
247 | dup2 (i, STDIN_FILENO); |
339 | dup2 (i, STDIN_FILENO); |
248 | close (i); |
340 | close (i); |
249 | } |
341 | } |
250 | |
342 | |
… | |
… | |
274 | */ |
366 | */ |
275 | for (r_argc = 0; r_argc < argc; r_argc++) |
367 | for (r_argc = 0; r_argc < argc; r_argc++) |
276 | if (!strcmp (argv[r_argc], "-e")) |
368 | if (!strcmp (argv[r_argc], "-e")) |
277 | break; |
369 | break; |
278 | |
370 | |
|
|
371 | if (r_argc == argc) |
|
|
372 | cmd_argv = NULL; |
|
|
373 | else if (!argv[r_argc + 1]) |
|
|
374 | rxvt_fatal ("option '-e' requires an argument, aborting.\n"); |
|
|
375 | else |
|
|
376 | { |
|
|
377 | cmd_argv = (const char **)rxvt_malloc (sizeof (char *) * (argc - r_argc)); |
|
|
378 | |
|
|
379 | for (i = 0; i < argc - r_argc - 1; i++) |
|
|
380 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
|
|
381 | |
|
|
382 | cmd_argv[i] = NULL; |
|
|
383 | } |
|
|
384 | |
279 | r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1)); |
385 | r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1)); |
280 | |
386 | |
281 | for (i = 0; i < r_argc; i++) |
387 | for (i = 0; i < r_argc; i++) |
282 | r_argv[i] = (const char *)argv[i]; |
388 | r_argv[i] = (const char *)argv[i]; |
283 | |
389 | |
284 | r_argv[i] = NULL; |
390 | r_argv[i] = NULL; |
285 | |
|
|
286 | if (r_argc == argc) |
|
|
287 | cmd_argv = NULL; |
|
|
288 | else |
|
|
289 | { |
|
|
290 | cmd_argv = (const char **)rxvt_malloc (sizeof (char *) * (argc - r_argc)); |
|
|
291 | |
|
|
292 | for (i = 0; i < argc - r_argc - 1; i++) |
|
|
293 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
|
|
294 | |
|
|
295 | cmd_argv[i] = NULL; |
|
|
296 | } |
|
|
297 | |
391 | |
298 | rs[Rs_name] = rxvt_basename (argv[0]); |
392 | rs[Rs_name] = rxvt_basename (argv[0]); |
299 | |
393 | |
300 | /* |
394 | /* |
301 | * Open display, get options/resources and create the window |
395 | * Open display, get options/resources and create the window |
… | |
… | |
305 | rs[Rs_display_name] = ":0"; |
399 | rs[Rs_display_name] = ":0"; |
306 | |
400 | |
307 | get_options (r_argc, r_argv); |
401 | get_options (r_argc, r_argv); |
308 | |
402 | |
309 | if (!(display = displays.get (rs[Rs_display_name]))) |
403 | if (!(display = displays.get (rs[Rs_display_name]))) |
|
|
404 | { |
|
|
405 | free (r_argv); |
310 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
406 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
|
|
407 | } |
311 | |
408 | |
312 | // using a local pointer decreases code size a lot |
409 | // using a local pointer decreases code size a lot |
313 | xa = display->xa; |
410 | xa = display->xa; |
314 | |
411 | |
315 | set (display); |
412 | set (display); |
… | |
… | |
441 | color_aliases (Color_fg); |
538 | color_aliases (Color_fg); |
442 | color_aliases (Color_bg); |
539 | color_aliases (Color_bg); |
443 | #ifndef NO_CURSORCOLOR |
540 | #ifndef NO_CURSORCOLOR |
444 | color_aliases (Color_cursor); |
541 | color_aliases (Color_cursor); |
445 | color_aliases (Color_cursor2); |
542 | color_aliases (Color_cursor2); |
446 | #endif /* NO_CURSORCOLOR */ |
543 | #endif /* NO_CURSORCOLOR */ |
447 | color_aliases (Color_pointer_fg); |
544 | color_aliases (Color_pointer_fg); |
448 | color_aliases (Color_pointer_bg); |
545 | color_aliases (Color_pointer_bg); |
449 | color_aliases (Color_border); |
546 | color_aliases (Color_border); |
450 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
547 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
451 | color_aliases (Color_BD); |
548 | color_aliases (Color_BD); |
452 | color_aliases (Color_UL); |
549 | color_aliases (Color_UL); |
453 | color_aliases (Color_RV); |
550 | color_aliases (Color_RV); |
454 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
551 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
455 | |
552 | |
456 | if (!rs[Rs_color + Color_border]) |
553 | if (!rs[Rs_color + Color_border]) |
457 | rs[Rs_color + Color_border] = rs[Rs_color + Color_bg]; |
554 | rs[Rs_color + Color_border] = rs[Rs_color + Color_bg]; |
458 | |
555 | |
459 | return cmd_argv; |
556 | return cmd_argv; |
… | |
… | |
479 | */ |
576 | */ |
480 | val = rxvt_network_display (rs[Rs_display_name]); |
577 | val = rxvt_network_display (rs[Rs_display_name]); |
481 | rs[Rs_display_name] = (const char *)val; |
578 | rs[Rs_display_name] = (const char *)val; |
482 | |
579 | |
483 | if (val == NULL) |
580 | if (val == NULL) |
484 | #endif /* DISPLAY_IS_IP */ |
581 | #endif /* DISPLAY_IS_IP */ |
485 | val = XDisplayString (dpy); |
582 | val = XDisplayString (dpy); |
486 | |
583 | |
487 | if (rs[Rs_display_name] == NULL) |
584 | if (rs[Rs_display_name] == NULL) |
488 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
585 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
489 | |
586 | |
… | |
… | |
529 | #ifdef HAVE_UNSETENV |
626 | #ifdef HAVE_UNSETENV |
530 | /* avoid passing old settings and confusing term size */ |
627 | /* avoid passing old settings and confusing term size */ |
531 | unsetenv ("LINES"); |
628 | unsetenv ("LINES"); |
532 | unsetenv ("COLUMNS"); |
629 | unsetenv ("COLUMNS"); |
533 | unsetenv ("TERMCAP"); /* terminfo should be okay */ |
630 | unsetenv ("TERMCAP"); /* terminfo should be okay */ |
534 | #endif /* HAVE_UNSETENV */ |
631 | #endif /* HAVE_UNSETENV */ |
535 | } |
632 | } |
536 | |
633 | |
537 | /*----------------------------------------------------------------------*/ |
634 | /*----------------------------------------------------------------------*/ |
538 | /* |
635 | /* |
539 | * This is more or less stolen straight from XFree86 xterm. |
636 | * This is more or less stolen straight from XFree86 xterm. |
… | |
… | |
560 | |
657 | |
561 | this->locale = "C"; |
658 | this->locale = "C"; |
562 | } |
659 | } |
563 | |
660 | |
564 | |
661 | |
565 | this->locale = rxvt_strdup (this->locale); |
662 | this->locale = strdup (this->locale); |
566 | SET_LOCALE (this->locale); |
663 | SET_LOCALE (this->locale); |
567 | mbstate.reset (); |
664 | mbstate.reset (); |
568 | #endif |
665 | #endif |
569 | |
666 | |
570 | #if HAVE_NL_LANGINFO |
667 | #if HAVE_NL_LANGINFO |
… | |
… | |
650 | int i; |
747 | int i; |
651 | |
748 | |
652 | #ifdef OFF_FOCUS_FADING |
749 | #ifdef OFF_FOCUS_FADING |
653 | pix_colors = pix_colors_focused; |
750 | pix_colors = pix_colors_focused; |
654 | #endif |
751 | #endif |
655 | |
752 | |
656 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
753 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
657 | { |
754 | { |
658 | const char *name = rs[Rs_color + i]; |
755 | const char *name = rs[Rs_color + i]; |
659 | |
756 | |
660 | if (!name) |
757 | if (!name) |
… | |
… | |
738 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
835 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
739 | cscroll.a) |
836 | cscroll.a) |
740 | )) |
837 | )) |
741 | alias_color (Color_topShadow, Color_White); |
838 | alias_color (Color_topShadow, Color_White); |
742 | } |
839 | } |
743 | #endif /* KEEP_SCROLLCOLOR */ |
840 | #endif /* KEEP_SCROLLCOLOR */ |
744 | |
841 | |
745 | #ifdef OFF_FOCUS_FADING |
842 | #ifdef OFF_FOCUS_FADING |
746 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
843 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
747 | update_fade_color (i); |
844 | update_fade_color (i); |
748 | #endif |
845 | #endif |
… | |
… | |
756 | if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) |
853 | if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) |
757 | { |
854 | { |
758 | int i = atoi (rs[Rs_color + idx]); |
855 | int i = atoi (rs[Rs_color + idx]); |
759 | |
856 | |
760 | if (i >= 8 && i <= 15) |
857 | if (i >= 8 && i <= 15) |
761 | { /* bright colors */ |
858 | /* bright colors */ |
762 | i -= 8; |
|
|
763 | rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i]; |
859 | rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i - 8]; |
764 | return; |
860 | else if (i >= 0 && i <= 7) |
765 | } |
861 | /* normal colors */ |
766 | |
|
|
767 | if (i >= 0 && i <= 7) /* normal colors */ |
|
|
768 | rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i]; |
862 | rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i]; |
769 | } |
863 | } |
770 | } |
864 | } |
771 | |
865 | |
772 | /*----------------------------------------------------------------------*/ |
866 | /*----------------------------------------------------------------------*/ |
… | |
… | |
1132 | |
1226 | |
1133 | /* |
1227 | /* |
1134 | * Debugging |
1228 | * Debugging |
1135 | */ |
1229 | */ |
1136 | #ifdef DEBUG_TTYMODE |
1230 | #ifdef DEBUG_TTYMODE |
1137 | #ifdef HAVE_TERMIOS_H |
|
|
1138 | /* c_iflag bits */ |
1231 | /* c_iflag bits */ |
1139 | fprintf (stderr, "Input flags\n"); |
1232 | fprintf (stderr, "Input flags\n"); |
1140 | |
1233 | |
1141 | /* cpp token stringize doesn't work on all machines <sigh> */ |
1234 | /* cpp token stringize doesn't work on all machines <sigh> */ |
1142 | # define FOO(flag,name) \ |
1235 | # define FOO(flag,name) \ |
… | |
… | |
1205 | FOO (VLNEXT, "VLNEXT"); |
1298 | FOO (VLNEXT, "VLNEXT"); |
1206 | # endif |
1299 | # endif |
1207 | |
1300 | |
1208 | fprintf (stderr, "\n"); |
1301 | fprintf (stderr, "\n"); |
1209 | # undef FOO |
1302 | # undef FOO |
1210 | # endif /* HAVE_TERMIOS_H */ |
1303 | #endif /* DEBUG_TTYMODE */ |
1211 | #endif /* DEBUG_TTYMODE */ |
|
|
1212 | } |
1304 | } |
1213 | |
1305 | |
1214 | /*----------------------------------------------------------------------*/ |
1306 | /*----------------------------------------------------------------------*/ |
1215 | /* |
1307 | /* |
1216 | * Run the command in a subprocess and return a file descriptor for the |
1308 | * Run the command in a subprocess and return a file descriptor for the |
… | |
… | |
1319 | rxvt_term::run_child (const char *const *argv) |
1411 | rxvt_term::run_child (const char *const *argv) |
1320 | { |
1412 | { |
1321 | char *login; |
1413 | char *login; |
1322 | |
1414 | |
1323 | if (option (Opt_console)) |
1415 | if (option (Opt_console)) |
|
|
1416 | { |
1324 | { /* be virtual console, fail silently */ |
1417 | /* be virtual console, fail silently */ |
1325 | #ifdef TIOCCONS |
1418 | #ifdef TIOCCONS |
1326 | unsigned int on = 1; |
1419 | unsigned int on = 1; |
1327 | |
1420 | |
1328 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
1421 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
1329 | #elif defined (SRIOCSREDIR) |
1422 | #elif defined (SRIOCSREDIR) |
… | |
… | |
1331 | |
1424 | |
1332 | fd = open (CONSOLE, O_WRONLY, 0); |
1425 | fd = open (CONSOLE, O_WRONLY, 0); |
1333 | if (fd >= 0) |
1426 | if (fd >= 0) |
1334 | if (ioctl (fd, SRIOCSREDIR, NULL) < 0) |
1427 | if (ioctl (fd, SRIOCSREDIR, NULL) < 0) |
1335 | close (fd); |
1428 | close (fd); |
1336 | #endif /* SRIOCSREDIR */ |
1429 | #endif /* SRIOCSREDIR */ |
1337 | } |
1430 | } |
1338 | |
1431 | |
1339 | /* reset signals and spin off the command interpreter */ |
1432 | /* reset signals and spin off the command interpreter */ |
1340 | signal (SIGINT, SIG_DFL); |
1433 | signal (SIGINT, SIG_DFL); |
1341 | signal (SIGQUIT, SIG_DFL); |
1434 | signal (SIGQUIT, SIG_DFL); |
… | |
… | |
1348 | */ |
1441 | */ |
1349 | #ifdef SIGTSTP |
1442 | #ifdef SIGTSTP |
1350 | signal (SIGTSTP, SIG_IGN); |
1443 | signal (SIGTSTP, SIG_IGN); |
1351 | signal (SIGTTIN, SIG_IGN); |
1444 | signal (SIGTTIN, SIG_IGN); |
1352 | signal (SIGTTOU, SIG_IGN); |
1445 | signal (SIGTTOU, SIG_IGN); |
1353 | #endif /* SIGTSTP */ |
1446 | #endif /* SIGTSTP */ |
1354 | |
1447 | |
1355 | // unblock signals (signals are blocked by iom.C |
1448 | // unblock signals (signals are blocked by iom.C |
1356 | sigset_t ss; |
1449 | sigset_t ss; |
1357 | sigemptyset (&ss); |
1450 | sigemptyset (&ss); |
1358 | sigprocmask (SIG_SETMASK, &ss, 0); |
1451 | sigprocmask (SIG_SETMASK, &ss, 0); |
1359 | |
1452 | |
1360 | /* command interpreter path */ |
1453 | /* command interpreter path */ |
1361 | if (argv != NULL) |
1454 | if (argv) |
1362 | { |
1455 | { |
1363 | # ifdef DEBUG_CMD |
1456 | # ifdef DEBUG_CMD |
1364 | int i; |
1457 | int i; |
1365 | |
1458 | |
1366 | for (i = 0; argv[i]; i++) |
1459 | for (i = 0; argv[i]; i++) |
… | |
… | |
1386 | login[0] = '-'; |
1479 | login[0] = '-'; |
1387 | strcpy (&login[1], argv0); |
1480 | strcpy (&login[1], argv0); |
1388 | argv0 = login; |
1481 | argv0 = login; |
1389 | } |
1482 | } |
1390 | |
1483 | |
1391 | execlp (shell, argv0, NULL); |
1484 | execlp (shell, argv0, (char *)0); |
1392 | /* no error message: STDERR is closed! */ |
1485 | /* no error message: STDERR is closed! */ |
1393 | } |
1486 | } |
1394 | |
1487 | |
1395 | return -1; |
1488 | return -1; |
1396 | } |
1489 | } |