Jemand zu Hause?Leser: 17
QuoteTo install this module, run the following commands:
perl Make.PL
make
make test
make install
Win32::Console auch keinerlei Tests hat; ich nehm' mal an, das ist dem Maintainer zu kompliziert und zeitaufwändig. 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; ... }
Term::ReadLine::Tiny umbenennen.
Term::ReadLine::Tiny jetzt anderes macht als
Term::ReadLine. Was macht Dein
Term::ReadLine::Tiny anders oder besser?
Term::ReadLine ist und warum es das jetzt so gibt.
Term::ReadLine::Gnu: kann das alles (außer no_echo) und vieles mehr, funktioniert aber nicht mit Windows.
Term::ReadLine::Perl5 behält die gesamte Eingabe in einer Zeile.
Term::ReadLine::Perl und
Term::ReadLine::Perl5 kommen damit nicht zurecht (falls ich beim dekodieren nichts vergessen habe).
Term::ReadLine::Perl und
Term::ReadLine::Perl5 unter Windows keinen default Wert
Term::ReadKey's ReadMode oder gleich
Term::ReadPassword... Wenn das in einem *ReadLine* drin ist, wäre das nett; aber IMHO nicht zwingend notwendig.2014-08-26T12:51:08 Kuerbis- Kein Echo bzw Asterix anstatt der Buchstaben:
Term::ReadLine::Tiny finde ich nichts zum Thema Positionieren. Daher muss ich nochmal doof nachfragen: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();
Term::ReadLine::Simple).
Tipp zum Debugging