kt.cc 719 B

12345678910111213141516171819202122232425262728293031
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <assert.h>
  4. #include <ncurses/curses.h>
  5. struct kd { int v; const char *n; } kds[]= {
  6. #include "curkeys.inc"
  7. };
  8. int main(int argc, char **argv) {
  9. int n=0, c, y,x;
  10. struct kd *kdp;
  11. initscr(); cbreak(); noecho(); nonl();
  12. keypad(stdscr,TRUE);
  13. getmaxyx(stdscr,y,x);
  14. mvprintw(5,5,"q to quit; b to beep; (y%d x%d)",y,x);
  15. for (;;) {
  16. refresh();
  17. c= getch(); if (c==ERR) { endwin(); perror("err"); exit(1); }
  18. for (kdp=kds; kdp->v != -1 && kdp->v != c; kdp++);
  19. n++; mvprintw(10 + (n%4),10,"n %10d keycode %4d %-10s F0 + %4d",n,c,
  20. kdp->n, c-KEY_F0);
  21. if (c == 'q') break;
  22. if (c == 'b') beep();
  23. }
  24. endwin();
  25. return 0;
  26. }