… | |
… | |
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]); |
351 | |
354 | |
352 | extract_resources (); |
355 | extract_resources (); |
|
|
356 | } |
|
|
357 | |
353 | free (r_argv); |
358 | free (r_argv); |
354 | |
359 | |
355 | /* |
360 | /* |
356 | * set any defaults not already set |
361 | * set any defaults not already set |
357 | */ |
362 | */ |
… | |
… | |
391 | pointerBlankDelay = 2; |
396 | pointerBlankDelay = 2; |
392 | #endif |
397 | #endif |
393 | |
398 | |
394 | /* no point having a scrollbar without having any scrollback! */ |
399 | /* no point having a scrollbar without having any scrollback! */ |
395 | if (!saveLines) |
400 | if (!saveLines) |
396 | CLR_OPTION (Opt_scrollBar); |
401 | set_option (Opt_scrollBar, 0); |
397 | |
402 | |
398 | #ifdef PRINTPIPE |
403 | #ifdef PRINTPIPE |
399 | if (!rs[Rs_print_pipe]) |
404 | if (!rs[Rs_print_pipe]) |
400 | rs[Rs_print_pipe] = PRINTPIPE; |
405 | rs[Rs_print_pipe] = PRINTPIPE; |
401 | #endif |
406 | #endif |
… | |
… | |
576 | * This should support all European type languages. |
581 | * This should support all European type languages. |
577 | */ |
582 | */ |
578 | void |
583 | void |
579 | rxvt_term::set_locale (const char *locale) |
584 | rxvt_term::set_locale (const char *locale) |
580 | { |
585 | { |
|
|
586 | TEMP_ENV; |
|
|
587 | |
581 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
588 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
582 | free (this->locale); |
589 | free (this->locale); |
583 | this->locale = setlocale (LC_CTYPE, locale); |
590 | this->locale = setlocale (LC_CTYPE, locale); |
584 | |
591 | |
585 | if (!this->locale) |
592 | if (!this->locale) |
586 | { |
593 | { |
587 | if (*locale) |
594 | if (*locale) |
588 | { |
595 | { |
589 | rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale); |
596 | rxvt_warn ("unable to set locale \"%s\", using C locale instead.\n", locale); |
590 | setlocale (LC_CTYPE, ""); |
597 | setlocale (LC_CTYPE, "C"); |
591 | } |
598 | } |
592 | else |
599 | else |
593 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
600 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
594 | |
601 | |
595 | this->locale = ""; |
602 | this->locale = "C"; |
596 | } |
603 | } |
597 | |
604 | |
598 | |
605 | |
599 | this->locale = rxvt_strdup (this->locale); |
606 | this->locale = rxvt_strdup (this->locale); |
600 | SET_LOCALE (this->locale); |
607 | SET_LOCALE (this->locale); |
… | |
… | |
615 | } |
622 | } |
616 | |
623 | |
617 | void |
624 | void |
618 | rxvt_term::init_xlocale () |
625 | rxvt_term::init_xlocale () |
619 | { |
626 | { |
|
|
627 | TEMP_ENV; |
|
|
628 | |
620 | #ifdef USE_XIM |
629 | #ifdef USE_XIM |
621 | if (!locale) |
630 | if (!locale) |
622 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
631 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
623 | else |
632 | else |
624 | { |
633 | { |
… | |
… | |
1032 | #endif |
1041 | #endif |
1033 | }; |
1042 | }; |
1034 | |
1043 | |
1035 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1044 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1036 | |
1045 | |
|
|
1046 | #if ENABLE_FRILLS |
|
|
1047 | if (rs[Rs_transient_for]) |
|
|
1048 | XSetTransientForHint (disp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
|
|
1049 | #endif |
|
|
1050 | |
1037 | #if ENABLE_EWMH |
1051 | #if ENABLE_EWMH |
1038 | long pid = getpid (); |
1052 | long pid = getpid (); |
1039 | |
1053 | |
1040 | XChangeProperty (disp, top, |
1054 | XChangeProperty (disp, top, |
1041 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1055 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
… | |
… | |
1084 | attributes.bit_gravity = NorthWestGravity; |
1098 | attributes.bit_gravity = NorthWestGravity; |
1085 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1099 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1086 | |
1100 | |
1087 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1101 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1088 | |
1102 | |
1089 | #ifdef POINTER_BLANK |
|
|
1090 | if (OPTION (Opt_pointerBlank)) |
1103 | if (OPTION (Opt_pointerBlank) |
|
|
1104 | #ifdef ENABLE_PERL |
|
|
1105 | || perl.self |
|
|
1106 | #endif |
|
|
1107 | ) |
1091 | vt_emask |= PointerMotionMask; |
1108 | vt_emask |= PointerMotionMask; |
1092 | else |
1109 | else |
1093 | #endif |
|
|
1094 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1110 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1095 | |
1111 | |
1096 | XSelectInput (disp, vt, vt_emask); |
1112 | XSelectInput (disp, vt, vt_emask); |
1097 | vt_ev.start (display, vt); |
1113 | vt_ev.start (display, vt); |
1098 | |
1114 | |
… | |
… | |
1397 | * the slave. |
1413 | * the slave. |
1398 | */ |
1414 | */ |
1399 | void |
1415 | void |
1400 | rxvt_term::run_command (const char *const *argv) |
1416 | rxvt_term::run_command (const char *const *argv) |
1401 | { |
1417 | { |
|
|
1418 | TEMP_ENV; // not very temporary... |
|
|
1419 | |
1402 | #if ENABLE_FRILLS |
1420 | #if ENABLE_FRILLS |
1403 | if (rs[Rs_pty_fd]) |
1421 | if (rs[Rs_pty_fd]) |
1404 | { |
1422 | { |
1405 | pty.pty = atoi (rs[Rs_pty_fd]); |
1423 | pty.pty = atoi (rs[Rs_pty_fd]); |
1406 | |
1424 | |
|
|
1425 | if (pty.pty >= 0) |
|
|
1426 | { |
1407 | if (getfd_hook) |
1427 | if (getfd_hook) |
1408 | pty.pty = (*getfd_hook) (pty.pty); |
1428 | pty.pty = (*getfd_hook) (pty.pty); |
1409 | |
1429 | |
1410 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1430 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1411 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1431 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
|
|
1432 | } |
1412 | } |
1433 | } |
1413 | else |
1434 | else |
1414 | #endif |
1435 | #endif |
1415 | if (!pty.get ()) |
1436 | if (!pty.get ()) |
1416 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1437 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
… | |
… | |
1570 | execvp (argv[0], (char *const *)argv); |
1591 | execvp (argv[0], (char *const *)argv); |
1571 | /* no error message: STDERR is closed! */ |
1592 | /* no error message: STDERR is closed! */ |
1572 | } |
1593 | } |
1573 | else |
1594 | else |
1574 | { |
1595 | { |
1575 | const char *argv0, *shell; |
1596 | const char *argv0, *shell; |
1576 | |
1597 | |
1577 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1598 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1578 | shell = "/bin/sh"; |
1599 | shell = "/bin/sh"; |
1579 | |
1600 | |
1580 | argv0 = (const char *)rxvt_r_basename (shell); |
1601 | argv0 = (const char *)rxvt_r_basename (shell); |
… | |
… | |
1585 | |
1606 | |
1586 | login[0] = '-'; |
1607 | login[0] = '-'; |
1587 | strcpy (&login[1], argv0); |
1608 | strcpy (&login[1], argv0); |
1588 | argv0 = login; |
1609 | argv0 = login; |
1589 | } |
1610 | } |
|
|
1611 | |
1590 | execlp (shell, argv0, NULL); |
1612 | execlp (shell, argv0, NULL); |
1591 | /* no error message: STDERR is closed! */ |
1613 | /* no error message: STDERR is closed! */ |
1592 | } |
1614 | } |
1593 | |
1615 | |
1594 | #else /* __QNX__ uses qnxspawn () */ |
1616 | #else /* __QNX__ uses qnxspawn () */ |