Revision 353735613466 () - Diff

Link to this snippet: https://friendpaste.com/53MKnWboUIKj7JwCqIi6Ym
Embed:
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
I have this class, and it works OK:

class Term::Curses {
has $.y is rw;
has $.x is rw;

has $!stdscr;


submethod BUILD() {
#setlocale(0, "");

# TODO: use newterm() instead of initscr()?
$!stdscr = initscr();

cbreak();
noecho();
nonl();
intrflush($!stdscr, 0);
keypad($!stdscr, 1);

wrefresh($!stdscr);
}


...
}


I'd like to define my own new(), so I can call Term::Curses.new(:!cbreak, :nl) or similar, basically to specify which functions get called at this time. But it doesn't work correctly. Seems that initscr() is getting called, but maybe $!stdscr isn't being set during self.bless()? Can you see what I'm doing wrong?


method new() {
#setlocale(0, "");

# TODO: use newterm() instead of initscr()?
my $stdscr = initscr();

cbreak();
noecho();
nonl();
intrflush($stdscr, 0);
keypad($stdscr, 1);

wrefresh($stdscr);

self.bless(*, :$stdscr);
}