add a short test program. use hard values instead of GDK defines in the 0
authorNalin Dahyabhai <nalin@src.gnome.org>
Sat, 14 Dec 2002 00:40:53 +0000 (00:40 +0000)
committerNalin Dahyabhai <nalin@src.gnome.org>
Sat, 14 Dec 2002 00:40:53 +0000 (00:40 +0000)
* src/buffer.c: add a short test program.
* src/iso2022.c: use hard values instead of GDK defines in the 0 map.  Add
_vte_iso2022_substitute_single() for performing a single mapping
operation.
* src/vte.c: use _vte_iso2022_substitute_single() instead of a local mapping
table when mapping line-drawing charset data, simplifies maintenance
of the mapping.

ChangeLog
README
src/Makefile.am
src/buffer.c
src/buffer.h
src/iso2022.c
src/iso2022.h
src/vte.c
vte.spec

index 36fcc46..09071f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-12-13  nalin
+       * src/buffer.c: add a short test program.
+       * src/iso2022.c: use hard values instead of GDK defines in the 0 map.
+       Add _vte_iso2022_substitute_single() for performing a single mapping
+       operation.
+       * src/vte.c: use _vte_iso2022_substitute_single() instead of a local
+       mapping table when mapping line-drawing charset data, simplifies        
+       maintenance of the mapping.
+
 2002-12-12  Pablo Saratxaga <pablo@mandrakesoft.com>
        * configure.in: Added Catalan (ca), Spanish (es)
        and Hebrew (he) to ALL_LINGUAS
@@ -29,7 +38,7 @@
        trying to run it, to avoid SIGPIPE failures when it's not installed.
        * src/vte.c: never grab focus -- let the shell app deal with it.
        Return TRUE from mouse motion and press/release events to keep them
-       from being passed up.
+       from being passed up. (#101089)
 
 2002-12-09  nalin
        * configure.in: add "uk" to the list of languages.
diff --git a/README b/README
index f1c8b68..a7caa5f 100644 (file)
--- a/README
+++ b/README
@@ -59,3 +59,7 @@
   http://www.debian.org/doc/manuals/intro-i18n/ch-output.en.html
 - Depending on your locale, the current encoding, and possibly the strengh
   of cosmic rays, the display width of certain Unicode characters changes.
+  For the most part this works correctly now, but if you find that it
+  doesn't, please file a bug report including a screenshot, the typescript
+  file produced by the incorrectly displayed program run under "script", and
+  the contents of your LANG environment variable.
index 99ede62..537c2af 100644 (file)
@@ -3,7 +3,7 @@ pkginclude_HEADERS = pty.h reaper.h vte.h vteaccess.h
 lib_LTLIBRARIES = libvte.la
 pkglib_PROGRAMS = interpret utf8echo nativeecho utf8mode iso8859mode slowcat
 pkglib_SCRIPTS = decset osc window
-noinst_PROGRAMS = dumpkeys iso2022 pty reaper ring table termcap trie
+noinst_PROGRAMS = buffer dumpkeys iso2022 pty reaper ring table termcap trie
 EXTRA_DIST = \
        $(pkglib_SCRIPTS) \
        genkeysyms.py \
@@ -182,6 +182,10 @@ reaper_SOURCES = \
        reaper.h
 reaper_LDADD = @LIBS@ @GOBJECT_LIBS@
 
+buffer_CFLAGS = @CFLAGS@ -DBUFFER_MAIN
+buffer_SOURCES = buffer.c
+buffer_LDADD = @GOBJECT_LIBS@
+
 dumpkeys_CFLAGS = @CFLAGS@
 dumpkeys_SOURCES = dumpkeys.c
 dumpkeys_LDADD = @LIBS@ @GOBJECT_LIBS@
index 82fbe75..d4ae286 100644 (file)
@@ -38,6 +38,9 @@ static void
 _vte_buffer_check(struct _vte_buffer *buffer, size_t length)
 {
        struct _vte_real_buffer *buf = (struct _vte_real_buffer*) buffer;
+       if (length > 0) {
+               g_assert(buf->bytes != NULL);
+       }
        g_assert(buf->buf_length >= length);
        g_assert(buf->buf_length >= buf->buf_used);
 }
@@ -273,6 +276,13 @@ _vte_buffer_append_buffer(struct _vte_buffer *buffer, struct _vte_buffer *s)
        _vte_buffer_append(buffer, buf->bytes, buf->buf_used);
 }
 
