3 in 1 (ugly)
Closed this issue · 2 comments
white-dragon commented
make new-button
text instead of boolean and allow write any
mayb it makes sense to do something like timeouts just for ncol?
includes #31 but tab-name-start
added tab-name-symbols
allow to something like this:
!URxvt.tabbedex.tab-name-symbols: 01234567
!URxvt.tabbedex.tab-name-symbols: 0123456789ABCDEF
URxvt.tabbedex.tab-name-symbols: #0123456789abcdefghijklmnopqrstuvwxyzαβγδεζηθικλμνξοπρστυφχψωабвгдеёжзийклмнопрстуфхцчшщъыьэюя
or something other from unicode
+++ tabbedex.n 2020-01-08 03:01:51.175514180 +0300
@@ -648,27 +648,25 @@
my ($root) = @_;
my $ncol = $root->ncol;
- my $new_button = '';
- if ($root->{new_button}) {
- if ($ncol >= 60) {
- $new_button = '[NEW]';
- } elsif ($ncol >= 30) {
- $new_button = 'NEW';
- } elsif ($ncol >= 13) {
- $new_button = '+';
- }
- }
+ my $new_button = $root->{new_button} || '';
$ncol -= !!$new_button + length $new_button;
my $max = int(($ncol - 1) / 3) - 3;
$max = $max < 2 ? 1 : $max;
my ($total_truncated, $total_full, $cur_idx) = (-1, -1);
+ my $defname = $root->{tab_name_symbols}
+ ? do{
+ sub baseX($@){$_[0]>0?baseX(int($_[0]/$#_),@_[1..$#_]).$_[$_[0]%$#_+1]:''}
+ my @symbs = split //, $root->{tab_name_symbols};
+ sub{ baseX($_[0] + $root->{tab_name_start}, @symbs) || $symbs[0] };
+ }
+ : sub{$_[0] + $root->{tab_name_start}};
my @names = map {
my $tab = $root->{tabs}[$_];
if ($tab == $root->{cur}) {
$cur_idx = $_;
}
- my $name = $tab->{name} || '' . ($_ + 1);
+ my $name = $tab->{name} || $defname->($_);
my $length = length $name;
$total_full += 3 + $length;
$total_truncated += 3 + ($length < $max ? $length : $max);
@@ -1060,12 +1058,14 @@
$root->{timeouts} = $root->parse_timeouts($rs->text(
'tabbar-timeouts', '0:▁:3:▂:6:▃:9:▄:12:▅:15:▆:18:▇:21:█'));
$root->{bell_timeout} = $rs->text('bell-timeout', 1) + 0;
- $root->{new_button} = $rs->bool('new-button', 0);
+ $root->{new_button} = $rs->text('new-button', '');
$root->{tab_title} = $rs->bool('title', 1);
$root->{autohide} = $rs->bool('autohide', 1);
$root->{register_keysyms} = !$rs->bool('no-tabbedex-keys', 0);
$root->{reopen_on_close} = $rs->bool('reopen-on-close', 0);
$root->{tab_arguments} = $rs->text('tab-arguments', '');
+ $root->{tab_name_start} = $rs->text('tab-name-start', 1);
+ $root->{tab_name_symbols} = $rs->text('tab-name-symbols', '');
# TODO: Remove the warning in late 2020.
if (defined $rs->text('new-tab-command')) {
white-dragon commented
added liltle prefomance
--- tabbedex.1 2020-01-08 03:02:37.767911757 +0300
+++ tabbedex 2020-01-08 03:27:34.483059190 +0300
@@ -648,16 +648,7 @@
my ($root) = @_;
my $ncol = $root->ncol;
- my $new_button = '';
- if ($root->{new_button}) {
- if ($ncol >= 60) {
- $new_button = '[NEW]';
- } elsif ($ncol >= 30) {
- $new_button = 'NEW';
- } elsif ($ncol >= 13) {
- $new_button = '+';
- }
- }
+ my $new_button = $root->{new_button} || '';
$ncol -= !!$new_button + length $new_button;
my $max = int(($ncol - 1) / 3) - 3;
@@ -668,7 +659,7 @@
if ($tab == $root->{cur}) {
$cur_idx = $_;
}
- my $name = $tab->{name} || '' . ($_ + 1);
+ my $name = $tab->{name} || $root->{tab_name_default}($_);
my $length = length $name;
$total_full += 3 + $length;
$total_truncated += 3 + ($length < $max ? $length : $max);
@@ -1060,12 +1051,22 @@
$root->{timeouts} = $root->parse_timeouts($rs->text(
'tabbar-timeouts', '0:▁:3:▂:6:▃:9:▄:12:▅:15:▆:18:▇:21:█'));
$root->{bell_timeout} = $rs->text('bell-timeout', 1) + 0;
- $root->{new_button} = $rs->bool('new-button', 0);
+ $root->{new_button} = $rs->text('new-button', '');
$root->{tab_title} = $rs->bool('title', 1);
$root->{autohide} = $rs->bool('autohide', 1);
$root->{register_keysyms} = !$rs->bool('no-tabbedex-keys', 0);
$root->{reopen_on_close} = $rs->bool('reopen-on-close', 0);
$root->{tab_arguments} = $rs->text('tab-arguments', '');
+ $root->{tab_name_start} = $rs->text('tab-name-start', 1);
+ $root->{tab_name_default} = $_
+ ? do{
+ sub baseX($@){$_[0]>0?baseX(int($_[0]/$#_),@_[1..$#_]).$_[$_[0]%$#_+1]:''}
+ my @symbs = split //, $_;
+ sub{ baseX($_[0] + $root->{tab_name_start}, @symbs) || $symbs[0] };
+ }
+ : sub{$_[0] + $root->{tab_name_start}}
+ for $rs->text('tab-name-symbols', '');
# TODO: Remove the warning in late 2020.
if (defined $rs->text('new-tab-command')) {
mina86 commented
I could be convinced about new-button
since that’d allow the button to be localised if someone is into that kind of thing, however two things would need to be changed:
- The old behaviour of
new-button: false
,new-button: true
and all other supported forms for boolean values needs to be preserved. - The button needs to be hidden if the terminal is to narrow.
- The text needs to be encoded via
$root->special_encode
.
tab-name-symbols
on the other hand isn’t worthwhile especially since it requires adding quite a bit of ugly code.