mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
term_getch() -> term_gets() which can be used to read multiple keypresses at
once. Also fixes keyboard not working with netbsd. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1935 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
09ca58961b
commit
801e593718
@ -327,15 +327,12 @@ static void key_delete_to_next_space(void)
|
||||
|
||||
void readline(void)
|
||||
{
|
||||
int key;
|
||||
unsigned char buffer[128];
|
||||
int ret, i;
|
||||
|
||||
for (;;) {
|
||||
key = term_getch();
|
||||
if (key == -1)
|
||||
break;
|
||||
|
||||
handle_key(key);
|
||||
}
|
||||
ret = term_gets(buffer, sizeof(buffer));
|
||||
for (i = 0; i < ret; i++)
|
||||
handle_key(buffer[i]);
|
||||
}
|
||||
|
||||
time_t get_idle_time(void)
|
||||
|
@ -363,18 +363,23 @@ void term_stop(void)
|
||||
irssi_redraw();
|
||||
}
|
||||
|
||||
int term_getch(void)
|
||||
int term_gets(unsigned char *buffer, int size)
|
||||
{
|
||||
int key;
|
||||
|
||||
key = getch();
|
||||
if (key == ERR)
|
||||
return -1;
|
||||
int key, count;
|
||||
|
||||
for (count = 0; count < size; ) {
|
||||
key = getch();
|
||||
#ifdef KEY_RESIZE
|
||||
if (key == KEY_RESIZE)
|
||||
return -1;
|
||||
if (key == KEY_RESIZE)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
return key;
|
||||
if (key == ERR)
|
||||
break;
|
||||
|
||||
buffer[count] = key;
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -312,7 +312,8 @@ void term_stop(void)
|
||||
irssi_redraw();
|
||||
}
|
||||
|
||||
int term_getch(void)
|
||||
int term_gets(unsigned char *buffer, int size)
|
||||
{
|
||||
return fgetc(current_term->in);
|
||||
/* fread() doesn't work */
|
||||
return read(fileno(current_term->in), buffer, size);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void term_refresh_thaw(void);
|
||||
void term_refresh(TERM_WINDOW *window);
|
||||
|
||||
void term_stop(void);
|
||||
int term_getch(void);
|
||||
int term_gets(unsigned char *buffer, int size);
|
||||
|
||||
/* internal */
|
||||
void term_common_init(void);
|
||||
|
@ -429,7 +429,7 @@ static void terminfo_input_init(TERM_REC *term)
|
||||
memcpy(&term->tio, &term->old_tio, sizeof(term->tio));
|
||||
|
||||
term->tio.c_lflag &= ~(ICANON | ECHO); /* CBREAK, no ECHO */
|
||||
term->tio.c_cc[VMIN] = 0; /* non-blocking read */
|
||||
term->tio.c_cc[VMIN] = 1; /* read() is satisfied after 1 char */
|
||||
term->tio.c_cc[VTIME] = 0; /* No timer */
|
||||
|
||||
/* Disable INTR, QUIT, VDSUSP and SUSP keys */
|
||||
|
Loading…
Reference in New Issue
Block a user