Add Run pshell menu item with terminal auto-detection

This commit is contained in:
kake26 2025-04-30 17:32:52 -05:00
parent 15256a982e
commit f809a7b321
Signed by: kake26
GPG key ID: E0A989B571D1F99F

View file

@ -168,6 +168,19 @@ my $which_line_item = Gtk3::MenuItem->new_with_label('Which Line?');
$which_line_item->signal_connect(activate => \&which_line_dialog);
$tools_menu->append($which_line_item);
my $run_pshell = Gtk3::MenuItem->new_with_label('Run pshell');
$run_pshell->signal_connect(activate => sub {
my $pshell_path = "$basedir/pshell";
my $terminal = find_terminal();
if (-x $pshell_path) {
system("$terminal -e $pshell_path &");
$statusbar->push(0, "Launched pshell in $terminal");
} else {
$statusbar->push(0, "Error: pshell not found at $pshell_path");
}
});
$tools_menu->append($run_pshell);
# HTML menu
my $html_menu = Gtk3::Menu->new;
my $html_item = Gtk3::MenuItem->new_with_label('HTML');
@ -280,6 +293,15 @@ while (<*.kpd>) {
}
my $nop = grep { $_ ne 'auto' } @n;
# Find available terminal
sub find_terminal {
my @terminals = qw(gnome-terminal konsole xterm);
for my $term (@terminals) {
return $term if `which $term 2>/dev/null` =~ /\S/;
}
return 'xterm'; # Fallback
}
# File handling
sub open_file {
my $dialog = Gtk3::FileChooserDialog->new(