diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-27 23:30:10 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-27 23:30:10 +0200 |
commit | 991892fff518f59f02bbe1c8a4637843a82bd74e (patch) | |
tree | f8bb934a4481582789c5ecdee92233bd4d183369 | |
parent | 9ec09b90c9bb023bb69a6b703ce4df40d397f5e6 (diff) | |
download | termo-991892fff518f59f02bbe1c8a4637843a82bd74e.tar.gz termo-991892fff518f59f02bbe1c8a4637843a82bd74e.tar.xz termo-991892fff518f59f02bbe1c8a4637843a82bd74e.zip |
Allow specifying terminal name in termo_new()term-string
-rw-r--r-- | demo-async.c | 2 | ||||
-rw-r--r-- | demo-draw.c | 2 | ||||
-rw-r--r-- | demo-glib.c | 2 | ||||
-rw-r--r-- | demo.c | 2 | ||||
-rw-r--r-- | termo.c | 8 | ||||
-rw-r--r-- | termo.h | 2 | ||||
-rw-r--r-- | tests/05read.c | 2 |
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"); @@ -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) { @@ -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; @@ -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"); |