Debian Codegraph @

demo

raw
1 #! /usr/bin/perl
2 ##
3 ## demo -- do some curses stuff
4 ##
5 ## Copyright (c) 1994-2000 William Setzer
6 ##
7 ## You may distribute under the terms of either the Artistic License
8 ## or the GNU General Public License, as specified in the README file.
9
10 use ExtUtils::testlib;
11 use Curses;
12
13 initscr();
14 $b = subwin(10, 20, 3, 3);
15
16 noecho();
17 cbreak();
18
19 addstr(0, 0, "ref b = " . ref $b);
20 addstr(1, 1, "fooalpha");
21
22 eval { attron(A_BOLD) };
23 addstr(2, 5, "bold ");
24 eval { attron(A_REVERSE) };
25 addstr("bold+reverse ");
26 eval { attrset(A_ITALIC) };
27 addstr("bold+reverse+italic ");
28 eval { attrset(A_NORMAL) };
29 addstr(" (if your curses has these modes)");
30
31 addstr(6, 1, "do12345678901234567890n't worry be happy");
32 eval { box($b, '|', '-') };
33
34 standout($b);
35 addstr($b, 2, 2, "ping");
36 standend($b);
37 addstr($b, 4, 4, "pong");
38
39 move($b, 3, 3);
40 move(6, 3);
41 deleteln($b);
42 insertln();
43
44 delch($b, 6, 5);
45 insch(8, 8, ord(a));
46
47 eval { keypad(1) };
48 addstr(14, 0, "hit a key: ");
49 refresh();
50 $ch = getch();
51
52 addstr(15, 0, "you typed: >>");
53 addch($ch);
54 addstr("<< and perl thinks you typed: >>$ch<<");
55
56 addstr(17, 0, "enter string: ");
57 refresh();
58 getstr($str);
59
60 addstr(18, 0, "you typed: >>$str<<");
61 getyx($m, $n);
62 addstr(19, 4, "y == $m (should be 18), x == $n (should be "
63 . (15 + length $str) . ")");
64
65 $ch = inch(19, 7);
66 addstr(20, 0, "The character at (19,7) is an '$ch' (should be an '=')");
67
68 addstr(21, 0, "testing KEY_*. Hit the up arrow on your keyboard: ");
69 refresh();
70 $ch = getch();
71 eval
72 {
73 if ($ch == KEY_UP) { addstr(22, 0, "KEY_UP was pressed!") }
74 else { addstr(22, 0, "Something else was pressed.") }
75 1;
76 } || addstr(22, 0, "You don't seem to have the KEY_UP macro");
77
78 move($LINES - 1, 0);
79 refresh();
80 sleep 2;
81 endwin();