+void
+_vte_buffer_append_buffer_contents(struct _vte_buffer *buffer,
+                                  struct _vte_buffer *s)
+{
+       _vte_buffer_append(buffer, s->bytes, _vte_buffer_length(s));
+}
+
 struct _vte_buffer *
 _vte_buffer_peek_buffer(struct _vte_buffer *buffer)
 {
@@ -295,3 +305,96 @@ _vte_buffer_read_buffer(struct _vte_buffer *buffer)
        _vte_buffer_consume(buffer, i);
        return ret;
 }
+
+#ifdef BUFFER_MAIN
+int
+main(int argc, char **argv)
+{
+       struct _vte_buffer *buffer, *tmp;
+       GString *string;
+       guint16 i16 = 0x1632;
+       guint32 i32 = 0x20406080;
+
+       string = g_string_new("Hello!");
+       buffer = _vte_buffer_new();
+       _vte_buffer_append_guint16(buffer, i16);
+       _vte_buffer_append_guint32(buffer, i32);
+       _vte_buffer_append_gstring(buffer, string);
+       tmp = _vte_buffer_new();
+       _vte_buffer_append_buffer_contents(tmp, buffer);
+       _vte_buffer_append_buffer(tmp, buffer);
+
+       /* Check the original buffer. */
+       i16 = _vte_buffer_peek_guint16(buffer);
+       g_print("%x ", i16);
+       i16 = _vte_buffer_read_guint16(buffer);
+       g_print("%x ", i16);
+       i32 = _vte_buffer_peek_guint32(buffer);
+       g_print("%x ", i32);
+       i32 = _vte_buffer_read_guint32(buffer);
+       g_print("%x ", i32);
+       string = _vte_buffer_peek_gstring(buffer);
+       g_print("'%s' ", string->str);
+       g_string_free(string, TRUE);
+       string = _vte_buffer_read_gstring(buffer);
+       g_print("'%s'\n", string->str);
+       g_string_free(string, TRUE);
+       _vte_buffer_free(buffer);
+
+       /* Check the first copy in the new buffer. */
+       i16 = _vte_buffer_peek_guint16(tmp);
+       g_print("%x ", i16);
+       i16 = _vte_buffer_read_guint16(tmp);
+       g_print("%x ", i16);
+       i32 = _vte_buffer_peek_guint32(tmp);
+       g_print("%x ", i32);
+       i32 = _vte_buffer_read_guint32(tmp);
+       g_print("%x ", i32);
+       string = _vte_buffer_peek_gstring(tmp);
+       g_print("'%s' ", string->str);
+       g_string_free(string, TRUE);
+       string = _vte_buffer_read_gstring(tmp);
+       g_print("'%s'\n", string->str);
+       g_string_free(string, TRUE);
+
+       /* Peek at the second copy in the new buffer. */
+       buffer = _vte_buffer_peek_buffer(tmp);
+       i16 = _vte_buffer_peek_guint16(buffer);
+       g_print("%x ", i16);
+       i16 = _vte_buffer_read_guint16(buffer);
+       g_print("%x ", i16);
+       i32 = _vte_buffer_peek_guint32(buffer);
+       g_print("%x ", i32);
+       i32 = _vte_buffer_read_guint32(buffer);
+       g_print("%x ", i32);
+       string = _vte_buffer_peek_gstring(buffer);
+       g_print("'%s' ", string->str);
+       g_string_free(string, TRUE);
+       string = _vte_buffer_read_gstring(buffer);
+       g_print("'%s'\n", string->str);
+       g_string_free(string, TRUE);
+       _vte_buffer_free(buffer);
+
+       /* Check the second copy in the new buffer. */
+       buffer = _vte_buffer_read_buffer(tmp);
+       i16 = _vte_buffer_peek_guint16(buffer);
+       g_print("%x ", i16);
+       i16 = _vte_buffer_read_guint16(buffer);
+       g_print("%x ", i16);
+       i32 = _vte_buffer_peek_guint32(buffer);
+       g_print("%x ", i32);
+       i32 = _vte_buffer_read_guint32(buffer);
+       g_print("%x ", i32);
+       string = _vte_buffer_peek_gstring(buffer);
+       g_print("'%s' ", string->str);
+       g_string_free(string, TRUE);
+       string = _vte_buffer_read_gstring(buffer);
+       g_print("'%s'\n", string->str);
+       g_string_free(string, TRUE);
+       _vte_buffer_free(buffer);
+
+       _vte_buffer_free(tmp);
+
+       return 0;
+}
+#endif
index 592934e..5f52d21 100644 (file)
@@ -62,6 +62,8 @@ GString * _vte_buffer_read_gstring(struct _vte_buffer *buffer);
 
 void _vte_buffer_append_buffer(struct _vte_buffer *buffer,
                               struct _vte_buffer *s);
