From 775806d32b73ebfe7abaec6e172de336431eca0d Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Thu, 8 Mar 2012 21:58:27 +0000 Subject: Added documentation for termkey_{start,stop}, termkey_is_started --- man/also | 2 ++ man/termkey_getkey.3.sh | 5 ++++- man/termkey_new.3 | 2 +- man/termkey_start.3 | 25 +++++++++++++++++++++++++ man/termkey_waitkey.3.sh | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 man/termkey_start.3 diff --git a/man/also b/man/also index 89ca23e..611ca45 100644 --- a/man/also +++ b/man/also @@ -5,3 +5,5 @@ termkey_get_canonflags.3 = termkey_set_canonflags.3 termkey_get_buffer_size.3 = termkey_set_buffer_size.3 termkey_get_waittime.3 = termkey_set_waittime.3 termkey_getkey_force.3 = termkey_getkey.3 +termkey_stop.3 = termkey_start.3 +termkey_is_started.3 = termkey_start.3 diff --git a/man/termkey_getkey.3.sh b/man/termkey_getkey.3.sh index c18b5a8..2f1b716 100644 --- a/man/termkey_getkey.3.sh +++ b/man/termkey_getkey.3.sh @@ -27,6 +27,9 @@ no bytes are waiting in the buffer. .TP .B TERMKEY_RES_EOF no bytes are ready and the input stream is now closed. +.TP +.B TERMKEY_RES_ERROR +called with terminal IO stopped, due to \fBtermkey_stop\fP(3). In this case \fIerrno\fP will be set to \fBEINVAL\fP. .PP \fBtermkey_getkey_force\fP() is similar to \fBtermkey_getkey\fP() but will not return \fBTERMKEY_RES_AGAIN\fP if a partial match is found. Instead, it will force an interpretation of the bytes, even if this means interpreting the start of an Escape-prefixed multi-byte sequence as a literal "Escape" key followed by normal letters. .PP @@ -34,7 +37,7 @@ Neither of these functions will block or perform any IO operations on the underl .PP Before returning, this function canonicalises the \fIkey\fP structure according to the rules given for \fBtermkey_canonicalise\fP(3). .SH "RETURN VALUE" -\fBtermkey_getkey\fP() returns an enumeration of one of \fBTERMKEY_RES_KEY\fP, \fBTEMRKEY_RES_AGAIN\fP, \fBTERMKEY_RES_NONE\fP or \fBTERMKEY_RES_EOF\fP. \fBtermkey_getkey_force\fP() returns one of the above, except for \fBTERMKEY_RES_AGAIN\fP. +\fBtermkey_getkey\fP() returns an enumeration of one of \fBTERMKEY_RES_KEY\fP, \fBTEMRKEY_RES_AGAIN\fP, \fBTERMKEY_RES_NONE\fP, \fBTERMKEY_RES_EOF\fP or \fBTERMKEY_RES_ERROR\fP. \fBtermkey_getkey_force\fP() returns one of the above, except for \fBTERMKEY_RES_AGAIN\fP. .SH EXAMPLE The following example program prints details of every keypress until the user presses "Ctrl-C". It demonstrates how to use the \fBtermkey\fP instance in a typical \fBpoll\fP(2)-driven asynchronous program, which may include mixed IO with other file handles. .PP diff --git a/man/termkey_new.3 b/man/termkey_new.3 index 32b2937..6fad1ef 100644 --- a/man/termkey_new.3 +++ b/man/termkey_new.3 @@ -21,7 +21,7 @@ Link with \fI\-ltermkey\fP. .PP The constructor attempts to detect if the current locale is UTF-8 aware or not, and sets either the \fBTERMKEY_FLAG_UTF8\fP or \fBTERMKEY_FLAG_RAW\fP flag. One of these two bits will always be in effect. The current flags in effect can be obtained by \fBtermkey_get_flags\fP(3). .PP -If a file handle is provided, the terminfo driver may send a string to initialise or set the state of the terminal before \fBtermkey_new\fP() returns. This will not be done if no file handle is provided, or if the file handle is a pipe (\fBS_ISFIFO\fP()). In this case it will be the caller's responsibility to ensure the terminal is in the correct mode. +If a file handle is provided, the terminfo driver may send a string to initialise or set the state of the terminal before \fBtermkey_new\fP() returns. This will not be done if no file handle is provided, or if the file handle is a pipe (\fBS_ISFIFO\fP()). In this case it will be the caller's responsibility to ensure the terminal is in the correct mode. Once initialised, the terminal can be stopped by \fBtermkey_stop\fP(3), and started again by \fBtermkey_start\fP(3). .SH VERSION CHECK MACRO Before calling any functions in the \fBtermkey\fP library, an application should use the \fBTERMKEY_CHECK_VERSION\fP macro to check that the loaded version of the library is compatible with the version it was compiled against. This should be done early on, ideally just after entering its \fBmain\fP() function. .SH "RETURN VALUE" diff --git a/man/termkey_start.3 b/man/termkey_start.3 new file mode 100644 index 0000000..22df70f --- /dev/null +++ b/man/termkey_start.3 @@ -0,0 +1,25 @@ +.TH TERMKEY_START 3 +.SH NAME +termkey_start, termkey_stop, termkey_is_started \- enable or disable terminal operations +.SH SYNOPSIS +.nf +.B #include +.sp +.BI "int termkey_start(TermKey *" tk ); +.BI "int termkey_stop(TermKey *" tk ); +.sp +.BI "int termkey_is_started(TermKey *" tk ); +.fi +.sp +Link with \fI\-ltermkey\fP. +.SH DESCRIPTION +\fBtermkey_start\fP() enables the terminal IO operations of the given \fBtermkey\fP(7) instance, including sending a terminal control sequence and setting the \fBtermios\fP(3) modes required. +.PP +\fBtermkey_stop\fP() disables terminal IO operations, by reversing the steps taken by \fPtermkey_start\fP(). A newly-constructed \fBtermkey\fP instance will have terminal IO enabled already. +.PP +\fBtermkey_is_started\fP() enquires whether terminal IO is currently enabled. +.SH "RETURN VALUE" +If successful, \fBtermkey_start\fP() and \fBtermkey_stop\fP() return a true value. On failure, zero is returned with \fIerrno\fP set to indicate the failure. \fBtermkey_is_started\fP() returns true or false to indicate whether terminal IO is currently enabled. +.SH "SEE ALSO" +.BR termkey_new (3), +.BR termkey (7) diff --git a/man/termkey_waitkey.3.sh b/man/termkey_waitkey.3.sh index 8e59e24..5a219b4 100644 --- a/man/termkey_waitkey.3.sh +++ b/man/termkey_waitkey.3.sh @@ -27,7 +27,7 @@ A key event as been provided. No key events are ready and the terminal has been closed, so no more will arrive. .TP .B TERMKEY_RES_ERROR -An IO error occured. \fIerrno\fP will be preserved. If the error is \fBEINTR\fP then this will only be returned if \fBTERMKEY_FLAG_EINTR\fP flag is not set; if it is then the IO operation will be retried instead. +An IO error occured. \fIerrno\fP will be preserved. If the error is \fBEINTR\fP then this will only be returned if \fBTERMKEY_FLAG_EINTR\fP flag is not set; if it is then the IO operation will be retried instead. If this is called with terminal IO stopped, due to \fBtermkey_stop\fP(3) then \fIerrno\fP will be set to \fBEINVAL\fP. .SH EXAMPLE The following example program prints details of every keypress until the user presses "Ctrl-C". .PP -- cgit v1.2.3-70-g09d2