mirror of
https://github.com/gryf/tabbedalt.git
synced 2025-12-17 19:40:31 +01:00
Clean up the code a bit
This commit is contained in:
72
tabbed
72
tabbed
@@ -1,6 +1,6 @@
|
||||
#! perl
|
||||
# Tabbed perl extension for rxvt-unicode terminal emulator.
|
||||
# Modified by Roman Dobosz <gryf73 at gmail do com>
|
||||
# Modified by Roman Dobosz <gryf73 at gmail dot com>
|
||||
#
|
||||
# 2008-08-22 18:01:55
|
||||
# - Modified shortcuts for tab navigation - now it uses shift + left/right
|
||||
@@ -18,8 +18,8 @@
|
||||
# 2009-11-23 13:25:13
|
||||
# - Merged activity indicator from
|
||||
# http://mina86.com/2009/05/16/tabbed-urxvt-extension/#more but without
|
||||
# changes on tabs (like adding term title just behind all tabs). New resources
|
||||
# can be use to change defaults (as in original solution):
|
||||
# changes on tabs (like adding term title just behind all tabs). New
|
||||
# resources can be use to change defaults (as in original solution):
|
||||
# - tabbed-timeouts with format:
|
||||
# (<timeout> ":" <character> ":")* <timeout> ":" <character> ":"
|
||||
# default '16:.:8:::4:+'. Asterisk is always present as a first indicator
|
||||
@@ -33,43 +33,45 @@
|
||||
# tab-numbers to false.
|
||||
#
|
||||
# 2009-11-25 21:40:30
|
||||
# - Added colors for tabs, which have activity on them. First is to be set when
|
||||
# first activity (active-fg, defaults to red) appear on inactive tab. Last one
|
||||
# (actived-fg, blue by default) is set when there is no more possible timeouts.
|
||||
# Third one (actives-fg, purple) is set on all in between of these two.
|
||||
# - Added colors for tabs, which have activity on them. First is to be set
|
||||
# when first activity (active-fg, defaults to red) appear on inactive tab.
|
||||
# Last one (actived-fg, blue by default) is set when there is no more
|
||||
# possible timeouts. Third one (actives-fg, purple) is set on all in between
|
||||
# of these two.
|
||||
#
|
||||
# 2010-07-25 13:49:01
|
||||
# - Integrated renaming ability for tabs from stepb
|
||||
# (http://github.com/stepb/urxvt-tabbedex)
|
||||
#
|
||||
# 2010-08-12 20:54:46
|
||||
# - Added functionality to create definitions of custom shells as a X resource,
|
||||
# under common tabcmds name. This functionality also deprecates feature called
|
||||
# here as a predefined actions. Without any configuration only simple shell is
|
||||
# available under CTRL+SHIFT+N shortcut. After creating first custom shell this
|
||||
# default is not available.
|
||||
# - Added functionality to create definitions of custom shells as a X
|
||||
# resource, under common tabcmds name. This functionality also deprecates
|
||||
# feature called here as a predefined actions. Without any configuration
|
||||
# only simple shell is available under CTRL+SHIFT+N shortcut. After creating
|
||||
# first custom shell this default is not available.
|
||||
#
|
||||
# Let's assume, that one want to mimic previous configuration, that means three
|
||||
# kind of custom shells: simple one (default shell in the system), midnight
|
||||
# commander and root (namely - su command). Three resources should be created:
|
||||
# Let's assume, that one want to mimic previous configuration, that means
|
||||
# three kind of custom shells: simple one (default shell in the system),
|
||||
# midnight commander and root (namely - su command). Three resources should
|
||||
# be created:
|
||||
#
|
||||
# URxvt.tabbed.tabcmds.1: N|shell
|
||||
# URxvt.tabbed.tabcmds.2: R|root|su -
|
||||
# URxvt.tabbed.tabcmds.3: M|mc|mc
|
||||
#
|
||||
# URxvt.tabbed.tabcmds.[number] is a ordinal number, started from 1. There
|
||||
# shouldn't be gaps between numbers, otherwise custom shells defined after a gap
|
||||
# will not work.
|
||||
# shouldn't be gaps between numbers, otherwise custom shells defined after a
|
||||
# gap will not work.
|
||||
#
|
||||
# Resource values are two or three pipe separated values, which are in order:
|
||||
# - shortcut key, which will be used for invoking custom shell together with
|
||||
# CTRL+SHIFT keys. Mod4 (aka Super or Windows key) are not supported, and most
|
||||
# probably will be removed from script soon, as lots of window managers out
|
||||
# there make a big use of those keys.
|
||||
# Note: There is limitation for characters used as a shortcut. Because some of
|
||||
# them are used for control terminal itself (i.e. CTRL+SHIFT+D may not work), and
|
||||
# also other characters (digits, some special characters etc.). Letters are
|
||||
# case insensitive.
|
||||
# CTRL+SHIFT keys. Mod4 (aka Super or Windows key) are not supported, and
|
||||
# most probably will be removed from script soon, as lots of window
|
||||
# managers out there make a big use of those keys.
|
||||
# Note: There is limitation for characters used as a shortcut. Because some
|
||||
# of them are used for control terminal itself (i.e. CTRL+SHIFT+D may not
|
||||
# work), and also other characters (digits, some special characters etc.).
|
||||
# Letters are case insensitive.
|
||||
# - name of the tab, it could be anything but the pipe.
|
||||
# - optional command. If omitted, simple shell will be launched.
|
||||
#
|
||||
@@ -80,9 +82,9 @@
|
||||
# there can be others). Observe memory taken by urxvt with top or ps. Also,
|
||||
# original tabbed extension is affected.
|
||||
#
|
||||
# This change will affect i.e. dynamic font change - it will not expand window
|
||||
# to reflect size of a font. Switching to next tab and back will rearrange
|
||||
# content of a tab to current window size.
|
||||
# This change will affect i.e. dynamic font change - it will not expand
|
||||
# window to reflect size of a font. Switching to next tab and back will
|
||||
# rearrange content of a tab to current window size.
|
||||
#
|
||||
# If anyone have a better idea how to fix memory consumption which is taking
|
||||
# place in copy_properties(), please step forward :)
|
||||
@@ -110,7 +112,9 @@
|
||||
#
|
||||
# 2019-09-13 15:15:18
|
||||
# - Added shortcut for creating new shell like in original tabbed
|
||||
# (SHIFT+Down). It can be disabled by an option "disable-shift-down".
|
||||
# (SHIFT+Down). It can be disabled by an option "disable-shift-down". More
|
||||
# information in README.
|
||||
# - Cleaned up a bit the code and comments.
|
||||
|
||||
sub tab_activity_mark ($$) {
|
||||
my ($self, $tab) = @_;
|
||||
@@ -211,7 +215,6 @@ sub new_tab {
|
||||
|
||||
push @urxvt::TERM_EXT, urxvt::ext::tabbed::tab::;
|
||||
|
||||
|
||||
my $term = new urxvt::term
|
||||
$self->env, $urxvt::RXVTNAME,
|
||||
-embed => $self->parent,
|
||||
@@ -403,6 +406,7 @@ sub on_init {
|
||||
|
||||
my $timeouts = $self->x_resource ("tabbar-timeouts");
|
||||
$timeouts = '16:.:8:::4:+' unless defined $timeouts;
|
||||
|
||||
if ($timeouts ne '') {
|
||||
my @timeouts;
|
||||
while ($timeouts =~ /^(\d+):(.)(?::(.*))?$/) {
|
||||
@@ -426,9 +430,11 @@ sub on_init {
|
||||
|
||||
%{$self->{tabcmds}} = ();
|
||||
for (my $idx = 1; defined (my $res = $self->x_resource("tabcmds.$idx")); $idx++) {
|
||||
|
||||
chomp($res);
|
||||
(my @args) = split('\|', $res);
|
||||
my $key = uc(shift(@args));
|
||||
|
||||
if ($#args == 0) {
|
||||
$self->{tabcmds}{$key} = [ $args[0] ];
|
||||
} else {
|
||||
@@ -462,6 +468,7 @@ sub on_start {
|
||||
|
||||
# Ugly as hell ``session'' implementation
|
||||
if (!(@argv) && (qx(ps x|grep "[ ]urxvt\$"|wc -l) < 2) && scalar(@{$self->{session}})){
|
||||
|
||||
my $count = 0;
|
||||
my @command;
|
||||
for my $item (@{$self->{session}}){
|
||||
@@ -565,9 +572,12 @@ sub tab_key_press {
|
||||
if ($event->{state} & urxvt::ShiftMask) {
|
||||
if ($event->{state} & urxvt::ControlMask) {
|
||||
if (exists($self->{tabcmds}{chr($keysym)})) {
|
||||
# Execute user defined classes of shell programs.
|
||||
$self->new_tab(@{$self->{tabcmds}{chr($keysym)}});
|
||||
return 1;
|
||||
} elsif ($self->{disable_shift_down} and $keysym == 0x4e) {
|
||||
# As a failsafe watch under CTRL+SHIFT+N for shell class (if
|
||||
# SHIFT+DOWN is disabled).
|
||||
$self->new_tab("shell");
|
||||
return 1;
|
||||
}
|
||||
@@ -588,6 +598,7 @@ sub tab_key_press {
|
||||
$self->refresh;
|
||||
return 1;
|
||||
} elsif (not $self->{disable_shift_down} and $keysym == 0xff54) {
|
||||
# Run shell on SHIFT+DOWN, if enabled.
|
||||
$self->new_tab("shell");
|
||||
return 1;
|
||||
}
|
||||
@@ -604,8 +615,7 @@ sub tab_key_press {
|
||||
$self->make_current ($self->{tabs}[$idx2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
elsif ($keysym > 0x2f and $keysym < 0x40) {
|
||||
} elsif ($keysym > 0x2f and $keysym < 0x40) {
|
||||
# make ctrl+1...0 switch to proper tab
|
||||
my $num = $keysym - 0x30;
|
||||
if ($num == 0) {
|
||||
|
||||
Reference in New Issue
Block a user