mirror of
https://github.com/irssi/irssi.git
synced 2026-08-21 01:22:26 +02: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
5 changed files with 24 additions and 21 deletions
|
|
@ -327,15 +327,12 @@ static void key_delete_to_next_space(void)
|
||||||
|
|
||||||
void readline(void)
|
void readline(void)
|
||||||
{
|
{
|
||||||
int key;
|
unsigned char buffer[128];
|
||||||
|
int ret, i;
|
||||||
|
|
||||||
for (;;) {
|
ret = term_gets(buffer, sizeof(buffer));
|
||||||
key = term_getch();
|
for (i = 0; i < ret; i++)
|
||||||
if (key == -1)
|
handle_key(buffer[i]);
|
||||||
break;
|
|
||||||
|
|
||||||
handle_key(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t get_idle_time(void)
|
time_t get_idle_time(void)
|
||||||
|
|
|
||||||
|
|
@ -363,18 +363,23 @@ void term_stop(void)
|
||||||
irssi_redraw();
|
irssi_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
int term_getch(void)
|
int term_gets(unsigned char *buffer, int size)
|
||||||
{
|
{
|
||||||
int key;
|
int key, count;
|
||||||
|
|
||||||
key = getch();
|
|
||||||
if (key == ERR)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
for (count = 0; count < size; ) {
|
||||||
|
key = getch();
|
||||||
#ifdef KEY_RESIZE
|
#ifdef KEY_RESIZE
|
||||||
if (key == KEY_RESIZE)
|
if (key == KEY_RESIZE)
|
||||||
return -1;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return key;
|
if (key == ERR)
|
||||||
|
break;
|
||||||
|
|
||||||
|
buffer[count] = key;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,8 @@ void term_stop(void)
|
||||||
irssi_redraw();
|
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_refresh(TERM_WINDOW *window);
|
||||||
|
|
||||||
void term_stop(void);
|
void term_stop(void);
|
||||||
int term_getch(void);
|
int term_gets(unsigned char *buffer, int size);
|
||||||
|
|
||||||
/* internal */
|
/* internal */
|
||||||
void term_common_init(void);
|
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));
|
memcpy(&term->tio, &term->old_tio, sizeof(term->tio));
|
||||||
|
|
||||||
term->tio.c_lflag &= ~(ICANON | ECHO); /* CBREAK, no ECHO */
|
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 */
|
term->tio.c_cc[VTIME] = 0; /* No timer */
|
||||||
|
|
||||||
/* Disable INTR, QUIT, VDSUSP and SUSP keys */
|
/* Disable INTR, QUIT, VDSUSP and SUSP keys */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue