Term-Screen-Win32

 view release on metacpan or  search on metacpan

lib/Term/Screen/Win32.pm  view on Meta::CPAN


sub flush_input
	{ while(key_pressed($_[0])) { getch($_[0]); }; return $_[0]; };

sub stuff_input
	{ push(@{(shift(@_))->{'key_pressed'}}, @_); return $_[0]; };

my %def_key = ( 16 => 'shift',
                17 => 'ctrl',
                18 => 'alt',
                19 => 'pause',
                20 => 'capslock',
                33 => 'pgup',
                34 => 'pgdn',
                35 => 'end',
                36 => 'home',
                37 => 'kl',
                38 => 'ku',
                39 => 'kr',
                40 => 'kd',
                45 => 'ins',
                46 => 'del',
                91 => 'lwin',
                92 => 'rwin',
                93 => 'winmenu',
               112 => 'k1',
               113 => 'k2',
               114 => 'k3',
               115 => 'k4',
               116 => 'k5',
               117 => 'k6',
               118 => 'k7',
               119 => 'k8',
               120 => 'k9',
               121 => 'k10',
               122 => 'k11',
               123 => 'k12',
               145 => 'scrlock',
               144 => 'numlock',
              );
 

sub new($%)
	{
	my ($class) = @_;

	my $self = undef;

	tie(%{$self}, 'Term::Screen::Win32::CursorAndSize');

	$self->{'key_pressed'} = [],
	$self->{'def_key'}     = {},
	$self->{'console'}     = Win32::Console->new(STD_INPUT_HANDLE),

    $self->{'origMode'} = $self->{'console'}->Mode();
    $self->{'console'}->Mode(ENABLE_PROCESSED_INPUT);
    at($self, 0, 0);

    %{$self->{'def_key'}} = %def_key;

	return bless $self => $class;
	};

sub cleanup
	{
	$_[0]->normal();
	if (defined($_[0]->{'console'}))
		{ $_[0]->{'console'}->Mode($_[0]->{'origMode'}); };
	};

sub DESTROY
	{ cleanup(@_); };


 1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

Term::Screen::Win32 - Simple L<Term::Screen> style interface to the L<Win32::Console> (and L<Win32::Console::ANSI>) capabilities

I<Version 0.03>

=head1 SYNOPSIS

    use Term::Screen::Win32;
    #
    # Do all the stuff you can do with Term::Screen
    #

See L<Term::Screen> for details

=head1 DESCRIPTION

This module provides the same interface as L<Term::Screen> provides.

It was created to be used with L<Term::Screen::Uni>.

=head2 Functions are not supported

These functions are not supported and will croak if called:

=item C<term()>

Useless on Win32

These functions are different from L<Term::Screen>:

=item C<def_key('name','input string')>

Provide 'virtual keycode' as an 'input string'

These functions are not exists in L<Term::Screen>:

=item C<cleanup()>

Return console to the origuinal mode. Called automatically on C<DESTROY>.

=head2 EXPORT

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.791 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )