X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=keyhandler.c;h=0ba3c6a368bcd9503e01ecf77369fe98408351c7;hb=851ac869ee55686234ae246ab9b5d938aec0f225;hp=6d8ca52d2f4b37c2c3289a362a566078321aa40e;hpb=7a1a81d517d3e95f6f9f5dba853fe6d9d8c27ab3;p=pd_readline diff --git a/keyhandler.c b/keyhandler.c index 6d8ca52..0ba3c6a 100644 --- a/keyhandler.c +++ b/keyhandler.c @@ -21,7 +21,8 @@ static struct termios old, new; /* Initialize new terminal i/o settings */ -void initTermios(int echo) { +void initTermios(int echo) +{ tcgetattr(0, &old); /* grab old terminal i/o settings */ new = old; /* make new settings same as old settings */ new.c_lflag &= ~ICANON; /* disable buffered i/o */ @@ -31,7 +32,8 @@ void initTermios(int echo) { /* Restore old terminal i/o settings */ -void resetTermios(void) { +void resetTermios(void) +{ tcsetattr(0, TCSANOW, &old); } @@ -66,44 +68,26 @@ char getche(void) { void keyhandler(buf b) { - int i = getch(); + int a = getch(); - switch(i) + int t = type(a); + + switch(t) { + case (1): break; /* Ctrl a */ case (2): break; /* Ctrl b */ - case (3): break; /* Ctrl c */ - - case (10): enter(); /* Enter */ - - case (27): spec(i); break; /* esc */ - - case (32): printf("%c", i); break; /* Printable chars. */ - case (33): printf("%c", i); break; /* Printable chars. */ - case (34): printf("%c", i); break; /* Printable chars. */ - - case (65): printf("%c", i); break; /* "A" */ - case (66): printf("%c", i); break; /* "B" */ - case (67): printf("%c", i); break; /* "C" */ - case (68): printf("%c", i); break; /* "D" */ - case (69): printf("%c", i); break; /* "E" */ - case (70): printf("%c", i); break; /* "F" */ - - case (97): printf("%c", i); break; /* "a" */ - case (98): printf("%c", i); break; /* "b" */ - case (99): printf("%c", i); break; /* "c" */ - case (100): printf("%c", i); break; /* "d" */ - case (101): printf("%c", i); break; /* "e" */ - case (102): printf("%c", i); break; /* "f" */ - - case (126): printf("%c", i); break; /* "~" */ - - case (127): delch(b); break; - - default: break; /* stuff(); */ + case (3): getch(); spec(); break; /* Ctrl c */ + case (4): set(b, a); break; /* Printable chars. */ + case (5): delch(b); break; + case (6): break; + default: break; + } - -} + +} + +