1
0
mirror of https://github.com/gryf/tabbedalt.git synced 2025-12-17 11:30:31 +01:00

Added pseudosession

This commit is contained in:
2011-08-15 10:15:01 +02:00
parent e66a87f2ce
commit 454dc4aa9d

43
tabbed
View File

@@ -88,6 +88,14 @@
# place in copy_properties(), please step forward :)
#
# [1] http://moc.daper.net
#
# 2011-07-12 21:05:26
# - Fixed defaults for not defined tabcommands - now it is possible to use
# tabbed just as described.
# - Added some sort of primitive session ability, defined via resource
# session, which should contain pipe separated shortcuts defined in tabcmds
# resource. If there is no shortcuts (or wrong was defined), plain shell tab
# will appear.
sub tab_activity_mark ($$) {
@@ -385,10 +393,9 @@ sub on_init {
my $key = uc(shift(@args));
$self->{tabcmds}{$key} = [ @args ];
}
if(not %{$self->{tabcmds}}){
# add default shell command
$self->{tabcmds}{'N'} = ('shell');
}
@{$self->{session}} = split('\|', $self->x_resource("session")) or ();
();
}
@@ -406,7 +413,23 @@ sub on_start {
shift @argv;
} while @argv && $argv[0] ne "-e";
$self->new_tab ("shell", @argv);
# Ugly as hell ``session'' implementation
my $count = 0;
if (qx(ps x|grep urxvt|grep -v grep|wc -l) < 2 && scalar(@{$self->{session}})){
for my $item (@{$self->{session}}){
if (exists($self->{tabcmds}{uc($item)})){
$self->new_tab(@{$self->{tabcmds}{uc($item)}});
$count++;
}
}
if ($count == 0) {
# no keys was valid, failsafe shell.
$self->new_tab ("shell", @argv);
}
}else{
$self->new_tab ("shell", @argv);
}
if (defined $self->{timeouts}) {
my $interval = ($self->{timeouts}[@{ $self->{timeouts} } - 1]->[0]);
@@ -493,7 +516,15 @@ sub tab_key_press {
if ($event->{state} & urxvt::ShiftMask) {
if ($event->{state} & urxvt::ControlMask) {
if (exists($self->{tabcmds}{chr($keysym)})){
if(not %{$self->{tabcmds}}){
print chr($keysym) . "\n";
print chr($keysym) == "M". "\n";
if ($keysym == 0x4e){
print "wtf?\n";
$self->new_tab("shell");
return 1;
}
}elsif(exists($self->{tabcmds}{chr($keysym)})){
$self->new_tab(@{$self->{tabcmds}{chr($keysym)}});
return 1;
}