[vte] Revert "all: Use terminfo instead of termcap"



commit d201742f47d85049eb3e0dd1d2489bbd01ba642c
Author: Christian Persch <chpe gnome org>
Date:   Thu Apr 24 20:04:41 2014 +0200

    Revert "all: Use terminfo instead of termcap"
    
    This reverts commit a65aae3bb5cb140a8cf5b6bdda2a5b333c574502.

 Makefile.am              |    2 +-
 configure.ac             |   54 ++-
 src/Makefile.am          |  147 ++-----
 src/app.vala             |    8 +-
 src/caps.c               |  355 +++++++++++++++++
 src/caps.h               |   10 +
 src/interpret.c          |   18 +-
 src/iso2022.c            |    2 +-
 src/keymap.c             |  297 +++++++++-----
 src/keymap.h             |    6 +-
 src/matcher.c            |  146 +++----
 src/matcher.h            |    5 +-
 src/table.c              |    2 +-
 src/vte-private.h        |    6 +-
 src/vte.c                |  112 +++---
 src/vte.gresource.xml.in |    3 +
 src/vteconv.c            |    7 +-
 src/vteseq.c             |   73 ++--
 src/vtetc.c              |  648 +++++++++++++++++++++++++++++++
 src/vtetc.h              |   59 +++
 src/vteti.c              |  628 ------------------------------
 src/vteti.h              |   94 -----
 src/vtetivars.awk        |   83 ----
 src/vtetivars.h          |  966 ----------------------------------------------
 termcaps/Makefile.am     |    4 +
 termcaps/xterm           |   33 ++
 termcaps/xterm-color     |   27 ++
 termcaps/xterm.baseline  |   35 ++
 28 files changed, 1639 insertions(+), 2191 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 07b86b3..2fd1ed9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
 
-SUBDIRS = src po doc perf
+SUBDIRS = src termcaps po doc perf
 
 EXTRA_DIST = \
        MAINTAINERS \
diff --git a/configure.ac b/configure.ac
index 65e19c6..8b03f43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,6 +171,8 @@ GLIB_REQUIRED=2.40.0
 GIO_REQUIRED=2.40.0
 PANGO_REQUIRED=1.22.0
 AC_DEFINE(GDK_MULTIHEAD_SAFE,1,[Force use of GDK multihead-safe APIs.])
+PKG_CHECK_MODULES(GLIB,[glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gio-2.0 >= $GIO_REQUIRED])
+PKG_CHECK_MODULES(GTK,[glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gio-2.0 >= $GIO_REQUIRED gtk+-$GTK_API_VERSION 
= $GTK_REQUIRED])
 
 AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal])
 AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
@@ -209,24 +211,52 @@ fi
 AC_CHECK_FUNC(floor,,AC_CHECK_LIB(m,floor,LIBS=["$LIBS -lm"]))
 AC_CHECK_FUNCS([ceil floor round])
 
