diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-02-10 19:23:18 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-02-10 19:23:18 +0000 |
commit | c71e1928a203855b10bc2524900fd00a48a8435e (patch) | |
tree | 82bbf5f0acb9cefd5cd76d662c2dda42a3de2b2d /termkey.c | |
parent | b3647c4861f6b46bf8054259a768f0e8b1ea3017 (diff) | |
download | termo-c71e1928a203855b10bc2524900fd00a48a8435e.tar.gz termo-c71e1928a203855b10bc2524900fd00a48a8435e.tar.xz termo-c71e1928a203855b10bc2524900fd00a48a8435e.zip |
Have 'termkey_advisereadable' return a value indicating if it's likely useful to call it again
Diffstat (limited to 'termkey.c')
-rw-r--r-- | termkey.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -444,6 +444,7 @@ termkey_result termkey_getkey(termkey_t *tk, termkey_key *key) case TERMKEY_RES_NONE: case TERMKEY_RES_EOF: + case TERMKEY_RES_AGAIN: break; } @@ -569,17 +570,21 @@ void termkey_pushinput(termkey_t *tk, unsigned char *input, size_t inputlen) tk->buffcount += inputlen; } -void termkey_advisereadable(termkey_t *tk) +termkey_result termkey_advisereadable(termkey_t *tk) { unsigned char buffer[64]; // Smaller than the default size size_t len = read(tk->fd, buffer, sizeof buffer); if(len == -1 && errno == EAGAIN) - return; - else if(len < 1) + return TERMKEY_RES_NONE; + else if(len < 1) { tk->is_closed = 1; - else + return TERMKEY_RES_NONE; + } + else { termkey_pushinput(tk, buffer, len); + return TERMKEY_RES_AGAIN; + } } const char *termkey_describe_sym(termkey_t *tk, termkey_keysym code) |