Handle cursor key mode (application vs. ANSI). "less" now works.

This commit is contained in:
Keith Winstein
2011-02-03 03:56:02 -05:00
parent 4ca5b35d7d
commit 5a3c4a201b
9 changed files with 41 additions and 14 deletions
+8 -4
View File
@@ -127,28 +127,32 @@ void emulate_terminal( int fd, int debug_fd )
pollfds[ 1 ].fd = fd;
pollfds[ 1 ].events = POLLIN;
swrite( STDOUT_FILENO, terminal.open().c_str() );
while ( 1 ) {
int active_fds = poll( pollfds, 2, -1 );
if ( active_fds <= 0 ) {
perror( "poll" );
return;
break;
}
if ( pollfds[ 0 ].revents & POLLIN ) {
if ( termemu( fd, STDIN_FILENO, true, debug_fd, &parser, &terminal ) < 0 ) {
return;
break;
}
} else if ( pollfds[ 1 ].revents & POLLIN ) {
if ( termemu( fd, fd, false, debug_fd, &parser, &terminal ) < 0 ) {
return;
break;
}
} else if ( (pollfds[ 0 ].revents | pollfds[ 1 ].revents)
& (POLLERR | POLLHUP | POLLNVAL) ) {
return;
break;
} else {
fprintf( stderr, "poll mysteriously woken up\n" );
}
}
swrite( STDOUT_FILENO, terminal.close().c_str() );
}
int termemu( int host_fd, int src_fd, bool user, int debug_fd,