53MKnWboUIKj7JwCqIi6Ym changeset
Changeset | 353735613466 (b) |
---|---|
Parent | None (a) |
a | b | ||
---|---|---|---|
0 | + | I have this class, and it works OK: | |
0 | + | ||
0 | + | class Term::Curses { | |
0 | + | has $.y is rw; | |
0 | + | has $.x is rw; | |
0 | + | ||
0 | + | has $!stdscr; | |
0 | + | ||
0 | + | ||
0 | + | submethod BUILD() { | |
0 | + | #setlocale(0, ""); | |
0 | + | ||
0 | + | # TODO: use newterm() instead of initscr()? | |
0 | + | $!stdscr = initscr(); | |
0 | + | ||
0 | + | cbreak(); | |
0 | + | noecho(); | |
0 | + | nonl(); | |
0 | + | intrflush($!stdscr, 0); | |
0 | + | keypad($!stdscr, 1); | |
0 | + | ||
0 | + | wrefresh($!stdscr); | |
0 | + | } | |
0 | + | ||
0 | + | ||
0 | + | ... | |
0 | + | } | |
0 | + | ||
0 | + | ||
0 | + | 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? | |
0 | + | ||
0 | + | ||
0 | + | method new() { | |
0 | + | #setlocale(0, ""); | |
0 | + | ||
0 | + | # TODO: use newterm() instead of initscr()? | |
0 | + | my $stdscr = initscr(); | |
0 | + | ||
0 | + | cbreak(); | |
0 | + | noecho(); | |
0 | + | nonl(); | |
0 | + | intrflush($stdscr, 0); | |
0 | + | keypad($stdscr, 1); | |
0 | + | ||
0 | + | wrefresh($stdscr); | |
0 | + | ||
0 | + | self.bless(*, :$stdscr); | |
0 | + | } | |
... |
|
|