--- rxvt-unicode/src/main.C 2004/02/13 12:16:21 1.32 +++ rxvt-unicode/src/main.C 2004/02/22 10:38:11 1.42 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*--------------------------------*-C-*---------------------------------*; * File: main.c *----------------------------------------------------------------------* * @@ -13,6 +13,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications + * Copyright (c) 2003-2004 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 @@ -92,13 +93,13 @@ #ifdef POINTER_BLANK pointer_ev (this, &rxvt_term::pointer_cb), #endif +#ifdef USE_XIM + im_ev (this, &rxvt_term::im_cb), +#endif check_ev (this, &rxvt_term::check_cb), destroy_ev (this, &rxvt_term::destroy_cb), pty_ev (this, &rxvt_term::pty_cb), - incr_ev (this, &rxvt_term::incr_cb), -#ifdef USE_XIM - im_ev (this, &rxvt_term::im_cb) -#endif + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } @@ -108,11 +109,6 @@ if (cmd_fd >= 0) close (cmd_fd); - scr_release (); - - free (locale); - free (codeset); - #ifndef NO_SETOWNER_TTYDEV privileged_ttydev (RESTORE); #endif @@ -120,12 +116,29 @@ privileged_utmp (RESTORE); #endif + delete TermWin.fontset; + + if (display) + if (TermWin.parent[0]) + XDestroyWindow (display->display, TermWin.parent[0]); + // TODO: free pixcolours, colours should become part of rxvt_display delete PixColors; - delete TermWin.fontset; displays.put (display); + + scr_release (); + + free (env_windowid); + free (env_display); + free (env_term); + free (env_colorfgbg); + free (locale); + free (codeset); + + delete envv; + delete argv; } void @@ -133,13 +146,9 @@ { if (display) { - if (TermWin.parent[0]) - XDestroyWindow (display->display, TermWin.parent[0]); - rootwin_ev.stop (display); termwin_ev.stop (display); vt_ev.stop (display); - #ifdef USE_XIM im_destroy (); im_ev.stop (display); @@ -255,15 +264,10 @@ init_xlocale (); scr_reset (); /* initialize screen */ -#ifdef RXVT_GRAPHICS - Gr_reset (); /* reset graphics */ -#endif #if 0 -#ifdef DEBUG_X XSynchronize (display->display, True); #endif -#endif #ifdef HAVE_SCROLLBARS if (Options & Opt_scrollBar) @@ -286,7 +290,6 @@ XMapWindow (display->display, TermWin.vt); XMapWindow (display->display, TermWin.parent[0]); - init_env (); init_command (cmd_argv); pty_ev.start (cmd_fd, EVENT_READ); @@ -714,13 +717,50 @@ * fontname == FONT_UP - switch to bigger font * fontname == FONT_DN - switch to smaller font */ -void -rxvt_term::change_font (int init, const char *fontname) -{} +bool +rxvt_term::change_font (const char *fontname) +{ + if (fontname == FONT_UP) + { + // TODO + } + else if (fontname == FONT_DN) + { + // TODO + } + else + { + rxvt_fontset *fs = new rxvt_fontset (this); -void + if (fs && fs->populate (fontname)) + { + delete TermWin.fontset; + TermWin.fontset = fs; + TermWin.fwidth = fs->base_font ()->width; + TermWin.fheight = fs->base_font ()->height; + TermWin.fbase = fs->base_font ()->ascent; + + // TODO: screen needs to be told about new fonts + + if (TermWin.parent[0]) + { + resize_all_windows (0, 0, 0); + scr_remap_chars (); + scr_touch (true); + } + + return true; + } + } + + return false; +} + +bool rxvt_term::font_up_down (int n, int direction) -{} +{ + return false; +} /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ @@ -875,8 +915,8 @@ #endif break; } + sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); - putenv (env_colorfgbg); #ifndef NO_BRIGHTCOLOR colorfgbg = DEFAULT_RSTYLE; @@ -991,11 +1031,6 @@ XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, window_vt_y, TermWin_TotalWidth (), TermWin_TotalHeight ()); -#ifdef RXVT_GRAPHICS - if (old_height) - Gr_Resize (old_width - szHint.base_width, - old_height - szHint.base_height); -#endif scr_clear (); #ifdef XPM_BACKGROUND resize_pixmap (); @@ -1311,7 +1346,7 @@ #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) - setlocale (LC_CTYPE, rs[Rs_imLocale]); + SET_LOCALE (rs[Rs_imLocale]); #endif p = rs[Rs_inputMethod]; @@ -1352,7 +1387,7 @@ done: #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) - setlocale (LC_CTYPE, locale); + SET_LOCALE (locale); #endif }