1
0
mirror of https://github.com/gryf/tabbedalt.git synced 2026-03-27 22:03:34 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
8da342b9b0 Fix an issue with confirmation to close terminal.
Sometimes, it happens that closing terminal with mouse/keyboard
confirmation dialog appears (no matter if it was graphical or the one
build on top of urxvt overlay).

The culprit was with lines origin from `ps` command, which wasn't
correctly split, but, what is more important, wasn't properly trimmed.
This commit fixing the issue by removing whitespace from both ends of
the string and splitting using space character rather, than regexp, and
second, be sure to chop off all the whitespace characters before
splitting line and after splitting process name and its arguments.
2024-12-10 19:02:41 +01:00
a9eb5cee5d Added ability to disable tab activity indicator. 2024-06-10 10:42:27 +02:00
2 changed files with 29 additions and 15 deletions

View File

@@ -121,6 +121,10 @@ You can change those values but bear in mind, that first group should have
timeout in seconds set higher, than middle one. You can also change symbols for timeout in seconds set higher, than middle one. You can also change symbols for
those groups. those groups.
Tab activity can be disabled by setting::
URxvt.tabbedalt.disable-activity: true
Flickering Flickering
~~~~~~~~~~ ~~~~~~~~~~

View File

@@ -155,6 +155,13 @@
# #
# 2023-10-28 16:30:32 # 2023-10-28 16:30:32
# - Added overlay based dialog to confirm closing urxvt window # - Added overlay based dialog to confirm closing urxvt window
#
# 2024-06-10 10:34:47
# - Added option for disabling activity marks and colors
#
# 2024-12-10 18:30:22
# - Fix an issue with requesting closing terminal, which appear to be a
# single instance
use Scalar::Util; use Scalar::Util;
@@ -228,6 +235,7 @@ package urxvt::ext::tabbedalt::main;
sub tab_activity_mark ($$) { sub tab_activity_mark ($$) {
my ($self, $tab) = @_; my ($self, $tab) = @_;
return ' ' unless defined $tab->{lastActivity}; return ' ' unless defined $tab->{lastActivity};
return ' ' if $self->{disable_activity};
return ' ' if $tab == $self->{cur}; return ' ' if $tab == $self->{cur};
if (defined $self->{timeouts}) { if (defined $self->{timeouts}) {
my $diff = int urxvt::NOW - $tab->{lastActivity}; my $diff = int urxvt::NOW - $tab->{lastActivity};
@@ -306,6 +314,7 @@ sub refresh {
if ($tab == $self->{cur}) { if ($tab == $self->{cur}) {
@$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab}) x $len; @$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab}) x $len;
} else { } else {
if (!$self->{disable_activity}) {
if ($act eq "*") { if ($act eq "*") {
@$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab_act}) x $len; @$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab_act}) x $len;
} elsif ($act eq $self->{timeouts}[0][1]) { } elsif ($act eq $self->{timeouts}[0][1]) {
@@ -314,6 +323,7 @@ sub refresh {
@$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab_acs}) x $len; @$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab_acs}) x $len;
} }
} }
}
# sub with make current will activate events with mouse buttons # sub with make current will activate events with mouse buttons
push @ofs, [ $ofs, $ofs + $len, sub { $_[0]->make_current ($tab) } ]; push @ofs, [ $ofs, $ofs + $len, sub { $_[0]->make_current ($tab) } ];
@@ -566,6 +576,7 @@ sub init {
$self->{stop_flickering} = $self->x_resource_boolean('stop-flickering'); $self->{stop_flickering} = $self->x_resource_boolean('stop-flickering');
$self->{confirm_quit} = $self->x_resource_boolean('confirm-quit'); $self->{confirm_quit} = $self->x_resource_boolean('confirm-quit');
$self->{confirm_program} = $self->x_resource('confirm-program'); $self->{confirm_program} = $self->x_resource('confirm-program');
$self->{disable_activity} = $self->x_resource_boolean('disable-activity');
my $timeouts = $self->x_resource ("tabbar-timeouts"); my $timeouts = $self->x_resource ("tabbar-timeouts");
$timeouts = '16:.:8:::4:+' unless defined $timeouts; $timeouts = '16:.:8:::4:+' unless defined $timeouts;
@@ -653,11 +664,12 @@ _on wm_delete_window => sub {
my %process_to_skip = ( "bash"=>1, "zsh"=>1, "ps"=>1, "fish"=>1, "sh"=>1 ); my %process_to_skip = ( "bash"=>1, "zsh"=>1, "ps"=>1, "fish"=>1, "sh"=>1 );
foreach my $line (@subprocesses) { foreach my $line (@subprocesses) {
chomp $line; $line =~ s/^\s+|\s+$//g;
my @split_line = split(/ /, $line); my @split_line = split(" ", $line);
my $pid = @split_line[0]; my $pid = @split_line[0];
my $proc_name = @split_line[1]; my @line = split(" ", @split_line[1]);
chomp $proc_name; my $proc_name = @line[0];
$proc_name =~ s/^\s+|\s+$//g;
if (!exists $process_to_skip{$proc_name}) { if (!exists $process_to_skip{$proc_name}) {
$subp_count = $subp_count + 1; $subp_count = $subp_count + 1;
} else { } else {
@@ -691,10 +703,8 @@ _on wm_delete_window => sub {
my $marginc = 0; my $marginc = 0;
$qst = "$qst (y/n)"; $qst = "$qst (y/n)";
if ((length $msg) > (length $qst)) { if ((length $msg) > (length $qst)) {
print("length $msg > length $qst\n");
$marginc = int(($self->ncol - length $msg)/2); $marginc = int(($self->ncol - length $msg)/2);
} elsif ((length $msg) <= (length $qst)) { } elsif ((length $msg) <= (length $qst)) {
print("length $msg <= length $qst\n");
$marginc = int(($self->ncol - length $qst)/2); $marginc = int(($self->ncol - length $qst)/2);
} }
my $marginr = int(($self->nrow - 4)/2); my $marginr = int(($self->nrow - 4)/2);