+void _vte_buffer_append_buffer_contents(struct _vte_buffer *buffer,
+                                       struct _vte_buffer *s);
 struct _vte_buffer *_vte_buffer_peek_buffer(struct _vte_buffer *buffer);
 struct _vte_buffer *_vte_buffer_read_buffer(struct _vte_buffer *buffer);
 
index 547f89c..f048a24 100644 (file)
@@ -57,8 +57,8 @@ static const struct _vte_iso2022_map _vte_iso2022_map_0[] = {
        {'c', 0x240c},  /* FF symbol */
        {'d', 0x240d},  /* CR symbol */
        {'e', 0x240a},  /* LF symbol */
-       {'f', GDK_degree},      /* degree */
-       {'g', GDK_plusminus},   /* plus/minus */
+       {'f', 0x00b0},  /* degree */
+       {'g', 0x00b1},  /* plus/minus */
        {'h', 0x2424},  /* NL symbol */
        {'i', 0x240b},  /* VT symbol */
        {'j', 0x2518},  /* downright corner */
@@ -448,10 +448,45 @@ _vte_iso2022_set_width(gunichar c, gssize width)
        return c;
 }
 
+gunichar
+_vte_iso2022_substitute_single(gunichar mapname, gunichar c)
+{
+       GTree *charmap;
+       gunichar result = c;
+       gssize width;
+       charmap = _vte_iso2022_map_get(mapname);
+       if (charmap) {
+               c = GPOINTER_TO_INT(g_tree_lookup(charmap, GINT_TO_POINTER(c)));
+               if (c != 0) {
+                       result = c;
+               }
+       }
+       /* Calculate width for ambiguous characters. */
+       switch (result) {
+               /* To be filled in some time, I guess. */
+       default:
+               /* For nonambiguous characters, just use
+                * the width glib has later on. */
+               width = 0;
+               break;
+       }
+       /* Override for drawing characters. */
+       if (mapname == '0') {
+               if ((result >= 0x2500) && (result <= 0x257f)) {
+                       width = 1;
+               }
+       }
+       /* Save the width if one was set. */
+       if (width != 0) {
+               result = _vte_iso2022_set_width(result, width);
+       }
+       return result;
+}
+
 gssize
 _vte_iso2022_substitute(struct _vte_iso2022 *outside_state,
-                      gunichar *instring, gssize length,
-                      gunichar *outstring, struct _vte_matcher *specials)
+                       gunichar *instring, gssize length,
+                       gunichar *outstring, struct _vte_matcher *specials)
 {
        int i, j, k, g;
        struct _vte_iso2022 state;
index 19a634d..cd0e9fc 100644 (file)
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 struct _vte_iso2022 *_vte_iso2022_new(void);
 struct _vte_iso2022 *_vte_iso2022_copy(struct _vte_iso2022 *original);
 void _vte_iso2022_free(struct _vte_iso2022 *p);
+gunichar _vte_iso2022_substitute_single(gunichar mapname, gunichar c);
 gssize _vte_iso2022_substitute(struct _vte_iso2022 *state,
                               gunichar *instring, gssize length,
                               gunichar *outstring,
index fc73df2..58334f9 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -6142,141 +6142,12 @@ vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
                                "for 0x%04x.\n", c);
                }
 #endif
