Readers: 17
QuoteTo install this module, run the following commands:
perl Make.PL
make
make test
make install
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 49 50 51 52 53 54 55 56 57 58
# ... use Encode::Locale; sub __init_term { my ( $self ) = @_; # Windows: $self->{input} = Win32::Console->new( STD_INPUT_HANDLE ); $self->{old_in_mode} = $self->{input}->Mode(); $self->{input}->Mode( ENABLE_PROCESSED_INPUT ); # Linux: #ReadMode( 'cbreak' ); } sub __get_key { my ( $self ) = @_; # Windows: return $self->{input}->InputChar(); # Linux: #return ReadKey( 0 ); } sub readline { my ( $self, $prompt, $opt ) = @_; # ... # ... local $| = 1; $self->__init_term(); my $str = encode( 'console_in', $opt->{default} ); $self->__print_readline( $opt, $prompt, $str ); while ( 1 ) { my $key = $self->{plugin}->__get_key(); return if ! defined $key; elsif ( $key eq "\n" or $key eq "\r" ) { print "\n"; $self->__reset_term(); return decode( 'console_in', $str ) if $^O eq 'MSWin32'; return decode( 'console_in', $str ) if utf8::is_utf8( $key ); return $str; } elsif ( ord $key == BSPACE || $key eq "\cH" ) { if ( length $str ) { $str = decode( 'console_in', $str ); $str =~ s/\X\z//; $str = encode( 'console_in', $str ); } $self->__print_readline( $opt, $prompt, $str ); next; } $key = encode( 'console_in', $key ) if utf8::is_utf8( $key ); $str .= $key; $self->__print_readline( $opt, $prompt, $str ); } } # ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sub new { my $class = shift; my ( $name ) = @_; my $self = bless { name => $name, handle_in => \*STDIN, handle_out => \*STDOUT, }, $class; ... } sub __print_readline { my ( $self, ... ) = @_; ... print $string; ... }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sub new { my $class = shift; my ( $name ) = @_; my $self = bless { name => $name, handle_in => \*STDIN, handle_out => \*STDOUT, }, $class; ... } sub __print_readline { my ( $self, ... ) = @_; ... print { $self->{handle_out} } $string; ... }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sub new { my $class = shift; my ( $name ) = @_; my $self = bless { name => $name, handle_in => \*STDIN, handle_out => select, }, $class; ... } sub __print_readline { my ( $self, ... ) = @_; ... print $string; ... }
2014-08-26T12:51:08 Kuerbis- Kein Echo bzw Asterix anstatt der Buchstaben:
1
2
3
4
5
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
1 2 3 4 5 6 7
$self->{plugin}->__restore_cursor_position(); if ( $str_row ) { # $str_row + 1: Anzahl der Zeilen die der String benötigt print "\n" x $str_row; $self->{plugin}->__up( $str_row ); } $self->{plugin}->__clear_output( $self->{prev_str_cols} ); $self->{plugin}->__save_cursor_position();