The below is admittedly cargo cult code.  I'm trying to understand
how the parts all fit together.  Let's say that I have a dozen other
sessions running. Each doing important things like balancing the
national debt or negotiating peace in the middle east. I don't want
to just whack them. Is there a way to tell all the running sessions
to close themselves down rather than just calling exit?

    use POE;
    use Curses;
    use POE::Wheel::Curses;

    use strict;
    use warnings;

    sub input_start {
        my $heap = $_[HEAP];
        $heap->{console} = POE::Wheel::Curses->new(
           InputEvent => 'display',
        );
    }

    sub input_stop {
        endwin;
        print "stopped\n";
        exit;
    }

    sub display {
        my ( $kernel, $keystroke, $wheel_id) = @_[KERNEL, ARG0, ARG1];

        if ($keystroke lt ' ') {
            $keystroke = '<' . uc(unctrl($keystroke)) . '>';
        }
        elsif ($keystroke =~ /^\d{2,}$/) {
            $keystroke = '<' . uc(keyname($keystroke)) . '>';
        }

        move ($LINES-1, 0);
        addstr( $keystroke );
        if ($keystroke eq 'q') {
            $kernel->yield('_stop');
        }
        refresh;
    }

    initscr;
    noecho();
    cbreak();

    POE::Session->create(
        inline_states => {
            _start => \&input_start,
            display => \&display,
            _stop   => \&input_stop,
        }
    );

    $poe_kernel->run();

    endwin;
    exit;

--
    Chris Fedde

Reply via email to