… | |
… | |
371 | if (!rs[Rs_iconName]) |
371 | if (!rs[Rs_iconName]) |
372 | rs[Rs_iconName] = rs[Rs_name]; |
372 | rs[Rs_iconName] = rs[Rs_name]; |
373 | } |
373 | } |
374 | |
374 | |
375 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
375 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
376 | saveLines = min (i, std::numeric_limits<int16_t>::max ()); |
376 | saveLines = min (i, MAX_SAVELINES); |
377 | |
377 | |
378 | #if ENABLE_FRILLS |
378 | #if ENABLE_FRILLS |
379 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
379 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
380 | int_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
380 | int_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
381 | |
381 | |
… | |
… | |
393 | pointerBlankDelay = 2; |
393 | pointerBlankDelay = 2; |
394 | #endif |
394 | #endif |
395 | |
395 | |
396 | /* no point having a scrollbar without having any scrollback! */ |
396 | /* no point having a scrollbar without having any scrollback! */ |
397 | if (!saveLines) |
397 | if (!saveLines) |
398 | options &= ~Opt_scrollBar; |
398 | CLR_OPTION (Opt_scrollBar); |
399 | |
399 | |
400 | #ifdef PRINTPIPE |
400 | #ifdef PRINTPIPE |
401 | if (!rs[Rs_print_pipe]) |
401 | if (!rs[Rs_print_pipe]) |
402 | rs[Rs_print_pipe] = PRINTPIPE; |
402 | rs[Rs_print_pipe] = PRINTPIPE; |
403 | #endif |
403 | #endif |
… | |
… | |
446 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
446 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
447 | #endif |
447 | #endif |
448 | |
448 | |
449 | #ifdef XTERM_REVERSE_VIDEO |
449 | #ifdef XTERM_REVERSE_VIDEO |
450 | /* this is how xterm implements reverseVideo */ |
450 | /* this is how xterm implements reverseVideo */ |
451 | if (options & Opt_reverseVideo) |
451 | if (OPTION (Opt_reverseVideo)) |
452 | { |
452 | { |
453 | if (!rs[Rs_color + Color_fg]) |
453 | if (!rs[Rs_color + Color_fg]) |
454 | rs[Rs_color + Color_fg] = def_colorName[Color_bg]; |
454 | rs[Rs_color + Color_fg] = def_colorName[Color_bg]; |
455 | if (!rs[Rs_color + Color_bg]) |
455 | if (!rs[Rs_color + Color_bg]) |
456 | rs[Rs_color + Color_bg] = def_colorName[Color_fg]; |
456 | rs[Rs_color + Color_bg] = def_colorName[Color_fg]; |
… | |
… | |
461 | if (!rs[Rs_color + i]) |
461 | if (!rs[Rs_color + i]) |
462 | rs[Rs_color + i] = def_colorName[i]; |
462 | rs[Rs_color + i] = def_colorName[i]; |
463 | |
463 | |
464 | #ifndef XTERM_REVERSE_VIDEO |
464 | #ifndef XTERM_REVERSE_VIDEO |
465 | /* this is how we implement reverseVideo */ |
465 | /* this is how we implement reverseVideo */ |
466 | if (options & Opt_reverseVideo) |
466 | if (OPTION (Opt_reverseVideo)) |
467 | ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); |
467 | ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); |
468 | #endif |
468 | #endif |
469 | |
469 | |
470 | /* convenient aliases for setting fg/bg to colors */ |
470 | /* convenient aliases for setting fg/bg to colors */ |
471 | color_aliases (Color_fg); |
471 | color_aliases (Color_fg); |
… | |
… | |
648 | * Initialize the command connection. |
648 | * Initialize the command connection. |
649 | * This should be called after the X server connection is established. |
649 | * This should be called after the X server connection is established. |
650 | */ |
650 | */ |
651 | |
651 | |
652 | #ifdef META8_OPTION |
652 | #ifdef META8_OPTION |
653 | meta_char = (options & Opt_meta8 ? 0x80 : C0_ESC); |
653 | meta_char = OPTION (Opt_meta8) ? 0x80 : C0_ESC; |
654 | #endif |
654 | #endif |
655 | |
655 | |
656 | get_ourmods (); |
656 | get_ourmods (); |
657 | |
657 | |
658 | if (!(options & Opt_scrollTtyOutput)) |
658 | if (!OPTION (Opt_scrollTtyOutput)) |
659 | priv_modes |= PrivMode_TtyOutputInh; |
659 | priv_modes |= PrivMode_TtyOutputInh; |
660 | if (options & Opt_scrollTtyKeypress) |
660 | if (OPTION (Opt_scrollTtyKeypress)) |
661 | priv_modes |= PrivMode_Keypress; |
661 | priv_modes |= PrivMode_Keypress; |
662 | if (!(options & Opt_jumpScroll)) |
662 | if (!OPTION (Opt_jumpScroll)) |
663 | priv_modes |= PrivMode_smoothScroll; |
663 | priv_modes |= PrivMode_smoothScroll; |
664 | |
664 | |
665 | #ifndef NO_BACKSPACE_KEY |
665 | #ifndef NO_BACKSPACE_KEY |
666 | if (strcmp (key_backspace, "DEC") == 0) |
666 | if (strcmp (key_backspace, "DEC") == 0) |
667 | priv_modes |= PrivMode_HaveBackSpace; |
667 | priv_modes |= PrivMode_HaveBackSpace; |
… | |
… | |
677 | if (menubar_visible ()) |
677 | if (menubar_visible ()) |
678 | { |
678 | { |
679 | priv_modes |= PrivMode_menuBar; |
679 | priv_modes |= PrivMode_menuBar; |
680 | SavedModes |= PrivMode_menuBar; |
680 | SavedModes |= PrivMode_menuBar; |
681 | } |
681 | } |
682 | |
|
|
683 | #ifdef CURSOR_BLINK |
|
|
684 | if (options & Opt_cursorBlink) |
|
|
685 | (void)gettimeofday (&lastcursorchange, NULL); |
|
|
686 | #endif |
|
|
687 | |
682 | |
688 | run_command (argv); |
683 | run_command (argv); |
689 | } |
684 | } |
690 | |
685 | |
691 | /*----------------------------------------------------------------------*/ |
686 | /*----------------------------------------------------------------------*/ |
… | |
… | |
706 | continue; |
701 | continue; |
707 | |
702 | |
708 | if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) |
703 | if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) |
709 | { |
704 | { |
710 | #ifndef XTERM_REVERSE_VIDEO |
705 | #ifndef XTERM_REVERSE_VIDEO |
711 | if (i < 2 && (options & Opt_reverseVideo)) |
706 | if (i < 2 && OPTION (Opt_reverseVideo)) |
712 | rs[Rs_color + i] = def_colorName[!i]; |
707 | rs[Rs_color + i] = def_colorName[!i]; |
713 | else |
708 | else |
714 | #endif |
709 | #endif |
715 | rs[Rs_color + i] = def_colorName[i]; |
710 | rs[Rs_color + i] = def_colorName[i]; |
716 | |
711 | |
… | |
… | |
939 | #endif |
934 | #endif |
940 | |
935 | |
941 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
936 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
942 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
937 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
943 | |
938 | |
944 | if (options & Opt_transparent) |
939 | if (OPTION (Opt_transparent)) |
945 | { |
940 | { |
946 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
941 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
947 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
942 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
948 | } |
943 | } |
949 | |
944 | |
950 | #if ENABLE_FRILLS |
945 | #if ENABLE_FRILLS |
951 | if (options & Opt_borderLess) |
946 | if (OPTION (Opt_borderLess)) |
952 | { |
947 | { |
953 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
948 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
954 | |
949 | |
955 | if (prop == None) |
950 | if (prop == None) |
956 | { |
951 | { |
… | |
… | |
1026 | classHint.res_name = (char *)rs[Rs_name]; |
1021 | classHint.res_name = (char *)rs[Rs_name]; |
1027 | classHint.res_class = (char *)RESCLASS; |
1022 | classHint.res_class = (char *)RESCLASS; |
1028 | |
1023 | |
1029 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1024 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1030 | wmHint.input = True; |
1025 | wmHint.input = True; |
1031 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1026 | wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; |
1032 | wmHint.window_group = top; |
1027 | wmHint.window_group = top; |
1033 | |
1028 | |
1034 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1029 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1035 | &szHint, &wmHint, &classHint); |
1030 | &szHint, &wmHint, &classHint); |
1036 | |
1031 | |
… | |
… | |
1079 | |
1074 | |
1080 | /* the vt window */ |
1075 | /* the vt window */ |
1081 | vt = XCreateSimpleWindow (disp, top, |
1076 | vt = XCreateSimpleWindow (disp, top, |
1082 | window_vt_x, |
1077 | window_vt_x, |
1083 | window_vt_y, |
1078 | window_vt_y, |
1084 | TermWin_TotalWidth (), |
1079 | width, |
1085 | TermWin_TotalHeight (), |
1080 | height, |
1086 | 0, |
1081 | 0, |
1087 | pix_colors_focused[Color_fg], |
1082 | pix_colors_focused[Color_fg], |
1088 | pix_colors_focused[Color_bg]); |
1083 | pix_colors_focused[Color_bg]); |
1089 | #ifdef DEBUG_X |
1084 | #ifdef DEBUG_X |
1090 | XStoreName (disp, vt, "vt window"); |
1085 | XStoreName (disp, vt, "vt window"); |
… | |
… | |
1094 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1089 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1095 | |
1090 | |
1096 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1091 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1097 | |
1092 | |
1098 | #ifdef POINTER_BLANK |
1093 | #ifdef POINTER_BLANK |
1099 | if (options & Opt_pointerBlank) |
1094 | if (OPTION (Opt_pointerBlank)) |
1100 | vt_emask |= PointerMotionMask; |
1095 | vt_emask |= PointerMotionMask; |
1101 | else |
1096 | else |
1102 | #endif |
1097 | #endif |
1103 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1098 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1104 | |
1099 | |
… | |
… | |
1108 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1103 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1109 | if (menuBar_height ()) |
1104 | if (menuBar_height ()) |
1110 | { |
1105 | { |
1111 | menuBar.win = XCreateSimpleWindow (disp, top, |
1106 | menuBar.win = XCreateSimpleWindow (disp, top, |
1112 | window_vt_x, 0, |
1107 | window_vt_x, 0, |
1113 | TermWin_TotalWidth (), |
1108 | width, |
1114 | menuBar_TotalHeight (), |
1109 | menuBar_TotalHeight (), |
1115 | 0, |
1110 | 0, |
1116 | pix_colors_focused[Color_fg], |
1111 | pix_colors_focused[Color_fg], |
1117 | pix_colors_focused[Color_scroll]); |
1112 | pix_colors_focused[Color_scroll]); |
1118 | |
1113 | |
… | |
… | |
1131 | } |
1126 | } |
1132 | #endif |
1127 | #endif |
1133 | |
1128 | |
1134 | #ifdef XPM_BACKGROUND |
1129 | #ifdef XPM_BACKGROUND |
1135 | if (rs[Rs_backgroundPixmap] != NULL |
1130 | if (rs[Rs_backgroundPixmap] != NULL |
1136 | && ! (options & Opt_transparent)) |
1131 | && ! OPTION (Opt_transparent)) |
1137 | { |
1132 | { |
1138 | const char *p = rs[Rs_backgroundPixmap]; |
1133 | const char *p = rs[Rs_backgroundPixmap]; |
1139 | |
1134 | |
1140 | if ((p = strchr (p, ';')) != NULL) |
1135 | if ((p = strchr (p, ';')) != NULL) |
1141 | { |
1136 | { |
… | |
… | |
1197 | /* |
1192 | /* |
1198 | * standard System V termios interface |
1193 | * standard System V termios interface |
1199 | */ |
1194 | */ |
1200 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1195 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1201 | { |
1196 | { |
1202 | /* return error - use system defaults */ |
1197 | // return error - use system defaults, |
|
|
1198 | // where possible, and zero elsewhere |
|
|
1199 | memset (tio, 0, sizeof (ttymode_t)); |
|
|
1200 | |
1203 | tio->c_cc[VINTR] = CINTR; |
1201 | tio->c_cc[VINTR] = CINTR; |
1204 | tio->c_cc[VQUIT] = CQUIT; |
1202 | tio->c_cc[VQUIT] = CQUIT; |
1205 | tio->c_cc[VERASE] = CERASE; |
1203 | tio->c_cc[VERASE] = CERASE; |
|
|
1204 | #ifdef VERASE2 |
|
|
1205 | tio->c_cc[VERASE2] = CERASE2; |
|
|
1206 | #endif |
1206 | tio->c_cc[VKILL] = CKILL; |
1207 | tio->c_cc[VKILL] = CKILL; |
1207 | tio->c_cc[VSTART] = CSTART; |
1208 | tio->c_cc[VSTART] = CSTART; |
1208 | tio->c_cc[VSTOP] = CSTOP; |
1209 | tio->c_cc[VSTOP] = CSTOP; |
1209 | tio->c_cc[VSUSP] = CSUSP; |
1210 | tio->c_cc[VSUSP] = CSUSP; |
1210 | # ifdef VDSUSP |
1211 | # ifdef VDSUSP |
… | |
… | |
1404 | { |
1405 | { |
1405 | #if ENABLE_FRILLS |
1406 | #if ENABLE_FRILLS |
1406 | if (rs[Rs_pty_fd]) |
1407 | if (rs[Rs_pty_fd]) |
1407 | { |
1408 | { |
1408 | pty.pty = atoi (rs[Rs_pty_fd]); |
1409 | pty.pty = atoi (rs[Rs_pty_fd]); |
|
|
1410 | |
|
|
1411 | if (getfd_hook) |
|
|
1412 | pty.pty = (*getfd_hook) (pty.pty); |
|
|
1413 | |
1409 | fcntl (pty.pty, F_SETFL, O_NONBLOCK); |
1414 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
|
|
1415 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1410 | } |
1416 | } |
1411 | else |
1417 | else |
1412 | #endif |
1418 | #endif |
1413 | if (!pty.get ()) |
1419 | if (!pty.get ()) |
1414 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1420 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
… | |
… | |
1515 | { |
1521 | { |
1516 | char *login; |
1522 | char *login; |
1517 | |
1523 | |
1518 | SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */ |
1524 | SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */ |
1519 | |
1525 | |
1520 | if (options & Opt_console) |
1526 | if (OPTION (Opt_console)) |
1521 | { /* be virtual console, fail silently */ |
1527 | { /* be virtual console, fail silently */ |
1522 | #ifdef TIOCCONS |
1528 | #ifdef TIOCCONS |
1523 | unsigned int on = 1; |
1529 | unsigned int on = 1; |
1524 | |
1530 | |
1525 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
1531 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
… | |
… | |
1575 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1581 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1576 | shell = "/bin/sh"; |
1582 | shell = "/bin/sh"; |
1577 | |
1583 | |
1578 | argv0 = (const char *)rxvt_r_basename (shell); |
1584 | argv0 = (const char *)rxvt_r_basename (shell); |
1579 | |
1585 | |
1580 | if (options & Opt_loginShell) |
1586 | if (OPTION (Opt_loginShell)) |
1581 | { |
1587 | { |
1582 | login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char)); |
1588 | login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char)); |
1583 | |
1589 | |
1584 | login[0] = '-'; |
1590 | login[0] = '-'; |
1585 | strcpy (&login[1], argv0); |
1591 | strcpy (&login[1], argv0); |
… | |
… | |
1620 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
1626 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
1621 | command = "/bin/sh"; |
1627 | command = "/bin/sh"; |
1622 | |
1628 | |
1623 | arg_a[0] = my_basename (command); |
1629 | arg_a[0] = my_basename (command); |
1624 | |
1630 | |
1625 | if (options & Opt_loginShell) |
1631 | if (OPTION (Opt_loginShell)) |
1626 | { |
1632 | { |
1627 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
1633 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
1628 | |
1634 | |
1629 | login[0] = '-'; |
1635 | login[0] = '-'; |
1630 | strcpy (&login[1], arg_a[0]); |
1636 | strcpy (&login[1], arg_a[0]); |