1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04: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:
Timo Sirainen 2001-10-28 23:47:47 +00:00 committed by cras
parent 09ca58961b
commit 801e593718
5 changed files with 24 additions and 21 deletions

View File

@ -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)

View File

@ -363,18 +363,23 @@ void term_stop(void)
irssi_redraw();
}
int term_getch(void)
int term_gets(unsigned char *buffer, int size)
{
int key;
int key, count;
for (count = 0; count < size; ) {
key = getch();
if (key == ERR)
return -1;
#ifdef KEY_RESIZE
if (key == KEY_RESIZE)
return -1;
continue;
#endif
return key;
if (key == ERR)
break;
buffer[count] = key;
count++;
}
return count;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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 */