… | |
… | |
384 | TermWin.ext_bwidth = EXTERNALBORDERWIDTH; |
384 | TermWin.ext_bwidth = EXTERNALBORDERWIDTH; |
385 | TermWin.lineSpace = LINESPACE; |
385 | TermWin.lineSpace = LINESPACE; |
386 | TermWin.saveLines = SAVELINES; |
386 | TermWin.saveLines = SAVELINES; |
387 | numPixColors = TOTAL_COLORS; |
387 | numPixColors = TOTAL_COLORS; |
388 | |
388 | |
389 | #ifndef NO_NEW_SELECTION |
|
|
390 | selection_style = NEW_SELECT; |
|
|
391 | #else |
|
|
392 | selection_style = OLD_SELECT; |
|
|
393 | #endif |
|
|
394 | |
|
|
395 | #ifndef NO_BRIGHTCOLOR |
389 | #ifndef NO_BRIGHTCOLOR |
396 | colorfgbg = DEFAULT_RSTYLE; |
390 | colorfgbg = DEFAULT_RSTYLE; |
397 | #endif |
391 | #endif |
398 | |
392 | |
399 | refresh_limit = 1; |
393 | refresh_limit = 1; |
… | |
… | |
500 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
494 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
501 | |
495 | |
502 | cmd_argv[i] = NULL; |
496 | cmd_argv[i] = NULL; |
503 | } |
497 | } |
504 | |
498 | |
505 | /* clear all resources */ |
|
|
506 | for (i = 0; i < NUM_RESOURCES;) |
|
|
507 | rs[i++] = NULL; |
|
|
508 | |
|
|
509 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
499 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
510 | |
500 | |
511 | /* |
501 | /* |
512 | * Open display, get options/resources and create the window |
502 | * Open display, get options/resources and create the window |
513 | */ |
503 | */ |
… | |
… | |
528 | } |
518 | } |
529 | #endif |
519 | #endif |
530 | |
520 | |
531 | if (!display |
521 | if (!display |
532 | && ! (display = displays.get (rs[Rs_display_name]))) |
522 | && ! (display = displays.get (rs[Rs_display_name]))) |
533 | { |
|
|
534 | rxvt_print_error ("can't open display %s", rs[Rs_display_name]); |
523 | rxvt_fatal ("can't open display %s", rs[Rs_display_name]); |
535 | exit (EXIT_FAILURE); |
|
|
536 | } |
|
|
537 | |
524 | |
538 | extract_resources (display->display, rs[Rs_name]); |
525 | extract_resources (display->display, rs[Rs_name]); |
539 | |
526 | |
540 | /* |
527 | /* |
541 | * set any defaults not already set |
528 | * set any defaults not already set |
… | |
… | |
622 | #endif |
609 | #endif |
623 | if (rs[Rs_answerbackstring]) |
610 | if (rs[Rs_answerbackstring]) |
624 | { |
611 | { |
625 | rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); |
612 | rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); |
626 | rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); |
613 | rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); |
627 | } |
|
|
628 | |
|
|
629 | if (rs[Rs_selectstyle]) |
|
|
630 | { |
|
|
631 | if (STRNCASECMP (rs[Rs_selectstyle], "oldword", 7) == 0) |
|
|
632 | selection_style = OLD_WORD_SELECT; |
|
|
633 | #ifndef NO_OLD_SELECTION |
|
|
634 | |
|
|
635 | else if (STRNCASECMP (rs[Rs_selectstyle], "old", 3) == 0) |
|
|
636 | selection_style = OLD_SELECT; |
|
|
637 | #endif |
|
|
638 | |
|
|
639 | } |
614 | } |
640 | |
615 | |
641 | #ifdef HAVE_SCROLLBARS |
616 | #ifdef HAVE_SCROLLBARS |
642 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], |
617 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], |
643 | rs[Rs_scrollBar_thickness]); |
618 | rs[Rs_scrollBar_thickness]); |
… | |
… | |
777 | free (this->locale); |
752 | free (this->locale); |
778 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
753 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
779 | SET_LOCALE (this->locale); |
754 | SET_LOCALE (this->locale); |
780 | mbstate.reset (); |
755 | mbstate.reset (); |
781 | #endif |
756 | #endif |
|
|
757 | #if 0 |
782 | #if HAVE_NL_LANGINFO |
758 | #if HAVE_NL_LANGINFO |
783 | free (codeset); |
759 | free (codeset); |
784 | codeset = strdup (nl_langinfo (CODESET)); |
760 | codeset = strdup (nl_langinfo (CODESET)); |
785 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
761 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
786 | || !STRCASECMP (codeset, "UTF8"); |
762 | || !STRCASECMP (codeset, "UTF8"); |
787 | #else |
763 | #else |
788 | enc_utf8 = 1; |
764 | enc_utf8 = 1; |
789 | #endif |
765 | #endif |
|
|
766 | #endif |
790 | } |
767 | } |
791 | |
768 | |
792 | void |
769 | void |
793 | rxvt_term::init_xlocale () |
770 | rxvt_term::init_xlocale () |
794 | { |
771 | { |
795 | #ifdef USE_XIM |
772 | #ifdef USE_XIM |
796 | if (!locale) |
773 | if (!locale) |
797 | rxvt_print_error ("Setting locale failed."); |
774 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
798 | else |
775 | else |
799 | { |
776 | { |
800 | Atom wmlocale; |
777 | Atom wmlocale; |
801 | |
778 | |
802 | wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); |
779 | wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); |
… | |
… | |
804 | XA_STRING, 8, PropModeReplace, |
781 | XA_STRING, 8, PropModeReplace, |
805 | (unsigned char *)locale, STRLEN (locale)); |
782 | (unsigned char *)locale, STRLEN (locale)); |
806 | |
783 | |
807 | if (!XSupportsLocale ()) |
784 | if (!XSupportsLocale ()) |
808 | { |
785 | { |
809 | rxvt_print_error ("The locale is not supported by Xlib"); |
786 | rxvt_warn ("the locale is not supported by Xlib, working withotu locale support.\n"); |
810 | return; |
787 | return; |
811 | } |
788 | } |
812 | |
789 | |
813 | im_ev.start (display); |
790 | im_ev.start (display); |
814 | |
791 | |
… | |
… | |
874 | if (Options & Opt_cursorBlink) |
851 | if (Options & Opt_cursorBlink) |
875 | (void)gettimeofday (&lastcursorchange, NULL); |
852 | (void)gettimeofday (&lastcursorchange, NULL); |
876 | #endif |
853 | #endif |
877 | |
854 | |
878 | if ((cmd_fd = run_command (argv)) < 0) |
855 | if ((cmd_fd = run_command (argv)) < 0) |
879 | { |
856 | rxvt_fatal ("failure while running command, aborting"); |
880 | rxvt_print_error ("aborting"); |
|
|
881 | exit (EXIT_FAILURE); |
|
|
882 | } |
|
|
883 | } |
857 | } |
884 | |
858 | |
885 | /*----------------------------------------------------------------------*/ |
859 | /*----------------------------------------------------------------------*/ |
886 | void |
860 | void |
887 | rxvt_term::Get_Colours () |
861 | rxvt_term::Get_Colours () |
… | |
… | |
912 | switch (i) |
886 | switch (i) |
913 | { |
887 | { |
914 | case Color_fg: |
888 | case Color_fg: |
915 | case Color_bg: |
889 | case Color_bg: |
916 | /* fatal: need bg/fg color */ |
890 | /* fatal: need bg/fg color */ |
917 | rxvt_print_error ("aborting"); |
891 | rxvt_fatal ("unable to get foreground/background colour, aborting"); |
918 | exit (EXIT_FAILURE); |
|
|
919 | /* NOTREACHED */ |
892 | /* NOTREACHED */ |
920 | break; |
893 | break; |
921 | #ifndef NO_CURSORCOLOR |
894 | #ifndef NO_CURSORCOLOR |
922 | case Color_cursor2: |
895 | case Color_cursor2: |
923 | xcol = PixColors[Color_fg]; |
896 | xcol = PixColors[Color_fg]; |
… | |
… | |
1267 | /* graphics context for the vt window */ |
1240 | /* graphics context for the vt window */ |
1268 | gcvalue.foreground = PixColors[Color_fg]; |
1241 | gcvalue.foreground = PixColors[Color_fg]; |
1269 | gcvalue.background = PixColors[Color_bg]; |
1242 | gcvalue.background = PixColors[Color_bg]; |
1270 | gcvalue.graphics_exposures = 1; |
1243 | gcvalue.graphics_exposures = 1; |
1271 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1244 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1272 | GCForeground | GCBackground |
1245 | GCForeground | GCBackground | GCGraphicsExposures, |
1273 | | GCGraphicsExposures, &gcvalue); |
1246 | &gcvalue); |
1274 | |
1247 | |
1275 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1248 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1276 | |
1249 | |
1277 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1250 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1278 | gcvalue.foreground = PixColors[Color_topShadow]; |
1251 | gcvalue.foreground = PixColors[Color_topShadow]; |
… | |
… | |
1295 | { |
1268 | { |
1296 | int cfd, er; |
1269 | int cfd, er; |
1297 | |
1270 | |
1298 | /* get master (pty) */ |
1271 | /* get master (pty) */ |
1299 | if ((cfd = rxvt_get_pty (& (tty_fd), & (ttydev))) < 0) |
1272 | if ((cfd = rxvt_get_pty (& (tty_fd), & (ttydev))) < 0) |
1300 | { |
|
|
1301 | rxvt_print_error ("can't open pseudo-tty"); |
1273 | rxvt_fatal ("can't open pseudo-tty"); |
1302 | return -1; |
|
|
1303 | } |
|
|
1304 | |
1274 | |
1305 | fcntl (cfd, F_SETFL, O_NONBLOCK); |
1275 | fcntl (cfd, F_SETFL, O_NONBLOCK); |
1306 | |
1276 | |
1307 | /* get slave (tty) */ |
1277 | /* get slave (tty) */ |
1308 | if (tty_fd < 0) |
1278 | if (tty_fd < 0) |
… | |
… | |
1312 | #endif |
1282 | #endif |
1313 | |
1283 | |
1314 | if ((tty_fd = rxvt_get_tty (ttydev)) < 0) |
1284 | if ((tty_fd = rxvt_get_tty (ttydev)) < 0) |
1315 | { |
1285 | { |
1316 | close (cfd); |
1286 | close (cfd); |
1317 | rxvt_print_error ("can't open slave tty %s", ttydev); |
1287 | rxvt_fatal ("can't open slave tty %s", ttydev); |
1318 | return -1; |
|
|
1319 | } |
1288 | } |
1320 | } |
1289 | } |
1321 | #ifndef NO_BACKSPACE_KEY |
1290 | #ifndef NO_BACKSPACE_KEY |
1322 | if (key_backspace[0] && !key_backspace[1]) |
1291 | if (key_backspace[0] && !key_backspace[1]) |
1323 | er = key_backspace[0]; |
1292 | er = key_backspace[0]; |
… | |
… | |
1333 | #ifndef __QNX__ |
1302 | #ifndef __QNX__ |
1334 | /* spin off the command interpreter */ |
1303 | /* spin off the command interpreter */ |
1335 | switch (cmd_pid = fork ()) |
1304 | switch (cmd_pid = fork ()) |
1336 | { |
1305 | { |
1337 | case -1: |
1306 | case -1: |
1338 | rxvt_print_error ("can't fork"); |
1307 | rxvt_fatal ("can't fork"); |
1339 | return -1; |
|
|
1340 | case 0: |
1308 | case 0: |
1341 | close (cfd); /* only keep tty_fd and STDERR open */ |
1309 | close (cfd); /* only keep tty_fd and STDERR open */ |
1342 | |
1310 | |
1343 | init_env (); |
1311 | init_env (); |
1344 | |
1312 | |
1345 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1313 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1346 | rxvt_print_error ("could not obtain control of tty"); |
1314 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1347 | else |
1315 | else |
1348 | { |
1316 | { |
1349 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1317 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1350 | dup2 (tty_fd, STDIN_FILENO); |
1318 | dup2 (tty_fd, STDIN_FILENO); |
1351 | dup2 (tty_fd, STDOUT_FILENO); |
1319 | dup2 (tty_fd, STDOUT_FILENO); |
… | |
… | |
1353 | |
1321 | |
1354 | if (tty_fd > 2) |
1322 | if (tty_fd > 2) |
1355 | close (tty_fd); |
1323 | close (tty_fd); |
1356 | |
1324 | |
1357 | run_child (argv); |
1325 | run_child (argv); |
|
|
1326 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1358 | } |
1327 | } |
|
|
1328 | |
1359 | exit (EXIT_FAILURE); |
1329 | _exit (EXIT_FAILURE); |
1360 | /* NOTREACHED */ |
1330 | |
1361 | default: |
1331 | default: |
1362 | { |
1332 | { |
1363 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1333 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1364 | int fdstdin; |
1334 | int fdstdin; |
1365 | |
1335 | |
… | |
… | |
1374 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1344 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1375 | |
1345 | |
1376 | dup2 (fdstdin, STDIN_FILENO); |
1346 | dup2 (fdstdin, STDIN_FILENO); |
1377 | close (fdstdin); |
1347 | close (fdstdin); |
1378 | #endif |
1348 | #endif |
1379 | |
|
|
1380 | } |
1349 | } |
|
|
1350 | |
1381 | close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ |
1351 | close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ |
1382 | break; |
1352 | break; |
1383 | } |
1353 | } |
1384 | #else /* __QNX__ uses qnxspawn () */ |
1354 | #else /* __QNX__ uses qnxspawn () */ |
1385 | fchmod (tty_fd, 0622); |
1355 | fchmod (tty_fd, 0622); |