… | |
… | |
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 | * |
15 | * |
15 | * 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 |
16 | * 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 |
17 | * the Free Software Foundation; either version 2 of the License, or |
18 | * the Free Software Foundation; either version 2 of the License, or |
18 | * (at your option) any later version. |
19 | * (at your option) any later version. |
… | |
… | |
383 | TermWin.ext_bwidth = EXTERNALBORDERWIDTH; |
384 | TermWin.ext_bwidth = EXTERNALBORDERWIDTH; |
384 | TermWin.lineSpace = LINESPACE; |
385 | TermWin.lineSpace = LINESPACE; |
385 | TermWin.saveLines = SAVELINES; |
386 | TermWin.saveLines = SAVELINES; |
386 | numPixColors = TOTAL_COLORS; |
387 | numPixColors = TOTAL_COLORS; |
387 | |
388 | |
388 | #ifndef NO_NEW_SELECTION |
|
|
389 | selection_style = NEW_SELECT; |
|
|
390 | #else |
|
|
391 | selection_style = OLD_SELECT; |
|
|
392 | #endif |
|
|
393 | |
|
|
394 | #ifndef NO_BRIGHTCOLOR |
389 | #ifndef NO_BRIGHTCOLOR |
395 | colorfgbg = DEFAULT_RSTYLE; |
390 | colorfgbg = DEFAULT_RSTYLE; |
396 | #endif |
|
|
397 | |
|
|
398 | #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) |
|
|
399 | ks_bigfont = XK_greater; |
|
|
400 | ks_smallfont = XK_less; |
|
|
401 | #endif |
|
|
402 | |
|
|
403 | #ifdef GREEK_SUPPORT |
|
|
404 | ks_greekmodeswith = GREEK_KEYBOARD_MODESWITCH; |
|
|
405 | #endif |
391 | #endif |
406 | |
392 | |
407 | refresh_limit = 1; |
393 | refresh_limit = 1; |
408 | refresh_type = SLOW_REFRESH; |
394 | refresh_type = SLOW_REFRESH; |
409 | prev_nrow = prev_ncol = 0; |
395 | prev_nrow = prev_ncol = 0; |
410 | #ifdef MULTICHAR_SET |
|
|
411 | # ifdef MULTICHAR_ENCODING |
|
|
412 | encoding_method = MULTICHAR_ENCODING; |
|
|
413 | # endif |
|
|
414 | multichar_decode = rxvt_euc2jis; |
|
|
415 | #endif |
|
|
416 | |
396 | |
417 | oldcursor.row = oldcursor.col = -1; |
397 | oldcursor.row = oldcursor.col = -1; |
418 | #ifdef XPM_BACKGROUND |
398 | #ifdef XPM_BACKGROUND |
419 | /* bgPixmap.w = bgPixmap.h = 0; */ |
399 | /* bgPixmap.w = bgPixmap.h = 0; */ |
420 | bgPixmap.x = bgPixmap.y = 50; |
400 | bgPixmap.x = bgPixmap.y = 50; |
… | |
… | |
601 | #endif |
581 | #endif |
602 | |
582 | |
603 | if (!rs[Rs_cutchars]) |
583 | if (!rs[Rs_cutchars]) |
604 | rs[Rs_cutchars] = CUTCHARS; |
584 | rs[Rs_cutchars] = CUTCHARS; |
605 | |
585 | |
606 | #ifdef ACS_ASCII |
|
|
607 | if (!rs[Rs_acs_chars]) |
|
|
608 | rs[Rs_acs_chars] = ACS_CHARS; |
|
|
609 | if ((i = STRLEN (rs[Rs_acs_chars])) < 0x20) |
|
|
610 | { |
|
|
611 | val = rxvt_realloc ((void *)rs[Rs_acs_chars], 0x20); |
|
|
612 | for (; i < 0x20; ) |
|
|
613 | val[i] = ' '; |
|
|
614 | rs[Rs_acs_chars] = val; |
|
|
615 | } |
|
|
616 | #endif |
|
|
617 | |
|
|
618 | #ifndef NO_BACKSPACE_KEY |
586 | #ifndef NO_BACKSPACE_KEY |
619 | if (!rs[Rs_backspace_key]) |
587 | if (!rs[Rs_backspace_key]) |
620 | # ifdef DEFAULT_BACKSPACE |
588 | # ifdef DEFAULT_BACKSPACE |
621 | key_backspace = DEFAULT_BACKSPACE; |
589 | key_backspace = DEFAULT_BACKSPACE; |
622 | # else |
590 | # else |
… | |
… | |
650 | { |
618 | { |
651 | rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); |
619 | rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); |
652 | rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); |
620 | rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); |
653 | } |
621 | } |
654 | |
622 | |
655 | if (rs[Rs_selectstyle]) |
|
|
656 | { |
|
|
657 | if (STRNCASECMP (rs[Rs_selectstyle], "oldword", 7) == 0) |
|
|
658 | selection_style = OLD_WORD_SELECT; |
|
|
659 | #ifndef NO_OLD_SELECTION |
|
|
660 | |
|
|
661 | else if (STRNCASECMP (rs[Rs_selectstyle], "old", 3) == 0) |
|
|
662 | selection_style = OLD_SELECT; |
|
|
663 | #endif |
|
|
664 | |
|
|
665 | } |
|
|
666 | |
|
|
667 | #ifdef HAVE_SCROLLBARS |
623 | #ifdef HAVE_SCROLLBARS |
668 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], |
624 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], |
669 | rs[Rs_scrollBar_thickness]); |
625 | rs[Rs_scrollBar_thickness]); |
670 | #endif |
626 | #endif |
671 | |
|
|
672 | TermWin.fontset = new rxvt_fontset (this); |
|
|
673 | TermWin.fontset->populate (rs[Rs_font]); |
|
|
674 | TermWin.fwidth = TermWin.fontset->base_font ()->width; |
|
|
675 | TermWin.fheight = TermWin.fontset->base_font ()->height; |
|
|
676 | TermWin.fbase = TermWin.fontset->base_font ()->ascent; |
|
|
677 | |
627 | |
678 | #ifdef XTERM_REVERSE_VIDEO |
628 | #ifdef XTERM_REVERSE_VIDEO |
679 | /* this is how xterm implements reverseVideo */ |
629 | /* this is how xterm implements reverseVideo */ |
680 | if (Options & Opt_reverseVideo) |
630 | if (Options & Opt_reverseVideo) |
681 | { |
631 | { |
… | |
… | |
762 | * @ DISPLAY: in case we started with -display |
712 | * @ DISPLAY: in case we started with -display |
763 | * @ WINDOWID: X window id number of the window |
713 | * @ WINDOWID: X window id number of the window |
764 | * @ COLORTERM: terminal sub-name and also indicates its color |
714 | * @ COLORTERM: terminal sub-name and also indicates its color |
765 | * @ TERM: terminal name |
715 | * @ TERM: terminal name |
766 | * @ TERMINFO: path to terminfo directory |
716 | * @ TERMINFO: path to terminfo directory |
|
|
717 | * @ COLORFGBG: fg;bg color codes |
767 | */ |
718 | */ |
768 | putenv (env_display); |
719 | putenv (env_display); |
769 | putenv (env_windowid); |
720 | putenv (env_windowid); |
|
|
721 | if (env_colorfgbg) |
|
|
722 | putenv (env_colorfgbg); |
770 | |
723 | |
771 | #ifdef RXVT_TERMINFO |
724 | #ifdef RXVT_TERMINFO |
772 | putenv ("TERMINFO=" RXVT_TERMINFO); |
725 | putenv ("TERMINFO=" RXVT_TERMINFO); |
773 | #endif |
726 | #endif |
774 | |
727 | |
… | |
… | |
802 | void |
755 | void |
803 | rxvt_term::set_locale (const char *locale) |
756 | rxvt_term::set_locale (const char *locale) |
804 | { |
757 | { |
805 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
758 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
806 | free (this->locale); |
759 | free (this->locale); |
807 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, "")); |
760 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
|
|
761 | SET_LOCALE (this->locale); |
|
|
762 | mbstate.reset (); |
808 | #endif |
763 | #endif |
809 | #if HAVE_NL_LANGINFO |
764 | #if HAVE_NL_LANGINFO |
810 | free (codeset); |
765 | free (codeset); |
811 | codeset = strdup (nl_langinfo (CODESET)); |
766 | codeset = strdup (nl_langinfo (CODESET)); |
812 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
767 | enc_utf8 = !STRCASECMP (codeset, "UTF-8") |
… | |
… | |
894 | if (menubar_visible ()) |
849 | if (menubar_visible ()) |
895 | { |
850 | { |
896 | PrivateModes |= PrivMode_menuBar; |
851 | PrivateModes |= PrivMode_menuBar; |
897 | SavedModes |= PrivMode_menuBar; |
852 | SavedModes |= PrivMode_menuBar; |
898 | } |
853 | } |
899 | |
|
|
900 | #ifdef GREEK_SUPPORT |
|
|
901 | greek_init (); |
|
|
902 | #endif |
|
|
903 | |
854 | |
904 | #ifdef CURSOR_BLINK |
855 | #ifdef CURSOR_BLINK |
905 | if (Options & Opt_cursorBlink) |
856 | if (Options & Opt_cursorBlink) |
906 | (void)gettimeofday (&lastcursorchange, NULL); |
857 | (void)gettimeofday (&lastcursorchange, NULL); |
907 | #endif |
858 | #endif |
… | |
… | |
1139 | } |
1090 | } |
1140 | |
1091 | |
1141 | /* grab colors before netscape does */ |
1092 | /* grab colors before netscape does */ |
1142 | Get_Colours (); |
1093 | Get_Colours (); |
1143 | |
1094 | |
1144 | change_font (1, NULL); |
1095 | if (!change_font (rs[Rs_font])) |
|
|
1096 | { |
|
|
1097 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
|
|
1098 | destroy (); |
|
|
1099 | return; |
|
|
1100 | } |
|
|
1101 | |
1145 | window_calc (0, 0); |
1102 | window_calc (0, 0); |
1146 | old_width = szHint.width; |
1103 | old_width = szHint.width; |
1147 | old_height = szHint.height; |
1104 | old_height = szHint.height; |
1148 | |
1105 | |
1149 | /* parent window - reverse video so we can see placement errors |
1106 | /* parent window - reverse video so we can see placement errors |
… | |
… | |
1175 | |
1132 | |
1176 | xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1133 | xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1177 | xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1134 | xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1178 | |
1135 | |
1179 | classHint.res_name = (char *)rs[Rs_name]; |
1136 | classHint.res_name = (char *)rs[Rs_name]; |
1180 | classHint.res_class = (char *)APL_CLASS; |
1137 | classHint.res_class = (char *)RESCLASS; |
1181 | |
1138 | |
1182 | wmHint.flags = (InputHint | StateHint | WindowGroupHint); |
1139 | wmHint.flags = (InputHint | StateHint | WindowGroupHint); |
1183 | wmHint.input = True; |
1140 | wmHint.input = True; |
1184 | wmHint.initial_state = (Options & Opt_iconic ? IconicState |
1141 | wmHint.initial_state = (Options & Opt_iconic ? IconicState |
1185 | : NormalState); |
1142 | : NormalState); |
… | |
… | |
1248 | |
1205 | |
1249 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1206 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1250 | if (menuBar_height ()) |
1207 | if (menuBar_height ()) |
1251 | { |
1208 | { |
1252 | menuBar.win = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1209 | menuBar.win = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1253 | window_vt_x, 0, |
1210 | window_vt_x, 0, |
1254 | TermWin_TotalWidth (), |
1211 | TermWin_TotalWidth (), |
1255 | menuBar_TotalHeight (), |
1212 | menuBar_TotalHeight (), |
1256 | 0, |
1213 | 0, |
1257 | PixColors[Color_fg], |
1214 | PixColors[Color_fg], |
1258 | PixColors[Color_scroll]); |
1215 | PixColors[Color_scroll]); |
|
|
1216 | |
1259 | #ifdef DEBUG_X |
1217 | #ifdef DEBUG_X |
1260 | XStoreName (display->display, menuBar.win, "menubar"); |
1218 | XStoreName (display->display, menuBar.win, "menubar"); |
1261 | #endif |
1219 | #endif |
1262 | |
1220 | |
|
|
1221 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
|
|
1222 | |
1263 | XDefineCursor (display->display, menuBar.win, pointer_leftptr); |
1223 | XDefineCursor (display->display, menuBar.win, |
|
|
1224 | XCreateFontCursor (display->display, XC_left_ptr)); |
1264 | |
1225 | |
1265 | XSelectInput (display->display, menuBar.win, |
1226 | XSelectInput (display->display, menuBar.win, |
1266 | (ExposureMask | ButtonPressMask | ButtonReleaseMask |
1227 | (ExposureMask | ButtonPressMask | ButtonReleaseMask |
1267 | | Button1MotionMask)); |
1228 | | Button1MotionMask)); |
1268 | menubar_ev.start (display, menuBar.win); |
1229 | menubar_ev.start (display, menuBar.win); |
… | |
… | |
1291 | gcvalue.graphics_exposures = 1; |
1252 | gcvalue.graphics_exposures = 1; |
1292 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1253 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1293 | GCForeground | GCBackground |
1254 | GCForeground | GCBackground |
1294 | | GCGraphicsExposures, &gcvalue); |
1255 | | GCGraphicsExposures, &gcvalue); |
1295 | |
1256 | |
|
|
1257 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
|
|
1258 | |
1296 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1259 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1297 | gcvalue.foreground = PixColors[Color_topShadow]; |
1260 | gcvalue.foreground = PixColors[Color_topShadow]; |
1298 | topShadowGC = XCreateGC (display->display, TermWin.vt, |
1261 | topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1299 | GCForeground, &gcvalue); |
|
|
1300 | gcvalue.foreground = PixColors[Color_bottomShadow]; |
1262 | gcvalue.foreground = PixColors[Color_bottomShadow]; |
1301 | botShadowGC = XCreateGC (display->display, TermWin.vt, |
1263 | botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1302 | GCForeground, &gcvalue); |
|
|
1303 | gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg |
1264 | gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; |
1304 | : Color_scroll)]; |
|
|
1305 | scrollbarGC = XCreateGC (display->display, TermWin.vt, |
1265 | scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1306 | GCForeground, &gcvalue); |
|
|
1307 | #endif |
1266 | #endif |
1308 | } |
1267 | } |
1309 | |
1268 | |
1310 | /*----------------------------------------------------------------------*/ |
1269 | /*----------------------------------------------------------------------*/ |
1311 | /* |
1270 | /* |
… | |
… | |
1360 | case -1: |
1319 | case -1: |
1361 | rxvt_print_error ("can't fork"); |
1320 | rxvt_print_error ("can't fork"); |
1362 | return -1; |
1321 | return -1; |
1363 | case 0: |
1322 | case 0: |
1364 | close (cfd); /* only keep tty_fd and STDERR open */ |
1323 | close (cfd); /* only keep tty_fd and STDERR open */ |
|
|
1324 | |
|
|
1325 | init_env (); |
1365 | |
1326 | |
1366 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1327 | if (rxvt_control_tty (tty_fd, ttydev) < 0) |
1367 | rxvt_print_error ("could not obtain control of tty"); |
1328 | rxvt_print_error ("could not obtain control of tty"); |
1368 | else |
1329 | else |
1369 | { |
1330 | { |