diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-26 12:55:16 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-26 12:55:16 +0000 |
commit | ea2d3073ac177d95fc14c310178aa2b7455b060a (patch) | |
tree | 28f36380bd0e1a6c21c2fe8e4d56f388e87dc3e4 | |
parent | 63f37cecd6c68914016451eae714a163cf988db3 (diff) | |
download | termo-ea2d3073ac177d95fc14c310178aa2b7455b060a.tar.gz termo-ea2d3073ac177d95fc14c310178aa2b7455b060a.tar.xz termo-ea2d3073ac177d95fc14c310178aa2b7455b060a.zip |
Created termkey_new_abstract()
-rw-r--r-- | man/termkey_new.3 | 5 | ||||
-rw-r--r-- | termkey.c | 18 | ||||
-rw-r--r-- | termkey.h.in | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/man/termkey_new.3 b/man/termkey_new.3 index dd188d6..c727d22 100644 --- a/man/termkey_new.3 +++ b/man/termkey_new.3 @@ -7,12 +7,15 @@ termkey_new, termkey_destroy \- create or destroy new termkey instance .sp .BI "TERMKEY_CHECK_VERSION;" .BI "TermKey *termkey_new(int " fd ", int " flags ); +.BI "TermKey *termkey_new_abstract(const char *" term ", int " flags ); .BI "void termkey_destroy(TermKey *" tk ); .fi .sp Link with \fI\-ltermkey\fP. .SH DESCRIPTION -\fBtermkey_new\fP() creates a new \fBtermkey\fP(7) instance connected to the file handle opened by \fIfd\fP using the \fIflags\fP. The \fITermKey\fP structure should be considered opaque; its contents are not intended for use outside of the library. If \fIfd\fP is given the value -1, then no file handle will be associated. +\fBtermkey_new\fP() creates a new \fBtermkey\fP(7) instance connected to the file handle opened by \fIfd\fP using the \fIflags\fP. The \fITermKey\fP structure should be considered opaque; its contents are not intended for use outside of the library. +.PP +\fBtermkey_new_abstract\fP() creates a new \fBtermkey\fP() instance with no file handle associated. As this is usually done for handling other sources of terminal byte input, it also takes a string indicating the termtype to use. .PP \fBtermkey_destroy\fP() destroys the given instance and releases any resources controlled by it. It will not close the underlying filehandle given as the \fIfd\fP argument to \fBtermkey_new\fP(). .PP @@ -369,6 +369,24 @@ TermKey *termkey_new(int fd, int flags) return tk; } +TermKey *termkey_new_abstract(const char *term, int flags) +{ + TermKey *tk = termkey_alloc(); + if(!tk) + return NULL; + + tk->fd = -1; + + termkey_set_flags(tk, flags); + + if(!termkey_init(tk, term)) { + free(tk); + return NULL; + } + + return tk; +} + void termkey_free(TermKey *tk) { free(tk->buffer); tk->buffer = NULL; diff --git a/termkey.h.in b/termkey.h.in index d61afb5..1db9d4d 100644 --- a/termkey.h.in +++ b/termkey.h.in @@ -157,6 +157,7 @@ enum { void termkey_check_version(int major, int minor); TermKey *termkey_new(int fd, int flags); +TermKey *termkey_new_abstract(const char *term, int flags); void termkey_free(TermKey *tk); void termkey_destroy(TermKey *tk); |