-               switch (c) {
-               case 95:
-                       c = 0x0020; /* empty space */
-                       forced_width = 1;
-                       break;
-               case 96:
-                       c = 0x25c6; /* diamond */
-                       forced_width = 1;
-                       break;
-               case 'a':
-                       c = 0x2592; /* checkerboard */
-                       forced_width = 1;
-                       break;
-               case 'b':
-                       c = 0x2409; /* ht */
-                       forced_width = 1;
-                       break;
-               case 'c':
-                       c = 0x240c; /*  ff */
-                       forced_width = 1;
-                       break;
-               case 'd':
-                       c = 0x240d; /* cr */
-                       forced_width = 1;
-                       break;
-               case 'e':
-                       c = 0x240a; /* lf */
-                       forced_width = 1;
-                       break;
-               case 'f':
-                       c = 0x00b0; /* degree */
-                       forced_width = 1;
-                       break;
-               case 'g':
-                       c = 0x00b1; /* plus/minus */
+               /* See if there's a mapping for it, and if there is, force
+                * the result's width to 1. */
+               cell.c = _vte_iso2022_substitute_single('0', c);
+               if (cell.c != c) {
+                       c = cell.c & ~(VTE_ISO2022_WIDTH_MASK);
                        forced_width = 1;
-                       break;
-               case 'h':
-                       c = 0x2424; /* nl */
-                       forced_width = 1;
-                       break;
-               case 'i':
-                       c = 0x240b; /* vt */
-                       forced_width = 1;
-                       break;
-               case 'j':
-                       c = 0x2518; /* downright corner */
-                       forced_width = 1;
-                       break;
-               case 'k':
-                       c = 0x2510; /* upright corner */
-                       forced_width = 1;
-                       break;
-               case 'l':
-                       c = 0x250c; /* upleft corner */
-                       forced_width = 1;
-                       break;
-               case 'm':
-                       c = 0x2514; /* downleft corner */
-                       forced_width = 1;
-                       break;
-               case 'n':
-                       c = 0x253c; /* cross */
-                       forced_width = 1;
-                       break;
-               case 'o':
-                       c = 0x23ba; /* scanline 1/9 */
-                       forced_width = 1;
-                       break;
-               case 'p':
-                       c = 0x23bb; /* scanline 3/9 */
-                       forced_width = 1;
-                       break;
-               case 'q':
-                       c = 0x2500; /* horizontal line */
-                       forced_width = 1;
-                       break;
-               case 'r':
-                       c = 0x23bc; /* scanline 7/9 */
-                       forced_width = 1;
-                       break;
-               case 's':
-                       c = 0x23bd; /* scanline 9/9 */
-                       forced_width = 1;
-                       break;
-               case 't':
-                       c = 0x251c; /* left t (points right) */
-                       forced_width = 1;
-                       break;
-               case 'u':
-                       c = 0x2524; /* right t (points left) */
-                       forced_width = 1;
-                       break;
-               case 'v':
-                       c = 0x2534; /* bottom tee (points up) */
-                       forced_width = 1;
-                       break;
-               case 'w':
-                       c = 0x252c; /* top tee (points down) */
-                       forced_width = 1;
-                       break;
-               case 'x':
-                       c = 0x2502; /* vertical line */
-                       forced_width = 1;
-                       break;
-               case 'y':
-                       c = 0x2264; /* <= */
-                       forced_width = 1;
-                       break;
-               case 'z':
-                       c = 0x2265; /* >= */
-                       forced_width = 1;
-                       break;
-               case '{':
-                       c = 0x03c0; /* pi */
-                       forced_width = 1;
-                       break;
-               case '|':
-                       c = 0x2260; /* != */
-                       forced_width = 1;
-                       break;
-               case '}':
-                       c = 0x00a3; /* british pound */
-                       forced_width = 1;
-                       break;
-               case '~':
-                       c = 0x00b7; /* bullet */
-                       forced_width = 1;
-                       break;
-               case 127:
-                                 ; /* delete */
-                       forced_width = 1;
-                       break;
-               default:
-                       break;
                }
        }
 
index 182a415..528c4fc 100644 (file)
--- a/vte.spec
+++ b/vte.spec
@@ -1,6 +1,6 @@
 Name: vte
 Version: 0.10.7
-Release: 1
+Release: 2
 Summary: An experimental terminal emulator.
 License: LGPL
 Group: User Interface/X
@@ -93,6 +93,9 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/python*/site-packages/*.a
 %{_libdir}/pkgconfig/*
 
 %changelog
+* Fri Dec 13 2002 Nalin Dahyabhai <nalin@redhat.com> 0.10.7-2
+- rebuild
+
 * Wed Dec 11 2002 Nalin Dahyabhai <nalin@redhat.com> 0.10.7-1
 - distinguish line-drawing character set code points from the same code points
   received from the local encoding