Commits

Herbert Breunung  committed 8c54f95

fix panel and IO a bit

  • Participants
  • Parent commits 2d36ad8

Comments (0)

Files changed (2)

File lib/Kephra/App/Panel.pm

 	$self;
 }
 
-sub append {
+sub prepend {
 	my ($self, @widgets) = @_;
-	my %presets = ( position => $self->{'sizer'}->GetChildren || 0, );
+	my %presets = ( position => 0 );
 	$self->_insert($_, \%presets) for @widgets;
 }
 
-sub prepend {
+sub append {
 	my ($self, @widgets) = @_;
-	my %presets = ( 0, );
+	my %presets = ( position => $self->{'sizer'}->GetChildren || 0 );
+	$self->_insert($_, \%presets) for @widgets;
+}
+
+sub insert {
+	my ($self, $position, @widgets) = @_;
+	my %presets = ( position => $position );
 	$self->_insert($_, \%presets) for @widgets;
 }
 
 	$item{'widget'}->Reparent($self) if $is_widget->( $item{'widget'} );
 }
 
-sub remove {
-	
-}
+sub remove {}
+sub show {}
 
 sub all_widgets { shift->{'widgets'} }
 sub widget_by_nr {

File lib/Kephra/App/Panel/IOUnit.pm

 use strict;
 use warnings;
 use Wx::AUI;
-use Wx::Perl::ProcessStream qw( 
-	EVT_WXP_PROCESS_STREAM_STDOUT
-	EVT_WXP_PROCESS_STREAM_STDERR
-	EVT_WXP_PROCESS_STREAM_EXIT
-);
+use Wx::Perl::ProcessStream;
 use Kephra::App::Util;
 
 package Kephra::App::Panel::IOUnit;
 my ($input, $output, %outputtext);
 my @slot_name = qw/drum perl shell output log all/;
 my $active_slot = 'drum';
+my $process;
 
 sub new {
 	my( $class, $parent) = @_;
 		my ($txt, $event ) = @_;
 		my $cmd = $txt->GetValue;
 		$input->Clear;
-		output('log',"command $cmd\n");
+		return unless $active_slot eq 'drum' or $active_slot eq 'perl' or $active_slot eq 'shell';
+		&say('log',"$active_slot command $cmd");
 		my $outxt = $outputtext{$active_slot};
-		if    ($active_slot eq 'perl')  { &say ('perl',  ">$cmd => ".eval($cmd) ) }
-		elsif ($active_slot eq 'shell') { &say ('shell', system($cmd) ) }
-		$outxt->ShowPosition( $outxt->GetCaretPosition);
+		if    ($active_slot eq 'drum')  { 
+		}
+		elsif ($active_slot eq 'perl')  { &say ('perl',  "\"$cmd\" => \"".eval($cmd) . '"' ) }
+		elsif ($active_slot eq 'shell') { 
+			$process = Wx::Perl::ProcessStream->OpenProcess
+				(qq~bash "$cmd"~ , __PACKAGE__, $outputtext{'output'});
+		}
 	});
+	Wx::Perl::ProcessStream::EVT_WXP_PROCESS_STREAM_STDOUT( $outputtext{'output'}, sub {
+		my ($txt, $event) = @_;
+		$event->Skip(1);
+		&say( $event->GetLine );
+	} );
+
 	Wx::Event::EVT_KEY_DOWN ($input, sub {
 		my ($ed, $event) = @_;
 		my $key = Kephra::App::Util::keycode_from_event($event);
 	$outputtext{$slot}->AppendText($msg);
 	$outputtext{$slot}->ShowPosition( $outputtext{$slot}->GetCaretPosition);
 	unless ($slot eq 'all') {
-		$outputtext{'all'}->AppendText($msg);
+		$outputtext{'all'}->AppendText("<$slot> $msg");
 		$outputtext{'all'}->ShowPosition( $outputtext{'all'}->GetCaretPosition);
 
 	}