Skip to content

Commit

Permalink
Support specifying left and right activity characters
Browse files Browse the repository at this point in the history
With this now supported, deprecate %matching_marks feature which
would automatically match (, [, { and < to their corresponding
closing brackets.

Fixes: #30
  • Loading branch information
mina86 committed Dec 29, 2019
1 parent ef45b51 commit 78e57bd
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tabbedex
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,17 @@ since last time there was any activity in the tab.
This resource allows for this to be customised. It's format is
( <timeout> ":" <character> ":" )* <timeout> ":" <character> ":"
( <timeout> ":" <char> <char>? ":" )* <timeout> ":" <char> <char>? ":"
where <timeout> is timeout in seconds and <character> is a single activity
character. If activity character is (, [, { or < it will be used as left
activity mark and matching character will be used on the right side.
where <timeout> is timeout in seconds and <char> is an activity character. If
two characters are given, they specify left and right activity marks. If one
character is given, it specifies both. For example:
URxvt.tabbedex.tabbar-timeouts: 0:|:3:():6:[]:9:{}:12:<>
As a deprecated feature, if a single character is given and it's (, [, { or <,
matching closing brace will be used for right activity mark. This is feature
will be removed in the future.
=item B<tabbed.tabbedex-rs-prefix>: I<string>
Expand Down Expand Up @@ -1008,15 +1014,19 @@ _on button_release => sub {

{

# TODO: Add a warning in late 2020 or thereabouts if this is used and then
# remove completely a year later or such.
my %matching_marks = ('[' => ']', '{' => '}', '(' => ')', '<' => '>');

sub parse_timeouts {
my ($root, $timeouts) = @_;
my $single_char = eval { qr/\X/ } // qr/./;
my $char = eval { qr/\X/ } // qr/./;
my @timeouts;
while ($timeouts =~ /\G(\d*\.\d+|\d+):($single_char)(?::|$)/g) {
while ($timeouts =~ /\G(\d*\.\d+|\d+):($char)($char)?(?::|$)/g) {
my $left = $root->special_encode($2);
push @timeouts, [$1 + 0, $left, $matching_marks{$2} // $left];
my $right = $root->special_encode(
$3 // $matching_marks{$2} // $2);
push @timeouts, [$1 + 0, $left, $right];
}
@timeouts = sort { $b->[0] <=> $a->[0] } @timeouts;
if (!@timeouts || $timeouts[$#timeouts][0] > 0) {
Expand Down

0 comments on commit 78e57bd

Please sign in to comment.