File: demo

package info (click to toggle)
libcurses-perl 1.08b-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 624 kB
  • ctags: 754
  • sloc: ansic: 8,714; perl: 1,773; makefile: 36; sh: 9
file content (79 lines) | stat: -rwxr-xr-x 1,691 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
##
##  demo -- do some curses stuff
##
##  Copyright (c) 1994-2000  William Setzer
##
##  You may distribute under the terms of either the Artistic License
##  or the GNU General Public License, as specified in the README file.

use ExtUtils::testlib;
use Curses;

initscr();
$b = subwin(10, 20, 3, 3);

noecho();
cbreak();

addstr(0, 0, "ref b = " . ref $b);
addstr(1, 1, "fooalpha");

eval { attron(A_BOLD) };
addstr(2, 5, "bold  ");
eval { attron(A_REVERSE) };
addstr("bold+reverse");
eval { attrset(A_NORMAL) };
addstr("  normal  (if your curses supports these modes)");

addstr(6, 1, "do12345678901234567890n't worry be happy");
eval { box($b, '|', '-') };

standout($b);
addstr($b, 2, 2, "ping");
standend($b);
addstr($b, 4, 4, "pong");

move($b, 3, 3);
move(6, 3);
deleteln($b);
insertln();

delch($b, 4, 5);
insch(7, 8, ord(a));

eval { keypad(1) };
addstr(14, 0, "hit a key: ");
refresh();
$ch = getch();

addstr(15, 0, "you typed: >>");
addch($ch);
addstr("<< and perl thinks you typed: >>$ch<<");

addstr(17, 0, "enter string: ");
refresh();
getstr($str);

addstr(18, 0, "you typed: >>$str<<");
getyx($m, $n);
addstr(19, 4, "y == $m (should be 18), x == $n (should be "
         . (15 + length $str) . ")");

$ch = inch(19, 7);
addstr(20, 0, "The character at (19,7) is an '$ch' (should be an '=')");

addstr(21, 0, "testing KEY_*.  Hit the up arrow on your keyboard: ");
refresh();
$ch = getch();
eval
{ 
    if ($ch == KEY_UP) { addstr(22, 0, "KEY_UP was pressed!") }
    else               { addstr(22, 0, "Something else was pressed.") }
    1;
} || addstr(22, 0, "You don't seem to have the KEY_UP macro");

move($LINES - 1, 0);
refresh();
sleep 2;
endwin();