=== modified file 'driver-ti.c' --- driver-ti.c 2012-01-18 14:03:39 +0000 +++ driver-ti.c 2011-09-23 23:04:01 +0000 @@ -296,7 +296,7 @@ /* The terminfo database will contain keys in application cursor key mode. * We may need to enable that mode */ - if(tk->fd != -1 && ti->start_string) { + if(ti->start_string) { // Can't call putp or tputs because they suck and don't give us fd control write(tk->fd, ti->start_string, strlen(ti->start_string)); } @@ -306,7 +306,7 @@ { TermKeyTI *ti = info; - if(tk->fd != -1 && ti->stop_string) { + if(ti->stop_string) { // Can't call putp or tputs because they suck and don't give us fd control write(tk->fd, ti->stop_string, strlen(ti->stop_string)); } === modified file 'man/termkey_advisereadable.3' --- man/termkey_advisereadable.3 2012-01-18 14:03:39 +0000 +++ man/termkey_advisereadable.3 2012-01-18 13:39:50 +0000 @@ -10,7 +10,7 @@ .sp Link with \fI-ltermkey\fP. .SH DESCRIPTION -\fBtermkey_advisereadable\fP() informs the instance that new input may be available on the underlying file descriptor and so it should call \fBread\fP(2) to obtain it. If at least one more byte was read it will return \fBTERMKEY_RES_AGAIN\fP to indicate it may be useful to call \fBtermkey_getkey\fP(3) again. If no more input was read then \fBTERMKEY_RES_NONE\fP is returned. If there was no buffer space remaining, then \fBTERMKEY_RES_ERROR\fP is returned with \fIerrno\fP set to \fBENOMEM\fP. If no filehandle is associated with this instance, \fBTERMKEY_RES_ERROR\fP is returned with \fIerrno\fP set to \fBEBADF\fP. +\fBtermkey_advisereadable\fP() informs the instance that new input may be available on the underlying file descriptor and so it should call \fBread\fP(2) to obtain it. If at least one more byte was read it will return \fBTERMKEY_RES_AGAIN\fP to indicate it may be useful to call \fBtermkey_getkey\fP(3) again. If no more input was read then \fBTERMKEY_RES_NONE\fP is returned. If there was no buffer space remaining, then \fBTERMKEY_RES_ERROR\fP is returned with \fIerrno\fP set to \fBENOMEM\fP. .PP This function, along with \fBtermkey_getkey\fP(3) make it possible to use the termkey instance in an asynchronous program. To provide bytes without using a readable file handle, use \fBtermkey_push_bytes\fP(3). .PP === modified file 'man/termkey_get_fd.3' --- man/termkey_get_fd.3 2012-01-18 14:03:39 +0000 +++ man/termkey_get_fd.3 2012-01-18 12:01:38 +0000 @@ -12,7 +12,7 @@ .SH DESCRIPTION \fBtermkey_get_fd\fP() returns the file descriptor that was passed as the \fIfd\fP argument to \fBtermkey_new\fP(3). .SH "RETURN VALUE" -\fBtermkey_get_fd\fP() returns the current file descriptor, or -1 if no file descriptor is associated with this instance. +\fBtermkey_get_fd\fP() returns the current file descriptor. .SH "SEE ALSO" .BR termkey_new (3), .BR termkey_get_flags (3) === modified file 'man/termkey_new.3' --- man/termkey_new.3 2012-01-18 14:03:39 +0000 +++ man/termkey_new.3 2012-01-18 12:01:38 +0000 @@ -12,12 +12,10 @@ .sp Link with \fI\-ltermkey\fP. .SH DESCRIPTION -\fBtermkey_new\fP() creates a new termkey 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 termkey 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_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 -A termkey instance contains a buffer of bytes representing keypresses yet to be returned to the application. This buffer may be fed bytes directly by calling \fBtermkey_push_bytes\fP(3), or by calling \fBtermkey_advisereadable\fP(3) which itself will \fBread\fP(3) them from the filehandle given by \fIfd\fP. Once in the buffer, these bytes can be returned as key press events by calling \fBtermkey_getkey\fP(3). The read and get operations are combined in a single function \fBtermkey_waitkey\fP(3), which may be more convenient to use in the standard case of blocking reads from the \fIstdin\fP filehandle. -.PP The following values may be given as the \fIflags\fP bitmask: .TP .B TERMKEY_FLAG_NOINTERPRET === modified file 'man/termkey_waitkey.3.sh' --- man/termkey_waitkey.3.sh 2012-01-18 14:03:39 +0000 +++ man/termkey_waitkey.3.sh 2012-01-18 12:01:38 +0000 @@ -12,7 +12,7 @@ .sp Link with \fI-ltermkey\fP. .SH DESCRIPTION -\fBtermkey_waitkey\fP(3) attempts to retrieve a single keypress event from the buffer, and put it in the structure referred to by \fIkey\fP. If successful it will return \fBTERMKEY_RES_KEY\fP to indicate that the structure now contains a new keypress event. If nothing is in the buffer it will block until one is available. If no events are ready and the input stream is now closed, will return \fBTERMKEY_RES_EOF\fP. If no filehandle is associated with this instance, \fBTERMKEY_RES_ERROR\fP is returned with \fIerrno\fP set to \fBEBADF\fP. +\fBtermkey_waitkey\fP(3) attempts to retrieve a single keypress event from the buffer, and put it in the structure referred to by \fIkey\fP. If successful it will return \fBTERMKEY_RES_KEY\fP to indicate that the structure now contains a new keypress event. If nothing is in the buffer it will block until one is available. If no events are ready and the input stream is now closed, will return \fBTERMKEY_RES_EOF\fP. .PP Before returning, this function canonicalises the \fIkey\fP structure according to the rules given for \fBtermkey_canonicalise\fP(3). .PP === modified file 't/01base.c' --- t/01base.c 2012-01-18 14:03:39 +0000 +++ t/01base.c 2011-03-31 12:51:21 +0000 @@ -8,7 +8,7 @@ plan_tests(2); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); ok(!!tk, "termkey_new"); === modified file 't/02getkey.c' --- t/02getkey.c 2012-01-18 14:03:39 +0000 +++ t/02getkey.c 2012-01-18 13:39:50 +0000 @@ -12,7 +12,7 @@ /* Sanitise this just in case */ putenv("TERM=vt100"); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); is_int(termkey_get_buffer_remaining(tk), 256, "buffer free initially 256"); === modified file 't/03utf8.c' --- t/03utf8.c 2012-01-18 14:03:39 +0000 +++ t/03utf8.c 2012-01-18 13:39:50 +0000 @@ -11,7 +11,7 @@ /* Sanitise this just in case */ putenv("TERM=vt100"); - tk = termkey_new(-1, TERMKEY_FLAG_UTF8); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS|TERMKEY_FLAG_UTF8); termkey_push_bytes(tk, "a", 1); === modified file 't/04flags.c' --- t/04flags.c 2012-01-18 14:03:39 +0000 +++ t/04flags.c 2012-01-18 13:39:50 +0000 @@ -12,7 +12,7 @@ /* Sanitise this just in case */ putenv("TERM=vt100"); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); termkey_push_bytes(tk, " ", 1); === modified file 't/10keyname.c' --- t/10keyname.c 2012-01-18 14:03:39 +0000 +++ t/10keyname.c 2011-04-01 12:26:54 +0000 @@ -9,7 +9,7 @@ plan_tests(10); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); sym = termkey_keyname2sym(tk, "Space"); is_int(sym, TERMKEY_SYM_SPACE, "keyname2sym Space"); === modified file 't/11strfkey.c' --- t/11strfkey.c 2012-01-18 14:03:39 +0000 +++ t/11strfkey.c 2011-04-01 09:48:15 +0000 @@ -10,7 +10,7 @@ plan_tests(28); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); key.type = TERMKEY_TYPE_UNICODE; key.code.codepoint = 'A'; === modified file 't/12strpkey.c' --- t/12strpkey.c 2012-01-18 14:03:39 +0000 +++ t/12strpkey.c 2011-04-07 19:19:34 +0000 @@ -11,7 +11,7 @@ plan_tests(53); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); CLEAR_KEY; endp = termkey_strpkey(tk, "A", &key, 0); === modified file 't/13cmpkey.c' --- t/13cmpkey.c 2012-01-18 14:03:39 +0000 +++ t/13cmpkey.c 2011-09-06 21:49:05 +0000 @@ -8,7 +8,7 @@ plan_tests(12); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); key1.type = TERMKEY_TYPE_UNICODE; key1.code.codepoint = 'A'; === modified file 't/20canon.c' --- t/20canon.c 2012-01-18 14:03:39 +0000 +++ t/20canon.c 2011-08-28 16:57:57 +0000 @@ -11,7 +11,7 @@ plan_tests(26); - tk = termkey_new(-1, 0); + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); CLEAR_KEY; endp = termkey_strpkey(tk, " ", &key, 0); === modified file 'termkey.c' --- termkey.c 2012-01-18 14:03:39 +0000 +++ termkey.c 2012-01-18 13:39:50 +0000 @@ -284,7 +284,7 @@ goto abort_free_keynames; } - if(fd != -1 && !(flags & TERMKEY_FLAG_NOTERMIOS)) { + if(!(flags & TERMKEY_FLAG_NOTERMIOS)) { struct termios termios; if(tcgetattr(fd, &termios) == 0) { tk->restore_termios = termios; @@ -887,11 +887,6 @@ TermKeyResult termkey_waitkey(TermKey *tk, TermKeyKey *key) { - if(tk->fd == -1) { - errno = EBADF; - return TERMKEY_RES_ERROR; - } - while(1) { TermKeyResult ret = termkey_getkey(tk, key); @@ -949,11 +944,6 @@ { ssize_t len; - if(tk->fd == -1) { - errno = EBADF; - return TERMKEY_RES_ERROR; - } - if(tk->buffstart) { memmove(tk->buffer, tk->buffer + tk->buffstart, tk->buffcount); tk->buffstart = 0;