… | |
… | |
9 | * - extensive modifications |
9 | * - extensive modifications |
10 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
10 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
11 | * - extensive modifications |
11 | * - extensive modifications |
12 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
12 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
13 | * - QNX support |
13 | * - QNX support |
14 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
14 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
15 | * |
15 | * |
16 | * This program is free software; you can redistribute it and/or modify |
16 | * This program is free software; you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License as published by |
17 | * it under the terms of the GNU General Public License as published by |
18 | * the Free Software Foundation; either version 2 of the License, or |
18 | * the Free Software Foundation; either version 2 of the License, or |
19 | * (at your option) any later version. |
19 | * (at your option) any later version. |
… | |
… | |
339 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
339 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
340 | |
340 | |
341 | /* |
341 | /* |
342 | * Open display, get options/resources and create the window |
342 | * Open display, get options/resources and create the window |
343 | */ |
343 | */ |
|
|
344 | { |
|
|
345 | TEMP_ENV; |
|
|
346 | |
344 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
347 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
345 | rs[Rs_display_name] = ":0"; |
348 | rs[Rs_display_name] = ":0"; |
346 | |
349 | |
347 | get_options (r_argc, r_argv); |
350 | get_options (r_argc, r_argv); |
348 | |
351 | |
349 | if (!(display = displays.get (rs[Rs_display_name]))) |
352 | if (!(display = displays.get (rs[Rs_display_name]))) |
350 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
353 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
|
|
354 | } |
351 | |
355 | |
352 | extract_resources (); |
356 | extract_resources (); |
353 | free (r_argv); |
357 | free (r_argv); |
354 | |
358 | |
355 | /* |
359 | /* |
… | |
… | |
391 | pointerBlankDelay = 2; |
395 | pointerBlankDelay = 2; |
392 | #endif |
396 | #endif |
393 | |
397 | |
394 | /* no point having a scrollbar without having any scrollback! */ |
398 | /* no point having a scrollbar without having any scrollback! */ |
395 | if (!saveLines) |
399 | if (!saveLines) |
396 | CLR_OPTION (Opt_scrollBar); |
400 | set_option (Opt_scrollBar, 0); |
397 | |
401 | |
398 | #ifdef PRINTPIPE |
402 | #ifdef PRINTPIPE |
399 | if (!rs[Rs_print_pipe]) |
403 | if (!rs[Rs_print_pipe]) |
400 | rs[Rs_print_pipe] = PRINTPIPE; |
404 | rs[Rs_print_pipe] = PRINTPIPE; |
401 | #endif |
405 | #endif |
… | |
… | |
576 | * This should support all European type languages. |
580 | * This should support all European type languages. |
577 | */ |
581 | */ |
578 | void |
582 | void |
579 | rxvt_term::set_locale (const char *locale) |
583 | rxvt_term::set_locale (const char *locale) |
580 | { |
584 | { |
|
|
585 | TEMP_ENV; |
|
|
586 | |
581 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
587 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
582 | free (this->locale); |
588 | free (this->locale); |
583 | this->locale = setlocale (LC_CTYPE, locale); |
589 | this->locale = setlocale (LC_CTYPE, locale); |
584 | |
590 | |
585 | if (!this->locale) |
591 | if (!this->locale) |
586 | { |
592 | { |
587 | if (*locale) |
593 | if (*locale) |
588 | { |
594 | { |
589 | rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale); |
595 | rxvt_warn ("unable to set locale \"%s\", using C locale instead.\n", locale); |
590 | setlocale (LC_CTYPE, ""); |
596 | setlocale (LC_CTYPE, "C"); |
591 | } |
597 | } |
592 | else |
598 | else |
593 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
599 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
594 | |
600 | |
595 | this->locale = ""; |
601 | this->locale = "C"; |
596 | } |
602 | } |
597 | |
603 | |
598 | |
604 | |
599 | this->locale = rxvt_strdup (this->locale); |
605 | this->locale = rxvt_strdup (this->locale); |
600 | SET_LOCALE (this->locale); |
606 | SET_LOCALE (this->locale); |
… | |
… | |
615 | } |
621 | } |
616 | |
622 | |
617 | void |
623 | void |
618 | rxvt_term::init_xlocale () |
624 | rxvt_term::init_xlocale () |
619 | { |
625 | { |
|
|
626 | TEMP_ENV; |
|
|
627 | |
620 | #ifdef USE_XIM |
628 | #ifdef USE_XIM |
621 | if (!locale) |
629 | if (!locale) |
622 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
630 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
623 | else |
631 | else |
624 | { |
632 | { |
… | |
… | |
1032 | #endif |
1040 | #endif |
1033 | }; |
1041 | }; |
1034 | |
1042 | |
1035 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1043 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1036 | |
1044 | |
|
|
1045 | #if ENABLE_FRILLS |
|
|
1046 | if (rs[Rs_transient_for]) |
|
|
1047 | XSetTransientForHint (disp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
|
|
1048 | #endif |
|
|
1049 | |
1037 | #if ENABLE_EWMH |
1050 | #if ENABLE_EWMH |
1038 | long pid = getpid (); |
1051 | long pid = getpid (); |
1039 | |
1052 | |
1040 | XChangeProperty (disp, top, |
1053 | XChangeProperty (disp, top, |
1041 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1054 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
… | |
… | |
1084 | attributes.bit_gravity = NorthWestGravity; |
1097 | attributes.bit_gravity = NorthWestGravity; |
1085 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1098 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1086 | |
1099 | |
1087 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1100 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1088 | |
1101 | |
1089 | #ifdef POINTER_BLANK |
|
|
1090 | if (OPTION (Opt_pointerBlank)) |
1102 | if (OPTION (Opt_pointerBlank) |
|
|
1103 | #ifdef ENABLE_PERL |
|
|
1104 | || perl.self |
|
|
1105 | #endif |
|
|
1106 | ) |
1091 | vt_emask |= PointerMotionMask; |
1107 | vt_emask |= PointerMotionMask; |
1092 | else |
1108 | else |
1093 | #endif |
|
|
1094 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1109 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1095 | |
1110 | |
1096 | XSelectInput (disp, vt, vt_emask); |
1111 | XSelectInput (disp, vt, vt_emask); |
1097 | vt_ev.start (display, vt); |
1112 | vt_ev.start (display, vt); |
1098 | |
1113 | |
… | |
… | |
1397 | * the slave. |
1412 | * the slave. |
1398 | */ |
1413 | */ |
1399 | void |
1414 | void |
1400 | rxvt_term::run_command (const char *const *argv) |
1415 | rxvt_term::run_command (const char *const *argv) |
1401 | { |
1416 | { |
|
|
1417 | TEMP_ENV; // not very temporary... |
|
|
1418 | |
1402 | #if ENABLE_FRILLS |
1419 | #if ENABLE_FRILLS |
1403 | if (rs[Rs_pty_fd]) |
1420 | if (rs[Rs_pty_fd]) |
1404 | { |
1421 | { |
1405 | pty.pty = atoi (rs[Rs_pty_fd]); |
1422 | pty.pty = atoi (rs[Rs_pty_fd]); |
1406 | |
1423 | |
|
|
1424 | if (pty.pty >= 0) |
|
|
1425 | { |
1407 | if (getfd_hook) |
1426 | if (getfd_hook) |
1408 | pty.pty = (*getfd_hook) (pty.pty); |
1427 | pty.pty = (*getfd_hook) (pty.pty); |
1409 | |
1428 | |
1410 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1429 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1411 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1430 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
|
|
1431 | } |
1412 | } |
1432 | } |
1413 | else |
1433 | else |
1414 | #endif |
1434 | #endif |
1415 | if (!pty.get ()) |
1435 | if (!pty.get ()) |
1416 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1436 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
… | |
… | |
1570 | execvp (argv[0], (char *const *)argv); |
1590 | execvp (argv[0], (char *const *)argv); |
1571 | /* no error message: STDERR is closed! */ |
1591 | /* no error message: STDERR is closed! */ |
1572 | } |
1592 | } |
1573 | else |
1593 | else |
1574 | { |
1594 | { |
1575 | const char *argv0, *shell; |
1595 | const char *argv0, *shell; |
1576 | |
1596 | |
1577 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1597 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1578 | shell = "/bin/sh"; |
1598 | shell = "/bin/sh"; |
1579 | |
1599 | |
1580 | argv0 = (const char *)rxvt_r_basename (shell); |
1600 | argv0 = (const char *)rxvt_r_basename (shell); |
… | |
… | |
1585 | |
1605 | |
1586 | login[0] = '-'; |
1606 | login[0] = '-'; |
1587 | strcpy (&login[1], argv0); |
1607 | strcpy (&login[1], argv0); |
1588 | argv0 = login; |
1608 | argv0 = login; |
1589 | } |
1609 | } |
|
|
1610 | |
1590 | execlp (shell, argv0, NULL); |
1611 | execlp (shell, argv0, NULL); |
1591 | /* no error message: STDERR is closed! */ |
1612 | /* no error message: STDERR is closed! */ |
1592 | } |
1613 | } |
1593 | |
1614 | |
1594 | #else /* __QNX__ uses qnxspawn () */ |
1615 | #else /* __QNX__ uses qnxspawn () */ |