File: cursor

package info (click to toggle)
libterm-slang-perl 0.07-7
  • links: PTS
  • area: main
  • in suites: woody
  • size: 100 kB
  • ctags: 39
  • sloc: perl: 614; makefile: 42
file content (65 lines) | stat: -rwxr-xr-x 1,075 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w

# $Id: cursor,v 1.3 2000/03/20 19:58:22 joey Rel $

use strict;
use ExtUtils::testlib;
use Term::Slang qw(:all);

SLtt_get_terminfo();
SLang_init_tty(-1,0,1);
SLsig_block_signals();
SLsmg_init_smg;
SLsig_unblock_signals();
SLkp_init();

my ($s_rows,$s_cols) = SLtt_get_screen_size();
my  $r = 10;

SLsmg_normal_video();
SLsmg_gotorc($r,0);

print "Version: $Term::Slang::VERSION\n";
print "Use the up and down arrows to continue\n";
print "Press any key ('q' quits).\n";

while(my $key = SLkp_getkey()) {

	last if $key == 113;

	# Up 258
	if ($key == 258) {
		SLsmg_gotorc($r,0);
		SLsmg_erase_eol();
		$r++;
		SLsmg_gotorc($r,0);
		SLsmg_write_string("-> $r - $key");
		SLsmg_refresh();
		if ($r >= $s_rows) {
			SLtt_beep();
			$r = $s_rows - 1;
			next;
		}
	}

	# Down 257
	if ($key == 257) {
		SLsmg_gotorc($r,0);
		SLsmg_erase_eol();
		$r--;
		SLsmg_gotorc($r,0);
		SLsmg_write_string("-> $r - $key");
		SLsmg_refresh();
		if ($r <= 0) {
			SLtt_beep();
			$r = 1;
			next;
		}
	}
}

SLsmg_refresh();
SLang_reset_tty();
SLsmg_reset_smg();

__END__