--- rxvt-unicode/src/main.C 2003/12/08 23:14:40 1.11 +++ rxvt-unicode/src/main.C 2003/12/18 05:45:11 1.15 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.11 2003/12/08 23:14:40 pcg Exp $ + * $Id: main.C,v 1.15 2003/12/18 05:45:11 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -44,6 +44,20 @@ # include #endif +#include + +static char curlocale[128]; + +void +rxvt_set_locale (const char *locale) +{ + if (locale && strncmp (locale, curlocale, 128)) + { + strncpy (curlocale, locale, 128); + setlocale (LC_CTYPE, curlocale); + } +} + void * rxvt_term::operator new (size_t s) { @@ -69,14 +83,18 @@ #endif x_ev (this, &rxvt_term::x_cb), destroy_ev (this, &rxvt_term::destroy_cb), - check_ev (this, &rxvt_term::check_cb) + check_ev (this, &rxvt_term::check_cb), + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } rxvt_term::~rxvt_term () { - rxvt_scr_release (this); + scr_release (); + + free (locale); + free (codeset); #ifndef NO_SETOWNER_TTYDEV rxvt_privileged_ttydev (this, RESTORE); @@ -176,8 +194,6 @@ bool rxvt_term::init (int argc, const char *const *argv) { - dR;//TODO (scrollbar, setidle) - /* * Save and then give up any super-user privileges * If we need privileges in any area then we must specifically request it. @@ -188,23 +204,30 @@ rxvt_privileges (this, SAVE); rxvt_privileges (this, IGNORE); - rxvt_init_secondary (this); +#if HAVE_XSETLOCALE || HAVE_SETLOCALE + locale = strdup (setlocale (LC_CTYPE, "")); +#endif +#if HAVE_NL_LANGINFO + codeset = strdup (nl_langinfo (CODESET)); +#endif + + init_secondary (); - const char **cmd_argv = rxvt_init_resources (this, argc, argv); + const char **cmd_argv = init_resources (argc, argv); #if (MENUBAR_MAX) rxvt_menubar_read (this, rs[Rs_menu]); #endif #ifdef HAVE_SCROLLBARS if (Options & Opt_scrollBar) - scrollbar_setIdle (); /* set existence for size calculations */ + scrollBar.setIdle (); /* set existence for size calculations */ #endif rxvt_Create_Windows (this, argc, argv); - rxvt_init_xlocale (this); + init_xlocale (); - rxvt_scr_reset (this); /* initialize screen */ + scr_reset (); /* initialize screen */ #ifdef RXVT_GRAPHICS rxvt_Gr_reset (this); /* reset graphics */ #endif @@ -233,8 +256,8 @@ XMapWindow (Xdisplay, TermWin.vt); XMapWindow (Xdisplay, TermWin.parent[0]); - rxvt_init_env (this); - rxvt_init_command (this, cmd_argv); + init_env (); + init_command (cmd_argv); x_ev.start (Xfd, EVENT_READ); pty_ev.start (cmd_fd, EVENT_READ); @@ -759,27 +782,26 @@ /* handle Color_BD, scrollbar background, etc. */ - rxvt_set_colorfgbg(aR); - rxvt_recolour_cursor(aR); + rxvt_set_colorfgbg (aR); + R->recolour_cursor (); /* the only reasonable way to enforce a clean update */ - rxvt_scr_poweron(aR); + rxvt_scr_poweron (aR); } #else # define rxvt_set_window_color(aR_ idx,color) ((void)0) #endif /* XTERM_COLOR_CHANGE */ -/* EXTPROTO */ void -rxvt_recolour_cursor(pR) +rxvt_term::recolour_cursor () { - rxvt_color xcol[2]; - #if TODO - xcol[0] = R->PixColors[Color_pointer]; - xcol[1] = R->PixColors[Color_bg]; - XQueryColors(R->Xdisplay, XCMAP, xcol, 2); - XRecolorCursor(R->Xdisplay, R->TermWin_cursor, &(xcol[0]), &(xcol[1])); + rxvt_color xcol[2]; + + xcol[0] = PixColors[Color_pointer]; + xcol[1] = PixColors[Color_bg]; + XQueryColors (Xdisplay, XCMAP, xcol, 2); + XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1])); #endif } @@ -941,7 +963,9 @@ /* scr_reset only works on the primary screen */ if (R->old_height) /* this is not the first time through */ curr_screen = rxvt_scr_change_screen(aR_ PRIMARY); - rxvt_scr_reset(aR); + + R->scr_reset(); + if (curr_screen >= 0) { /* this is not the first time through */ rxvt_scr_change_screen(aR_ curr_screen); rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0)); @@ -1130,6 +1154,11 @@ if (R->Input_Context) return; +#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) + if (R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, R->rs[Rs_imLocale]); +#endif + p = R->rs[Rs_inputMethod]; if (p && *p) { @@ -1155,18 +1184,24 @@ free(s); if (found) - return; + goto done; } /* try with XMODIFIERS env. var. */ if ((p = XSetLocaleModifiers ("")) && *p && rxvt_IM_get_IC (aR)) - return; + goto done; /* try with no modifiers base IF the user didn't specify an IM */ if ((p = XSetLocaleModifiers ("@im=none")) && *p && rxvt_IM_get_IC (aR) == True) - return; + goto done; + +done: +#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) + if (R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, R->locale); +#endif } /*