diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-04-16 21:14:05 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-04-16 21:14:05 +0000 |
commit | e361d2f498442315a074703caa63a6c55ab8b578 (patch) | |
tree | 0bd046d05ce3141ff518dbae645043e4c3c39d32 /src/fe-text/term-terminfo.c | |
parent | 77dd63ac835d32b0343098a4d7b61588da9ed6f1 (diff) | |
download | irssi-e361d2f498442315a074703caa63a6c55ab8b578.zip |
Remove the need to buffer input by moving the 'gui key pressed' events
generation into term_gets.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4805 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/term-terminfo.c')
-rw-r--r-- | src/fe-text/term-terminfo.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 4b1b2bb8..293a0595 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -608,40 +608,40 @@ void term_set_input_type(int type) } } -int term_gets(unichar *buffer, int size) +void term_gets(void) { int ret, i, char_len; if (term_detached) - return 0; + return; /* fread() doesn't work */ - if (size > sizeof(term_inbuf)-term_inbuf_pos) - size = sizeof(term_inbuf)-term_inbuf_pos; ret = read(fileno(current_term->in), - term_inbuf + term_inbuf_pos, size); + term_inbuf + term_inbuf_pos, sizeof(term_inbuf)-term_inbuf_pos); if (ret == 0) { /* EOF - terminal got lost */ if (auto_detach) term_detach(); + else ret = -1; } else if (ret == -1 && (errno == EINTR || errno == EAGAIN)) ret = 0; + if (ret == -1) + signal_emit("command quit", 1, "Lost terminal"); if (ret > 0) { /* convert input to unichars. */ term_inbuf_pos += ret; - ret = 0; for (i = 0; i < term_inbuf_pos; ) { + unichar key; char_len = input_func(term_inbuf+i, term_inbuf_pos-i, - buffer); + &key); if (char_len < 0) break; + signal_emit("gui key pressed", 1, GINT_TO_POINTER(key)); i += char_len; - buffer++; - ret++; } if (i >= term_inbuf_pos) @@ -651,6 +651,4 @@ int term_gets(unichar *buffer, int size) term_inbuf_pos -= i; } } - - return ret; } |