9
my $app = Demo::App->new;
23
$frame = Shell::App::Frame->new($self);
29
my $self = $class->SUPER::new(@_);
44
my ($self, @commands) = @_;
45
$self->{commands}->{$_}++ for @commands;
55
package Shell::App::Frame;
59
use Wx qw(:everything);
67
my ($class, $app, $windows) = @_;
68
$windows = 1 if not defined $windows;
69
die if $windows !~ /^[123]$/;
71
my $self = $class->SUPER::new( undef, -1,
73
wxDefaultPosition, [600, 600],
76
$self->{prompt} = '>';
77
$self->{windows} = $windows;
79
my $main = Wx::SplitterWindow->new(
80
$self, -1, wxDefaultPosition, wxDefaultSize,
81
wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN );
84
$out = Wx::TextCtrl->new( $main, -1, '', wxDefaultPosition, wxDefaultSize,
85
wxTE_MULTILINE|wxNO_FULL_REPAINT_ON_RESIZE
89
} elsif ($windows == 2) {
91
$out = Wx::TextCtrl->new( $main, -1, '', wxDefaultPosition, wxDefaultSize,
92
wxTE_READONLY|wxTE_MULTILINE|wxNO_FULL_REPAINT_ON_RESIZE
94
$in = Wx::TextCtrl->new( $main, -1, '', wxDefaultPosition, wxDefaultSize,
95
wxTE_PROCESS_ENTER|wxNO_FULL_REPAINT_ON_RESIZE
97
Wx::Event::EVT_TEXT_ENTER($self, $in, \&enter);
98
$main->SplitHorizontally( $out, $in, -50 );
100
die "windows=3 Not implemented yet\n";
103
#Wx::Event::EVT_TEXT($in, \&text_changed ); #here is where we can implement command line cleverness?
106
$out->AppendText($self->{prompt});
108
Wx::Event::EVT_CLOSE( $self, sub {
109
my ( $self, $event ) = @_;
116
my ($self, $event) = @_;
118
if ($self->{windows} eq 1) {
119
$output = $self->enter_1($event);
120
} elsif ($self->{windows} eq 2) {
121
$output = $self->enter_2($event);
123
$output = $self->enter_2($event);
130
my ($self, $event) = @_;
131
my $cmd_line = $in->GetValue;
137
my ($self, $event) = @_;
139
my $cmd_line = $in->GetValue;
141
$out->AppendText("$cmd_line\n");
142
my ($cmd, $args) = split /\s+/, $cmd_line, 2;
143
$self->{_app}->{args} = $args;
145
if ($self->{_app}->{commands}->{$cmd}) {
146
my $output = $self->{_app}->$cmd();
147
$out->AppendText($output);
149
$out->AppendText("No such command '$cmd'\n");
151
$out->AppendText($self->{prompt});
162
use base 'Shell::App';
176
my $dir = $self->args;
177
$dir = '.' if not defined $dir;
179
#return "running ls\n";
181
if (opendir my $dh, $dir) {
182
my @items = readdir $dh;
183
foreach my $thing (@items) {
187
$res = "Could not open '$dir': $!";