aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-09-27 23:30:10 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-09-27 23:30:10 +0200
commit991892fff518f59f02bbe1c8a4637843a82bd74e (patch)
treef8bb934a4481582789c5ecdee92233bd4d183369
parent9ec09b90c9bb023bb69a6b703ce4df40d397f5e6 (diff)
downloadtermo-991892fff518f59f02bbe1c8a4637843a82bd74e.tar.gz
termo-991892fff518f59f02bbe1c8a4637843a82bd74e.tar.xz
termo-991892fff518f59f02bbe1c8a4637843a82bd74e.zip
Allow specifying terminal name in termo_new()term-string
-rw-r--r--demo-async.c2
-rw-r--r--demo-draw.c2
-rw-r--r--demo-glib.c2
-rw-r--r--demo.c2
-rw-r--r--termo.c8
-rw-r--r--termo.h2
-rw-r--r--tests/05read.c2
7 files changed, 12 insertions, 8 deletions
diff --git a/demo-async.c b/demo-async.c
index 6b29a58..302312f 100644
--- a/demo-async.c
+++ b/demo-async.c
@@ -25,7 +25,7 @@ main (int argc, char *argv[])
TERMO_CHECK_VERSION;
setlocale (LC_CTYPE, "");
- termo_t *tk = termo_new (STDIN_FILENO, NULL, 0);
+ termo_t *tk = termo_new (STDIN_FILENO, NULL, NULL, 0);
if (!tk)
{
diff --git a/demo-draw.c b/demo-draw.c
index 26b583f..c193302 100644
--- a/demo-draw.c
+++ b/demo-draw.c
@@ -158,7 +158,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- termo_t *tk = termo_new (STDIN_FILENO, NULL, 0);
+ termo_t *tk = termo_new (STDIN_FILENO, NULL, NULL, 0);
if (!tk)
{
fprintf (stderr, "Cannot allocate termo instance\n");
diff --git a/demo-glib.c b/demo-glib.c
index 80f3a7b..5ad346d 100644
--- a/demo-glib.c
+++ b/demo-glib.c
@@ -57,7 +57,7 @@ main (int argc, char *argv[])
TERMO_CHECK_VERSION;
setlocale (LC_CTYPE, "");
- tk = termo_new (STDIN_FILENO, NULL, 0);
+ tk = termo_new (STDIN_FILENO, NULL, NULL, 0);
if (!tk)
{
fprintf (stderr, "Cannot allocate termo instance\n");
diff --git a/demo.c b/demo.c
index bc416c0..6550358 100644
--- a/demo.c
+++ b/demo.c
@@ -46,7 +46,7 @@ main(int argc, char *argv[])
}
}
- tk = termo_new (STDIN_FILENO, NULL,
+ tk = termo_new (STDIN_FILENO, NULL, NULL,
TERMO_FLAG_SPACESYMBOL | TERMO_FLAG_CTRLC);
if (!tk)
{
diff --git a/termo.c b/termo.c
index 953bc88..8a92821 100644
--- a/termo.c
+++ b/termo.c
@@ -415,7 +415,7 @@ abort_free_to_utf32:
}
termo_t *
-termo_new (int fd, const char *encoding, int flags)
+termo_new (int fd, const char *term, const char *encoding, int flags)
{
termo_t *tk = termo_alloc ();
if (!tk)
@@ -424,7 +424,11 @@ termo_new (int fd, const char *encoding, int flags)
tk->fd = fd;
termo_set_flags (tk, flags);
- const char *term = getenv ("TERM");
+ // In theory, we might have multiple different terminals open
+ // simultaneously; I'm not currently sure if it works
+ if (!term)
+ term = getenv ("TERM");
+
if (termo_init (tk, term, encoding)
&& termo_start (tk))
return tk;
diff --git a/termo.h b/termo.h
index 9df3e73..624060c 100644
--- a/termo.h
+++ b/termo.h
@@ -203,7 +203,7 @@ enum
void termo_check_version (int major, int minor);
-termo_t *termo_new (int fd, const char *encoding, int flags);
+termo_t *termo_new (int fd, const char *term, const char *encoding, int flags);
termo_t *termo_new_abstract (const char *term,
const char *encoding, int flags);
void termo_free (termo_t *tk);
diff --git a/tests/05read.c b/tests/05read.c
index 226acca..67f2092 100644
--- a/tests/05read.c
+++ b/tests/05read.c
@@ -21,7 +21,7 @@ main (int argc, char *argv[])
// Sanitise this just in case
putenv ("TERM=vt100");
- tk = termo_new (fd[0], NULL, TERMO_FLAG_NOTERMIOS);
+ tk = termo_new (fd[0], NULL, NULL, TERMO_FLAG_NOTERMIOS);
is_int (termo_get_buffer_remaining (tk), 256,
"buffer free initially 256");