--- rxvt-unicode/src/main.C 2005/12/22 16:44:10 1.152 +++ rxvt-unicode/src/main.C 2006/01/08 07:55:36 1.166 @@ -13,7 +13,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,8 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ +#include "keyboard.h" +#include "rxvtperl.h" #include @@ -46,13 +48,9 @@ # include #endif -#ifdef KEYSYM_RESOURCE -# include "keyboard.h" -#endif - vector rxvt_term::termlist; -static char curlocale[128]; +static char curlocale[128], savelocale[128]; bool rxvt_set_locale (const char *locale) @@ -65,6 +63,19 @@ return true; } +bool +rxvt_push_locale (const char *locale) +{ + strcpy (savelocale, curlocale); + rxvt_set_locale (locale); +} + +void +rxvt_pop_locale () +{ + rxvt_set_locale (savelocale); +} + #if ENABLE_COMBINING class rxvt_composite_vec rxvt_composite; @@ -197,6 +208,8 @@ rxvt_term::~rxvt_term () { + HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)); + termlist.erase (find (termlist.begin (), termlist.end(), this)); emergency_cleanup (); @@ -263,6 +276,9 @@ #if OFF_FOCUS_FADING delete pix_colors_unfocused; #endif +#if USE_XGETDEFAULT + XrmDestroyDatabase (xrmdatabase); +#endif displays.put (display); @@ -295,7 +311,7 @@ { cmd_pid = 0; - if (!(options & Opt_hold)) + if (!OPTION (Opt_hold)) destroy (); } @@ -471,10 +487,23 @@ menubar_read (rs[Rs_menu]); #endif #ifdef HAVE_SCROLLBARS - if (options & Opt_scrollBar) + if (OPTION (Opt_scrollBar)) scrollBar.setIdle (); /* set existence for size calculations */ #endif +#if ENABLE_PERL + if (!rs[Rs_perl_ext_1]) + rs[Rs_perl_ext_1] = "default"; + + if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) + || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) + || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) + { + rxvt_perl.init (); + HOOK_INVOKE ((this, HOOK_INIT, DT_END)); + } +#endif + create_windows (argc, argv); dDisp; @@ -488,7 +517,7 @@ #endif #ifdef HAVE_SCROLLBARS - if (options & Opt_scrollBar) + if (OPTION (Opt_scrollBar)) resize_scrollbar (); /* create and map scrollbar */ #endif #if (MENUBAR_MAX) @@ -496,7 +525,7 @@ XMapWindow (disp, menuBar.win); #endif #ifdef TRANSPARENT - if (options & Opt_transparent) + if (OPTION (Opt_transparent)) { XSelectInput (disp, display->root, PropertyChangeMask); check_our_parents (); @@ -513,10 +542,13 @@ free (cmd_argv); - pty_ev.start (pty.pty, EVENT_READ); + if (pty.pty >= 0) + pty_ev.start (pty.pty, EVENT_READ); check_ev.start (); + HOOK_INVOKE ((this, HOOK_START, DT_END)); + return true; } @@ -586,6 +618,10 @@ old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); // TODO: handle this with exceptions and tolerate the memory loss XSetIOErrorHandler (rxvt_xioerror_handler); + +#ifdef USE_XGETDEFAULT + XrmInitialize (); +#endif } /* ------------------------------------------------------------------------- * @@ -683,7 +719,7 @@ void rxvt_term::privileged_utmp (rxvt_privaction action) { - if ((options & Opt_utmpInhibit) + if (OPTION (Opt_utmpInhibit) || !pty.name || !*pty.name) return; @@ -785,7 +821,7 @@ { sb_w = scrollbar_TotalWidth (); szHint.base_width += sb_w; - if (!(options & Opt_scrollBar_right)) + if (!OPTION (Opt_scrollBar_right)) window_vt_x += sb_w; } @@ -823,7 +859,7 @@ szHint.height = szHint.base_height + height; } - if (scrollbar_visible () && (options & Opt_scrollBar_right)) + if (scrollbar_visible () && OPTION (Opt_scrollBar_right)) window_sb_x = szHint.width - sb_w; if (recalc_x) @@ -902,7 +938,7 @@ fwidth = prop.width; fheight = prop.height; - fbase = (*fs)[1]->ascent; + fbase = prop.ascent; for (int style = 1; style < 4; style++) { @@ -946,7 +982,6 @@ void rxvt_term::set_string_property (Atom prop, const char *str, int len) { - // TODO: SMART_WINDOW_TITLE XChangeProperty (display->display, parent[0], prop, XA_STRING, 8, PropModeReplace, (const unsigned char *)str, len >= 0 ? len : strlen (str)); @@ -954,7 +989,6 @@ void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) { - // TODO: SMART_WINDOW_TITLE wchar_t *ws = rxvt_mbstowcs (str, len); char *s = rxvt_wcstoutf8 (ws); @@ -1005,11 +1039,9 @@ if (i >= 8 && i <= 15) { /* bright colors */ i -= 8; -# ifndef NO_BRIGHTCOLOR pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; SET_PIXCOLOR (idx); goto done; -# endif } if (i >= 0 && i <= 7) @@ -1203,11 +1235,11 @@ if (menubar_visible ()) XMoveResizeWindow (disp, menuBar.win, window_vt_x, 0, - TermWin_TotalWidth (), menuBar_TotalHeight ()); + width, menuBar_TotalHeight ()); XMoveResizeWindow (disp, vt, window_vt_x, window_vt_y, - TermWin_TotalWidth (), TermWin_TotalHeight ()); + width, height); scr_clear (); #ifdef XPM_BACKGROUND