]>
jfr.im git - irssi-scripts.git/blob - title.pl
2 use vars
qw($VERSION %IRSSI);
3 use Irssi
20020120.0250 ();
6 authors
=> 'Timo Sirainen, David Leadbeater',
7 contact
=> 'tss@iki.fi, dgl@dgl.cx',
9 description
=> 'Display configurable title as XTerm title',
11 url
=> 'http://irssi.dgl.cx/',
15 # title_string: The string used in the title, see below for explaination
16 # title_topic_length: The length to truncate the topic to (some terminals have
17 # problems with long titles).
18 # title_screen_window: (EXPERIMENTAL), sets the screen window title rather than
21 # The $vars are normal Irssi vars (docs/special_vars.txt).
22 # $.var does some magic, adds a space at the begining and brackets around
23 # the item but only if it produces output.
25 # Here is some examples:
27 # /set title_string Irssi: [$N@$tag]$.C$.winname$.act
28 # Quite nice with lots of info:
29 # /set title_string $cumode$winname$C$.M$.act$.topic
30 # Nickname with usermode
31 # /set title_string $N(+$usermode)
33 # To use this with screen you need some lines in your ~/.screenrc
34 # termcap xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
35 # terminfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
36 # This probably only works if you have $TERM set to xterm.
45 if(Irssi
::settings_get_bool
('title_screen_window')) {
46 print STDERR
"\033k$text\033\\";
48 print STDERR
"\033]0;$text\007";
53 my $title = Irssi
::settings_get_str
('title_string');
54 $title =~ s/\$([A-Za-z.,;:]+)/special_var($1)/eg;
71 $result = topic_str
();
72 }elsif($str eq 'act') {
75 my $item = ref Irssi
::active_win
() ? Irssi
::active_win
()->{active
} : '';
76 $item = Irssi
::active_server
() unless ref $item;
77 return '' unless ref $item;
79 $result = $item->parse_special('$' . $str);
82 $begin = '(+', $end = ')' if $str eq 'M' && $begin;
84 return $result ? $begin . $result . $end : '';
88 my $server = Irssi
::active_server
();
89 my $item = ref Irssi
::active_win
() ? Irssi
::active_win
()->{active
} : '';
91 if(ref $server && ref $item && $item->{type
} eq 'CHANNEL') {
92 my $topic = $item->{topic
};
93 # Remove colour and bold from topic...
94 $topic =~ s/\003(\d{1,2})(\,(\d{1,2})|)//g;
95 $topic =~ s/[\x00-\x1f]//g;
96 $topic = substr($topic, 0,Irssi
::settings_get_int
('title_topic_length'));
97 return $topic if length $topic;
104 for my $winref(keys %act) {
105 # handle windows with items and not gracefully
106 my $window = Irssi
::window_find_refnum
($winref);
107 if(defined($window)) {
108 for my $win ($window->items or $window) {
109 if($win->{data_level
} >= 3 || $win->{data_lev
} >= 3) {
110 push(@acts,$win->{server
}->{tag
} . '/' . $win->{name
});
112 delete($act{$winref});
116 delete($act{$winref});
119 return join(', ',@acts);
124 return unless ref Irssi
::active_win
() &&
125 Irssi
::active_win
()->{active
}->{type
} eq 'CHANNEL';
126 return unless lc $chan->{name
} eq lc Irssi
::active_win
()->{active
}->{name
};
133 return unless ref $win && $win->{data_level
} >= 3;
134 $act{$win->{refnum
}}++;
139 Irssi
::signal_add_last
('window changed', 'refresh_topic');
140 Irssi
::signal_add_last
('window item changed', 'refresh_topic');
141 Irssi
::signal_add_last
('window server changed', 'refresh_topic');
142 Irssi
::signal_add_last
('server nick changed', 'refresh_topic');
143 Irssi
::signal_add_last
('channel topic changed', 'topic_changed');
144 Irssi
::signal_add_last
('window hilight', 'hilight_win');
145 Irssi
::signal_add_last
('setup changed', 'refresh_topic');
147 Irssi
::settings_add_str
('misc', 'title_string', 'Irssi: [$N@$tag]$.C$.winname$.act');
148 Irssi
::settings_add_int
('misc', 'title_topic_length', 250);
149 Irssi
::settings_add_bool
('misc', 'title_screen_window', 0);