mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
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
This commit is contained in:
parent
77dd63ac83
commit
e361d2f498
@ -722,25 +722,12 @@ static void key_delete_to_next_space(void)
|
||||
|
||||
static void sig_input(void)
|
||||
{
|
||||
unichar buffer[128];
|
||||
int ret, i;
|
||||
|
||||
if (!active_entry) {
|
||||
/* no active entry yet - wait until we have it */
|
||||
return;
|
||||
}
|
||||
|
||||
ret = term_gets(buffer, sizeof(buffer)/sizeof(buffer[0]));
|
||||
if (ret == -1) {
|
||||
/* lost terminal */
|
||||
if (!term_detached)
|
||||
signal_emit("command quit", 1, "Lost terminal");
|
||||
} else {
|
||||
for (i = 0; i < ret; i++) {
|
||||
signal_emit("gui key pressed", 1,
|
||||
GINT_TO_POINTER(buffer[i]));
|
||||
}
|
||||
}
|
||||
term_gets();
|
||||
}
|
||||
|
||||
time_t get_idle_time(void)
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "signals.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "term.h"
|
||||
@ -384,16 +385,15 @@ void term_set_input_type(int type)
|
||||
{
|
||||
}
|
||||
|
||||
int term_gets(unichar *buffer, int size)
|
||||
void term_gets(void)
|
||||
{
|
||||
int count;
|
||||
#ifdef WIDEC_CURSES
|
||||
wint_t key;
|
||||
#else
|
||||
int key;
|
||||
#endif
|
||||
|
||||
for (count = 0; count < size; ) {
|
||||
for (;;) {
|
||||
#ifdef WIDEC_CURSES
|
||||
if (get_wch(&key) == ERR)
|
||||
#else
|
||||
@ -405,8 +405,6 @@ int term_gets(unichar *buffer, int size)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
buffer[count++] = key;
|
||||
signal_emit("gui key pressed", 1, GINT_TO_POINTER(key));
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ void term_stop(void);
|
||||
|
||||
/* keyboard input handling */
|
||||
void term_set_input_type(int type);
|
||||
int term_gets(unichar *buffer, int size);
|
||||
void term_gets(void);
|
||||
|
||||
/* internal */
|
||||
void term_common_init(void);
|
||||
|
Loading…
Reference in New Issue
Block a user