析取pageup pagedown end home 的值 如果用于翻页 绝对好东西
#include <stdio.h>#include<stdlib.h>
#include <termios.h>
#include <unistd.h>
int getch()
{ /*无回显接收一个字符*/
struct termios t1,t2;
int fd = STDIN_FILENO ,a;
if(tcgetattr(fd,&t1) < 0)
return -1;
t2 = t1;
cfmakeraw (&t1);
if(tcsetattr(fd,TCSANOW,&t1) < 0)
return -1;
a = fgetc(stdin);
if(tcsetattr(fd,TCSANOW,&t2) < 0)
return -1;
return a;
}
int main()
{
char ch;
ch = getch();
printf("ch = %c, %d\n",ch,ch);
ch = getch();
printf("ch = %c, %d\n",ch,ch);
ch = getch();
if(ch == 49)
printf("home\n");
if(ch==52)
printf("end\n");
if(ch ==54)
printf("pagedown\n");
if(ch ==53)
printf("pageup\n");
printf("ch = %c, %d\n",ch,ch);
ch = getch();
printf("ch = %c, %d\n",ch,ch);
return 0;
}