… | |
… | |
38 | #include "init.h" |
38 | #include "init.h" |
39 | #include "keyboard.h" |
39 | #include "keyboard.h" |
40 | |
40 | |
41 | #include <limits> |
41 | #include <limits> |
42 | |
42 | |
43 | #include <csignal> |
43 | #include <signal.h> |
44 | |
44 | |
45 | #include <fcntl.h> |
45 | #include <fcntl.h> |
46 | |
46 | |
47 | #ifdef HAVE_XSETLOCALE |
47 | #ifdef HAVE_XSETLOCALE |
48 | # define X_LOCALE |
48 | # define X_LOCALE |
49 | # include <X11/Xlocale.h> |
49 | # include <X11/Xlocale.h> |
50 | #else |
50 | #else |
51 | # ifdef HAVE_SETLOCALE |
|
|
52 | # include <clocale> |
51 | # include <locale.h> |
53 | # endif |
|
|
54 | #endif |
52 | #endif |
55 | |
53 | |
56 | #ifdef HAVE_NL_LANGINFO |
54 | #ifdef HAVE_NL_LANGINFO |
57 | # include <langinfo.h> |
55 | # include <langinfo.h> |
58 | #endif |
56 | #endif |
… | |
… | |
852 | |
850 | |
853 | #if ENABLE_PERL |
851 | #if ENABLE_PERL |
854 | rootwin_ev.start (display, display->root); |
852 | rootwin_ev.start (display, display->root); |
855 | #endif |
853 | #endif |
856 | |
854 | |
857 | set_colorfgbg (); |
855 | init_done = 1; |
858 | |
856 | |
859 | init_command (cmd_argv); |
857 | init_command (cmd_argv); |
860 | |
858 | |
861 | if (pty->pty >= 0) |
859 | if (pty->pty >= 0) |
862 | pty_ev.start (pty->pty, ev::READ); |
860 | pty_ev.start (pty->pty, ev::READ); |
… | |
… | |
906 | /*----------------------------------------------------------------------*/ |
904 | /*----------------------------------------------------------------------*/ |
907 | void |
905 | void |
908 | rxvt_term::init_env () |
906 | rxvt_term::init_env () |
909 | { |
907 | { |
910 | char *val; |
908 | char *val; |
|
|
909 | char *env_display; |
|
|
910 | char *env_windowid; |
|
|
911 | char *env_colorfgbg; |
|
|
912 | char *env_term; |
911 | |
913 | |
912 | #ifdef DISPLAY_IS_IP |
914 | #ifdef DISPLAY_IS_IP |
913 | /* Fixup display_name for export over pty to any interested terminal |
915 | /* Fixup display_name for export over pty to any interested terminal |
914 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
916 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
915 | * (for the first non-loopback interface) that we get from |
917 | * (for the first non-loopback interface) that we get from |
… | |
… | |
932 | |
934 | |
933 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
935 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
934 | |
936 | |
935 | sprintf (env_display, "DISPLAY=%s", val); |
937 | sprintf (env_display, "DISPLAY=%s", val); |
936 | |
938 | |
|
|
939 | env_windowid = (char *)rxvt_malloc (21); |
937 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
940 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
938 | |
941 | |
939 | /* add entries to the environment: |
942 | /* add entries to the environment: |
940 | * @ DISPLAY: in case we started with -display |
943 | * @ DISPLAY: in case we started with -display |
941 | * @ WINDOWID: X window id number of the window |
944 | * @ WINDOWID: X window id number of the window |
… | |
… | |
945 | * @ COLORFGBG: fg;bg color codes |
948 | * @ COLORFGBG: fg;bg color codes |
946 | */ |
949 | */ |
947 | putenv (env_display); |
950 | putenv (env_display); |
948 | putenv (env_windowid); |
951 | putenv (env_windowid); |
949 | |
952 | |
950 | if (env_colorfgbg) |
953 | env_colorfgbg = get_colorfgbg (); |
951 | putenv (env_colorfgbg); |
954 | putenv (env_colorfgbg); |
952 | |
955 | |
953 | #ifdef RXVT_TERMINFO |
956 | #ifdef RXVT_TERMINFO |
954 | putenv ("TERMINFO=" RXVT_TERMINFO); |
957 | putenv ("TERMINFO=" RXVT_TERMINFO); |
955 | #endif |
958 | #endif |
956 | |
959 | |
… | |
… | |
980 | void |
983 | void |
981 | rxvt_term::set_locale (const char *locale) |
984 | rxvt_term::set_locale (const char *locale) |
982 | { |
985 | { |
983 | set_environ (envv); |
986 | set_environ (envv); |
984 | |
987 | |
985 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
|
|
986 | free (this->locale); |
988 | free (this->locale); |
987 | this->locale = setlocale (LC_CTYPE, locale); |
989 | this->locale = setlocale (LC_CTYPE, locale); |
988 | |
990 | |
989 | if (!this->locale) |
991 | if (!this->locale) |
990 | { |
992 | { |
… | |
… | |
1001 | |
1003 | |
1002 | |
1004 | |
1003 | this->locale = strdup (this->locale); |
1005 | this->locale = strdup (this->locale); |
1004 | SET_LOCALE (this->locale); |
1006 | SET_LOCALE (this->locale); |
1005 | mbstate.reset (); |
1007 | mbstate.reset (); |
1006 | #endif |
|
|
1007 | |
1008 | |
1008 | #if HAVE_NL_LANGINFO |
1009 | #if HAVE_NL_LANGINFO |
1009 | char *codeset = nl_langinfo (CODESET); |
1010 | char *codeset = nl_langinfo (CODESET); |
1010 | // /^UTF.?8/i |
1011 | // /^UTF.?8/i |
1011 | enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u') |
1012 | enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u') |
… | |
… | |
1188 | /*----------------------------------------------------------------------*/ |
1189 | /*----------------------------------------------------------------------*/ |
1189 | /* color aliases, fg/bg bright-bold */ |
1190 | /* color aliases, fg/bg bright-bold */ |
1190 | void |
1191 | void |
1191 | rxvt_term::color_aliases (int idx) |
1192 | rxvt_term::color_aliases (int idx) |
1192 | { |
1193 | { |
1193 | if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) |
1194 | if (rs[Rs_color + idx] && isdigit (*rs[Rs_color + idx])) |
1194 | { |
1195 | { |
1195 | int i = atoi (rs[Rs_color + idx]); |
1196 | int i = atoi (rs[Rs_color + idx]); |
1196 | |
1197 | |
1197 | if (i >= 8 && i <= 15) |
1198 | if (i >= 8 && i <= 15) |
1198 | /* bright colors */ |
1199 | /* bright colors */ |
… | |
… | |
1474 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1475 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1475 | &attributes); |
1476 | &attributes); |
1476 | |
1477 | |
1477 | this->parent = top; |
1478 | this->parent = top; |
1478 | |
1479 | |
1479 | old_width = szHint.width; |
|
|
1480 | old_height = szHint.height; |
|
|
1481 | |
|
|
1482 | set_title (rs [Rs_title]); |
1480 | set_title (rs [Rs_title]); |
1483 | set_icon_name (rs [Rs_iconName]); |
1481 | set_icon_name (rs [Rs_iconName]); |
1484 | |
1482 | |
1485 | classHint.res_name = (char *)rs[Rs_name]; |
1483 | classHint.res_name = (char *)rs[Rs_name]; |
1486 | classHint.res_class = (char *)RESCLASS; |
1484 | classHint.res_class = (char *)RESCLASS; |
… | |
… | |
1548 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1546 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1549 | |
1547 | |
1550 | /* the vt window */ |
1548 | /* the vt window */ |
1551 | vt = XCreateSimpleWindow (dpy, top, |
1549 | vt = XCreateSimpleWindow (dpy, top, |
1552 | window_vt_x, window_vt_y, |
1550 | window_vt_x, window_vt_y, |
1553 | width, height, |
1551 | vt_width, vt_height, |
1554 | 0, |
1552 | 0, |
1555 | pix_colors_focused[Color_fg], |
1553 | pix_colors_focused[Color_fg], |
1556 | pix_colors_focused[Color_bg]); |
1554 | pix_colors_focused[Color_bg]); |
1557 | |
1555 | |
1558 | attributes.bit_gravity = NorthWestGravity; |
1556 | attributes.bit_gravity = NorthWestGravity; |