From 4af7b8ba7d3e2badd9d230e43393ef227a245c62 Mon Sep 17 00:00:00 2001 From: pcg Date: Sat, 6 Mar 2004 00:05:00 +0000 Subject: [PATCH] *** empty log message *** --- autoconf/configure.in | 10 ++--- configure | 58 ++++++++++++++++++++--------- src/defaultfont.h | 2 +- src/init.h | 2 +- src/main.C | 63 +++++++++++++++++++++++++++++++ src/menubar.C | 3 +- src/misc.C | 22 +++++++++++ src/ptytty.C | 6 +-- src/rxvt.h | 87 ++++++++++++++++++++++++++++++------------- src/rxvtlib.h.in | 12 +++--- 10 files changed, 205 insertions(+), 60 deletions(-) diff --git a/autoconf/configure.in b/autoconf/configure.in index 6c1ef814..001bb9f9 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -1060,7 +1060,7 @@ LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS AC_CACHE_CHECK(for working plain setlocale, rxvt_cv_func_setlocale, -[AC_TRY_LINK([#include ], +[AC_TRY_LINK([#include ], [setlocale(LC_CTYPE, "");], rxvt_cv_func_setlocale=yes, rxvt_cv_func_setlocale=no)]) if test x$rxvt_cv_func_setlocale = xyes; then @@ -1078,7 +1078,7 @@ fi AC_CACHE_CHECK(for getpt, rxvt_cv_func_getpt, [AC_TRY_LINK([#define _GNU_SOURCE #ifdef HAVE_STDLIB_H -# include +# include #endif], [(void)getpt();], rxvt_cv_func_getpt=yes, rxvt_cv_func_getpt=no)]) @@ -1307,10 +1307,10 @@ fi dnl AC_SUBST($1)]) RXVT_DEFINE_TO_INCLUDE(include_stdint_h, stdint.h, ac_cv_header_stdint_h, yes, notset, dontmatch) -RXVT_DEFINE_TO_INCLUDE(include_stdarg_h, stdarg.h, ac_cv_header_stdarg_h, yes, notset, dontmatch) -RXVT_DEFINE_TO_INCLUDE(include_stdlib_h, stdlib.h, ac_cv_header_stdlib_h, yes, notset, dontmatch) +RXVT_DEFINE_TO_INCLUDE(include_stdarg_h, cstdarg, ac_cv_header_stdarg_h, yes, notset, dontmatch) +RXVT_DEFINE_TO_INCLUDE(include_stdlib_h, cstdlib, ac_cv_header_stdlib_h, yes, notset, dontmatch) RXVT_DEFINE_TO_INCLUDE(include_unistd_h, unistd.h, ac_cv_header_unistd_h, yes, notset, dontmatch) -RXVT_DEFINE_TO_INCLUDE(include_string_h, string.h, ac_cv_header_string_h, yes, notset, dontmatch) +RXVT_DEFINE_TO_INCLUDE(include_string_h, cstring, ac_cv_header_string_h, yes, notset, dontmatch) RXVT_DEFINE_TO_INCLUDE(include_fcntl_h, fcntl.h, ac_cv_header_fcntl_h, yes, notset, dontmatch) RXVT_DEFINE_TO_INCLUDE(include_util_h, util.h, ac_cv_header_util_h, yes, notset, dontmatch) RXVT_DEFINE_TO_INCLUDE(include_assert_h, assert.h, ac_cv_header_assert_h, yes, notset, dontmatch) diff --git a/configure b/configure index 7140f663..909ecc58 100755 --- a/configure +++ b/configure @@ -1031,6 +1031,7 @@ Optional Features: NOTE: this option is order dependent NOTE: automatically enabled with --enable-shared --enable-unicode3 use 21 instead of 16 bits to represent unicode characters + --enable-combining enable composition of base and combining characters --enable-xft enable xft support on systems that have it --enable-utmp enable utmp (utmpx) support --enable-wtmp enable wtmp (wtmpx) support (requires --enable-utmp) @@ -1077,7 +1078,7 @@ Optional Packages: --with-pic try to use only PIC/non-PIC objects default=use both --with-codesets=NAME,.. compile in additional codesets (jp,jp_ext,kr,cn,cn_ext,all) --with-res-name=NAME use this as default resource name (default: urxvt) - --with-res-class=NAME use this as the resource class (default: URxvt) + --with-res-class=CLASS use this as the resource class (default: URxvt) --with-name=NAME set the basename for the installed binaries (default: urxvt) --with-term=NAME set the terminal to NAME (default: rxvt) --with-terminfo=PATH set the path to the terminfo tree to PATH @@ -5036,7 +5037,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes case "$host" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 5039 "configure"' > conftest.$ac_ext + echo '#line 5040 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5587,7 +5588,7 @@ chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no -if { (eval echo configure:5590: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then +if { (eval echo configure:5591: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then @@ -7203,7 +7204,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { @@ -15985,7 +15996,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _GNU_SOURCE #ifdef HAVE_STDLIB_H -# include +# include #endif int main () @@ -16394,9 +16405,16 @@ cat >>confdefs.h <<\_ACEOF #define UNICODE_3 1 _ACEOF +fi +if test x$support_combining = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define ENCODING_COMPOSE 1 +_ACEOF + fi if test x$codesets = xall; then - codesets=jp,jp-ext,kr,cn,cn-ext,vn + codesets=jp,jp-ext,kr,cn,cn-ext fi for codeset in `echo $codesets | tr "a-z,\\-" "A-Z _"`; do @@ -16496,14 +16514,14 @@ else include_stdint_h="/* #include */" fi if test "$ac_cv_header_stdarg_h" = "yes" -o "$notset" = "dontmatch"; then - include_stdarg_h="#include " + include_stdarg_h="#include " else - include_stdarg_h="/* #include */" + include_stdarg_h="/* #include */" fi if test "$ac_cv_header_stdlib_h" = "yes" -o "$notset" = "dontmatch"; then - include_stdlib_h="#include " + include_stdlib_h="#include " else - include_stdlib_h="/* #include */" + include_stdlib_h="/* #include */" fi if test "$ac_cv_header_unistd_h" = "yes" -o "$notset" = "dontmatch"; then include_unistd_h="#include " @@ -16511,9 +16529,9 @@ else include_unistd_h="/* #include */" fi if test "$ac_cv_header_string_h" = "yes" -o "$notset" = "dontmatch"; then - include_string_h="#include " + include_string_h="#include " else - include_string_h="/* #include */" + include_string_h="/* #include */" fi if test "$ac_cv_header_fcntl_h" = "yes" -o "$notset" = "dontmatch"; then include_fcntl_h="#include " @@ -18028,13 +18046,17 @@ else " fi if test x$term != x; then - echo " set TERM to: $term -" + echo " set TERM to: $term" fi if test x$terminfo != x; then - echo " set TERMINFO to: $terminfo -" + echo " set TERMINFO to: $terminfo" +fi +echo " default resource name: $RESNAME" +echo " resource class: $RESCLASS" +if test x$RESFALLBACK != x; then + echo " resource class fallback: $RESFALLBACK" fi +echo if test x$rxvt_cv_ptys = xUNKNOWN; then echo ".----------------------------------------------------------------." echo ". WARNING: could not determine pty/tty type. Do not build until ." diff --git a/src/defaultfont.h b/src/defaultfont.h index f588c60f..7cdc7565 100644 --- a/src/defaultfont.h +++ b/src/defaultfont.h @@ -11,7 +11,7 @@ # include #else # ifdef HAVE_SETLOCALE -# include +# include # endif #endif /* HAVE_XLOCALE */ diff --git a/src/init.h b/src/init.h index 7d5b63cd..e57ef594 100644 --- a/src/init.h +++ b/src/init.h @@ -9,7 +9,7 @@ # include #else # ifdef HAVE_SETLOCALE -# include +# include # endif #endif /* HAVE_XLOCALE */ diff --git a/src/main.C b/src/main.C index 7ab5dd5d..b38c4b6b 100644 --- a/src/main.C +++ b/src/main.C @@ -58,6 +58,69 @@ rxvt_set_locale (const char *locale) } } +class rxvt_composite_vec rxvt_composite; + +text_t rxvt_composite_vec::compose (uint32_t c1, uint32_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 (uint32_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; + +} + +extern struct rxvt_composite_vec rxvt_composite; void * rxvt_term::operator new (size_t s) { diff --git a/src/menubar.C b/src/menubar.C index 8064ab46..75c95811 100644 --- a/src/menubar.C +++ b/src/menubar.C @@ -24,8 +24,7 @@ #include "../config.h" /* NECESSARY */ -#include -#include +#include #include "rxvt.h" /* NECESSARY */ #ifdef MENUBAR diff --git a/src/misc.C b/src/misc.C index 793cbab7..3f04220e 100644 --- a/src/misc.C +++ b/src/misc.C @@ -27,6 +27,28 @@ #include "rxvt.h" /* NECESSARY */ #include "misc.intpro" /* PROTOS for internal routines */ +/* EXTPROTO */ +char * +rxvt_wcstombs (const wchar_t *str, int len) +{ + mbstate mbs; + char *r = (char *)rxvt_malloc (len * MB_CUR_MAX + 1); + + char *dst = r; + while (len--) + { + int l = wcrtomb (dst, *str++, mbs); + if (l < 0) + *dst++ = '?'; + else + dst += l; + } + + *dst++ = 0; + + return r; +} + /* EXTPROTO */ char * rxvt_strdup (const char *str) diff --git a/src/ptytty.C b/src/ptytty.C index e982b77d..2ee5b8f1 100644 --- a/src/ptytty.C +++ b/src/ptytty.C @@ -32,9 +32,9 @@ #endif #endif -#include +#include #ifdef HAVE_STDLIB_H -# include +# include #endif #ifdef HAVE_SYS_TYPES_H # include @@ -43,7 +43,7 @@ # include #endif #if defined(HAVE_STRING_H) -# include +# include #endif #ifdef HAVE_FCNTL_H # include diff --git a/src/rxvt.h b/src/rxvt.h index d31f1686..33940a6b 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -15,8 +15,6 @@ #include "iom.h" #include "salloc.h" -#include - /* ***************************************************************************** * SYSTEM HACKS @@ -360,33 +358,34 @@ enum { XTerm_name = 0, XTerm_iconName = 1, XTerm_title = 2, - XTerm_property = 3, /* change X property, not yet implemented */ - XTerm_Color = 4, /* change colors */ - XTerm_Color00 = 10, /* not implemented, CLASH! */ - XTerm_Color01 = 11, /* not implemented */ - XTerm_Color_cursor = 12, /* change actual 'Cursor' color */ - XTerm_Color_pointer = 13, /* change actual 'Pointer' color */ - XTerm_Color04 = 14, /* not implemented */ - XTerm_Color05 = 15, /* not implemented */ - XTerm_Color06 = 16, /* not implemented */ - XTerm_Color_RV = 17, /* change actual 'Highlight' color */ - XTerm_logfile = 46, /* not implemented */ + XTerm_property = 3, // change X property, not yet implemented + XTerm_Color = 4, // change colors + XTerm_Color00 = 10, // not implemented, CLASH! + XTerm_Color01 = 11, // not implemented + XTerm_Color_cursor = 12, // change actual 'Cursor' color + XTerm_Color_pointer = 13, // change actual 'Pointer' color + XTerm_Color04 = 14, // not implemented + XTerm_Color05 = 15, // not implemented + XTerm_Color06 = 16, // not implemented + XTerm_Color_RV = 17, // change actual 'Highlight' color + XTerm_logfile = 46, // not implemented XTerm_font = 50, - XTerm_konsole30 = 30, /* reserved for konsole */ - XTerm_konsole31 = 31, /* reserved for konsole */ - XTerm_emacs51 = 51, /* reserved for emacs shell */ + XTerm_konsole30 = 30, // reserved for konsole + XTerm_konsole31 = 31, // reserved for konsole + XTerm_emacs51 = 51, // reserved for emacs shell /* * rxvt extensions of XTerm OSCs: ESC ] Ps;Pt (ST|BEL) */ - XTerm_locale = 9, /* change locale */ - XTerm_Menu = 10, /* set menu item */ - XTerm_Color_BD = 18, /* change actual 'Bold' color */ - XTerm_Color_UL = 19, /* change actual 'Underline' color */ - XTerm_Pixmap = 20, /* new bg pixmap */ - XTerm_restoreFG = 39, /* change default fg color */ - XTerm_restoreBG = 49, /* change default bg color */ - XTerm_dumpscreen = 55, /* dump scrollback and all of screen */ + XTerm_Menu = 10, // set menu item + XTerm_Color_BD = 18, // change actual 'Bold' color + XTerm_Color_UL = 19, // change actual 'Underline' color + XTerm_Pixmap = 20, // new bg pixmap + XTerm_restoreFG = 39, // change default fg color + XTerm_restoreBG = 49, // change default bg color + XTerm_dumpscreen = 55, // dump scrollback and all of screen + XTerm_locale = 701, // change locale + XTerm_findfont = 702, // find font of given character (in decimal) }; /* Words starting with `Color_' are colours. Others are counts */ @@ -833,8 +832,46 @@ struct mbstate { mbstate () { reset (); } }; +#if UNICODE3 +# define COMPOSE_LO 0x40000000UL +# define COMPOSE_HI 0x400fffffUL +# define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) +#else +# define COMPOSE_LO 0xd800UL +# define COMPOSE_HI 0xf8ffUL // dfff should be safer, but... +# define IS_COMPOSE(n) (COMPOSE_LO <= (n) && (n) <= COMPOSE_HI) +#endif + +#if ENCODING_COMPOSE +// compose chars are used to represent composite characters +// that are not representable in unicode, as well as characters +// not fitting in the BMP. +struct compose_char { + uint32_t c1, c2; // any chars != NOCHAR are valid + compose_char (uint32_t c1, uint32_t c2) + : c1(c1), c2(c2) + { } +}; + +class rxvt_composite_vec { + vector v; +public: + text_t compose (uint32_t c1, uint32_t c2 = NOCHAR); + int expand (uint32_t c, wchar_t *r); + compose_char *operator [](text_t c) + { + return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () + ? &v[c - COMPOSE_LO] + : 0; + } +}; + +extern class rxvt_composite_vec rxvt_composite; +#endif + + struct rxvt_term : rxvt_vars { - struct mbstate mbstate; + struct mbstate mbstate; unsigned char want_refresh:1, #ifdef TRANSPARENT diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index dcce4663..2d1157cf 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -1,9 +1,9 @@ #ifndef _RXVTLIB_H_ /* include once only */ #define _RXVTLIB_H_ -#include -#include -#include +#include +#include +#include @include_stdarg_h@ @include_stdlib_h@ @include_stdint_h@ @@ -22,6 +22,8 @@ #include #include +#include + extern "C" { #include /* Xlib, Xutil, Xresource, Xfuncproto */ } @@ -63,7 +65,7 @@ typedef struct { int32_t col; } row_col_t; -#if UNICODE3 +#if UNICODE_3 typedef uint32_t text_t; #else typedef uint16_t text_t; // saves lots of memory @@ -159,7 +161,7 @@ enum selection_op_t { }; typedef struct { - unsigned char *text; /* selected text */ + wchar_t *text; /* selected text */ uint32_t len; /* length of selected text */ short screen; /* screen being used */ short clicks; /* number of clicks */ -- 2.34.1