+# Look for tgetent
+
+AC_CHECK_FUNC([tgetent],[vte_cv_termcap_lib=libc],
+  [AC_CHECK_LIB([ncurses],[tgetent],[vte_cv_termcap_lib=libncurses],
+    [AC_CHECK_LIB([tinfo],[tgetent],[vte_cv_termcap_lib=libtinfo],
+      [AC_CHECK_LIB([curses],[tgetent],[vte_cv_termcap_lib=libcurses],
+        [AC_CHECK_LIB([termcap],[tgetent],[vte_cv_termcap_lib=libtermcap],
+          [vte_cv_termcap_lib=])])])])])
+
+case "$vte_cv_termcap_lib" in
+  libc)       # FIXME: which headers to include here?
+              ;;
+  libncurses) # We need ncurses.h and term.h, or ncurses/curses.h and ncurses/term.h
+              AC_CHECK_HEADERS([ncurses.h term.h],[],
+                [AC_CHECK_HEADERS([ncurses/curses.h ncurses/term.h],[],
+                  [AC_MSG_ERROR([ncurses headers not found])])])
+              LIBS="-lncurses $LIBS"
+              ;;
+  libtinfo)   # Need ncurses/curses.h and ncurses/term.h
+              AC_CHECK_HEADERS([ncurses.h term.h],[],
+                [AC_CHECK_HEADERS([ncurses/curses.h ncurses/term.h],[],
+                  [AC_MSG_ERROR([ncurses headers not found])])])
+              LIBS="-ltinfo $LIBS"
+              ;;
+  libcurses)  # Need curses.h and term.h
+              AC_CHECK_HEADERS([curses.h term.h],[],
+                [AC_MSG_ERROR([curses headers not found])],
+                [[#ifdef HAVE_CURSES_H
+                  #include <curses.h>
+                  #endif]])
+              LIBS="-lcurses $LIBS"
+              ;;
+  libtermcap) # Need termcap.h
+              AC_CHECK_HEADERS([termcap.h],[],
+                [AC_MSG_ERROR([termcap headers not found])])
+              LIBS="-ltermcap $LIBS"
+              ;;
+  *)          AC_MSG_ERROR([tgetent not found in any library]) ;;
+esac
+
 # Search for the required modules.
 
 VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$GTK_API_VERSION >= 
$GTK_REQUIRED gobject-2.0 gio-2.0 gio-unix-2.0"
 PKG_CHECK_MODULES([VTE],[$VTE_PKGS])
 AC_SUBST([VTE_PKGS])
 
-PKG_CHECK_MODULES([TERMINFO],[tinfo])
-PKG_CHECK_MODULES([GLIB],[glib-2.0 >= $GLIB_REQUIRED])
-PKG_CHECK_MODULES([GOBJECT],[gobject-2.0])
-PKG_CHECK_MODULES([GTK],[gtk+-$GTK_API_VERSION >= $GTK_REQUIRED])
-
-# terminfo
-
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $TERMINFO_CFLAGS"
-AC_CHECK_HEADERS([ncurses.h term.h tic.h],[],[AC_MSG_ERROR([ncurses terminfo headers not found])])
-CFLAGS="$save_CFLAGS"
-
 wcs_funcs_includes="
 #ifdef HAVE_STRING_H
 # if !STDC_HEADERS && HAVE_MEMORY_H
diff --git a/src/Makefile.am b/src/Makefile.am
index b9094a4..b119dde 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,11 +1,9 @@
+
+EXTRA_DIST = iso2022.txt
+
 bin_PROGRAMS =
 noinst_PROGRAMS =
 
-CLEANFILES =
-DISTCLEANFILES =
-MAINTAINERCLEANFILES =
-EXTRA_DIST =
-
 # The library
 
 headerdir = $(includedir)/vte-$(VTE_API_VERSION)/vte
@@ -75,9 +73,8 @@ libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_SOURCES = \
        vtestream.h \
        vtestream-base.h \
        vtestream-file.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
+       vtetc.c \
+       vtetc.h \
        vtetree.c \
        vtetree.h \
        vtetypebuiltins.c \
@@ -99,28 +96,22 @@ libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_CPPFLAGS = \
        -DVTE_COMPILATION \
        $(AM_CPPFLAGS)
 
-libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_CFLAGS = \
-       $(VTE_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-
+libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_CFLAGS = $(VTE_CFLAGS) $(AM_CFLAGS)
+libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LIBADD = $(VTE_LIBS)
 libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LDFLAGS = \
        $(VTE_LDFLAGS) \
        -version-info $(LT_VERSION_INFO) \
        -export-symbols-regex "^vte_.*" \
        $(AM_LDFLAGS)
 
-libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LIBADD = \
-       $(VTE_LIBS) \
-       $(TERMINFO_LIBS)
 
 # Generated sources
 
 VTESEQ_BUILTSOURCES = vteseq-list.h vteseq-2.c vteseq-n.c
 BUILT_SOURCES = box_drawing.h marshal.c marshal.h vtetypebuiltins.c vtetypebuiltins.h vteresources.c 
$(VTESEQ_BUILTSOURCES)
-MAINTAINERCLEANFILES+ = $(VTESEQ_BUILTSOURCES)
-EXTRA_DIST += $(VTESEQ_BUILTSOURCES) box_drawing.txt iso2022.txt vtetivars.awk
-CLEANFILES += box_drawing.h marshal.c marshal.h vtetypebuiltins.c vtetypebuiltins.h stamp-vtetypebuiltins.h 
vteresources.c
+MAINTAINERCLEANFILES = $(VTESEQ_BUILTSOURCES)
+EXTRA_DIST += $(VTESEQ_BUILTSOURCES) box_drawing.txt
+CLEANFILES = box_drawing.h marshal.c marshal.h vtetypebuiltins.c vtetypebuiltins.h stamp-vtetypebuiltins.h 
vteresources.c
 
 box_drawing.h: box_drawing.txt
        $(AM_V_GEN) $(srcdir)/box_drawing_generate.sh < $< > $@
@@ -160,10 +151,6 @@ vteseq-list.h: vteseq-2.gperf vteseq-n.gperf
 vteresources.c: vte.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies 
vte.gresource.xml)
        $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir . --generate --c-name vte $<
 
-vtetivars.h: vtetivars.awk
-       $(AM_V_GEN) $(top_srcdir)/missing --run gawk -f $< Caps > $  tmp && \
-       mv -f $  tmp $@
-
 # introspection
 
 INTROSPECTION_GIRS =
@@ -295,16 +282,16 @@ TEST_SH = \
        $(NULL)
 EXTRA_DIST += $(TEST_SH)
 
-check_PROGRAMS = dumpkeys iso2022 reflect-text-view reflect-vte mev table trie xticker vteconv vteti
+check_PROGRAMS = dumpkeys iso2022 reflect-text-view reflect-vte mev table trie xticker vteconv vtetc
 TESTS = table trie $(TEST_SH)
 
-reflect_text_view_CPPFLAGS = -DUSE_TEXT_VIEW $(AM_CPPFLAGS)
-reflect_text_view_CFLAGS = $(VTE_CFLAGS) $(AM_CFLAGS)
+reflect_text_view_CPPFLAGS = -DUSE_TEXT_VIEW
+reflect_text_view_CFLAGS = $(VTE_CFLAGS)
 reflect_text_view_SOURCES = reflect.c
 reflect_text_view_LDADD = $(VTE_LIBS)
 
-reflect_vte_CPPFLAGS = -DUSE_VTE $(AM_CPPFLAGS)
-reflect_vte_CFLAGS = $(VTE_CFLAGS) $(AM_CFLAGS)
+reflect_vte_CPPFLAGS = -DUSE_VTE
+reflect_vte_CFLAGS = $(VTE_CFLAGS)
 reflect_vte_SOURCES = reflect.c
 reflect_vte_LDADD = libvte-$(VTE_API_VERSION).la $(VTE_LIBS)
 
@@ -324,9 +311,9 @@ interpret_SOURCES = \
        trie.h \
        vteconv.c \
        vteconv.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
+       vteresources.c \
+       vtetc.c \
+       vtetc.h \
        vtetree.c \
        vtetree.h \
        interpret.c
@@ -334,16 +321,8 @@ interpret_CPPFLAGS = \
        -DINTERPRET_MAIN \
        -DVTE_API_VERSION=\"$(VTE_API_VERSION)\" \
        $(AM_CPPFLAGS)
-interpret_CFLAGS = \
-       $(GLIB_CFLAGS) \
-       $(GOBJECT_CFLAGS) \
-       $(GTK_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-interpret_LDADD = \
-       $(GLIB_LIBS) \
-       $(GOBJECT_LIBS) \
-       $(TERMINFO_LIBS)
+interpret_CFLAGS = $(GTK_CFLAGS)
+interpret_LDADD = $(GTK_LIBS)
 
 iso2022_SOURCES = \
        buffer.h \
@@ -361,23 +340,13 @@ iso2022_SOURCES = \
        trie.h \
        vteconv.c \
        vteconv.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
+       vtetc.c \
+       vtetc.h \
        vtetree.c \
        vtetree.h
-iso2022_CPPFLAGS = \
-       -DISO2022_MAIN \
-       $(AM_CPPFLAGS)
-iso2022_CFLAGS = \
-       $(GLIB_CFLAGS) \
-       $(GTK_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-iso2022_LDADD = \
-       $(GLIB_LIBS) \
-       $(GOBJECT_LIBS) \
-       $(TERMINFO_LIBS)
+iso2022_CPPFLAGS = -DISO2022_MAIN
+iso2022_CFLAGS = $(GTK_CFLAGS)
+iso2022_LDADD = $(GTK_LIBS)
 
 slowcat_SOURCES = \
        slowcat.c \
@@ -399,21 +368,11 @@ table_SOURCES = \
        trie.h \
        vteconv.c \
        vteconv.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
-       $(NULL)
-table_CPPFLAGS = \
-       -DTABLE_MAIN \
-       $(AM_CPPFLAGS)
-table_CFLAGS = \
-       $(GLIB_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-table_LDADD = \
-       $(GLIB_LIBS) \
-       $(GOBJECT_LIBS) \
-       $(TERMINFO_LIBS)
+       vtetc.c \
+       vtetc.h
+table_CPPFLAGS = -DTABLE_MAIN
+table_CFLAGS = $(VTE_CFLAGS)
+table_LDADD = $(VTE_LIBS)
 
 trie_SOURCES = \
        trie.c \
@@ -429,44 +388,18 @@ trie_SOURCES = \
        table.h \
        vteconv.c \
        vteconv.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
-       $(NULL)
-trie_CPPFLAGS = \
-       -DTRIE_MAIN \
-       $(AM_CPPFLAGS)
-trie_CFLAGS = \
-       $(GLIB_CFLAGS) \
-       $(GOBJECT_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-trie_LDADD = \
-       $(GLIB_LIBS) \
-       $(GOBJECT_LIBS) \
-       $(TERMINFO_LIBS)
-
-vteti_SOURCES = \
-       debug.c \
-       debug.h \
-       vteti.c \
-       vteti.h \
-       vtetivars.h \
-       $(NULL)
-vteti_CPPFLAGS = \
-       -DTERMINFO_MAIN \
-       $(AM_CPPFLAGS)
-vteti_CFLAGS = \
-       $(GLIB_CFLAGS) \
-       $(TERMINFO_CFLAGS) \
-       $(AM_CFLAGS)
-vteti_LDADD = \
-       $(GLIB_LIBS) \
-       $(TERMINFO_LIBS)
+       vtetc.c \
+       vtetc.h 
+trie_CPPFLAGS = -DTRIE_MAIN
+trie_CFLAGS = $(VTE_CFLAGS)
+trie_LDADD = $(VTE_LIBS)
+
+vtetc_SOURCES = vtetc.c vtetc.h debug.c debug.h
+vtetc_CPPFLAGS = -DTERMCAP_MAIN
 
 vteconv_SOURCES = buffer.h debug.c debug.h vteconv.c vteconv.h
-vteconv_CPPFLAGS = -DVTECONV_MAIN $(AM_CPPFLAGS)
-vteconv_CFLAGS = $(VTE_CFLAGS) $(AM_CFLAGS)
+vteconv_CPPFLAGS = -DVTECONV_MAIN
+vteconv_CFLAGS = $(VTE_CFLAGS)
 vteconv_LDADD = $(VTE_LIBS)
 
 dumpkeys_SOURCES = dumpkeys.c
diff --git a/src/app.vala b/src/app.vala
index 66938cd..21cb2d4 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -102,8 +102,8 @@ class Window : Gtk.ApplicationWindow
                if (App.Options.no_double_buffer)
                        terminal.set_double_buffered(true);
 
-               if (App.Options.term != null)
-                       terminal.set_emulation(App.Options.term);
+               if (App.Options.termcap != null)
+                       terminal.set_emulation(App.Options.termcap);
                if (App.Options.encoding != null)
                        terminal.set_encoding(App.Options.encoding);
 
@@ -562,7 +562,7 @@ class App : Gtk.Application
                private static string? pty_flags_string = null;
                public static bool reverse = false;
                public static int scrollback_lines = 512;
-               public static string? term = null;
+               public static string? termcap = null;
                public static int transparency_percent = 0;
                public static bool version = false;
                public static string? working_directory = null;
@@ -755,7 +755,7 @@ class App : Gtk.Application
                          "Reverse foreground/background colors", null },
                        { "scrollback-lines", 'n', 0, OptionArg.INT, ref scrollback_lines,
                          "Specify the number of scrollback-lines", null },
-                       { "term", 't', 0, OptionArg.STRING, ref term,
+                       { "termcap", 't', 0, OptionArg.STRING, ref termcap,
                          "Specify the terminal emulation to use", null },
                        { "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
                          "Enable the use of a transparent background", "0..100" },
diff --git a/src/caps.c b/src/caps.c
index acc34bc..137cea5 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -39,6 +39,327 @@
 #define SO  "\016"
 #define SI  "\017"
 
+/* This list combined from the Linux termcap(5) man page, and
+ * termcap_&_terminfo by Strang, Mui, and O'Reilly. */
+struct _vte_capability_quark _vte_terminal_capability_strings[] = {
+       {"!1", TRUE, 0},
+       {"!2", TRUE, 0},
+       {"!3", TRUE, 0},
+
+       {"#1", TRUE, 0},
+       {"#2", TRUE, 0},
+       {"#3", TRUE, 0},
+       {"#4", TRUE, 0},
+
+       {"%0", TRUE, 0},
+       {"%1", TRUE, 0},
+       {"%2", TRUE, 0},
+       {"%3", TRUE, 0},
+       {"%4", TRUE, 0},
+       {"%5", TRUE, 0},
+       {"%6", TRUE, 0},
+       {"%7", TRUE, 0},
+       {"%8", TRUE, 0},
+       {"%9", TRUE, 0},
+       {"%a", TRUE, 0},
+       {"%b", TRUE, 0},
+       {"%c", TRUE, 0},
+       {"%d", TRUE, 0},
+       {"%e", TRUE, 0},
+       {"%f", TRUE, 0},
+       {"%g", TRUE, 0},
+       {"%h", TRUE, 0},
+       {"%i", TRUE, 0},
+       {"%j", TRUE, 0},
+
+       {"&0", TRUE, 0},
+       {"&1", TRUE, 0},
+       {"&2", TRUE, 0},
+       {"&3", TRUE, 0},
+       {"&4", TRUE, 0},
+       {"&5", TRUE, 0},
+       {"&6", TRUE, 0},
+       {"&7", TRUE, 0},
+       {"&8", TRUE, 0},
+       {"&9", TRUE, 0},
+
+       {"*0", TRUE, 0},
+       {"*1", TRUE, 0},
+       {"*2", TRUE, 0},
+       {"*3", TRUE, 0},
+       {"*4", TRUE, 0},
+       {"*5", TRUE, 0},
+       {"*6", TRUE, 0},
+       {"*7", TRUE, 0},
+       {"*8", TRUE, 0},
+       {"*9", TRUE, 0},
+
+       {"@0", TRUE, 0},
+       {"@1", TRUE, 0},
+       {"@2", TRUE, 0},
+       {"@3", TRUE, 0},
+       {"@4", TRUE, 0},
+       {"@5", TRUE, 0},
+       {"@6", TRUE, 0},
+       {"@7", TRUE, 0},
+       {"@8", TRUE, 0},
+       {"@9", TRUE, 0},
+
+       {"ae", FALSE, 0},
+       {"al", FALSE, 0},
+       {"AL", FALSE, 0},
+       {"as", FALSE, 0},
+
+       {"bc", FALSE, 0},
+       {"bl", FALSE, 0},
+       {"bt", FALSE, 0},
+
+       {"cb", FALSE, 0},
+       {"cc", FALSE, 0},
+       {"cd", FALSE, 0},
+       {"ce", FALSE, 0},
+       {"ch", FALSE, 0},
+       {"cl", FALSE, 0},
+       {"cm", FALSE, 0},
+       {"CM", FALSE, 0},
+       {"cr", FALSE, 0},
+       {"cs", FALSE, 0},
+       {"ct", FALSE, 0},
+       {"cv", FALSE, 0},
+
+       {"dc", FALSE, 0},
+       {"DC", FALSE, 0},
+       {"dl", FALSE, 0},
+       {"DL", FALSE, 0},
+       {"dm", FALSE, 0},
+       {"do", FALSE, 0},
+       {"DO", FALSE, 0},
+       {"ds", FALSE, 0},
+
+       {"eA", FALSE, 0},
+       {"ec", FALSE, 0},
+       {"ed", FALSE, 0},
+       {"ei", FALSE, 0},
+
+       {"F1", TRUE, 0},
+       {"F2", TRUE, 0},
+       {"F3", TRUE, 0},
+       {"F4", TRUE, 0},
+       {"F5", TRUE, 0},
+       {"F6", TRUE, 0},
+       {"F7", TRUE, 0},
+       {"F8", TRUE, 0},
+       {"F9", TRUE, 0},
+       {"FA", TRUE, 0},
+       {"FB", TRUE, 0},
+       {"FC", TRUE, 0},
+       {"FD", TRUE, 0},
+       {"FE", TRUE, 0},
+       {"FF", TRUE, 0},
+       {"FG", TRUE, 0},
+       {"FH", TRUE, 0},
+       {"FI", TRUE, 0},
+       {"FJ", TRUE, 0},
+       {"FK", TRUE, 0},
+       {"FL", TRUE, 0},
+       {"FM", TRUE, 0},
+       {"FN", TRUE, 0},
+       {"FO", TRUE, 0},
+       {"FP", TRUE, 0},
+       {"FQ", TRUE, 0},
+       {"FR", TRUE, 0},
+       {"FS", TRUE, 0},
+       {"FT", TRUE, 0},
+       {"FU", TRUE, 0},
+       {"FV", TRUE, 0},
+       {"FW", TRUE, 0},
+       {"FX", TRUE, 0},
+       {"FY", TRUE, 0},
+       {"FZ", TRUE, 0},
+
+       {"Fa", TRUE, 0},
+       {"Fb", TRUE, 0},
+       {"Fc", TRUE, 0},
+       {"Fd", TRUE, 0},
+       {"Fe", TRUE, 0},
+       {"Ff", TRUE, 0},
+       {"Fg", TRUE, 0},
+       {"Fh", TRUE, 0},
+       {"Fi", TRUE, 0},
+       {"Fj", TRUE, 0},
+       {"Fk", TRUE, 0},
+       {"Fl", TRUE, 0},
+       {"Fm", TRUE, 0},
+       {"Fn", TRUE, 0},
+       {"Fo", TRUE, 0},
+       {"Fp", TRUE, 0},
+       {"Fq", TRUE, 0},
+       {"Fr", TRUE, 0},
+
+       {"ff", FALSE, 0},
+       {"fs", FALSE, 0},
+
+       {"hd", FALSE, 0},
+       {"ho", FALSE, 0},
+       {"hu", FALSE, 0},
+
+       {"i1", FALSE, 0},
+       {"i3", FALSE, 0},
+
+       {"ic", FALSE, 0},
+       {"IC", FALSE, 0},
+       {"if", FALSE, 0},
+       {"im", FALSE, 0},
+       {"ip", FALSE, 0},
+       {"iP", FALSE, 0},
+       {"is", FALSE, 0},
+
+       {"K1", TRUE, 0},
+       {"K2", TRUE, 0},
+       {"K3", TRUE, 0},
+       {"K4", TRUE, 0},
+       {"K5", TRUE, 0},
+
+       {"k0", TRUE, 0},
+       {"k1", TRUE, 0},
+       {"k2", TRUE, 0},
+       {"k3", TRUE, 0},
+       {"k4", TRUE, 0},
+       {"k5", TRUE, 0},
+       {"k6", TRUE, 0},
+       {"k7", TRUE, 0},
+       {"k8", TRUE, 0},
+       {"k9", TRUE, 0},
+       {"k;", TRUE, 0},
+       {"ka", TRUE, 0},
+       {"kA", TRUE, 0},
+       {"kb", TRUE, 0},
+       {"kB", TRUE, 0},
+       {"kC", TRUE, 0},
+       {"kd", TRUE, 0},
+       {"kD", TRUE, 0},
+       {"ke", TRUE, 0},
+       {"kE", TRUE, 0},
+       {"kF", TRUE, 0},
+       {"kh", TRUE, 0},
+       {"kH", TRUE, 0},
+       {"kI", TRUE, 0},
+       {"kl", TRUE, 0},
+       {"kL", TRUE, 0},
+       {"kM", TRUE, 0},
+       {"kN", TRUE, 0},
+       {"kP", TRUE, 0},
+       {"kr", TRUE, 0},
+       {"kR", TRUE, 0},
+       {"ks", TRUE, 0},
+       {"kS", TRUE, 0},
+       {"kt", TRUE, 0},
+       {"kT", TRUE, 0},
+       {"ku", TRUE, 0},
+
+       {"l0", FALSE, 0},
+       {"l1", FALSE, 0},
+       {"l2", FALSE, 0},
+       {"l3", FALSE, 0},
+       {"l4", FALSE, 0},
+       {"l5", FALSE, 0},
+       {"l6", FALSE, 0},
+       {"l7", FALSE, 0},
+       {"l8", FALSE, 0},
+       {"l9", FALSE, 0},
+
+       {"la", FALSE, 0},
+       {"le", FALSE, 0},
+       {"LE", FALSE, 0},
+       {"LF", FALSE, 0},
+       {"ll", FALSE, 0},
+       {"LO", FALSE, 0},
+
+       {"mb", FALSE, 0},
+       {"MC", FALSE, 0},
+       {"md", FALSE, 0},
+       {"me", FALSE, 0},
+       {"mh", FALSE, 0},
+       {"mk", FALSE, 0},
+       {"ml", FALSE, 0},
+       {"ML", FALSE, 0},
+       {"mm", FALSE, 0},
+       {"mo", FALSE, 0},
+       {"mp", FALSE, 0},
+       {"mr", FALSE, 0},
+       {"MR", FALSE, 0},
+       {"mu", FALSE, 0},
+
+       {"nd", FALSE, 0},
+       {"nl", FALSE, 0},
+       {"nw", FALSE, 0},
+
+       {"pc", FALSE, 0},
+       {"pf", FALSE, 0},
+       {"pk", FALSE, 0},
+       {"pl", FALSE, 0},
+       {"pn", FALSE, 0},
+       {"po", FALSE, 0},
+       {"pO", FALSE, 0},
+       {"ps", FALSE, 0},
+       {"px", FALSE, 0},
+
+       {"r1", FALSE, 0},
+       {"r2", FALSE, 0},
+       {"r3", FALSE, 0},
+
+       {"RA", FALSE, 0},
+       {"rc", FALSE, 0},
+       {"rf", FALSE, 0},
+       {"RF", FALSE, 0},
+       {"RI", FALSE, 0},
+       {"rp", FALSE, 0},
+       {"rP", FALSE, 0},
+       {"rs", FALSE, 0},
+       {"RX", FALSE, 0},
+
+       {"s0", FALSE, 0},
+       {"s1", FALSE, 0},
+       {"s2", FALSE, 0},
+       {"s3", FALSE, 0},
+
+       {"sa", FALSE, 0},
+       {"SA", FALSE, 0},
+       {"sc", FALSE, 0},
+       {"se", FALSE, 0},
+       {"sf", FALSE, 0},
+       {"SF", FALSE, 0},
+       /* {"so", 0}, standout is always the same as another attribute. */
+       {"sr", FALSE, 0},
+       {"SR", FALSE, 0},
+       {"st", FALSE, 0},
+       {"SX", FALSE, 0},
+
+       {"ta", FALSE, 0},
+       /* {"te", 0}, terminal end-use is "logical". */
+       /* {"ti", 0}, terminal init is "logical". */
+       {"ts", FALSE, 0},
+
+       {"uc", FALSE, 0},
+       {"ue", FALSE, 0},
+       {"up", FALSE, 0},
+       {"UP", FALSE, 0},
+       {"us", FALSE, 0},
+
+       {"vb", FALSE, 0},
+       /* {"ve", FALSE, 0}, */
+       {"vi", FALSE, 0},
+       /* {"vs", FALSE, 0}, */
+
+       {"wi", FALSE, 0},
+
+       {"XF", FALSE, 0},
+       {"XN", FALSE, 0},
+
+
+       {"", FALSE, 0}
+};
+
 /* From some really old XTerm docs we had at the office, and an updated
  * version at Moy, Gildea, and Dickey. */
 struct _vte_capability_string _vte_xterm_capability_strings[] = {
@@ -274,3 +595,37 @@ struct _vte_capability_string _vte_xterm_capability_strings[] = {
 
        {NULL, NULL, 0},
 };
+
+#if 0
+/**
+ * vte_capability_init:
+ *
+ * Initializes the vte_terminal_capability_strings and
+ * vte_xterm_capability_strings structures used by the terminal.  Can
+ * be called multiple times without ill effect.
+ *
+ * Returns: void
+ */
+
+void
+_vte_capability_init(void)
+{
+       unsigned int i;
+       for (i = 0; _vte_terminal_capability_strings[i].capability[0]; i++) {
+               const char *tmp;
+               GQuark quark;
+               tmp = _vte_terminal_capability_strings[i].capability;
+               quark = g_quark_from_static_string(tmp);
+               _vte_terminal_capability_strings[i].quark = quark;
+       }
+       for (i = 0; i < G_N_ELEMENTS(_vte_xterm_capability_strings); i++) {
+               const char *tmp;
+               GQuark quark;
+               tmp = _vte_xterm_capability_strings[i].value;
+               if (tmp != NULL) {
+                       quark = g_quark_from_static_string(tmp);
+                       _vte_xterm_capability_strings[i].quark = quark;
+               }
+       }
+}
+#endif
diff --git a/src/caps.h b/src/caps.h
index f28f3bd..a043c58 100644
--- a/src/caps.h
+++ b/src/caps.h
@@ -35,12 +35,22 @@ G_BEGIN_DECLS
 #define _VTE_CAP_SS2 _VTE_CAP_ESC "N"  /* Single-shift to G2 */
 #define _VTE_CAP_SS3 _VTE_CAP_ESC "O"  /* Single-shift to G3 */
 
+/* A NULL-terminated list of capability strings which have string values,
+ * which means they're either key sequences or commands. */
+struct _vte_capability_quark {
+       const char capability[4];
+       gboolean key;
+       GQuark quark;
+};
 struct _vte_capability_string {
        const char *code;
        const char *value;
        GQuark quark;
 };
 
+/* The known capability strings in termcap entries, terminated by NULLs. */
+extern struct _vte_capability_quark _vte_terminal_capability_strings[];
+
 /* The xterm-specific terminal control strings, terminated by NULLs. */
 extern struct _vte_capability_string _vte_xterm_capability_strings[];
 
diff --git a/src/interpret.c b/src/interpret.c
index 7d79037..4165637 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -33,13 +33,14 @@
 #include "debug.h"
 #include "iso2022.h"
 #include "matcher.h"
-#include "vteti.h"
+#include "vtetc.h"
 
 int
 main(int argc, char **argv)
 {
+       char *terminal = NULL;
        struct _vte_matcher *matcher = NULL;
-       struct _vte_terminfo *terminfo = NULL;
+       struct _vte_termcap *termcap = NULL;
        GArray *array;
        unsigned int i, j;
        int l;
@@ -54,7 +55,7 @@ main(int argc, char **argv)
        _vte_debug_init();
 
        if (argc < 2) {
-               g_print("usage: %s TERM [file]\n", argv[0]);
+               g_print("usage: %s terminal [file]\n", argv[0]);
                return 1;
        }
 
@@ -70,15 +71,16 @@ main(int argc, char **argv)
        }
 
        g_type_init();
-       terminfo = _vte_terminfo_new(argv[1]);
-        if (terminfo == NULL) {
-                g_printerr ("No terminfo entry for '%s'\n", argv[1]);
+       terminal = argv[1];
+       termcap = _vte_termcap_new(terminal);
+        if (termcap == NULL) {
+                g_printerr ("No termcap entry for '%s'\n", terminal);
                 return 1;
         }
 
        array = g_array_new(FALSE, FALSE, sizeof(gunichar));
 
-       matcher = _vte_matcher_new(terminfo);
+       matcher = _vte_matcher_new(terminal, termcap);
 
        subst = _vte_iso2022_state_new(NULL, VTE_ISO2022_DEFAULT_UTF8_AMBIGUOUS_WIDTH, NULL, NULL);
 
@@ -164,7 +166,7 @@ main(int argc, char **argv)
 
        _vte_iso2022_state_free(subst);
        g_array_free(array, TRUE);
-       _vte_terminfo_unref(terminfo);
+       _vte_termcap_free(termcap);
        _vte_matcher_free(matcher);
        return 0;
 }
diff --git a/src/iso2022.c b/src/iso2022.c
index 0989082..f493496 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -35,7 +35,7 @@
 #endif
 #include <glib/gi18n-lib.h>
 
-#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
 
 /* Maps which jive with XTerm's ESC ()*+ ? sequences, RFC 1468.  Add the
  * PC437 map because despite knowing that XTerm doesn't support it, certain
diff --git a/src/keymap.c b/src/keymap.c
index 0e0fa26..c61d7d8 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -27,6 +27,26 @@
 #include "caps.h"
 #include "debug.h"
 #include "keymap.h"
+#include "vtetc.h"
+
+#if defined(HAVE_NCURSES_H) && defined(HAVE_TERM_H)
+#include <ncurses.h>
+#include <term.h>
+#define VTE_TERMCAP_NAME "ncurses"
+#elif defined(HAVE_NCURSES_CURSES_H) && defined(HAVE_NCURSES_TERM_H)
+#include <ncurses/curses.h>
+#include <ncurses/term.h>
+#define VTE_TERMCAP_NAME "ncurses"
+#elif defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
+#include <curses.h>
+#include <term.h>
+#define VTE_TERMCAP_NAME "curses"
+#elif defined(HAVE_TERMCAP_H)
+#include <termcap.h>
+#define VTE_TERMCAP_NAME "termcap"
+#else
+#error No termcap??
+#endif
 
 #ifdef VTE_DEBUG
 static void
@@ -132,7 +152,7 @@ struct _vte_keymap_entry {
        GdkModifierType mod_mask;
        const char normal[8];
        gssize normal_length;
-       const char cap[8];
+       const char special[4];
 };
 
 #define X_NULL ""
@@ -161,7 +181,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_space[] = {
 static const struct _vte_keymap_entry _vte_keymap_GDK_Tab[] = {
        /* Shift+Tab = Back-Tab */
        {cursor_all, keypad_all, fkey_all,
-        GDK_SHIFT_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_BTAB},
+        GDK_SHIFT_MASK, X_NULL, 0, "kB"},
        {cursor_all, keypad_all, fkey_all,
         GDK_SHIFT_MASK, _VTE_CAP_CSI "Z", -1, X_NULL},
        /* Alt+Tab = Esc+Tab */
@@ -169,7 +189,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Tab[] = {
         VTE_META_MASK, _VTE_CAP_ESC "\t", -1, X_NULL},
        /* Regular tab. */
        {cursor_all, keypad_all, fkey_all,
-        0, X_NULL, 0, VTE_TERMINFO_CAP_TAB /* not a KEY_ cap ‽ */},
+        0, X_NULL, 0, "ta"},
        {cursor_all, keypad_all, fkey_all, 0, "\t", 1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
@@ -190,7 +210,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Escape[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Insert[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_IC},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kI"},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "Q", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "2z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "2~", -1, X_NULL},
@@ -198,7 +218,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Insert[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_ISO_Left_Tab[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_BTAB},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kB"},
        {cursor_all, keypad_all, fkey_all, 0, _VTE_CAP_CSI "Z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
@@ -256,26 +276,26 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Minus[] = {
 /* Home and End are strange cases because their sequences vary wildly from
  * system to system, or mine's just broken.  But anyway. */
 static const struct _vte_keymap_entry _vte_keymap_GDK_Home[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_HOME},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kh"},
        {cursor_all, keypad_all, fkey_vt220, 0, _VTE_CAP_CSI "1~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "h", -1, X_NULL},
-       {cursor_all, keypad_all, fkey_nothpvt, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_HOME},
+       {cursor_all, keypad_all, fkey_nothpvt, 0, X_NULL, 0, "kh"},
        {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "H", -1, X_NULL},
        {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "H", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_End[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_END},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "@7"},
        {cursor_all, keypad_all, fkey_vt220, 0, _VTE_CAP_CSI "4~", -1, X_NULL},
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_END},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "@7"},
        {cursor_default, keypad_all, fkey_default, 0, _VTE_CAP_CSI "F", -1, X_NULL},
        {cursor_app, keypad_all, fkey_default, 0, _VTE_CAP_SS3 "F", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Page_Up[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_PPAGE},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kP"},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "T", -1, X_NULL},
        {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "5~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "5z", -1, X_NULL},
@@ -283,7 +303,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Page_Up[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Page_Down[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_NPAGE},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kN"},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "S", -1, X_NULL},
        {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "6~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "6z", -1, X_NULL},
@@ -292,7 +312,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Page_Down[] = {
 
 /* Keys affected by the cursor key mode. */
 static const struct _vte_keymap_entry _vte_keymap_GDK_Up[] = {
-       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_UP},
+       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, "ku"},
        {cursor_default, keypad_all, fkey_nothp, 0, _VTE_CAP_CSI "A", -1, X_NULL},
        {cursor_default, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "A", -1, X_NULL},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "A", -1, X_NULL},
@@ -300,7 +320,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Up[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Down[] = {
-       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_DOWN},
+       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, "kd"},
        {cursor_default, keypad_all, fkey_nothp, 0, _VTE_CAP_CSI "B", -1, X_NULL},
        {cursor_default, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "B", -1, X_NULL},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "B", -1, X_NULL},
@@ -308,7 +328,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Down[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Right[] = {
-       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_RIGHT},
+       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, "kr"},
        {cursor_default, keypad_all, fkey_nothp, 0, _VTE_CAP_CSI "C", -1, X_NULL},
        {cursor_default, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "C", -1, X_NULL},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "C", -1, X_NULL},
@@ -316,7 +336,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_Right[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_Left[] = {
-       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_LEFT},
+       {cursor_default, keypad_all, fkey_all, 0, X_NULL, 0, "kl"},
        {cursor_default, keypad_all, fkey_nothp, 0, _VTE_CAP_CSI "D", -1, X_NULL},
        {cursor_default, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "D", -1, X_NULL},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "D", -1, X_NULL},
@@ -337,7 +357,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Tab[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Enter[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_ENTER},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "@8"},
        {cursor_all, keypad_app, fkey_all, VTE_NUMLOCK_MASK | GDK_CONTROL_MASK, "\n", 1, X_NULL},
        {cursor_all, keypad_app, fkey_all, VTE_NUMLOCK_MASK, "\r", 1, X_NULL},
        {cursor_all, keypad_app, fkey_all, 0, _VTE_CAP_SS3 "M", -1, X_NULL},
@@ -347,25 +367,25 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Enter[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_F1[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F1},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "k1"},
        {cursor_all, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "P", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_F2[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F2},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "k2"},
        {cursor_all, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "Q", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_F3[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F3},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "k3"},
        {cursor_all, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "R", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_F4[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F4},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "k4"},
        {cursor_all, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "S", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
@@ -481,7 +501,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Insert[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_End[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_C1},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "K4"},
        {cursor_all, keypad_default, fkey_notvt220,
         0, _VTE_CAP_CSI "4~", -1, X_NULL},
        {cursor_all, keypad_default, fkey_vt220, 0, "1", 1, X_NULL},
@@ -493,7 +513,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_End[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Down[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_DOWN},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kd"},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "B", -1, X_NULL},
        {cursor_default, keypad_all, fkey_notvt220,
         0, _VTE_CAP_CSI "B", -1, X_NULL},
@@ -503,7 +523,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Down[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Page_Down[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_C3},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "K5"},
        {cursor_all, keypad_default, fkey_notsunvt,
         0, _VTE_CAP_CSI "6~", -1, X_NULL},
        {cursor_all, keypad_default, fkey_sun, 0, _VTE_CAP_CSI "6z", -1, X_NULL},
@@ -514,7 +534,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Page_Down[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Left[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_LEFT},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kl"},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "D", -1, X_NULL},
        {cursor_default, keypad_all, fkey_notvt220,
         0, _VTE_CAP_CSI "D", -1, X_NULL},
@@ -524,7 +544,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Left[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Begin[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_B2 /* FIXMEchpe: not KEY_A1 
!? */},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "K2"},
        {cursor_app, keypad_all, fkey_notvt220, 0, _VTE_CAP_SS3 "E", -1, X_NULL},
        {cursor_default, keypad_all, fkey_notvt220, 0, _VTE_CAP_CSI "E", -1, X_NULL},
        {cursor_all, keypad_default, fkey_vt220, 0, "5", 1, X_NULL},
@@ -533,7 +553,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Begin[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Right[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_RIGHT},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "kr"},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "C", -1, X_NULL},
        {cursor_default, keypad_all, fkey_notvt220,
         0, _VTE_CAP_CSI "C", -1, X_NULL},
@@ -543,7 +563,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Right[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Home[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_A1},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "K1"},
        {cursor_all, keypad_default, fkey_notvt220,
         0, _VTE_CAP_CSI "1~", -1, X_NULL},
        {cursor_all, keypad_default, fkey_vt220, 0, "7", 1, X_NULL},
@@ -555,7 +575,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Home[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Up[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_UP},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "ku"},
        {cursor_app, keypad_all, fkey_all, 0, _VTE_CAP_SS3 "A", -1, X_NULL},
        {cursor_default, keypad_all, fkey_notvt220,
         0, _VTE_CAP_CSI "A", -1, X_NULL},
@@ -565,7 +585,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Up[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Page_Up[] = {
-       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_A3},
+       {cursor_all, keypad_default, fkey_all, 0, X_NULL, 0, "K3"},
        {cursor_all, keypad_default, fkey_notvt220,
         0, _VTE_CAP_CSI "5~", -1, X_NULL},
        {cursor_all, keypad_default, fkey_vt220, 0, "9", 1, X_NULL},
@@ -577,9 +597,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_KP_Page_Up[] = {
 
 /* Keys affected by the function key mode. */
 static const struct _vte_keymap_entry _vte_keymap_GDK_F1[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F1},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F13},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F1},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k1"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F3"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k1"},
        {cursor_all, keypad_all, fkey_default, GDK_CONTROL_MASK, _VTE_CAP_CSI "P", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, GDK_SHIFT_MASK, _VTE_CAP_CSI "P", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, VTE_META_MASK, _VTE_CAP_CSI "P", -1, X_NULL},
@@ -594,9 +614,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F1[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F2[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F2},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F14},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F2},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k2"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F4"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k2"},
        {cursor_all, keypad_all, fkey_default, GDK_CONTROL_MASK, _VTE_CAP_CSI "Q", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, GDK_SHIFT_MASK, _VTE_CAP_CSI "Q", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, VTE_META_MASK, _VTE_CAP_CSI "Q", -1, X_NULL},
@@ -611,9 +631,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F2[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F3[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F3},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F15},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F3},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k3"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F5"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k3"},
        {cursor_all, keypad_all, fkey_default, GDK_CONTROL_MASK, _VTE_CAP_CSI "R", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, GDK_SHIFT_MASK, _VTE_CAP_CSI "R", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, VTE_META_MASK, _VTE_CAP_CSI "R", -1, X_NULL},
@@ -628,9 +648,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F3[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F4[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F4},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F16},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F4},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k4"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F6"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k4"},
        {cursor_all, keypad_all, fkey_default, GDK_CONTROL_MASK, _VTE_CAP_CSI "S", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, GDK_SHIFT_MASK, _VTE_CAP_CSI "S", -1, X_NULL},
        {cursor_all, keypad_all, fkey_default, VTE_META_MASK, _VTE_CAP_CSI "S", -1, X_NULL},
@@ -645,9 +665,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F4[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F5[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F5},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F17},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F5},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k5"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F7"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k5"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "15~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "228z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "t", -1, X_NULL},
@@ -659,9 +679,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F5[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F6[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F6},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F18},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F6},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k6"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F8"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k6"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "17~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "229z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "u", -1, X_NULL},
@@ -673,9 +693,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F6[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F7[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F7},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F19},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F7},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k7"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "F9"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k7"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "18~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "230z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "v", -1, X_NULL},
@@ -687,9 +707,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F7[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F8[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F8},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F20},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F8},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k8"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "FA"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k8"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "19~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "231z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "w", -1, X_NULL},
@@ -701,9 +721,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F8[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F9[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F9},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F21},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F9},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k9"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "FB"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k9"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "20~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "232z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_CSI "20~", -1, X_NULL},
@@ -715,9 +735,9 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F9[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F10[] = {
-       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F10},
-       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F22},
-       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F10},
+       {cursor_all, keypad_all, fkey_notvt220, 0, X_NULL, 0, "k;"},
+       {cursor_all, keypad_all, fkey_vt220, GDK_CONTROL_MASK, X_NULL, 0, "FC"},
+       {cursor_all, keypad_all, fkey_vt220, 0, X_NULL, 0, "k;"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "21~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "233z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_CSI "21~", -1, X_NULL},
@@ -729,7 +749,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F10[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F11[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F11},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F1"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "23~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "192z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_CSI "23~", -1, X_NULL},
@@ -739,7 +759,7 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F11[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F12[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F12},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F2"},
        {cursor_all, keypad_all, fkey_default, 0, _VTE_CAP_CSI "24~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "193z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_CSI "24~", -1, X_NULL},
@@ -749,133 +769,133 @@ static const struct _vte_keymap_entry _vte_keymap_GDK_F12[] = {
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F13[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F13},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F3"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "25~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "194z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F14[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F14},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F4"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "26~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "195z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F15[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F15},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F5"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "28~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "196z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F16[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F16},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F6"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "29~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "197z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F17[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F17},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F7"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "31~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "198z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F18[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F18},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F8"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "32~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "199z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F19[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F19},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "F9"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "33~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "200z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F20[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F20},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FA"},
        {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "34~", -1, X_NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "201z", -1, X_NULL},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F21[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F21},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FB"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F22[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F22},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FC"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F23[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F23},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FD"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F24[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F24},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FE"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F25[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F25},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FF"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F26[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F26},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FG"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F27[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F27},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FH"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F28[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F28},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FI"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F29[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F29},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FJ"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F30[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F30},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FK"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F31[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F31},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FL"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F32[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F32},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FM"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F33[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F33},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FN"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F34[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F34},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FO"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
 static const struct _vte_keymap_entry _vte_keymap_GDK_F35[] = {
-       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, VTE_TERMINFO_CAP_KEY_F35},
+       {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, "FP"},
        {cursor_all, keypad_all, fkey_all, 0, X_NULL, 0, X_NULL},
 };
 
@@ -994,21 +1014,25 @@ _vte_keymap_map(guint keyval,
                gboolean vt220_mode,
                gboolean app_cursor_keys,
                gboolean app_keypad_keys,
-               struct _vte_terminfo *terminfo,
+               struct _vte_termcap *termcap,
+               const char *terminal,
                char **normal,
                gssize *normal_length,
-               const char **terminfo_cap)
+               const char **special)
 {
        gsize i;
        const struct _vte_keymap_entry *entries;
        enum _vte_cursor_mode cursor_mode;
        enum _vte_keypad_mode keypad_mode;
        enum _vte_fkey_mode fkey_mode;
-       const char *cap = NULL;
+       char *cap, *tmp;
+       const char *termcap_special = NULL;
+       char ncurses_buffer[4096];
+       char ncurses_area[512];
 
        g_return_if_fail(normal != NULL);
        g_return_if_fail(normal_length != NULL);
-       g_return_if_fail(terminfo_cap != NULL);
+       g_return_if_fail(special != NULL);
 
        _VTE_DEBUG_IF(VTE_DEBUG_KEYBOARD) 
                _vte_keysym_print(keyval, modifiers,
@@ -1019,8 +1043,8 @@ _vte_keymap_map(guint keyval,
 
        /* Start from scratch. */
        *normal = NULL;
+       *special = NULL;
        *normal_length = 0;
-       *terminfo_cap = NULL;
 
        /* Search for the list for this key. */
        entries = NULL;
@@ -1031,9 +1055,9 @@ _vte_keymap_map(guint keyval,
                /* Check for NULL strings with non-zero length, and
                 * vice-versa. */
                entries = _vte_keymap[i].entries;
-               for (j = 0; entries[j].normal_length || entries[j].cap[0]; j++) {
+               for (j = 0; entries[j].normal_length || entries[j].special[0]; j++) {
                        if (entries[j].normal_length) {
-                               g_assert(!entries[j].cap[0]);
+                               g_assert(!entries[j].special[0]);
                        } else {
                                g_assert(!entries[j].normal[0]);
                        }
@@ -1041,7 +1065,7 @@ _vte_keymap_map(guint keyval,
                /* Check for coverage. This check is not exhaustive. */
                fkey_mode = 0;
                mods = GDK_SHIFT_MASK | GDK_CONTROL_MASK | VTE_META_MASK | VTE_NUMLOCK_MASK;
-               for (j = 0; entries[j].normal_length || entries[j].cap[0]; j++) {
+               for (j = 0; entries[j].normal_length || entries[j].special[0]; j++) {
                        if (entries[j].fkey_mode != fkey_all) {
                                fkey_mode |= entries[j].fkey_mode;
                        }
@@ -1096,7 +1120,7 @@ _vte_keymap_map(guint keyval,
        modifiers &= (GDK_SHIFT_MASK | GDK_CONTROL_MASK | VTE_META_MASK | VTE_NUMLOCK_MASK);
 
        /* Search for the conditions. */
-       for (i = 0; entries[i].normal_length || entries[i].cap[0]; i++)
+       for (i = 0; entries[i].normal_length || entries[i].special[0]; i++)
        if ((entries[i].cursor_mode & cursor_mode) &&
            (entries[i].keypad_mode & keypad_mode) &&
            (entries[i].fkey_mode & fkey_mode))
@@ -1119,22 +1143,83 @@ _vte_keymap_map(guint keyval,
                                                          cursor_mode & cursor_app,
                                                          normal,
                                                          normal_length);
-                       _vte_debug_print(VTE_DEBUG_KEYBOARD,
-                                         " to '%s'.\n",
-                                         _vte_terminfo_sequence_to_string(*normal));
+                       _VTE_DEBUG_IF(VTE_DEBUG_KEYBOARD) {
+                               int j;
+                               g_printerr(" to '");
+                               for (j = 0; j < *normal_length; j++) {
+                                       if (((*normal)[j] < 32) ||
+                                           ((*normal)[j] >= 127)) {
+                                               g_printerr("<0x%02x>",
+                                                       (*normal)[j]);
+                                       } else {
+                                               g_printerr("%c",
+                                                       (*normal)[j]);
+                                       }
+                               }
+                               g_printerr("'.\n");
+                       }
                        return;
                } else {
-                        cap = _vte_terminfo_get_string_by_cap(terminfo, entries[i].cap, FALSE);
-                        if (cap != NULL && cap[0] != 0) {
-                                /* Save the special string. */
-                                *terminfo_cap = entries[i].cap;
-
-                                _vte_debug_print(VTE_DEBUG_KEYBOARD,
-                                                 " via terminfo cap '%s' to '%s' , returning.\n",
-                                                 entries[i].cap,
-                                                 _vte_terminfo_sequence_to_string(cap));
-                                return;
+                       termcap_special = entries[i].special;
+                       cap = _vte_termcap_find_string(termcap,
+                                                      terminal,
+                                                      entries[i].special);
+                       if (cap != NULL) {
+                               *special = NULL;
+                               if (strlen(cap) > 0) {
+                                       /* Save the special string. */
+                                       *special = entries[i].special;
+                                       _vte_debug_print(VTE_DEBUG_KEYBOARD,
+                                                       " to \"%s\"", *special);
+                               }
+                               g_free(cap);
+                               if (*special != NULL) {
+                                       /* Return the special string. */
+                                       _vte_debug_print(VTE_DEBUG_KEYBOARD,
+                                                       ", returning.\n");
+                                       return;
+                               }
+                       }
+               }
+       }
+       if (termcap_special != NULL) {
+               tmp = g_strdup(terminal);
+               cap = NULL;
+               if (tgetent(ncurses_buffer, tmp) == 1) {
+                       cap = ncurses_area;
+                       tmp = g_strdup(termcap_special);
+                       cap = tgetstr(tmp, &cap);
+               }
+               if ((cap == NULL) && (strstr(terminal, "xterm") != NULL)) {
+                       /* try, try again */
+                       if (tgetent(ncurses_buffer, "xterm-xfree86") == 1) {
+                               cap = ncurses_area;
+                               tmp = g_strdup(termcap_special);
+                               cap = tgetstr(tmp, &cap);
+                       }
+               }
+               g_free(tmp);
+               if ((cap != NULL) && (*cap != '\0')) {
+                       *normal_length = strlen(cap);
+                       *normal = g_strdup(cap);
+#ifdef VTE_DEBUG
+                       if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
+                               int j;
+                               g_printerr(" via " VTE_TERMCAP_NAME " to '");
+                               for (j = 0; j < *normal_length; j++) {
+                                       if (((*normal)[j] < 32) ||
+                                           ((*normal)[j] >= 127)) {
+                                               g_printerr("<0x%02x>",
+                                                       (*normal)[j]);
+                                       } else {
+                                               g_printerr("%c",
+                                                       (*normal)[j]);
+                                       }
+                               }
+                               g_printerr("', returning.\n");
                        }
+#endif
+                       return;
                }
        }
 
diff --git a/src/keymap.h b/src/keymap.h
index bd57f98..0f19aef 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -23,8 +23,7 @@
 
 #include <glib.h>
 #include <gdk/gdk.h>
-
-#include "vteti.h"
+#include "vtetc.h"
 
 G_BEGIN_DECLS
 
@@ -41,7 +40,8 @@ void _vte_keymap_map(guint keyval,
                     gboolean vt220_mode,
                     gboolean app_cursor_keys,
                     gboolean app_keypad_keys,
-                    struct _vte_terminfo *terminfo,
+                    struct _vte_termcap *termcap,
+                    const char *term,
                     char **normal,
                     gssize *normal_length,
                     const char **special);
diff --git a/src/matcher.c b/src/matcher.c
index a9f8b2b..fddae0a 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -33,11 +33,8 @@ struct _vte_matcher {
        GValueArray *free_params;
 };
 
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
 static GStaticMutex _vte_matcher_mutex = G_STATIC_MUTEX_INIT;
 static GCache *_vte_matcher_cache = NULL;
-G_GNUC_END_IGNORE_DEPRECATIONS;
-
 static struct _vte_matcher_impl dummy_vte_matcher_trie = {
        &_vte_matcher_trie
 };
@@ -45,12 +42,6 @@ static struct _vte_matcher_impl dummy_vte_matcher_table = {
        &_vte_matcher_table
 };
 
-#ifdef VTE_COMPILATION
-#include "vte-private.h"
-#else
-static gboolean _vte_terminal_can_handle_sequence(const char *name) { return TRUE; }
-#endif
-
 /* Add a string to the matcher. */
 static void
 _vte_matcher_add(const struct _vte_matcher *matcher,
@@ -60,72 +51,54 @@ _vte_matcher_add(const struct _vte_matcher *matcher,
        matcher->impl->klass->add(matcher->impl, pattern, length, result, quark);
 }
 
-static void
-_vte_matcher_add_one(struct _vte_terminfo *terminfo,
-                     const char *cap,
-                     const char *compat_cap,
-                     const char *value,
-                     gpointer user_data)
-{
-        struct _vte_matcher *matcher = user_data;
-
-        /* Skip key caps, which all start with 'k' in terminfo */
-        if (cap[0] == 'k')
-                return;
-
-        /* Skip anything that doesn't start with a control character. This catches
-         * ACS_CHARS and SGR, and the F0..F10 key labels (lf0..lf10).
-         */
-        if (value[0] >= 0x20 && value[0] < 0x7f){
-                _vte_debug_print(VTE_DEBUG_PARSE,
-                                 "Dropping caps %s with printable value '%s'\n",
-                                 cap, _vte_terminfo_sequence_to_string(value));
-                return;
-        }
-
-        /* We use the 2-character termcap code instead of the terminfo code
-         * if it exists, since that makes matching faster by using vteseq-2.
-         */
-        if (compat_cap[0] != 0)
-                cap = compat_cap;
-
-        /* If there is no handler for it, it'd be pointless to continue. */
-        if (!_vte_terminal_can_handle_sequence(cap)) {
-                _vte_debug_print(VTE_DEBUG_PARSE, "No handler for cap %s with value '%s', skipping\n",
-                                 cap, _vte_terminfo_sequence_to_string(value));
-                return;
-        }
-
-        _vte_debug_print(VTE_DEBUG_PARSE,
-                         "Adding caps %s with value '%s'\n", cap,
-                         _vte_terminfo_sequence_to_string(value));
-
-        _vte_matcher_add(matcher, value, strlen(value), cap, 0);
-}
-
 /* Loads all sequences into matcher */
 static void
-_vte_matcher_init(struct _vte_matcher *matcher,
-                  struct _vte_terminfo *terminfo)
+_vte_matcher_init(struct _vte_matcher *matcher, const char *emulation,
+                 struct _vte_termcap *termcap)
 {
        const char *code, *value;
+       gboolean found_cr = FALSE, found_lf = FALSE;
+       gssize stripped_length;
+       char *stripped;
        int i;
 
        _vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_init()\n");
 
-       if (terminfo != NULL) {
-                _vte_terminfo_foreach_string(terminfo, TRUE, _vte_matcher_add_one, matcher);
-
-                /* FIXME: we used to always add LF and CR to the matcher if they weren't in the
-                 * termcap. However this seems unlikely to happen since if the terminfo is so
-                 * broken it doesn't include CR and LF, everything else will be broken too.
-                 */
-        }
+       if (termcap != NULL) {
+               /* Load the known capability strings from the termcap
+                * structure into the table for recognition. */
+               for (i = 0;
+                               _vte_terminal_capability_strings[i].capability[0];
+                               i++) {
+                       if (_vte_terminal_capability_strings[i].key) {
+                               continue;
+                       }
+                       code = _vte_terminal_capability_strings[i].capability;
+                       stripped = _vte_termcap_find_string_length(termcap,
+                                       emulation,
+                                       code,
+                                       &stripped_length);
+                       if (stripped[0] != '\0') {
+                               _vte_matcher_add(matcher,
+                                               stripped, stripped_length,
+                                               code, 0);
+                               if (stripped[0] == '\r') {
+                                       found_cr = TRUE;
+                               } else
+                                       if (stripped[0] == '\n') {
+                                               if (strcmp(code, "sf") == 0 ||
+                                                               strcmp(code, "do") == 0) {
+                                                       found_lf = TRUE;
+                                               }
+                                       }
+                       }
+                       g_free(stripped);
+               }
+       }
 
        /* Add emulator-specific sequences. */
-        if (terminfo != NULL && _vte_terminfo_is_xterm_like(terminfo)) {
+       if (strstr(emulation, "xterm") || strstr(emulation, "dtterm")) {
                /* Add all of the xterm-specific stuff. */
-
                for (i = 0;
                     _vte_xterm_capability_strings[i].value != NULL;
                     i++) {
@@ -136,6 +109,14 @@ _vte_matcher_init(struct _vte_matcher *matcher,
                }
        }
 
+       /* Always define cr and lf. */
+       if (!found_cr) {
+               _vte_matcher_add(matcher, "\r", 1, "cr", 0);
+       }
+       if (!found_lf) {
+               _vte_matcher_add(matcher, "\n", 1, "sf", 0);
+       }
+
        _VTE_DEBUG_IF(VTE_DEBUG_TRIE) {
                g_printerr("Trie contents:\n");
                _vte_matcher_print(matcher);
@@ -147,7 +128,7 @@ _vte_matcher_init(struct _vte_matcher *matcher,
 static gpointer
 _vte_matcher_create(gpointer key)
 {
-        struct _vte_terminfo *terminfo = key;
+       char *emulation = key;
        struct _vte_matcher *ret = NULL;
 
        _vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_create()\n");
@@ -156,10 +137,10 @@ _vte_matcher_create(gpointer key)
        ret->match = NULL;
        ret->free_params = NULL;
 
-        /* FIXMEchpe: this means the trie one is always unused? It also seems totally broken
-         * since when accidentally using it instead of table, all was messed up
-         */
-        if (_vte_terminfo_is_xterm_like(terminfo)) {
+       if (strcmp(emulation, "xterm") == 0) {
+               ret->impl = &dummy_vte_matcher_table;
+       } else
+       if (strcmp(emulation, "dtterm") == 0) {
                ret->impl = &dummy_vte_matcher_table;
        }
 
@@ -183,33 +164,31 @@ _vte_matcher_destroy(gpointer value)
 
 /* Create and init matcher. */
 struct _vte_matcher *
-_vte_matcher_new(struct _vte_terminfo *terminfo)
+_vte_matcher_new(const char *emulation, struct _vte_termcap *termcap)
 {
        struct _vte_matcher *ret = NULL;
-
-        g_return_val_if_fail(terminfo != NULL, NULL);
-
-        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
        g_static_mutex_lock(&_vte_matcher_mutex);
 
+       if (emulation == NULL) {
+               emulation = "";
+       }
+
        if (_vte_matcher_cache == NULL) {
-               _vte_matcher_cache = g_cache_new((GCacheNewFunc)_vte_matcher_create,
-                                                 (GCacheDestroyFunc)_vte_matcher_destroy,
-                                                 (GCacheDupFunc)_vte_terminfo_ref,
-                                                 (GCacheDestroyFunc)_vte_terminfo_unref,
-                                                 g_direct_hash, g_direct_hash, g_direct_equal);
+               _vte_matcher_cache = g_cache_new(_vte_matcher_create,
+                               _vte_matcher_destroy,
+                               (GCacheDupFunc) g_strdup, g_free,
+                               g_str_hash, g_direct_hash, g_str_equal);
        }
 
-       ret = g_cache_insert(_vte_matcher_cache, terminfo);
+       ret = g_cache_insert(_vte_matcher_cache, (gpointer) emulation);
 
        if (ret->match == NULL) {
                ret->impl = ret->impl->klass->create();
                ret->match = ret->impl->klass->match;
-               _vte_matcher_init(ret, terminfo);
+               _vte_matcher_init(ret, emulation, termcap);
        }
 
        g_static_mutex_unlock(&_vte_matcher_mutex);
-        G_GNUC_END_IGNORE_DEPRECATIONS;
        return ret;
 }
 
@@ -218,11 +197,9 @@ void
 _vte_matcher_free(struct _vte_matcher *matcher)
 {
        g_assert(_vte_matcher_cache != NULL);
-        G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
        g_static_mutex_lock(&_vte_matcher_mutex);
        g_cache_remove(_vte_matcher_cache, matcher);
        g_static_mutex_unlock(&_vte_matcher_mutex);
-        G_GNUC_END_IGNORE_DEPRECATIONS;
 }
 
 /* Check if a string matches a sequence the matcher knows about. */
@@ -268,3 +245,4 @@ _vte_matcher_free_params_array(struct _vte_matcher *matcher,
                params->n_values = 0;
        }
 }
+
diff --git a/src/matcher.h b/src/matcher.h
index 3136fc8..6e00073 100644
--- a/src/matcher.h
+++ b/src/matcher.h
@@ -23,7 +23,7 @@
 
 
 #include <glib-object.h>
-#include "vteti.h"
+#include "vtetc.h"
 
 G_BEGIN_DECLS
 
@@ -53,7 +53,8 @@ struct _vte_matcher_class{
 };
 
 /* Create and init matcher. */
-struct _vte_matcher *_vte_matcher_new(struct _vte_terminfo *terminfo);
+struct _vte_matcher *_vte_matcher_new(const char *emulation,
+                                     struct _vte_termcap *termcap);
 
 /* Free a matcher. */
 void _vte_matcher_free(struct _vte_matcher *matcher);
diff --git a/src/table.c b/src/table.c
index be2cd31..f1ea798 100644
--- a/src/table.c
+++ b/src/table.c
@@ -740,7 +740,7 @@ _vte_table_match(struct _vte_table *table,
                                        p += 2;
                                } else {
                                        _vte_debug_print (VTE_DEBUG_PARSE,
-                                                         "Invalid terminfo sequence %s\n",
+                                                         "Invalid termcap sequence %s\n",
                                                          original);
                                }
                        } /* else Literal. */
diff --git a/src/vte-private.h b/src/vte-private.h
index 842004d..77582b3 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -168,12 +168,13 @@ struct _VteTerminalPrivate {
         glong column_count;
 
        /* Emulation setup data. */
-       struct _vte_terminfo *terminfo; /* terminfo */
+       struct _vte_termcap *termcap;   /* termcap storage */
        struct _vte_matcher *matcher;   /* control sequence matcher */
        const char *emulation;          /* terminal type to emulate */
-       struct vte_terminal_flags {     /* boolean terminfo flags */
+       struct vte_terminal_flags {     /* boolean termcap flags */
                gboolean am;
                gboolean bw;
+               gboolean LP;
                gboolean ul;
                gboolean xn;
        } flags;
@@ -469,7 +470,6 @@ void _vte_terminal_handle_sequence(VteTerminal *terminal,
                                   const char *match_s,
                                   GQuark match,
                                   GValueArray *params);
-gboolean _vte_terminal_can_handle_sequence(const char *name);
 gboolean _vte_terminal_xy_to_grid(VteTerminal *terminal,
                                   long x,
                                   long y,
diff --git a/src/vte.c b/src/vte.c
index 22fc52d..39c5a08 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -55,7 +55,7 @@
 #include "vteint.h"
 #include "vtepty.h"
 #include "vtepty-private.h"
-#include "vteti.h"
+#include "vtetc.h"
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
@@ -80,7 +80,7 @@ typedef gunichar wint_t;
 #endif
 
 static void vte_terminal_set_visibility (VteTerminal *terminal, GdkVisibilityState state);
-static void vte_terminal_set_terminfo(VteTerminal *terminal);
+static void vte_terminal_set_termcap(VteTerminal *terminal);
 static void vte_terminal_paste(VteTerminal *terminal, GdkAtom board);
 static void vte_terminal_real_copy_clipboard(VteTerminal *terminal);
 static void vte_terminal_real_paste_clipboard(VteTerminal *terminal);
@@ -1083,9 +1083,10 @@ vte_terminal_set_default_tabstops(VteTerminal *terminal)
                g_hash_table_destroy(terminal->pvt->tabstops);
        }
        terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
-       if (terminal->pvt->terminfo != NULL) {
-               width = _vte_terminfo_get_numeric(terminal->pvt->terminfo,
-                                                  VTE_TERMINFO_VAR_INIT_TABS);
+       if (terminal->pvt->termcap != NULL) {
+               width = _vte_termcap_find_numeric(terminal->pvt->termcap,
+                                                 terminal->pvt->emulation,
+                                                 "it");
        }
        if (width == 0) {
                width = VTE_TAB_WIDTH;
@@ -4798,6 +4799,8 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
 {
        VteTerminal *terminal;
        GdkModifierType modifiers;
+       struct _vte_termcap *termcap;
+       const char *tterm;
        char *normal = NULL, *output;
        gssize normal_length = 0;
        int i;
@@ -4982,7 +4985,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                                suppress_meta_esc = FALSE;
                                break;
                        case VTE_ERASE_DELETE_SEQUENCE:
-                               special = VTE_TERMINFO_CAP_KEY_DC;
+                               special = "kD";
                                suppress_meta_esc = TRUE;
                                break;
                        case VTE_ERASE_TTY:
@@ -5040,11 +5043,10 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                        case VTE_ERASE_DELETE_SEQUENCE:
                        case VTE_ERASE_AUTO:
                        default:
-                               special = VTE_TERMINFO_CAP_KEY_DC;
+                               special = "kD";
                                break;
                        }
                        handled = TRUE;
-                        /* FIXMEchpe: why? this overrides the FALSE set above? */
                        suppress_meta_esc = TRUE;
                        break;
                case GDK_KEY_KP_Insert:
@@ -5150,7 +5152,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                }
                /* If the above switch statement didn't do the job, try mapping
                 * it to a literal or capability name. */
-               if (handled == FALSE && terminal->pvt->terminfo != NULL) {
+               if (handled == FALSE && terminal->pvt->termcap != NULL) {
                        _vte_keymap_map(keyval, modifiers,
                                        terminal->pvt->sun_fkey_mode,
                                        terminal->pvt->hp_fkey_mode,
@@ -5158,7 +5160,9 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                                        terminal->pvt->vt220_fkey_mode,
                                        terminal->pvt->cursor_mode == VTE_KEYMODE_APPLICATION,
                                        terminal->pvt->keypad_mode == VTE_KEYMODE_APPLICATION,
-                                       terminal->pvt->terminfo,
+                                       terminal->pvt->termcap,
+                                       terminal->pvt->emulation ?
+                                       terminal->pvt->emulation : vte_get_default_emulation(),
                                        &normal,
                                        &normal_length,
                                        &special);
@@ -5230,9 +5234,13 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                        g_free(normal);
                } else
                /* If the key maps to characters, send them to the child. */
-               if (special != NULL) {
-                        normal = g_strdup(_vte_terminfo_get_string_by_cap(terminal->pvt->terminfo, special, 
FALSE));
-                        normal_length = strlen(normal);
+               if (special != NULL && terminal->pvt->termcap != NULL) {
+                       termcap = terminal->pvt->termcap;
+                       tterm = terminal->pvt->emulation;
+                       normal = _vte_termcap_find_string_length(termcap,
+                                                                tterm,
+                                                                special,
+                                                                &normal_length);
                        _vte_keymap_key_add_key_modifiers(keyval,
                                                          modifiers,
                                                          terminal->pvt->sun_fkey_mode,
@@ -5244,13 +5252,12 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                                                          &normal_length);
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
-                        /* FIXMEchpe: wtf! */
                        output = g_strdup_printf(normal, 1);
 #pragma GCC diagnostic pop
                        vte_terminal_feed_child_using_modes(terminal,
                                                            output, -1);
-                        g_free(normal);
                        g_free(output);
+                       g_free(normal);
                }
                /* Keep the cursor on-screen. */
                if (!scrolled && !modifier &&
@@ -8018,7 +8025,7 @@ vte_terminal_set_vadjustment(VteTerminal *terminal,
  * @emulation: (allow-none): the name of a terminal description, or %NULL to use the default
  *
  * Sets what type of terminal the widget attempts to emulate by scanning for
- * control sequences defined in the system's terminfo file.  Unless you
+ * control sequences defined in the system's termcap file.  Unless you
  * are interested in this feature, always use "xterm".
  */
 void
@@ -8040,36 +8047,45 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation)
        terminal->pvt->emulation = g_intern_string(emulation);
        _vte_debug_print(VTE_DEBUG_MISC,
                        "Setting emulation to `%s'...\n", emulation);
-       /* Find and read the right terminfo file. */
-       vte_terminal_set_terminfo(terminal);
+       /* Find and read the right termcap file. */
+       vte_terminal_set_termcap(terminal);
 
        /* Create a table to hold the control sequences. */
        if (terminal->pvt->matcher != NULL) {
                _vte_matcher_free(terminal->pvt->matcher);
        }
-       terminal->pvt->matcher = _vte_matcher_new(terminal->pvt->terminfo);
+       terminal->pvt->matcher = _vte_matcher_new(emulation, terminal->pvt->termcap);
 
-       if (terminal->pvt->terminfo != NULL) {
+       if (terminal->pvt->termcap != NULL) {
                /* Read emulation flags. */
-               terminal->pvt->flags.am = _vte_terminfo_get_boolean(terminal->pvt->terminfo,
-                                                                   VTE_TERMINFO_VAR_AUTO_RIGHT_MARGIN);
-               terminal->pvt->flags.bw = _vte_terminfo_get_boolean(terminal->pvt->terminfo,
-                                                                   VTE_TERMINFO_VAR_AUTO_LEFT_MARGIN);
-               terminal->pvt->flags.ul = _vte_terminfo_get_boolean(terminal->pvt->terminfo,
-                                                                   VTE_TERMINFO_VAR_TRANSPARENT_UNDERLINE);
-               terminal->pvt->flags.xn = _vte_terminfo_get_boolean(terminal->pvt->terminfo,
-                                                                   VTE_TERMINFO_VAR_EAT_NEWLINE_GLITCH);
+               terminal->pvt->flags.am = _vte_termcap_find_boolean(terminal->pvt->termcap,
+                                                                   terminal->pvt->emulation,
+                                                                   "am");
+               terminal->pvt->flags.bw = _vte_termcap_find_boolean(terminal->pvt->termcap,
+                                                                   terminal->pvt->emulation,
+                                                                   "bw");
+               terminal->pvt->flags.LP = _vte_termcap_find_boolean(terminal->pvt->termcap,
+                                                                   terminal->pvt->emulation,
+                                                                   "LP");
+               terminal->pvt->flags.ul = _vte_termcap_find_boolean(terminal->pvt->termcap,
+                                                                   terminal->pvt->emulation,
+                                                                   "ul");
+               terminal->pvt->flags.xn = _vte_termcap_find_boolean(terminal->pvt->termcap,
+                                                                   terminal->pvt->emulation,
+                                                                   "xn");
 
                /* Resize to the given default. */
-               columns = _vte_terminfo_get_numeric(terminal->pvt->terminfo,
-                                                   VTE_TERMINFO_VAR_COLUMNS);
+               columns = _vte_termcap_find_numeric(terminal->pvt->termcap,
+                                                   terminal->pvt->emulation,
+                                                   "co");
                if (columns <= 0) {
                        columns = VTE_COLUMNS;
                }
                terminal->pvt->default_column_count = columns;
 
-               rows = _vte_terminfo_get_numeric(terminal->pvt->terminfo,
-                                                 VTE_TERMINFO_VAR_LINES);
+               rows = _vte_termcap_find_numeric(terminal->pvt->termcap,
+                                                terminal->pvt->emulation,
+                                                "li");
                if (rows <= 0 ) {
                        rows = VTE_ROWS;
                }
@@ -8132,9 +8148,9 @@ _vte_terminal_inline_error_message(VteTerminal *terminal, const char *format, ..
        g_free (str);
 }
 
-/* Set the path to the terminfo file we read, and read it in. */
+/* Set the path to the termcap file we read, and read it in. */
 static void
-vte_terminal_set_terminfo(VteTerminal *terminal)
+vte_terminal_set_termcap(VteTerminal *terminal)
 {
         GObject *object = G_OBJECT(terminal);
         const char *emulation;
@@ -8144,14 +8160,14 @@ vte_terminal_set_terminfo(VteTerminal *terminal)
         emulation = terminal->pvt->emulation ? terminal->pvt->emulation
                                              : vte_get_default_emulation();
 
-       _vte_debug_print(VTE_DEBUG_MISC, "Loading terminfo `%s'...",
+       _vte_debug_print(VTE_DEBUG_MISC, "Loading termcap `%s'...",
                         emulation);
-       if (terminal->pvt->terminfo != NULL) {
-               _vte_terminfo_unref(terminal->pvt->terminfo);
+       if (terminal->pvt->termcap != NULL) {
+               _vte_termcap_free(terminal->pvt->termcap);
        }
-       terminal->pvt->terminfo = _vte_terminfo_new(emulation);
+       terminal->pvt->termcap = _vte_termcap_new(emulation);
        _vte_debug_print(VTE_DEBUG_MISC, "\n");
-       if (terminal->pvt->terminfo == NULL) {
+       if (terminal->pvt->termcap == NULL) {
                _vte_terminal_inline_error_message(terminal,
                                "Failed to load terminal capabilities for '%s'",
                                emulation);
@@ -8167,7 +8183,7 @@ _vte_terminal_codeset_changed_cb(struct _vte_iso2022_state *state, gpointer p)
 }
 
 /* Initialize the terminal widget after the base widget stuff is initialized.
- * We need to create a new psuedo-terminal pair, read in the terminfo file, and
+ * We need to create a new psuedo-terminal pair, read in the termcap file, and
  * set ourselves up to do the interpretation of sequences. */
 static void
 vte_terminal_init(VteTerminal *terminal)
@@ -8243,7 +8259,7 @@ vte_terminal_init(VteTerminal *terminal)
        vte_terminal_set_encoding(terminal, NULL);
        g_assert(terminal->pvt->encoding != NULL);
 
-       /* Load the terminfo data and set up the emulation. */
+       /* Load the termcap data and set up the emulation. */
        pvt->keypad_mode = VTE_KEYMODE_NORMAL;
        pvt->cursor_mode = VTE_KEYMODE_NORMAL;
        pvt->dec_saved = g_hash_table_new(NULL, NULL);
@@ -8752,8 +8768,8 @@ vte_terminal_finalize(GObject *object)
        if (terminal->pvt->matcher != NULL) {
                _vte_matcher_free(terminal->pvt->matcher);
        }
-       if (terminal->pvt->terminfo != NULL) {
-               _vte_terminfo_unref(terminal->pvt->terminfo);
+       if (terminal->pvt->termcap != NULL) {
+               _vte_termcap_free(terminal->pvt->termcap);
        }
 
        remove_update_timeout (terminal);
@@ -10736,7 +10752,9 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
                                terminal->pvt->vt220_fkey_mode,
                                terminal->pvt->cursor_mode == VTE_KEYMODE_APPLICATION,
                                terminal->pvt->keypad_mode == VTE_KEYMODE_APPLICATION,
-                               terminal->pvt->terminfo,
+                               terminal->pvt->termcap,
+                               terminal->pvt->emulation ?
+                               terminal->pvt->emulation : vte_get_default_emulation(),
                                &normal,
                                &normal_length,
                                &special);
@@ -11693,14 +11711,14 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                     VTE_TYPE_ERASE_BINDING,
                                     VTE_ERASE_AUTO,
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
+     
         /**
          * VteTerminal:emulation:
          *
          * Sets what type of terminal the widget attempts to emulate by scanning for
-         * control sequences defined in the system's terminfo file.  Unless you
+         * control sequences defined in the system's termcap file.  Unless you
          * are interested in this feature, always use the default which is "xterm".
-         *
+         * 
          * Since: 0.20
          */
         g_object_class_install_property
diff --git a/src/vte.gresource.xml.in b/src/vte.gresource.xml.in
index 1196a60..1c39baf 100644
--- a/src/vte.gresource.xml.in
+++ b/src/vte.gresource.xml.in
@@ -16,4 +16,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <gresources>
+  <gresource prefix="/org/gnome/vte/@VTE_API_VERSION@/termcap">
+    <file alias="xterm">@top_srcdir@/termcaps/xterm</file>
+  </gresource>
 </gresources>
diff --git a/src/vteconv.c b/src/vteconv.c
index a64b0a0..ef94880 100644
--- a/src/vteconv.c
+++ b/src/vteconv.c
@@ -18,20 +18,15 @@
 
 /* The interfaces in this file are subject to change at any time. */
 
-#include "config.h"
 
+#include <config.h>
 #include <sys/types.h>
 #include <errno.h>
 #include <string.h>
 #include <glib.h>
 #include "buffer.h"
 #include "vteconv.h"
-
-#ifdef VTE_COMPILATION
 #include "vte-private.h"
-#else
-#define VTE_UTF8_BPC                    (6) /* Maximum number of bytes used per UTF-8 character */
-#endif
 
 typedef size_t (*convert_func)(GIConv converter,
                          const guchar **inbuf,
diff --git a/src/vteseq.c b/src/vteseq.c
index 1897678..e05fc29 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -28,7 +28,7 @@
 
 #include "vte.h"
 #include "vte-private.h"
-#include "vteti.h"
+#include "vtetc.h"
 
 #define BEL "\007"
 #define ST _VTE_CAP_ST
@@ -397,19 +397,22 @@ _vte_terminal_scroll_text (VteTerminal *terminal, int scroll_amount)
 }
 
 static gboolean
-vte_terminal_terminfo_string_same_as_for (VteTerminal *terminal,
-                                          const char *cap_str,
-                                          guint var_other)
+vte_terminal_termcap_string_same_as_for (VteTerminal *terminal,
+                                        const char  *cap_str,
+                                        const char  *cap_other)
 {
-       const char *other_str;
+       char *other_str;
+       gboolean ret;
 
-       other_str = _vte_terminfo_get_string(terminal->pvt->terminfo,
-                                             var_other);
+       other_str = _vte_termcap_find_string(terminal->pvt->termcap,
+                                            terminal->pvt->emulation,
+                                            cap_other);
 
-        /* FIXMEchpe: why case insensitive compare!? */
-        return cap_str &&
-               other_str &&
-               g_ascii_strcasecmp(cap_str, other_str) == 0;
+       ret = other_str && (g_ascii_strcasecmp(cap_str, other_str) == 0);
+
+       g_free (other_str);
+
+       return ret;
 }
 
 /* Set icon/window titles. */
@@ -2002,7 +2005,7 @@ vte_sequence_handler_scroll_up (VteTerminal *terminal, GValueArray *params)
 static void
 vte_sequence_handler_se (VteTerminal *terminal, GValueArray *params)
 {
-       const char *standout;
+       char *standout;
 
        /* Standout may be mapped to another attribute, so attempt to do
         * the Right Thing here.
@@ -2010,22 +2013,24 @@ vte_sequence_handler_se (VteTerminal *terminal, GValueArray *params)
         * If the standout sequence is the same as another sequence, do what
         * we'd do for that other sequence instead. */
 
-       standout = _vte_terminfo_get_string(terminal->pvt->terminfo,
-                                            VTE_TERMINFO_VAR_ENTER_STANDOUT_MODE);
+       standout = _vte_termcap_find_string(terminal->pvt->termcap,
+                                           terminal->pvt->emulation,
+                                           "so");
+       g_assert(standout != NULL);
 
-        /* FIXMEchpe: why not cache this in pvt? */
-       if (standout != NULL &&
-            (vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_BLINK_MODE)     /* blink */   ||
-             vte_terminal_terminfo_string_same_as_for (terminal, standout, VTE_TERMINFO_VAR_ENTER_BOLD_MODE) 
     /* bold */    ||
-             vte_terminal_terminfo_string_same_as_for (terminal, standout, VTE_TERMINFO_VAR_ENTER_DIM_MODE)  
     /* half */    ||
-             vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_REVERSE_MODE)   /* reverse */ ||
-             vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_UNDERLINE_MODE) /* underline */))
+       if (vte_terminal_termcap_string_same_as_for (terminal, standout, "mb") /* blink */   ||
+           vte_terminal_termcap_string_same_as_for (terminal, standout, "md") /* bold */    ||
+           vte_terminal_termcap_string_same_as_for (terminal, standout, "mh") /* half */    ||
+           vte_terminal_termcap_string_same_as_for (terminal, standout, "mr") /* reverse */ ||
+           vte_terminal_termcap_string_same_as_for (terminal, standout, "us") /* underline */)
        {
                vte_sequence_handler_me (terminal, params);
        } else {
                /* Otherwise just set standout mode. */
                terminal->pvt->screen->defaults.attr.standout = 0;
        }
+
+       g_free(standout);
 }
 
 /* Cursor down, with scrolling. */
@@ -2047,7 +2052,7 @@ vte_sequence_handler_SF (VteTerminal *terminal, GValueArray *params)
 static void
 vte_sequence_handler_so (VteTerminal *terminal, GValueArray *params)
 {
-       const char *standout;
+       char *standout;
 
        /* Standout may be mapped to another attribute, so attempt to do
         * the Right Thing here.
@@ -2055,23 +2060,27 @@ vte_sequence_handler_so (VteTerminal *terminal, GValueArray *params)
         * If the standout sequence is the same as another sequence, do what
         * we'd do for that other sequence instead. */
 
-       standout = _vte_terminfo_get_string(terminal->pvt->terminfo,
-                                            VTE_TERMINFO_VAR_ENTER_STANDOUT_MODE);
+       standout = _vte_termcap_find_string(terminal->pvt->termcap,
+                                           terminal->pvt->emulation,
+                                           "so");
+       g_assert(standout != NULL);
 
-       if (vte_terminal_terminfo_string_same_as_for (terminal, standout, VTE_TERMINFO_VAR_ENTER_BLINK_MODE) 
/* blink */)
+       if (vte_terminal_termcap_string_same_as_for (terminal, standout, "mb") /* blink */)
                vte_sequence_handler_mb (terminal, params);
-       else if (vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_BOLD_MODE) /* bold */)
+       else if (vte_terminal_termcap_string_same_as_for (terminal, standout, "md") /* bold */)
                vte_sequence_handler_md (terminal, params);
-       else if (vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_DIM_MODE) /* half */)
+       else if (vte_terminal_termcap_string_same_as_for (terminal, standout, "mh") /* half */)
                vte_sequence_handler_mh (terminal, params);
-       else if (vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_REVERSE_MODE) /* reverse */)
+       else if (vte_terminal_termcap_string_same_as_for (terminal, standout, "mr") /* reverse */)
                vte_sequence_handler_mr (terminal, params);
-       else if (vte_terminal_terminfo_string_same_as_for (terminal, standout, 
VTE_TERMINFO_VAR_ENTER_UNDERLINE_MODE) /* underline */)
+       else if (vte_terminal_termcap_string_same_as_for (terminal, standout, "us") /* underline */)
                vte_sequence_handler_us (terminal, params);
        else {
                /* Otherwise just set standout mode. */
                terminal->pvt->screen->defaults.attr.standout = 1;
        }
+
+       g_free(standout);
 }
 
 /* Cursor up, scrolling if need be. */
@@ -3725,9 +3734,3 @@ _vte_terminal_handle_sequence(VteTerminal *terminal,
                                  match_s);
        }
 }
-
-gboolean
- _vte_terminal_can_handle_sequence(const char *name)
-{
-        return _vte_sequence_get_handler(name) != NULL;
-}
diff --git a/src/vtetc.c b/src/vtetc.c
new file mode 100644
index 0000000..8c8e20c
--- /dev/null
+++ b/src/vtetc.c
@@ -0,0 +1,648 @@
+/*
+ * Copyright © 2006 Ryan Lortie <desrt desrt ca>
+ * based on code © 2000-2002 Red Hat, Inc. and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "vtetc.h"
+
+/*
+ * --- a termcap file is represented by a simple tree ---
+ */
+typedef struct _vte_termcap
+{
+  GBytes *data;
+  GTree *tree;
+  const char *end;
+} VteTermcap;
+
+/* a special strcmp that treats any character in
+ * its third argument (plus '\0') as end of
+ * string.
+ *
+ *  we have to be a little bit careful, however.
+ *  note that '=' < 'A' < '|' and consider the
+ *  following three strings with "=|" given as
+ *  the 3rd argument:
+ *
+ *  foo=
+ *  fooA
+ *  foo|
+ *
+ *  if we just do the normal *a - *b thing when
+ *  the strings don't match then we will find
+ *
+ *      "foo=" < "fooA"
+ *
+ *  and
+ *
+ *      "foo|" > "fooA"
+ *
+ *  but of course,
+ *
+ *      "foo=" == "foo|"
+ *
+ *  which means that our ordering isn't proper
+ *  which may cause odd things to happen inside of
+ *  the tree.  for this reason, all of the
+ *  terminating characters are treated as '\0' for
+ *  purposes of deciding greater or less than.
+ *
+ *  note: if anything in this file should be
+ *        micro-optimised then it is probably
+ *        this function!
+ */
+static int
+_vte_termcap_strcmp (const char *a,
+                     const char *b,
+                     const char *enders)
+{
+  /* note: strchr on '\0' returns the
+   * end of the string (not NULL)
+   */
+
+  while (!strchr (enders, *a))
+  {
+    if (*a != *b)
+    {
+      /* we're in the loop so we know that *a is not a terminator.
+       * but maybe *b is?
+       */
+      if (strchr (enders, *b))
+        return *a - '\0';
+      else
+        /* b is not a terminator.  proceed normally. */
+        return *a - *b;
+    }
+    a++;
+    b++;
+  }
+
+  /* *a is a terminator for sure, but maybe *b is too. */
+  if (strchr (enders, *b))
+    /* b is too, so we have a match. */
+    return 0;
+
+  /* else, since *a is a terminator character and *b is not, *a is
+   * less than *b. */
+  return -1;
+}
+
+/*
+ * --- routines for searching the tree ---
+ */
+static const char *
+_vte_termcap_find_start (VteTermcap *termcap,
+                         const char *tname,
+                         const char *cap)
+{
+  const char *contents;
+  const char *start;
+  char *chain;
+
+  /* find the terminal */
+  contents = g_tree_lookup (termcap->tree, tname);
+
+  if (contents == NULL)
+    return NULL;
+
+  start = contents;
+  while (contents != termcap->end)
+  {
+    if (*contents == '\\' &&
+        contents + 1 != termcap->end &&
+        contents[1] == '\n')
+    {
+      /* we've hit \ at the end of a line.  skip. */
+      contents++;
+    }
+    else if (*contents == ':' || *contents == '\n')
+    {
+      if (!_vte_termcap_strcmp (start, cap, "=#:\n"))
+        return start;
+
+      start = contents + 1;
+      if (*contents == '\n')
+        break;
+    }
+
+    contents++;
+  }
+
+  /* else, try to find it in the term listed in our 'tc' entry.
+   * obviously, don't recurse when we're trying to find "tc"
+   * itself else we infinite loop.
+   */
+  if (!strcmp (cap, "tc"))
+    return NULL;
+
+  chain = _vte_termcap_find_string (termcap, tname, "tc");
+  if (chain[0])
+    start = _vte_termcap_find_start (termcap, chain, cap);
+  g_free (chain);
+
+  return start;
+}
+
+static int
+_vte_termcap_unescape_string(const char *string, char *result)
+{
+  int value = -1;
+  int length = 0;
+
+  while (TRUE)
+  {
+    /* Each time through the loop puts a value into 'value' if it
+     * wants to have it written into the string.  We do the write
+     * here because it is complicated (check for NULL result, etc)
+     *
+     * We finish and return the length whenb value is 0.
+     */
+    if (value >= 0)
+    {
+      if (result != NULL)
+        result[length] = value;
+      length++;
+
+      if (value == 0)
+        return length;
+
+      value = -1;
+    }
+
+    /* Now, decide what value should be for the next iteration.
+     * Here, "continue;" means "I've possibly set 'value' and I want
+     * to continue looking at the string starting at the next
+     * character pointed to by 'string'.
+     */
+    switch (*string++)
+    {
+      case '\n':
+      case '\0':
+      case ':':
+        value = 0;
+        continue;
+
+      case '\\':
+        switch (*string++)
+        {
+          case '\n':
+            while (*string == ' ' || *string == '\t')
+              string++;
+            continue;
+          case 'E':
+          case 'e':
+            value = 27;
+            continue;
+          case 'n':
+            value = 10;
+            continue;
+          case 'r':
+            value = 13;
+            continue;
+          case 't':
+            value = 8;
+            continue;
+          case 'b':
+            value = 9;
+            continue;
+          case 'f':
+            value = 12;
+            continue;
+          case '0':
+          case '1':
+            value = strtol(string - 1, (void *) &string, 8);
+            continue;
+          default:
+            /* invalid escape sequence.  write the \ and
+             * continue as if we never saw it...
+             */
+            value = '\\';
+            string--;
+            continue;
+        }
+
+      case '^':
+        if (*string >= 'A' && *string <= 'Z')
+        {
+          value = *string++ - '@';
+          break;
+        }
+
+        /* else, invalid control sequnce.  write the ^
+         * and continue as if we never saw it...
+         */
+
+      default:
+        /* else, the value is this character and the pointer has
+         * already been advanced to the next character. */
+        value = string[-1];
+    }
+  }
+}
+
+char *
+_vte_termcap_find_string_length (VteTermcap *termcap,
+                                 const char *tname,
+                                 const char *cap,
+                                 gssize *length)
+{
+  const char *result = _vte_termcap_find_start (termcap, tname, cap);
+  char *string;
+
+  if (result == NULL || result[2] != '=')
+  {
+    *length = 0;
+    return g_strdup ("");
+  }
+
+  result += 3;
+
+  *length = _vte_termcap_unescape_string (result, NULL);
+  string = g_malloc (*length);
+  _vte_termcap_unescape_string (result, string);
+
+  (*length)--;
+
+  return string;
+}
+
+char *
+_vte_termcap_find_string (VteTermcap *termcap,
+                          const char *tname,
+                          const char *cap)
+{
+  gssize length;
+
+  return _vte_termcap_find_string_length (termcap, tname, cap, &length);
+}
+
+long
+_vte_termcap_find_numeric (VteTermcap *termcap,
+                           const char *tname,
+                           const char *cap)
+{
+  const char *result = _vte_termcap_find_start (termcap, tname, cap);
+  long value;
+  char *end;
+
+  if (result == NULL || result[2] != '#')
+    return 0;
+
+  result += 3;
+
+  value = strtol (result, &end, 0);
+  if (*end != ':' && *end != '\0' && *end != '\n')
+    return 0;
+
+  return value;
+}
+
+gboolean
+_vte_termcap_find_boolean (VteTermcap *termcap,
+                           const char *tname,
+                           const char *cap)
+{
+  const char *result = _vte_termcap_find_start (termcap, tname, cap);
+
+  if (result == NULL)
+    return FALSE;
+
+  result += 2;
+
+  if (*result != ':' && *result != '\0' && *result != '\n')
+    return FALSE;
+
+  return TRUE;
+}
+
+/*
+ * --- routines for building the tree from the file ---
+ */
+static void
+_vte_termcap_parse_entry (GTree *termcap, const char **cnt, const char *end)
+{
+  gboolean seen_content;
+  const char *contents;
+  const char *start;
+  const char *caps;
+
+  contents = *cnt;
+
+  /* look for the start of the capabilities.
+   */
+  caps = contents;
+  while (caps != end)
+    if (*caps == ':')
+      break;
+    else
+      caps++;
+
+  if (*caps != ':')
+    return;
+
+  /* parse all of the aliases and insert one item into the termcap
+   * tree for each alias, pointing it to our caps.
+   */
+  seen_content = FALSE;
+  start = contents;
+  while (contents != end)
+  {
+    /* 
+    if (contents == end)
+    {
+       * we can't deal with end of file directly following a
+       * terminal name without any delimiters or even a newline.
+       * but honestly, what did they expect?  end of file without
+       * newline in the middle of a terminal alias with no
+       * capability definitions?  i'll doubt they notice that
+       * anything is missing.
+    }
+    */
+
+    if (*contents == '\\' && contents + 1 != end && contents[1] == '\n')
+    {
+      /* we've hit \ at the end of a line.  skip. */
+      contents++;
+    }
+    else if (*contents == '|' || *contents == ':' || *contents == '\n')
+    {
+      /* we wait to find the terminator before putting anything in
+       * the tree to ensure that _vte_termcap_strcmp will always
+       * terminate.  we also only add the alias if we've seen
+       * actual characters (not just spaces, continuations, etc)
+       */
+      if (seen_content)
+        g_tree_insert (termcap, (gpointer) start, (gpointer) caps);
+      start = contents + 1;
+      seen_content = FALSE;
+
+      /* we've either hit : and need to move on to capabilities or
+       * end of line and then there are no capabilities for this
+       * terminal.  any aliases have already been added to the tree
+       * so we can just move on.  if it was '\n' then the next while
+       * loop will exit immediately.
+       */
+      if (*contents == ':' || *contents == '\n')
+        break;
+    }
+    else if (*contents != ' ' && *contents != '\t')
+      seen_content = TRUE;
+
+    contents++;
+  }
+
+  /* we've processed all of the aliases.  now skip past the capabilities
+   * so that we're ready to go on the next entry. */
+  while (contents != end)
+  {
+    if (*contents == '\\' && contents + 1 != end && contents[1] == '\n')
+    {
+      /* we've hit \ at the end of a line.  skip. */
+      contents++;
+    }
+    else if (*contents == '\n')
+      break;
+
+    contents++;
+  }
+
+  *cnt = contents;
+}
+
+static GTree *
+_vte_termcap_parse_file (const char *contents, int length)
+{
+  const char *end = contents + length;
+  GTree *termcap;
+
+  /* this tree contains terminal alias names which in a proper
+   * termcap file will always be followed by : or |.  we
+   * include \n to be extra-permissive. \0 is here to allow
+   * us to notice the end of strings passed to us by vte.
+   */
+  termcap = g_tree_new_full ((GCompareDataFunc) _vte_termcap_strcmp,
+                             (gpointer)":|\n", NULL, NULL);
+
+  while (contents != end)
+  {
+    switch (*contents++)
+    {
+      /* comments */
+      case '#':
+        /* eat up to (but not) the \n */
+        while (contents != end && *contents != '\n')
+          contents++;
+
+      /* whitespace */
+      case ' ':
+      case '\t':
+      case '\n':
+        continue;
+
+      default:
+        /* bring back the character */
+        contents--;
+
+        /* parse one entry (ie: one line) */
+        _vte_termcap_parse_entry (termcap, &contents, end);
+    }
+  }
+
+  return termcap;
+}
+
+static VteTermcap *
+_vte_termcap_new_take_bytes (GBytes *data)
+{
+  VteTermcap *termcap;
+  const char *contents;
+  gsize length;
+
+  contents = g_bytes_get_data (data, &length);
+
+  termcap = g_slice_new (VteTermcap);
+  termcap->data = data; /* adopted */
+  termcap->tree = _vte_termcap_parse_file (contents, length);
+  termcap->end = contents + length;
+
+  return termcap;
+}
+
+static VteTermcap *
+_vte_termcap_new_from_file (const char *path)
+{
+  GMappedFile *file;
+  GBytes *data;
+
+  file = g_mapped_file_new (path, FALSE, NULL);
+  if (file == NULL)
+    return NULL;
+
+  data = g_bytes_new_with_free_func (g_mapped_file_get_contents (file),
+                                     g_mapped_file_get_length (file),
+                                     (GDestroyNotify) g_mapped_file_unref,
+                                     file);
+
+  return _vte_termcap_new_take_bytes (data);
+}
+
+static VteTermcap *
+_vte_termcap_create (const char *name)
+{
+#ifdef VTE_API_VERSION
+  char *path;
+  GBytes *data;
+
+  /* First try the builtin termcaps */
+  path = g_build_path ("/",
+                       "/org/gnome/vte",
+                       VTE_API_VERSION,
+                       "termcap",
+                       name,
+                       NULL);
+  data = g_resources_lookup_data (path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
+  g_free(path);
+  if (data != NULL)
+    return _vte_termcap_new_take_bytes (data);
+#endif /* VTE_API_VERSION */
+
+  /* Try /etc/termcap */
+  return _vte_termcap_new_from_file ("/etc/termcap");
+}
+
+static void
+_vte_termcap_destroy (VteTermcap *termcap)
+{
+  if (!termcap)
+    return;
+  g_tree_destroy (termcap->tree);
+  g_bytes_unref (termcap->data);
+  g_slice_free (VteTermcap, termcap);
+}
+
+/*
+ * --- cached interface to create/destroy termcap trees ---
+ */
+static GStaticMutex _vte_termcap_mutex = G_STATIC_MUTEX_INIT;
+static GCache *_vte_termcap_cache = NULL;
+
+VteTermcap *
+_vte_termcap_new(const char *name)
+{
+  VteTermcap *result;
+
+  g_static_mutex_lock (&_vte_termcap_mutex);
+
+  if (_vte_termcap_cache == NULL)
+    _vte_termcap_cache = g_cache_new((GCacheNewFunc) _vte_termcap_create,
+                                     (GCacheDestroyFunc) _vte_termcap_destroy,
+                                     (GCacheDupFunc) g_strdup,
+                                     (GCacheDestroyFunc) g_free,
+                                     g_str_hash, g_direct_hash, g_str_equal);
+
+  result = g_cache_insert (_vte_termcap_cache, (gpointer) name);
+
+  g_static_mutex_unlock (&_vte_termcap_mutex);
+
+  return result;
+}
+
+void
+_vte_termcap_free (VteTermcap *termcap)
+{
+  g_static_mutex_lock (&_vte_termcap_mutex);
+  g_cache_remove (_vte_termcap_cache, termcap);
+  g_static_mutex_unlock (&_vte_termcap_mutex);
+}
+
+#ifdef TERMCAP_MAIN
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  VteTermcap *tc;
+  char *str;
+  gssize len;
+  int i;
+
+  if (argc < 4)
+  {
+    g_printerr("vtetc /path/to/termcap termname attrs...\n"
+                     "  where attrs are\n"
+                     "    :xx for boolean\n"
+                     "    =xx for string\n"
+                     "    +xx for string displayed in hex\n"
+                     "    #xx for numeric\n");
+    return 1;
+  }
+
+  tc = _vte_termcap_new_from_file (argv[1]);
+
+  if (tc == NULL)
+  {
+    perror ("open");
+    return 1;
+  }
+
+  for (i = 3; i < argc; i++)
+  {
+    printf ("%s -> ", argv[i]);
+
+    switch (argv[i][0])
+    {
+      case ':':
+        printf ("%s\n", _vte_termcap_find_boolean (tc, argv[2], argv[i] + 1)?
+                        "true" : "false");
+        break;
+
+      case '=':
+      case '+':
+        str = _vte_termcap_find_string_length (tc, argv[2], argv[i] + 1, &len);
+
+        if (argv[i][0] == '=')
+          printf ("'%s' (%d)\n", str, (int)len);
+        else
+        {
+          int i;
+
+          for (i = 0; str[i]; i++)
+            printf ("%02x", str[i]);
+          printf (" (%d) \n", (int)len);
+        }
+        g_free (str);
+        break;
+
+      case '#':
+        printf ("%ld\n", _vte_termcap_find_numeric (tc, argv[2], argv[i] + 1));
+        break;
+
+      default:
+        g_printerr("unrecognised type '%c'\n", argv[i][0]);
+    }
+  }
+
+  _vte_termcap_free(tc);
+
+  return 0;
+}
+#endif
diff --git a/src/vtetc.h b/src/vtetc.h
new file mode 100644
index 0000000..0b914ce
--- /dev/null
+++ b/src/vtetc.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2000-2002 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/* The interfaces in this file are subject to change at any time. */
+
+#ifndef vte_termcap_h_included
+#define vte_termcap_h_included
+
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+struct _vte_termcap;
+
+/* Create a new termcap structure. */
+struct _vte_termcap *_vte_termcap_new(const char *name);
+
+/* Free a termcap structure. */
+void _vte_termcap_free(struct _vte_termcap *termcap);
+
+/* Read a boolean capability for a given terminal. */
+gboolean _vte_termcap_find_boolean(struct _vte_termcap *termcap,
+                                  const char *tname, const char *cap);
+
+/* Read a numeric capability for a given terminal. */
+long _vte_termcap_find_numeric(struct _vte_termcap *termcap, const char *tname,
+                              const char *cap);
+
+/* Read a string capability for a given terminal.  The returned string should
+ * be freed with g_free(). */
+char *_vte_termcap_find_string(struct _vte_termcap *termcap, const char *tname,
+                              const char *cap);
+
+/* Read a string capability for a given terminal, and return the length of
+ * the result in addition to the result itself.  The returned string should
+ * be freed with g_free(). */
+char *_vte_termcap_find_string_length(struct _vte_termcap *termcap,
+                                     const char *tname,
+                                     const char *cap, gssize *length);
+
+G_END_DECLS
+
+#endif
diff --git a/termcaps/Makefile.am b/termcaps/Makefile.am
new file mode 100644
index 0000000..da5eeae
--- /dev/null
+++ b/termcaps/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = xterm.baseline
+dist_noinst_DATA = xterm
+
+-include $(top_srcdir)/git.mk
diff --git a/termcaps/xterm b/termcaps/xterm
new file mode 100644
index 0000000..cc48373
--- /dev/null
+++ b/termcaps/xterm
@@ -0,0 +1,33 @@
+# This is a cut-down version of the termcap file from my box with some entries
+# removed (add them back in to override the terminal's behavior):
+# kI (Insert, Delete is handled programmatically)
+# kP/kN (Page Up, Page Down)
+# ku/kd/kl/kr (Up, Down, Left, Right)
+# k1/kd2/k3/k4/k5/k6/k7/k8/k9/k; (F1-F10)
+# K1/K2/K3/K4/K5 (KP Up, Down, Left, Right, Begin)
+xterm-xfree86|xterm-new|xterm terminal emulator (XFree86):\
+       :am:km:mi:ms:xn:\
+       :co#80:it#8:li#24:\
+       :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\
+       :LE=\E[%dD:\
+       :RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:bt=\E[Z:\
+       :cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\
+       :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\
+       :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
+       :kD=\177:\
+       :kb=^H:ke=\E[?1l\E>:\
+       :ks=\E[?1h\E=:le=^H:mb=\E[5m:md=\E[1m:\
+       :me=\E[m\017:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[27m:\
+       :sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[?1047l\E[?1048l:\
+       :ti=\E[?1048h\E[?1047h:ue=\E[24m:up=\E[A:us=\E[4m:\
+       :vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h:
+# xterm-redhat is identical to xterm-xfree86 with the addition of a small
+# VT220-ism regarding the backspace and delete keys; this is mandated by
+# the keyboard configuration section of the Debian Policy Manual.
+xterm-redhat|Red Hat xterm (backspace and delete changed):\
+       :kD=\E[3~:kb=\177:tc=xterm-xfree86:
+# This is the only entry which you should have to customize, since "xterm"
+# is widely used for a variety of incompatible terminal emulations including
+# color_xterm and rxvt.
+xterm|X11 terminal emulator:\
+       :tc=xterm-redhat:
diff --git a/termcaps/xterm-color b/termcaps/xterm-color
new file mode 100644
index 0000000..f0b0840
--- /dev/null
+++ b/termcaps/xterm-color
@@ -0,0 +1,27 @@
+# This is a cut-down version of the termcap file from my box.
+
+xterm-color|generic "ANSI" color xterm (X Window System):\
+       :Co#8:NC@:pa#64:\
+       :AB=\E[4%dm:AF=\E[3%dm:op=\E[m:tc=xterm-r6:
+
+xterm-r6|xterm-old|xterm X11R6 version:\
+       :am:km:mi:ms:xn:\
+       :co#80:it#8:li#24:\
+       :@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\
+       :F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\
+       :F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\
+       :Km=\E[M:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:\
+       :bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\
+       :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:eA=\E)0:\
+       :ei=\E[4l:ho=\E[H:im=\E[4h:\
+       :is=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:k1=\EOP:\
+       :k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:\
+       :k8=\E[19~:k9=\E[20~:k;=\E[21~:kD=\177:kI=\E[2~:kN=\E[6~:\
+       :kP=\E[5~:kb=^H:kd=\EOB:ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:\
+       :kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:mb@:md=\E[1m:me=\E[m:\
+       :ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:rc=\E8:\
+       :rs=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:sc=\E7:\
+       :se=\E[m:sf=^J:so=\E[7m:sr=\EM:ta=^I:te=\E[2J\E[?47l\E8:\
+       :ti=\E7\E[?47h:u6=\E[%i%d;%dR:u7=\E[6n:u8=\E[?1;2c:\
+       :u9=\E[c:ue=\E[m:up=\E[A:us=\E[4m:
+
diff --git a/termcaps/xterm.baseline b/termcaps/xterm.baseline
new file mode 100644
index 0000000..47876b1
--- /dev/null
+++ b/termcaps/xterm.baseline
@@ -0,0 +1,35 @@
+# XFree86 updates/notes/new entries (including xterm-8bit, xterm-16color)
+# - Thomas E. Dickey <dickey clark net>
+# [snip]
+xterm-xfree86|xterm-new|xterm terminal emulator (XFree86):\
+       :am:km:mi:ms:xn:\
+       :co#80:it#8:li#24:\
+       :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\
+       :K1=\EOw:K2=\EOy:K3=\EOu:K4=\EOq:K5=\EOs:LE=\E[%dD:\
+       :RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:bt=\E[Z:\
+       :cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\
+       :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\
+       :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
+       :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\
+       :k7=\E[18~:k8=\E[19~:k9=\E[20~:kD=\177:kI=\E[2~:kN=\E[6~:\
+       :kP=\E[5~:kb=^H:kd=\EOB:ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:\
+       :kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:mb=\E[5m:md=\E[1m:\
+       :me=\E[m\017:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[27m:\
+       :sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[?1047l\E[?1048l:\
+       :ti=\E[?1048h\E[?1047h:ue=\E[24m:up=\E[A:us=\E[4m:\
+       :vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h:
+# xterm-redhat is identical to xterm-xfree86 with the addition of a small
+# VT220-ism regarding the backspace and delete keys; this is mandated by
+# the keyboard configuration section of the Debian Policy Manual.
+xterm-redhat|Red Hat xterm (backspace and delete changed):\
+       :kD=\E[3~:kb=\177:tc=xterm-xfree86:
+# This should work for the commonly used "color xterm" variations (XFree86
+# xterm, color_xterm, nxterm, rxvt):
+xterm-color|generic "ANSI" color xterm (X Window System):\
+       :Co#8:NC@:pa#64:\
+       :AB=\E[4%dm:AF=\E[3%dm:op=\E[m:tc=xterm-r6:
+# This is the only entry which you should have to customize, since "xterm"
+# is widely used for a variety of incompatible terminal emulations including
+# color_xterm and rxvt.
+xterm|X11 terminal emulator:\
+       :tc=xterm-redhat:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]