1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
program test_event;
{$MODE OBJFPC}
uses
ncurses, sysutils;
var
ch: chtype;
begin
try
initscr();
noecho();
clear();
cbreak();
keypad(stdscr, TRUE);
mousemask(1, nil);
mvaddstr(1, 1,'press F10 or q to exit');
mvaddstr(2, 1,'press 1 to cbreak mode');
mvaddstr(3, 1,'press 2 to raw mode');
mvaddstr(4, 1,'press 3 to halfdelay(10) mode');
repeat
ch := getch;
mvaddstr(LINES - 1, 1,' ');
case ch of
ERR: mvaddstr(LINES - 1, 1,'timeout: 1 sec');
chtype('1'): cbreak();
chtype('2'): raw();
chtype('3'): halfdelay(10);
else
mvaddstr(LINES - 1, 1,PChar(Format('name:%-14s code:%d', [ keyname(ch), ch ] )));
end;
until (ch = chtype('q')) OR (ch = KEY_F(10));
finally
endwin();
end;
end.
|