--- rxvt-unicode/src/main.C 2004/02/21 20:35:33 1.37 +++ rxvt-unicode/src/main.C 2004/03/15 00:08:11 1.54 @@ -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 @@ -57,6 +58,70 @@ } } +#if ENABLE_COMBINING +class rxvt_composite_vec rxvt_composite; + +text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) +{ + compose_char *cc; + + // break compose chains, as stupid readline really likes to duplicate + // composing characters for some reason near the end of a line. + cc = (*this)[c1]; + while (cc) + { + if (cc->c2 == c2) return c1; + cc = (*this)[cc->c1]; + } + + // check to see wether this combination already exists otherwise + for (cc = v.end (); cc-- > v.begin (); ) + { + if (cc->c1 == c1 && cc->c2 == c2) + return COMPOSE_LO + (cc - v.begin ()); + } + + // allocate a new combination + if (v.size () == COMPOSE_HI - COMPOSE_LO + 1) + { + static int seen; + + if (!seen++) + fprintf (stderr, "too many unrepresentable composite characters, try --enable-unicode3\n"); + + return REPLACEMENT_CHAR; + } + + v.push_back (compose_char (c1, c2)); + + return v.size () - 1 + COMPOSE_LO; +} + +int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) +{ + compose_char *cc = (*this)[c]; + + if (!cc) + { + if (r) *r = c; + return 1; + } + + int len = expand (cc->c1, r); + + if (r) r += len; + + if (cc->c2 != NOCHAR) + { + len++; + if (r) *r++ = cc->c2; + } + + return len; + +} +#endif + void * rxvt_term::operator new (size_t s) { @@ -81,7 +146,7 @@ scrollbar_ev (this, &rxvt_term::x_cb), #endif #ifdef MENUBAR - menubar_ev (this, &rxvt_term::x_cb), fixme + menubar_ev (this, &rxvt_term::x_cb), #endif #ifdef CURSOR_BLINK cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), @@ -118,8 +183,17 @@ delete TermWin.fontset; if (display) - if (TermWin.parent[0]) - XDestroyWindow (display->display, TermWin.parent[0]); + { +#if defined(MENUBAR) && (MENUBAR_MAX > 1) + delete menuBar.drawable; + //if (menuBar.win) + // XDestroyWindow (display->display, menuBar.win); +#endif + delete TermWin.drawable; + // destroy all windows + if (TermWin.parent[0]) + XDestroyWindow (display->display, TermWin.parent[0]); + } // TODO: free pixcolours, colours should become part of rxvt_display @@ -250,7 +324,7 @@ set_locale (""); -#if (MENUBAR_MAX) +#if MENUBAR_MAX menubar_read (rs[Rs_menu]); #endif #ifdef HAVE_SCROLLBARS @@ -263,9 +337,6 @@ init_xlocale (); scr_reset (); /* initialize screen */ -#ifdef RXVT_GRAPHICS - Gr_reset (); /* reset graphics */ -#endif #if 0 XSynchronize (display->display, True); @@ -276,7 +347,7 @@ resize_scrollbar (); /* create and map scrollbar */ #endif #if (MENUBAR_MAX) - if (menubar_visible (r)) + if (menubar_visible ()) XMapWindow (display->display, menuBar.win); #endif #ifdef TRANSPARENT @@ -380,7 +451,7 @@ if (p) return p; - fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); rxvt_clean_exit (); exit (EXIT_FAILURE); /* NOTREACHED */ @@ -396,7 +467,7 @@ if (p) return p; - fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); rxvt_clean_exit (); exit (EXIT_FAILURE); /* NOTREACHED */ @@ -415,7 +486,7 @@ if (p) return p; - fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); + fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); rxvt_clean_exit (); exit (EXIT_FAILURE); /* NOTREACHED */ @@ -617,6 +688,7 @@ } } } + /* TODO: BOUNDS */ TermWin.width = TermWin.ncol * TermWin.fwidth; TermWin.height = TermWin.nrow * TermWin.fheight; @@ -719,13 +791,48 @@ * 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 ? fontname : "fixed")) + { + delete TermWin.fontset; + TermWin.fontset = fs; + TermWin.fwidth = fs->base_font ()->width; + TermWin.fheight = fs->base_font ()->height; + TermWin.fbase = fs->base_font ()->ascent; + + 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; +} /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ @@ -736,7 +843,7 @@ #ifndef SMART_WINDOW_TITLE XStoreName (display->display, TermWin.parent[0], str); #else - char *name; + char *name; if (XFetchName (display->display, TermWin.parent[0], &name) == 0) name = NULL; @@ -753,7 +860,7 @@ #ifndef SMART_WINDOW_TITLE XSetIconName (display->display, TermWin.parent[0], str); #else - char *name; + char *name; if (XGetIconName (display->display, TermWin.parent[0], &name)) name = NULL; @@ -768,8 +875,8 @@ void rxvt_term::set_window_color (int idx, const char *color) { - rxvt_color xcol; - int i; + rxvt_color xcol; + int i; if (color == NULL || *color == '\0') return; @@ -996,12 +1103,7 @@ 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 (); + scr_clear (height != old_height); #ifdef XPM_BACKGROUND resize_pixmap (); #endif @@ -1316,7 +1418,7 @@ #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) - rxvt_set_locale (rs[Rs_imLocale]); + SET_LOCALE (rs[Rs_imLocale]); #endif p = rs[Rs_inputMethod]; @@ -1357,7 +1459,7 @@ done: #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) - rxvt_set_locale (locale); + SET_LOCALE (locale); #endif }