--- Revision None +++ Revision 353735613466 @@ -0,0 +1,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); + }