From 020f40693a08b836abdea74f3823a0bce0378ec5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 17 May 2009 16:44:54 +0200 Subject: line editing: add an option to emit ESC [ 6 n and use results This makes line editing able to recognize case when cursor was not at the beginning of the line. It may also be adapted later to find out display size (serial line users would love it). Signed-off-by: Denys Vlasenko --- include/libbb.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index bae7efb00..788140d14 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -962,16 +962,23 @@ enum { KEYCODE_FUN11 = -22, KEYCODE_FUN12 = -23, #endif - /* How long the longest ESC sequence we know? */ - KEYCODE_BUFFER_SIZE = 4 + KEYCODE_CURSOR_POS = -0x100, + /* How long is the longest ESC sequence we know? + * We want it big enough to be able to contain + * cursor position sequence "ESC [ 9999 ; 9999 R" + */ + KEYCODE_BUFFER_SIZE = 16 }; /* Note: fd may be in blocking or non-blocking mode, both make sense. * For one, less uses non-blocking mode. * Only the first read syscall inside read_key may block indefinitely * (unless fd is in non-blocking mode), * subsequent reads will time out after a few milliseconds. + * Return of -1 means EOF or error (errno == 0 on EOF). + * buffer[0] is used as a counter of buffered chars and must be 0 + * on first call. */ -int read_key(int fd, smalluint *nbuffered, char *buffer) FAST_FUNC; +int64_t read_key(int fd, char *buffer) FAST_FUNC; /* Networking */ -- cgit v1.2.3