Commit 4e253be9 authored by Egmont Koblinger's avatar Egmont Koblinger

emulation: No longer rely on terminfo; drop ncurses dependency

https://bugzilla.gnome.org/show_bug.cgi?id=728900#c5
parent 99e912b2
......@@ -3,16 +3,9 @@ cleaning it as fast as possible and aiming for a 1.0 release "next year".
Please contact people listed in filed MAINTAINERS if you intend to hack
on it, especially if you want to commit stuff.
Vte is different from other terminal emulators in that instead of hard
coding behavior of a few select terminals, it can emulate any terminal
simply by reading its terminfo capabilities file. The idea being that
if applications can communicate with any terminal by reading its
capabilities, the emulation widget can also behave like any terminal by
reading that file. Well, that's just the idea :).
This is the most useful resource in understanding various internal states
as well as control sequences:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
And to understand termcap, terminfo, etc, "make terminfo" is a great start.
And to understand termcap, terminfo, etc, "man 5 terminfo" is a great start.
......@@ -5,9 +5,6 @@ and a minimal sample application (vte) using that. Vte is mainly used in
gnome-terminal, but can also be used to embed a console/terminal in games,
editors, IDEs, etc.
VTE supports Unicode and character set conversion, as well as emulating any
terminal known to the system's terminfo database.
VTE doesn't have a homepage. Report any issues at:
http://bugzilla.gnome.org/enter_bug.cgi?product=vte
......@@ -172,8 +172,8 @@ AC_DEFINE(GDK_MULTIHEAD_SAFE,1,[Force use of GDK multihead-safe APIs.])
AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal])
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
VTE_DEFAULT_EMULATION=xterm
AC_DEFINE_UNQUOTED(VTE_DEFAULT_EMULATION,"$VTE_DEFAULT_EMULATION",[The default terminal type to be emulated.])
VTE_DEFAULT_TERM=xterm
AC_DEFINE_UNQUOTED(VTE_DEFAULT_TERM,"$VTE_DEFAULT_TERM",[The default value $TERM is set to.])
# Check for headers.
AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h stropts.h termios.h util.h wchar.h)
......@@ -212,18 +212,10 @@ VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$
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
......
......@@ -66,8 +66,6 @@ vte_terminal_match_set_cursor_type
vte_terminal_match_set_cursor_name
vte_terminal_set_cjk_ambiguous_width
vte_terminal_get_cjk_ambiguous_width
vte_terminal_set_emulation
vte_terminal_get_emulation
vte_terminal_set_encoding
vte_terminal_get_encoding
vte_terminal_write_contents
......@@ -79,7 +77,6 @@ vte_terminal_search_set_gregex
vte_terminal_search_set_wrap_around
<SUBSECTION>
vte_get_default_emulation
vte_get_user_shell
<SUBSECTION>
......
......@@ -37,8 +37,6 @@ EXTRA_libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
unitable.JIS0208 \
unitable.JIS0212 \
unitable.KSX1001 \
vteseq-2.gperf \
vteseq-2.c \
vteseq-n.gperf \
vteseq-n.c \
vtetypebuiltins.c.template \
......@@ -88,9 +86,6 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_SOURCES = \
vtestream-base.h \
vtestream-file.h \
vteterminal.h \
vteti.c \
vteti.h \
vtetivars.h \
vtetree.c \
vtetree.h \
vteunistr.c \
......@@ -121,7 +116,6 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_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_LDFLAGS = \
......@@ -131,15 +125,14 @@ libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_LDFLAGS = \
$(AM_LDFLAGS)
libvte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_la_LIBADD = \
$(VTE_LIBS) \
$(TERMINFO_LIBS)
$(VTE_LIBS)
# Generated sources
VTESEQ_BUILTSOURCES = vteseq-list.h vteseq-2.c vteseq-n.c
VTESEQ_BUILTSOURCES = vteseq-list.h 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 box_drawing_generate.sh iso2022.txt vtetivars.awk
EXTRA_DIST += $(VTESEQ_BUILTSOURCES) box_drawing.txt box_drawing_generate.sh iso2022.txt
CLEANFILES += box_drawing.h marshal.c marshal.h vtetypebuiltins.c vtetypebuiltins.h stamp-vtetypebuiltins.h vteresources.c
box_drawing.h: box_drawing.txt
......@@ -164,15 +157,11 @@ vtetypebuiltins.c: vtetypebuiltins.c.template vteenums.h
&& (cmp -s xgen-vtbc vtetypebuiltins.c || cp xgen-vtbc vtetypebuiltins.c ) \
&& rm -f xgen-vtbc
vteseq-2.c: vteseq-2.gperf
$(AM_V_GEN) $(top_srcdir)/missing --run gperf -m 100 --no-strlen $< > $@.tmp && \
mv -f $@.tmp $@
vteseq-n.c: vteseq-n.gperf
$(AM_V_GEN) $(top_srcdir)/missing --run gperf -m 100 $< > $@.tmp && \
mv -f $@.tmp $@
vteseq-list.h: vteseq-2.gperf vteseq-n.gperf
vteseq-list.h: vteseq-n.gperf
$(AM_V_GEN) echo '/* Generated file. Do not edit */' > $@.tmp && \
cat $^ | grep -v '^#' | grep '\<VTE_SEQUENCE_HANDLER\>'| sed 's/.*, //' | LANG=C sort -u >> $@.tmp && \
mv -f $@.tmp $@
......@@ -180,10 +169,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 =
......@@ -320,7 +305,7 @@ 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
TESTS = table trie vteconv $(TEST_SH)
reflect_text_view_CPPFLAGS = -DUSE_TEXT_VIEW $(AM_CPPFLAGS)
......@@ -349,9 +334,6 @@ interpret_SOURCES = \
trie.h \
vteconv.c \
vteconv.h \
vteti.c \
vteti.h \
vtetivars.h \
vtetree.c \
vtetree.h \
interpret.c
......@@ -363,12 +345,10 @@ interpret_CFLAGS = \
$(GLIB_CFLAGS) \
$(GOBJECT_CFLAGS) \
$(GTK_CFLAGS) \
$(TERMINFO_CFLAGS) \
$(AM_CFLAGS)
interpret_LDADD = \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(TERMINFO_LIBS)
$(GOBJECT_LIBS)
iso2022_SOURCES = \
buffer.h \
......@@ -386,9 +366,6 @@ iso2022_SOURCES = \
trie.h \
vteconv.c \
vteconv.h \
vteti.c \
vteti.h \
vtetivars.h \
vtetree.c \
vtetree.h
iso2022_CPPFLAGS = \
......@@ -397,12 +374,10 @@ iso2022_CPPFLAGS = \
iso2022_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(TERMINFO_CFLAGS) \
$(AM_CFLAGS)
iso2022_LDADD = \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(TERMINFO_LIBS)
$(GOBJECT_LIBS)
slowcat_SOURCES = \
slowcat.c \
......@@ -424,21 +399,16 @@ 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)
$(GOBJECT_LIBS)
trie_SOURCES = \
trie.c \
......@@ -454,9 +424,6 @@ trie_SOURCES = \
table.h \
vteconv.c \
vteconv.h \
vteti.c \
vteti.h \
vtetivars.h \
$(NULL)
trie_CPPFLAGS = \
-DTRIE_MAIN \
......@@ -464,30 +431,10 @@ trie_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)
$(GOBJECT_LIBS)
vteconv_SOURCES = buffer.h debug.c debug.h vteconv.c vteconv.h
vteconv_CPPFLAGS = -DVTECONV_MAIN $(AM_CPPFLAGS)
......
......@@ -106,8 +106,6 @@ 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.encoding != null)
terminal.set_encoding(App.Options.encoding);
......@@ -563,7 +561,6 @@ 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 int transparency_percent = 0;
public static bool version = false;
public static string? working_directory = null;
......@@ -756,8 +753,6 @@ 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 },
{ "terminfo", 't', 0, OptionArg.STRING, ref term,
"Specify the terminal emulation to use", null },
{ "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
"Enable the use of a transparent background", "0..100" },
{ "version", 0, 0, OptionArg.NONE, ref version,
......
......@@ -59,3 +59,45 @@ _vte_debug_init(void)
_vte_debug_print(0xFFFFFFFF, "VTE debug flags = %x\n", _vte_debug_flags);
#endif /* VTE_DEBUG */
}
const char *
_vte_debug_sequence_to_string(const char *str)
{
#if defined(VTE_DEBUG)
static const char codes[][6] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
"SPACE"
};
static GString *buf;
int i;
if (str == NULL)
return "(nil)";
if (buf == NULL)
buf = g_string_new(NULL);
g_string_truncate(buf, 0);
for (i = 0; str[i]; i++) {
guint8 c = (guint8)str[i];
if (i > 0)
g_string_append_c(buf, ' ');
if (c <= 0x20)
g_string_append(buf, codes[c]);
else if (c == 0x7f)
g_string_append(buf, "DEL");
else if (c >= 0x80)
g_string_append_printf(buf, "\\%02x ", c);
else
g_string_append_c(buf, c);
}
return buf->str;
#else
return NULL;
#endif /* VTE_DEBUG */
}
......@@ -64,6 +64,7 @@ typedef enum {
} VteDebugFlags;
void _vte_debug_init(void);
const char *_vte_debug_sequence_to_string(const char *str);
extern VteDebugFlags _vte_debug_flags;
static inline gboolean _vte_debug_on(VteDebugFlags flags) G_GNUC_CONST G_GNUC_UNUSED;
......
......@@ -33,13 +33,11 @@
#include "debug.h"
#include "iso2022.h"
#include "matcher.h"
#include "vteti.h"
int
main(int argc, char **argv)
{
struct _vte_matcher *matcher = NULL;
struct _vte_terminfo *terminfo = NULL;
GArray *array;
unsigned int i, j;
int l;
......@@ -53,15 +51,15 @@ main(int argc, char **argv)
_vte_debug_init();
if (argc < 2) {
g_print("usage: %s TERM [file]\n", argv[0]);
if (argc < 1) {
g_print("usage: %s [file]\n", argv[0]);
return 1;
}
if ((argc > 2) && (strcmp(argv[2], "-") != 0)) {
infile = open (argv[2], O_RDONLY);
if ((argc > 1) && (strcmp(argv[1], "-") != 0)) {
infile = open (argv[1], O_RDONLY);
if (infile == -1) {
g_print("error opening %s: %s\n", argv[2],
g_print("error opening %s: %s\n", argv[1],
strerror(errno));
exit(1);
}
......@@ -70,15 +68,10 @@ 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]);
return 1;
}
array = g_array_new(FALSE, FALSE, sizeof(gunichar));
matcher = _vte_matcher_new(terminfo);
matcher = _vte_matcher_new();
subst = _vte_iso2022_state_new(NULL, VTE_ISO2022_DEFAULT_UTF8_AMBIGUOUS_WIDTH, NULL, NULL);
......@@ -164,7 +157,6 @@ main(int argc, char **argv)
_vte_iso2022_state_free(subst);
g_array_free(array, TRUE);
_vte_terminfo_unref(terminfo);
_vte_matcher_free(matcher);
return 0;
}
......@@ -773,7 +773,7 @@ _vte_keymap_map(guint keyval,
normal_length);
_vte_debug_print(VTE_DEBUG_KEYBOARD,
" to '%s'.\n",
_vte_terminfo_sequence_to_string(*normal));
_vte_debug_sequence_to_string(*normal));
return;
}
......
......@@ -24,8 +24,6 @@
#include <glib.h>
#include <gdk/gdk.h>
#include "vteti.h"
G_BEGIN_DECLS
#define VTE_META_MASK GDK_META_MASK
......
......@@ -33,24 +33,14 @@ 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 GMutex _vte_matcher_mutex;
static struct _vte_matcher *_vte_matcher_singleton = NULL;
static int _vte_matcher_ref_count = 0;
static struct _vte_matcher_impl dummy_vte_matcher_trie = {
&_vte_matcher_trie
};
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,82 +50,22 @@ _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 *code, *value;
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.
*/
for (i = 0; _vte_xterm_capability_strings[i].value != NULL; i++) {
code = _vte_xterm_capability_strings[i].code;
value = _vte_xterm_capability_strings[i].value;
_vte_matcher_add(matcher, code, strlen (code),
value, 0);
}
/* Add emulator-specific sequences. */
if (terminfo != NULL && _vte_terminfo_is_xterm_like(terminfo)) {
/* Add all of the xterm-specific stuff. */
for (i = 0;
_vte_xterm_capability_strings[i].value != NULL;
i++) {
code = _vte_xterm_capability_strings[i].code;
value = _vte_xterm_capability_strings[i].value;
_vte_matcher_add(matcher, code, strlen (code),
value, 0);
}
}
_VTE_DEBUG_IF(VTE_DEBUG_TRIE) {
g_printerr("Trie contents:\n");
_vte_matcher_print(matcher);
......@@ -144,34 +74,25 @@ _vte_matcher_init(struct _vte_matcher *matcher,
}
/* Allocates new matcher structure. */
static gpointer
_vte_matcher_create(gpointer key)
static struct _vte_matcher *
_vte_matcher_create(void)
{
struct _vte_terminfo *terminfo = key;
struct _vte_matcher *ret = NULL;
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_create()\n");
ret = g_slice_new(struct _vte_matcher);
ret->impl = &dummy_vte_matcher_trie;
/* FIXMEchpe,egmont: The trie matcher is never used, we should remove it */
ret->impl = &dummy_vte_matcher_table;
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)) {
ret->impl = &dummy_vte_matcher_table;
}
return ret;
}
/* Noone uses this matcher, free it. */
static void
_vte_matcher_destroy(gpointer value)
_vte_matcher_destroy(struct _vte_matcher *matcher)
{
struct _vte_matcher *matcher = value;
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_destroy()\n");
if (matcher->free_params != NULL) {
g_value_array_free (matcher->free_params);
......@@ -183,46 +104,39 @@ _vte_matcher_destroy(gpointer value)
/* Create and init matcher. */
struct _vte_matcher *
_vte_matcher_new(struct _vte_terminfo *terminfo)
_vte_matcher_new(void)
{
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 (_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);
}
g_mutex_lock(&_vte_matcher_mutex);
ret = g_cache_insert(_vte_matcher_cache, terminfo);
if (_vte_matcher_ref_count++ == 0) {
g_assert(_vte_matcher_singleton == NULL);
ret = _vte_matcher_create();
if (ret->match == NULL) {
ret->impl = ret->impl->klass->create();
ret->match = ret->impl->klass->match;
_vte_matcher_init(ret, terminfo);
if (ret->match == NULL) {
ret->impl = ret->impl->klass->create();
ret->match = ret->impl->klass->match;
_vte_matcher_init(ret);
}
_vte_matcher_singleton = ret;
}
g_static_mutex_unlock(&_vte_matcher_mutex);
G_GNUC_END_IGNORE_DEPRECATIONS;
return ret;
g_mutex_unlock(&_vte_matcher_mutex);
return _vte_matcher_singleton;
}
/* Free a matcher. */
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;
g_assert(_vte_matcher_singleton != NULL);
g_mutex_lock(&_vte_matcher_mutex);
if (--_vte_matcher_ref_count == 0) {
_vte_matcher_destroy(matcher);
_vte_matcher_singleton = NULL;
}
g_mutex_unlock(&_vte_matcher_mutex);
}
/* Check if a string matches a sequence the matcher knows about. */
......
......@@ -23,7 +23,6 @@
#include <glib-object.h>
#include "vteti.h"
G_BEGIN_DECLS
......@@ -53,7 +52,7 @@ struct _vte_matcher_class{
};
/* Create and init matcher. */
struct _vte_matcher *_vte_matcher_new(struct _vte_terminfo *terminfo);
struct _vte_matcher *_vte_matcher_new(void);
/* Free a matcher. */
void _vte_matcher_free(struct _vte_matcher *matcher);
......
......@@ -226,7 +226,6 @@ struct _VtePtyPrivate {
VtePtyFlags flags;
int pty_fd;
const char *term;
VtePtyChildSetupData child_setup_data;
gpointer helper_tag; /* only use when using_helper is TRUE */
......@@ -354,9 +353,9 @@ vte_pty_child_setup (VtePty *pty)
_vte_pty_reset_signal_handlers();
/* Now set the TERM environment variable */
if (priv->term != NULL) {
g_setenv("TERM", priv->term, TRUE);
}
/* FIXME: Setting environment here seems to have no effect, the merged envp2 will override on exec.
* By the way, we'd need to set the one from there, if any. */
g_setenv("TERM", VTE_DEFAULT_TERM, TRUE);
g_snprintf (version, sizeof (version), "%u", VTE_VERSION_NUMERIC);
g_setenv ("VTE_VERSION", version, TRUE);
......@@ -374,7 +373,6 @@ vte_pty_child_setup (VtePty *pty)
/*
* __vte_pty_merge_environ:
* @envp: environment vector
* @term_value: the value for the TERM env variable, or %NULL
* @inherit: whether to use the parent environment
*
* Merges @envp to the parent environment, and returns a new environment vector.
......@@ -383,7 +381,6 @@ vte_pty_child_setup (VtePty *pty)
*/
static gchar **
__vte_pty_merge_environ (char **envp,
const char *term_value,
gboolean inherit)
{
GHashTable *table;
......@@ -405,6 +402,9 @@ __vte_pty_merge_environ (char **envp,
g_strfreev (parent_environ);
}
/* Make sure the one in envp overrides the default. */
g_hash_table_replace (table, g_strdup ("TERM"), g_strdup (VTE_DEFAULT_TERM));
if (envp != NULL) {
for (i = 0; envp[i] != NULL; i++) {
name = g_strdup (envp[i]);
......@@ -417,9 +417,6 @@ __vte_pty_merge_environ (char **envp,
}
}
if (term_value != NULL)
g_hash_table_replace (table, g_strdup ("TERM"), g_strdup (term_value));
g_hash_table_replace (table, g_strdup ("VTE_VERSION"), g_strdup_printf ("%u", VTE_VERSION_NUMERIC));
array = g_ptr_array_sized_new (g_hash_table_size (table) + 1);
......@@ -493,7 +490,7 @@ __vte_pty_spawn (VtePty *pty,
spawn_flags &= ~VTE_SPAWN_NO_PARENT_ENVV;
/* add the given environment to the childs */
envp2 = __vte_pty_merge_environ (envv, pty->priv->term, inherit_envv);
envp2 = __vte_pty_merge_environ (envv, inherit_envv);
_VTE_DEBUG_IF (VTE_DEBUG_MISC) {
g_printerr ("Spawing command:\n");
......@@ -1431,7 +1428,6 @@ enum {
PROP_0,
PROP_FLAGS,
PROP_FD,
PROP_TERM
};
/* GInitable impl */
......@@ -1530,7 +1526,6 @@ vte_pty_init (VtePty *pty)
priv->foreign = FALSE;
priv->using_helper = FALSE;
priv->helper_tag = NULL;
priv->term = vte_get_default_emulation(); /* already interned */
}
static void
......@@ -1573,10 +1568,6 @@ vte_pty_get_property (GObject *object,
g_value_set_int(value, vte_pty_get_fd(pty));
break;
case PROP_TERM:
g_value_set_string(value, priv->term);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
......@@ -1601,10 +1592,6 @@ vte_pty_set_property (GObject *object,
priv->foreign = (priv->pty_fd != -1);
break;
case PROP_TERM:
vte_pty_set_term(pty, g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
......@@ -1654,22 +1641,6 @@ vte_pty_class_init (VtePtyClass *klass)