[poe-commits] poe/POE/Wheel ReadLine.pm,1.22,1.23
Brought to you by:
rcaputo
From: <su...@us...> - 2002-09-19 01:49:35
|
Update of /cvsroot/poe/poe/POE/Wheel In directory usw-pr-cvs1:/tmp/cvs-serv18917/POE/Wheel Modified Files: ReadLine.pm Log Message: convert the last remaining macros to subroutines. samples/readline.perl runs flawlessly and all tests pass Index: ReadLine.pm =================================================================== RCS file: /cvsroot/poe/poe/POE/Wheel/ReadLine.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ReadLine.pm 17 Sep 2002 05:45:30 -0000 1.22 --- ReadLine.pm 19 Sep 2002 01:49:32 -0000 1.23 *************** *** 2,9 **** package POE::Wheel::ReadLine; - use POE::Preprocessor; use strict; - use vars qw($VERSION); $VERSION = (qw($Revision$ ))[1]; --- 2,7 ---- *************** *** 85,134 **** } ! # Wipe the current input line. Implemented as a macro to avoid ! # circular closure problems with $self. We can dump the macro if we ! # figure this one out. ! macro wipe_input_line { ! # Clear the current prompt and input, and home the cursor. ! print $stdout $termcap->Tgoto( 'LE', 1, ! ( $$self_cursor_display + length($$self_prompt) ! ) ! ); ! if ($tc_has_ke) { ! print $stdout $termcap->Tputs( 'kE', 1 ); ! } ! else { ! my $wipe_length = length($$self_prompt) + display_width($$self_input); ! print( $stdout ! (' ' x $wipe_length), $termcap->Tgoto( 'LE', 1, $wipe_length) ! ); ! } } ! # Helper to flush any buffered output. A macro to avoid circular ! # closure problems with $self. ! macro flush_output_buffer { ! # Flush anything buffered. ! if (@$self_put_buffer) { ! print $stdout @$self_put_buffer; ! # Do not change the interior listref, or the event handlers will ! # become confused. ! @$self_put_buffer = ( ); ! } } ! # Set up the prompt and input line like nothing happened. A macro to ! # avoid circular closure problems with $self. ! ! macro repaint_input_line { ! print( $stdout $$self_prompt, normalize($$self_input) ); ! if ($$self_cursor_input != length($$self_input)) { ! $termcap->Tgoto( 'LE', 1, ! ( display_width($$self_input) - $$self_cursor_display ), ! $stdout ! ); ! } } --- 83,139 ---- } ! # Wipe the current input line. ! sub wipe_input_line { ! my %args = @_; ! my $stdout = $args{stdout}; ! # Clear the current prompt and input, and home the cursor. ! print $stdout $args{termcap}->Tgoto( 'LE', 1, ! ( ${ $args{self_cursor_display} } + length( ${ $args{self_prompt} } ) ) ! ); ! if ( $args{tc_has_ke} ) { ! print $stdout $args{termcap}->Tputs( 'kE', 1 ); ! } ! else { ! $args{wipe_length} = ! length( ${ $args{self_prompt} } ) + ! display_width( ${ $args{self_input} } ); ! print( $stdout ( ' ' x $args{wipe_length} ), ! $args{termcap}->Tgoto( 'LE', 1, $args{wipe_length} ) ); ! } } ! # Helper to flush any buffered output. ! sub flush_output_buffer { ! my %args = @_; ! my $stdout = $args{stdout}; ! # Flush anything buffered. ! if ( @{ $args{self_put_buffer} } ) { ! print $stdout @{ $args{self_put_buffer} }; ! # Do not change the interior listref, or the event handlers will ! # become confused. ! @{ $args{self_put_buffer} } = (); ! } } ! # Set up the prompt and input line like nothing happened. ! sub repaint_input_line { ! my %args = @_; ! my $stdout = $args{stdout}; ! print( $stdout ${ $args{self_prompt} }, ! normalize( ${ $args{self_input} } ) ! ); ! if ( ${ $args{self_cursor_input} } != length( ${ $args{self_input} } ) ) { ! $args{termcap}->Tgoto( ! 'LE', 1, ! ( ! display_width( ${ $args{self_input} } ) - ! ${ $args{self_cursor_display} } ! ), ! $stdout ! ); ! } } *************** *** 353,359 **** if (@$self_put_buffer) { ! {% wipe_input_line %} ! {% flush_output_buffer %} ! {% repaint_input_line %} } --- 358,382 ---- if (@$self_put_buffer) { ! wipe_input_line( ! self_cursor_display => $self_cursor_display, ! self_input => $self_input, ! self_prompt => $self_prompt, ! stdout => $stdout, ! tc_has_ke => $tc_has_ke, ! termcap => $termcap, ! ); ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ## Please see file perltidy.ERR ! ); ! repaint_input_line( ! self_cursor_input => $self_cursor_input, ! self_input => $self_input, ! self_prompt => $self_prompt, ! stdout => $stdout, ! termcap => $termcap, ! ); ! } *************** *** 473,477 **** $$reading = 0; $$hist_index = @$hist_list; ! {% flush_output_buffer %} next; } --- 496,504 ---- $$reading = 0; $$hist_index = @$hist_list; ! ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ); next; } *************** *** 537,541 **** $$reading = 0; $$hist_index = @$hist_list; ! {% flush_output_buffer %} return; } --- 564,572 ---- $$reading = 0; $$hist_index = @$hist_list; ! ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ); return; } *************** *** 575,579 **** $$reading = 0; $$hist_index = @$hist_list; ! {% flush_output_buffer %} next; } --- 606,614 ---- $$reading = 0; $$hist_index = @$hist_list; ! ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ); next; } *************** *** 616,620 **** $$reading = 0; $$hist_index = @$hist_list; ! {% flush_output_buffer %} next; } --- 651,659 ---- $$reading = 0; $$hist_index = @$hist_list; ! ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ); next; } *************** *** 1192,1198 **** my $self_input = \$self->[SELF_INPUT]; my $self_cursor_input = \$self->[SELF_CURSOR_INPUT]; ! {% wipe_input_line %} ! {% flush_output_buffer %} # Print the new stuff. --- 1231,1248 ---- my $self_input = \$self->[SELF_INPUT]; my $self_cursor_input = \$self->[SELF_CURSOR_INPUT]; + wipe_input_line( + self_cursor_display => $self_cursor_display, + self_input => $self_input, + self_prompt => $self_prompt, + stdout => $stdout, + tc_has_ke => $tc_has_ke, + termcap => $termcap, + ); ! ! flush_output_buffer( ! self_put_buffer => $self_put_buffer, ! stdout => $stdout, ! ); # Print the new stuff. *************** *** 1201,1205 **** # Only repaint the input if we're reading a line. if ($self->[SELF_READING_LINE]) { ! {% repaint_input_line %} } --- 1251,1262 ---- # Only repaint the input if we're reading a line. if ($self->[SELF_READING_LINE]) { ! repaint_input_line( ! self_cursor_input => $self_cursor_input, ! self_input => $self_input, ! self_prompt => $self_prompt, ! stdout => $stdout, ! termcap => $termcap, ! ); ! } |