… | |
… | |
41 | #include <limits> |
41 | #include <limits> |
42 | |
42 | |
43 | #include <signal.h> |
43 | #include <signal.h> |
44 | |
44 | |
45 | #include <fcntl.h> |
45 | #include <fcntl.h> |
|
|
46 | |
|
|
47 | #ifdef HAVE_XMU |
|
|
48 | # include <X11/Xmu/CurUtil.h> |
|
|
49 | #endif |
46 | |
50 | |
47 | #ifdef HAVE_XSETLOCALE |
51 | #ifdef HAVE_XSETLOCALE |
48 | # define X_LOCALE |
52 | # define X_LOCALE |
49 | # include <X11/Xlocale.h> |
53 | # include <X11/Xlocale.h> |
50 | #else |
54 | #else |
… | |
… | |
665 | if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0) |
669 | if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0) |
666 | multiClickTime = i; |
670 | multiClickTime = i; |
667 | else |
671 | else |
668 | multiClickTime = 500; |
672 | multiClickTime = 500; |
669 | |
673 | |
|
|
674 | cursor_type = option (Opt_cursorUnderline) ? 1 : 0; |
|
|
675 | |
670 | /* no point having a scrollbar without having any scrollback! */ |
676 | /* no point having a scrollbar without having any scrollback! */ |
671 | if (!saveLines) |
677 | if (!saveLines) |
672 | set_option (Opt_scrollBar, 0); |
678 | set_option (Opt_scrollBar, 0); |
673 | |
679 | |
674 | if (!rs[Rs_cutchars]) |
680 | if (!rs[Rs_cutchars]) |
… | |
… | |
746 | envv->push_back (0); |
752 | envv->push_back (0); |
747 | |
753 | |
748 | this->argv = argv; |
754 | this->argv = argv; |
749 | this->envv = envv; |
755 | this->envv = envv; |
750 | |
756 | |
|
|
757 | env = new char *[this->envv->size ()]; |
|
|
758 | for (int i = 0; i < this->envv->size (); i++) |
|
|
759 | env[i] = this->envv->at (i); |
|
|
760 | |
751 | init2 (argv->size () - 1, argv->begin ()); |
761 | init2 (argv->size () - 1, argv->begin ()); |
752 | } |
762 | } |
753 | |
763 | |
754 | void |
764 | void |
755 | rxvt_term::init (int argc, const char *const *argv, const char *const *envv) |
765 | rxvt_term::init (int argc, const char *const *argv, const char *const *envv) |
… | |
… | |
773 | void |
783 | void |
774 | rxvt_term::init2 (int argc, const char *const *argv) |
784 | rxvt_term::init2 (int argc, const char *const *argv) |
775 | { |
785 | { |
776 | SET_R (this); |
786 | SET_R (this); |
777 | set_locale (""); |
787 | set_locale (""); |
778 | set_environ (envv); // a few things in X do not call setlocale :( |
788 | set_environ (env); // a few things in X do not call setlocale :( |
779 | |
789 | |
780 | init_vars (); |
790 | init_vars (); |
781 | |
791 | |
782 | const char **cmd_argv = init_resources (argc, argv); |
792 | const char **cmd_argv = init_resources (argc, argv); |
783 | |
793 | |
… | |
… | |
950 | |
960 | |
951 | /*----------------------------------------------------------------------*/ |
961 | /*----------------------------------------------------------------------*/ |
952 | void |
962 | void |
953 | rxvt_term::set_locale (const char *locale) |
963 | rxvt_term::set_locale (const char *locale) |
954 | { |
964 | { |
955 | set_environ (envv); |
965 | set_environ (env); |
956 | |
966 | |
957 | free (this->locale); |
967 | free (this->locale); |
958 | this->locale = setlocale (LC_CTYPE, locale); |
968 | this->locale = setlocale (LC_CTYPE, locale); |
959 | |
969 | |
960 | if (!this->locale) |
970 | if (!this->locale) |
… | |
… | |
988 | } |
998 | } |
989 | |
999 | |
990 | void |
1000 | void |
991 | rxvt_term::init_xlocale () |
1001 | rxvt_term::init_xlocale () |
992 | { |
1002 | { |
993 | set_environ (envv); |
1003 | set_environ (env); |
994 | |
1004 | |
995 | #if USE_XIM |
1005 | #if USE_XIM |
996 | if (!locale) |
1006 | if (!locale) |
997 | rxvt_warn ("setting locale failed, continuing without locale support.\n"); |
1007 | rxvt_warn ("setting locale failed, continuing without locale support.\n"); |
998 | else |
1008 | else |
… | |
… | |
1050 | run_command (argv); |
1060 | run_command (argv); |
1051 | } |
1061 | } |
1052 | |
1062 | |
1053 | /*----------------------------------------------------------------------*/ |
1063 | /*----------------------------------------------------------------------*/ |
1054 | void |
1064 | void |
1055 | rxvt_term::get_colours () |
1065 | rxvt_term::get_colors () |
1056 | { |
1066 | { |
1057 | int i; |
1067 | int i; |
1058 | |
1068 | |
1059 | #ifdef OFF_FOCUS_FADING |
1069 | #ifdef OFF_FOCUS_FADING |
1060 | pix_colors = pix_colors_focused; |
1070 | pix_colors = pix_colors_focused; |
1061 | #endif |
1071 | #endif |
1062 | |
1072 | |
1063 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1073 | for (i = 0; i < NRS_COLORS; i++) |
1064 | { |
|
|
1065 | const char *name = rs[Rs_color + i]; |
1074 | if (const char *name = rs[Rs_color + i]) |
1066 | |
|
|
1067 | if (!name) |
|
|
1068 | continue; |
|
|
1069 | |
|
|
1070 | rxvt_color xcol; |
|
|
1071 | |
|
|
1072 | if (!set_color (xcol, name)) |
1075 | set_color (pix_colors [i], name); |
1073 | { |
|
|
1074 | #ifndef XTERM_REVERSE_VIDEO |
|
|
1075 | if (i < 2 && option (Opt_reverseVideo)) |
|
|
1076 | name = def_colorName [1 - i]; |
|
|
1077 | else |
|
|
1078 | #endif |
|
|
1079 | name = def_colorName [i]; |
|
|
1080 | |
|
|
1081 | if (!name) |
|
|
1082 | continue; |
|
|
1083 | |
|
|
1084 | if (!set_color (xcol, name)) |
|
|
1085 | { |
|
|
1086 | switch (i) |
|
|
1087 | { |
|
|
1088 | case Color_fg: |
|
|
1089 | case Color_bg: |
|
|
1090 | rxvt_warn ("unable to get foreground/background colour, continuing.\n"); |
|
|
1091 | name = ""; |
|
|
1092 | break; |
|
|
1093 | #ifndef NO_CURSORCOLOR |
|
|
1094 | case Color_cursor2: |
|
|
1095 | #endif |
|
|
1096 | case Color_pointer_fg: |
|
|
1097 | name = rs[Rs_color + Color_fg]; |
|
|
1098 | xcol.set (this, name); |
|
|
1099 | break; |
|
|
1100 | default: |
|
|
1101 | name = rs[Rs_color + Color_bg]; |
|
|
1102 | xcol.set (this, name); |
|
|
1103 | break; |
|
|
1104 | } |
|
|
1105 | } |
|
|
1106 | } |
|
|
1107 | |
|
|
1108 | pix_colors[i] = xcol; |
|
|
1109 | rs[Rs_color + i] = name; |
|
|
1110 | } |
|
|
1111 | |
|
|
1112 | if (depth <= 2) |
|
|
1113 | { |
|
|
1114 | if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg); |
|
|
1115 | if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg); |
|
|
1116 | if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg); |
|
|
1117 | } |
|
|
1118 | |
1076 | |
1119 | /* |
1077 | /* |
1120 | * get scrollBar shadow colors |
1078 | * get scrollBar shadow colors |
1121 | * |
1079 | * |
1122 | * The calculations of topShadow/bottomShadow values are adapted |
1080 | * The calculations of topShadow/bottomShadow values are adapted |
1123 | * from the fvwm window manager. |
1081 | * from the fvwm window manager. |
1124 | */ |
1082 | */ |
1125 | #ifdef RXVT_SCROLLBAR |
1083 | #ifdef RXVT_SCROLLBAR |
1126 | if (depth <= 2) |
|
|
1127 | { |
|
|
1128 | /* Monochrome */ |
|
|
1129 | alias_color (Color_scroll, Color_fg); |
|
|
1130 | alias_color (Color_topShadow, Color_bg); |
|
|
1131 | alias_color (Color_bottomShadow, Color_bg); |
|
|
1132 | } |
|
|
1133 | else |
|
|
1134 | { |
|
|
1135 | pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); |
1084 | pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); |
1136 | |
1085 | |
1137 | rgba cscroll; |
1086 | rgba cscroll; |
1138 | pix_colors [Color_scroll].get (cscroll); |
1087 | pix_colors [Color_scroll].get (cscroll); |
1139 | |
1088 | |
1140 | /* topShadowColor */ |
1089 | /* topShadowColor */ |
1141 | if (!pix_colors[Color_topShadow].set (this, |
1090 | if (!pix_colors[Color_topShadow].set (this, |
1142 | rgba ( |
1091 | rgba ( |
1143 | min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), |
1092 | min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), |
1144 | min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), |
1093 | min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), |
1145 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
1094 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
1146 | cscroll.a) |
1095 | cscroll.a) |
1147 | )) |
1096 | )) |
1148 | alias_color (Color_topShadow, Color_White); |
1097 | alias_color (Color_topShadow, Color_White); |
1149 | } |
|
|
1150 | #endif |
1098 | #endif |
1151 | |
1099 | |
1152 | #ifdef OFF_FOCUS_FADING |
1100 | #ifdef OFF_FOCUS_FADING |
1153 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1101 | for (i = 0; i < NRS_COLORS; i++) |
1154 | update_fade_color (i); |
1102 | update_fade_color (i, true); |
1155 | #endif |
1103 | #endif |
1156 | } |
1104 | } |
1157 | |
1105 | |
1158 | /*----------------------------------------------------------------------*/ |
1106 | /*----------------------------------------------------------------------*/ |
1159 | /* color aliases, fg/bg bright-bold */ |
1107 | /* color aliases, fg/bg bright-bold */ |
… | |
… | |
1208 | for (j = map->max_keypermod; j--; k++) |
1156 | for (j = map->max_keypermod; j--; k++) |
1209 | { |
1157 | { |
1210 | if (kc[k] == 0) |
1158 | if (kc[k] == 0) |
1211 | break; |
1159 | break; |
1212 | |
1160 | |
1213 | switch (XKeycodeToKeysym (dpy, kc[k], 0)) |
1161 | switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0)) |
1214 | { |
1162 | { |
1215 | case XK_Num_Lock: |
1163 | case XK_Num_Lock: |
1216 | ModNumLockMask = modmasks[i - 1]; |
1164 | ModNumLockMask = modmasks[i - 1]; |
1217 | continue; |
1165 | continue; |
1218 | |
1166 | |
… | |
… | |
1263 | } |
1211 | } |
1264 | |
1212 | |
1265 | void |
1213 | void |
1266 | rxvt_term::set_icon (const char *file) |
1214 | rxvt_term::set_icon (const char *file) |
1267 | { |
1215 | { |
1268 | #if HAVE_PIXBUF |
1216 | #if HAVE_PIXBUF && ENABLE_EWMH |
1269 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
1217 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
1270 | if (!pixbuf) |
1218 | if (!pixbuf) |
1271 | { |
1219 | { |
1272 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1220 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1273 | return; |
1221 | return; |
… | |
… | |
1338 | Window top, parent; |
1286 | Window top, parent; |
1339 | |
1287 | |
1340 | dLocal (Display *, dpy); |
1288 | dLocal (Display *, dpy); |
1341 | |
1289 | |
1342 | /* grab colors before netscape does */ |
1290 | /* grab colors before netscape does */ |
1343 | get_colours (); |
1291 | get_colors (); |
1344 | |
1292 | |
1345 | if (!set_fonts ()) |
1293 | if (!set_fonts ()) |
1346 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1294 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1347 | |
1295 | |
1348 | parent = display->root; |
1296 | parent = display->root; |
… | |
… | |
1459 | | ExposureMask | StructureNotifyMask); |
1407 | | ExposureMask | StructureNotifyMask); |
1460 | |
1408 | |
1461 | termwin_ev.start (display, top); |
1409 | termwin_ev.start (display, top); |
1462 | |
1410 | |
1463 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1411 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
|
|
1412 | unsigned int shape = XC_xterm; |
|
|
1413 | |
|
|
1414 | #ifdef HAVE_XMU |
|
|
1415 | if (rs[Rs_pointerShape]) |
|
|
1416 | { |
|
|
1417 | int stmp = XmuCursorNameToIndex (rs[Rs_pointerShape]); |
|
|
1418 | if (stmp >= 0) |
|
|
1419 | shape = stmp; |
|
|
1420 | } |
|
|
1421 | #endif |
|
|
1422 | |
1464 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1423 | TermWin_cursor = XCreateFontCursor (dpy, shape); |
1465 | |
1424 | |
1466 | /* the vt window */ |
1425 | /* the vt window */ |
1467 | vt = XCreateSimpleWindow (dpy, top, |
1426 | vt = XCreateSimpleWindow (dpy, top, |
1468 | window_vt_x, window_vt_y, |
1427 | window_vt_x, window_vt_y, |
1469 | vt_width, vt_height, |
1428 | vt_width, vt_height, |
… | |
… | |
1501 | if (rs[Rs_fade]) |
1460 | if (rs[Rs_fade]) |
1502 | pix_colors = pix_colors_unfocused; |
1461 | pix_colors = pix_colors_unfocused; |
1503 | #endif |
1462 | #endif |
1504 | |
1463 | |
1505 | pointer_unblank (); |
1464 | pointer_unblank (); |
1506 | scr_recolour (); |
1465 | scr_recolor (); |
1507 | } |
1466 | } |
1508 | |
1467 | |
1509 | /*----------------------------------------------------------------------*/ |
1468 | /*----------------------------------------------------------------------*/ |
1510 | /* |
1469 | /* |
1511 | * Run the command in a subprocess and return a file descriptor for the |
1470 | * Run the command in a subprocess and return a file descriptor for the |