diff options
author | Mike Crute <crutem@amazon.com> | 2017-06-29 08:41:59 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2017-06-29 08:41:59 -0700 |
commit | aaf0d7c5cb22ea64d132465aead10b923b7287ac (patch) | |
tree | 2c75364155b3d630a7a2ace99fd8fded9999be17 /.irssi | |
parent | b1d422ba6dfc9c9f55d6f16d16f3f38540c77cbf (diff) | |
download | dotfiles-aaf0d7c5cb22ea64d132465aead10b923b7287ac.tar.bz2 dotfiles-aaf0d7c5cb22ea64d132465aead10b923b7287ac.tar.xz dotfiles-aaf0d7c5cb22ea64d132465aead10b923b7287ac.zip |
Update irssi scripts
Diffstat (limited to '.irssi')
l--------- | .irssi/scripts/autorun/hilightwin.pl | 1 | ||||
l--------- | .irssi/scripts/autorun/irssi-notify.pl | 1 | ||||
-rw-r--r-- | .irssi/scripts/hilightwin.pl | 54 | ||||
-rw-r--r-- | .irssi/scripts/screen_away.pl | 243 | ||||
-rw-r--r-- | .irssi/scripts/trackbar.pl | 623 |
5 files changed, 512 insertions, 410 deletions
diff --git a/.irssi/scripts/autorun/hilightwin.pl b/.irssi/scripts/autorun/hilightwin.pl deleted file mode 120000 index fb9568b..0000000 --- a/.irssi/scripts/autorun/hilightwin.pl +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | ../hilightwin.pl \ No newline at end of file | ||
diff --git a/.irssi/scripts/autorun/irssi-notify.pl b/.irssi/scripts/autorun/irssi-notify.pl deleted file mode 120000 index accb805..0000000 --- a/.irssi/scripts/autorun/irssi-notify.pl +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | ../irssi-notify.pl \ No newline at end of file | ||
diff --git a/.irssi/scripts/hilightwin.pl b/.irssi/scripts/hilightwin.pl index e508809..3bb2863 100644 --- a/.irssi/scripts/hilightwin.pl +++ b/.irssi/scripts/hilightwin.pl | |||
@@ -5,26 +5,51 @@ | |||
5 | # Modded a tiny bit by znx to stop private messages entering the hilighted | 5 | # Modded a tiny bit by znx to stop private messages entering the hilighted |
6 | # window (can be toggled) and to put up a timestamp. | 6 | # window (can be toggled) and to put up a timestamp. |
7 | # | 7 | # |
8 | # Changed a little by rummik to optionally show network name. Enable with | ||
9 | # `/set hilightwin_shownetwork on` | ||
10 | # | ||
8 | 11 | ||
12 | use strict; | ||
9 | use Irssi; | 13 | use Irssi; |
10 | use POSIX; | 14 | use POSIX; |
11 | use vars qw($VERSION %IRSSI); | 15 | use vars qw($VERSION %IRSSI); |
12 | 16 | ||
13 | $VERSION = "0.02"; | 17 | $VERSION = "1.00"; |
14 | %IRSSI = ( | 18 | %IRSSI = ( |
15 | authors => "Timo \'cras\' Sirainen, Mark \'znx\' Sangster", | 19 | authors => "Timo \'cras\' Sirainen, Mark \'znx\' Sangster, Kimberly \'rummik\' Zick", |
16 | contact => "tss\@iki.fi, znxster\@gmail.com", | 20 | contact => "tss\@iki.fi, znxster\@gmail.com, git\@zick.kim", |
17 | name => "hilightwin", | 21 | name => "hilightwin", |
18 | description => "Print hilighted messages to window named \"hilight\"", | 22 | description => "Print hilighted messages to window named \"hilight\"", |
19 | license => "Public Domain", | 23 | license => "Public Domain", |
20 | url => "http://irssi.org/", | 24 | url => "http://irssi.org/", |
21 | changed => "Sun May 25 18:59:57 BST 2008" | 25 | changed => "Thu Apr 6 15:30:25 EDT 2017" |
22 | ); | 26 | ); |
23 | 27 | ||
28 | sub is_ignored { | ||
29 | my ($dest) = @_; | ||
30 | |||
31 | my @ignore = split(' ', Irssi::settings_get_str('hilightwin_ignore_targets')); | ||
32 | return 0 if (!@ignore); | ||
33 | |||
34 | my %targets = map { $_ => 1 } @ignore; | ||
35 | |||
36 | return 1 if exists($targets{"*"}); | ||
37 | return 1 if exists($targets{$dest->{target}}); | ||
38 | |||
39 | if ($dest->{server}) { | ||
40 | my $tag = $dest->{server}->{tag}; | ||
41 | return 1 if exists($targets{$tag . "/*"}); | ||
42 | return 1 if exists($targets{$tag . "/" . $dest->{target}}); | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
24 | sub sig_printtext { | 48 | sub sig_printtext { |
25 | my ($dest, $text, $stripped) = @_; | 49 | my ($dest, $text, $stripped) = @_; |
26 | 50 | ||
27 | my $opt = MSGLEVEL_HILIGHT; | 51 | my $opt = MSGLEVEL_HILIGHT; |
52 | my $shownetwork = Irssi::settings_get_bool('hilightwin_show_network'); | ||
28 | 53 | ||
29 | if(Irssi::settings_get_bool('hilightwin_showprivmsg')) { | 54 | if(Irssi::settings_get_bool('hilightwin_showprivmsg')) { |
30 | $opt = MSGLEVEL_HILIGHT|MSGLEVEL_MSGS; | 55 | $opt = MSGLEVEL_HILIGHT|MSGLEVEL_MSGS; |
@@ -32,25 +57,28 @@ sub sig_printtext { | |||
32 | 57 | ||
33 | if( | 58 | if( |
34 | ($dest->{level} & ($opt)) && | 59 | ($dest->{level} & ($opt)) && |
35 | ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 | 60 | ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 && |
61 | (!is_ignored($dest)) | ||
36 | ) { | 62 | ) { |
37 | $window = Irssi::window_find_name('hilight'); | 63 | my $window = Irssi::window_find_name('hilight'); |
38 | 64 | ||
39 | if ($dest->{level} & MSGLEVEL_PUBLIC) { | 65 | if ($dest->{level} & MSGLEVEL_PUBLIC) { |
40 | $text = $dest->{target}.": ".$text; | 66 | $text = $dest->{target}.": ".$text; |
67 | $text = $dest->{server}->{tag} . "/" . $text if ($shownetwork); | ||
68 | } elsif ($shownetwork) { | ||
69 | $text = $dest->{server}->{tag} . ": " . $text; | ||
41 | } | 70 | } |
42 | $text = strftime( | 71 | $text =~ s/%/%%/g; |
43 | Irssi::settings_get_str('timestamp_format')." ", | 72 | $window->print($text, MSGLEVEL_CLIENTCRAP) if ($window); |
44 | localtime | ||
45 | ).$text; | ||
46 | $window->print($text, MSGLEVEL_NEVER) if ($window); | ||
47 | } | 73 | } |
48 | } | 74 | } |
49 | 75 | ||
50 | $window = Irssi::window_find_name('(hi)'); | 76 | my $window = Irssi::window_find_name('hilight'); |
51 | Irssi::print("Create a window named 'hilight'") if (!$window); | 77 | Irssi::print("Create a window named 'hilight'") if (!$window); |
52 | 78 | ||
53 | Irssi::settings_add_bool('hilightwin','hilightwin_showprivmsg',1); | 79 | Irssi::settings_add_bool('hilightwin','hilightwin_showprivmsg',1); |
80 | Irssi::settings_add_str('hilightwin', 'hilightwin_ignore_targets', ''); | ||
81 | Irssi::settings_add_bool('hilightwin','hilightwin_show_network', 0); | ||
54 | 82 | ||
55 | Irssi::signal_add('print text', 'sig_printtext'); | 83 | Irssi::signal_add('print text', 'sig_printtext'); |
56 | 84 | ||
diff --git a/.irssi/scripts/screen_away.pl b/.irssi/scripts/screen_away.pl deleted file mode 100644 index 86e3087..0000000 --- a/.irssi/scripts/screen_away.pl +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | use Irssi; | ||
2 | use strict; | ||
3 | use FileHandle; | ||
4 | |||
5 | use vars qw($VERSION %IRSSI); | ||
6 | |||
7 | $VERSION = "0.9.7.1"; | ||
8 | %IRSSI = ( | ||
9 | authors => 'Andreas \'ads\' Scherbaum <ads@wars-nicht.de>', | ||
10 | name => 'screen_away', | ||
11 | description => 'set (un)away, if screen is attached/detached', | ||
12 | license => 'GPL v2', | ||
13 | url => 'none', | ||
14 | ); | ||
15 | |||
16 | # screen_away irssi module | ||
17 | # | ||
18 | # written by Andreas 'ads' Scherbaum <ads@ufp.de> | ||
19 | # | ||
20 | # changes: | ||
21 | # 07.02.2004 fix error with away mode | ||
22 | # thanks to Michael Schiansky for reporting and fixing this one | ||
23 | # 07.08.2004 new function for changing nick on away | ||
24 | # 24.08.2004 fixing bug where the away nick was not storedcorrectly | ||
25 | # thanks for Harald Wurpts for help debugging this one | ||
26 | # 17.09.2004 rewrote init part to use $ENV{'STY'} | ||
27 | # 05.12.2004 add patch for remember away state | ||
28 | # thanks to Jilles Tjoelker <jilles@stack.nl> | ||
29 | # change "chatnet" to "tag" | ||
30 | # 18.05.2007 fix '-one' for SILC networks | ||
31 | # | ||
32 | # | ||
33 | # usage: | ||
34 | # | ||
35 | # put this script into your autorun directory and/or load it with | ||
36 | # /SCRIPT LOAD <name> | ||
37 | # | ||
38 | # there are 5 settings available: | ||
39 | # | ||
40 | # /set screen_away_active ON/OFF/TOGGLE | ||
41 | # /set screen_away_repeat <integer> | ||
42 | # /set screen_away_message <string> | ||
43 | # /set screen_away_window <string> | ||
44 | # /set screen_away_nick <string> | ||
45 | # | ||
46 | # active means, that you will be only set away/unaway, if this | ||
47 | # flag is set, default is ON | ||
48 | # repeat is the number of seconds, after the script will check the | ||
49 | # screen status again, default is 5 seconds | ||
50 | # message is the away message sent to the server, default: not here ... | ||
51 | # window is a window number or name, if set, the script will switch | ||
52 | # to this window, if it sets you away, default is '1' | ||
53 | # nick is the new nick, if the script goes away | ||
54 | # will only be used it not empty | ||
55 | # | ||
56 | # normal you should be able to rename the script to something other | ||
57 | # than 'screen_away' (as example, if you dont like the name) by simple | ||
58 | # changing the 'name' parameter in the %IRSSI hash at the top of this script | ||
59 | |||
60 | |||
61 | # variables | ||
62 | my $timer_name = undef; | ||
63 | my $away_status = 0; | ||
64 | my %old_nicks = (); | ||
65 | my %away = (); | ||
66 | |||
67 | # Register formats | ||
68 | Irssi::theme_register( | ||
69 | [ | ||
70 | 'screen_away_crap', | ||
71 | '{line_start}{hilight ' . $IRSSI{'name'} . ':} $0' | ||
72 | ]); | ||
73 | |||
74 | # if we are running | ||
75 | my $screen_away_used = 0; | ||
76 | |||
77 | # try to find out, if we are running in a screen | ||
78 | # (see, if $ENV{STY} is set | ||
79 | if (!defined($ENV{STY})) { | ||
80 | # just return, we will never be called again | ||
81 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
82 | "could not open status file for parent process (pid: " . getppid() . "): $!"); | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | my ($socket_name, $socket_path); | ||
87 | |||
88 | # search for socket | ||
89 | # normal we could search the socket file, ... if we know the path | ||
90 | # but so we have to call one time the screen executable | ||
91 | # disable locale | ||
92 | # the quotes around C force perl 5.005_03 to use the shell | ||
93 | # thanks to Jilles Tjoelker <jilles@stack.nl> for pointing this out | ||
94 | my $socket = `LC_ALL="C" screen -ls`; | ||
95 | |||
96 | |||
97 | |||
98 | my $running_in_screen = 0; | ||
99 | # locale doesnt seems to be an problem (yet) | ||
100 | if ($socket !~ /^No Sockets found/s) { | ||
101 | # ok, should have only one socket | ||
102 | $socket_name = $ENV{'STY'}; | ||
103 | $socket_path = $socket; | ||
104 | $socket_path =~ s/^.+\d+ Sockets? in ([^\n]+)\.\n.+$/$1/s; | ||
105 | if (length($socket_path) != length($socket)) { | ||
106 | # only activate, if string length is different | ||
107 | # (to make sure, we really got a dir name) | ||
108 | $screen_away_used = 1; | ||
109 | } else { | ||
110 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
111 | "error reading screen informations from:"); | ||
112 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
113 | "$socket"); | ||
114 | return; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | # last check | ||
119 | if ($screen_away_used == 0) { | ||
120 | # we will never be called again | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | # build complete socket name | ||
125 | $socket = $socket_path . "/" . $socket_name; | ||
126 | |||
127 | # register config variables | ||
128 | Irssi::settings_add_bool('misc', $IRSSI{'name'} . '_active', 1); | ||
129 | Irssi::settings_add_int('misc', $IRSSI{'name'} . '_repeat', 5); | ||
130 | Irssi::settings_add_str('misc', $IRSSI{'name'} . '_message', "not here ..."); | ||
131 | Irssi::settings_add_str('misc', $IRSSI{'name'} . '_window', "1"); | ||
132 | Irssi::settings_add_str('misc', $IRSSI{'name'} . '_nick', ""); | ||
133 | |||
134 | # init process | ||
135 | screen_away(); | ||
136 | |||
137 | # screen_away() | ||
138 | # | ||
139 | # check, set or reset the away status | ||
140 | # | ||
141 | # parameter: | ||
142 | # none | ||
143 | # return: | ||
144 | # 0 (OK) | ||
145 | sub screen_away { | ||
146 | my ($away, @screen, $screen); | ||
147 | |||
148 | # only run, if activated | ||
149 | if (Irssi::settings_get_bool($IRSSI{'name'} . '_active') == 1) { | ||
150 | if ($away_status == 0) { | ||
151 | # display init message at first time | ||
152 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
153 | "activating $IRSSI{'name'} (interval: " . Irssi::settings_get_int($IRSSI{'name'} . '_repeat') . " seconds)"); | ||
154 | } | ||
155 | # get actual screen status | ||
156 | my @screen = stat($socket); | ||
157 | # 00100 is the mode for "user has execute permissions", see stat.h | ||
158 | if (($screen[2] & 00100) == 0) { | ||
159 | # no execute permissions, Detached | ||
160 | $away = 1; | ||
161 | } else { | ||
162 | # execute permissions, Attached | ||
163 | $away = 2; | ||
164 | } | ||
165 | |||
166 | # check if status has changed | ||
167 | if ($away == 1 and $away_status != 1) { | ||
168 | # set away | ||
169 | if (length(Irssi::settings_get_str($IRSSI{'name'} . '_window')) > 0) { | ||
170 | # if length of window is greater then 0, make this window active | ||
171 | Irssi::command('window goto ' . Irssi::settings_get_str($IRSSI{'name'} . '_window')); | ||
172 | } | ||
173 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
174 | "Set away"); | ||
175 | my $message = Irssi::settings_get_str($IRSSI{'name'} . '_message'); | ||
176 | if (length($message) == 0) { | ||
177 | # we have to set a message or we wouldnt go away | ||
178 | $message = "not here ..."; | ||
179 | } | ||
180 | my ($server); | ||
181 | foreach $server (Irssi::servers()) { | ||
182 | if (!$server->{usermode_away}) { | ||
183 | # user isnt yet away | ||
184 | $away{$server->{'tag'}} = 0; | ||
185 | $server->command("AWAY " . (($server->{chat_type} ne 'SILC') ? "-one " : "") . "$message") if (!$server->{usermode_away}); | ||
186 | if (length(Irssi::settings_get_str($IRSSI{'name'} . '_nick')) > 0) { | ||
187 | # only change, if actual nick isnt already the away nick | ||
188 | if (Irssi::settings_get_str($IRSSI{'name'} . '_nick') ne $server->{nick}) { | ||
189 | # keep old nick | ||
190 | $old_nicks{$server->{'tag'}} = $server->{nick}; | ||
191 | # set new nick | ||
192 | $server->command("NICK " . Irssi::settings_get_str($IRSSI{'name'} . '_nick')); | ||
193 | } | ||
194 | } | ||
195 | } else { | ||
196 | # user is already away, remember this | ||
197 | $away{$server->{'tag'}} = 1; | ||
198 | } | ||
199 | } | ||
200 | $away_status = $away; | ||
201 | } elsif ($away == 2 and $away_status != 2) { | ||
202 | # unset away | ||
203 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'screen_away_crap', | ||
204 | "Reset away"); | ||
205 | my ($server); | ||
206 | foreach $server (Irssi::servers()) { | ||
207 | if ($away{$server->{'tag'}} == 1) { | ||
208 | # user was already away, dont reset away | ||
209 | $away{$server->{'tag'}} = 0; | ||
210 | next; | ||
211 | } | ||
212 | $server->command("AWAY" . (($server->{chat_type} ne 'SILC') ? " -one" : "")) if ($server->{usermode_away}); | ||
213 | if (defined($old_nicks{$server->{'tag'}}) and length($old_nicks{$server->{'tag'}}) > 0) { | ||
214 | # set old nick | ||
215 | $server->command("NICK " . $old_nicks{$server->{'tag'}}); | ||
216 | $old_nicks{$server->{'tag'}} = ""; | ||
217 | } | ||
218 | } | ||
219 | $away_status = $away; | ||
220 | } | ||
221 | } | ||
222 | # but everytimes install a new timer | ||
223 | register_screen_away_timer(); | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | # register_screen_away_timer() | ||
228 | # | ||
229 | # remove old timer and install a new one | ||
230 | # | ||
231 | # parameter: | ||
232 | # none | ||
233 | # return: | ||
234 | # none | ||
235 | sub register_screen_away_timer { | ||
236 | if (defined($timer_name)) { | ||
237 | # remove old timer, if defined | ||
238 | Irssi::timeout_remove($timer_name); | ||
239 | } | ||
240 | # add new timer with new timeout (maybe the timeout has been changed) | ||
241 | $timer_name = Irssi::timeout_add(Irssi::settings_get_int($IRSSI{'name'} . '_repeat') * 1000, 'screen_away', ''); | ||
242 | } | ||
243 | |||
diff --git a/.irssi/scripts/trackbar.pl b/.irssi/scripts/trackbar.pl index 7123330..0d10882 100644 --- a/.irssi/scripts/trackbar.pl +++ b/.irssi/scripts/trackbar.pl | |||
@@ -1,189 +1,508 @@ | |||
1 | # trackbar.pl | 1 | # trackbar.pl |
2 | # | 2 | # |
3 | # This little script will do just one thing: it will draw a line each time you | 3 | # This little script will do just one thing: it will draw a line each time you |
4 | # switch away from a window. This way, you always know just upto where you've | 4 | # switch away from a window. This way, you always know just upto where you've |
5 | # been reading that window :) It also removes the previous drawn line, so you | 5 | # been reading that window :) It also removes the previous drawn line, so you |
6 | # don't see double lines. | 6 | # don't see double lines. |
7 | # | 7 | # |
8 | # Usage: | 8 | # redraw trackbar only works on irssi 0.8.17 or higher. |
9 | # | ||
10 | # | ||
11 | # Usage: | ||
9 | # | 12 | # |
10 | # The script works right out of the box, but if you want you can change | 13 | # The script works right out of the box, but if you want you can change |
11 | # the working by /set'ing the following variables: | 14 | # the working by /set'ing the following variables: |
12 | # | 15 | # |
13 | # trackbar_string The characters to repeat to draw the bar | 16 | # Setting: trackbar_style |
14 | # trackbar_style The style for the bar, %r is red for example | 17 | # Description: This setting will be the color of your trackbar line. |
15 | # See formats.txt that came with irssi | 18 | # By default the value will be '%K', only Irssi color |
16 | # | 19 | # formats are allowed. If you don't know the color formats |
17 | # /mark is a command that will redraw the line at the bottom. However! This | 20 | # by heart, you can take a look at the formats documentation. |
18 | # requires irssi version after 20021228. otherwise you'll get the error | 21 | # You will find the proper docs on http://www.irssi.org/docs. |
19 | # redraw: unknown command, and your screen is all goofed up :) | 22 | # |
20 | # | 23 | # Setting: trackbar_string |
21 | # /upgrade & buf.pl notice: This version tries to remove the trackbars before | 24 | # Description: This is the string that your line will display. This can |
22 | # the upgrade is done, so buf.pl does not restore them, as they are not removeable | 25 | # be multiple characters or just one. For example: '~-~-' |
23 | # afterwards by trackbar. Unfortiounatly, to make this work, trackbar and buf.pl | 26 | # The default setting is '-'. |
24 | # need to be loaded in a specific order. Please experiment to see which order works | 27 | # |
25 | # for you (strangely, it differs from configuration to configuration, something I will | 28 | # Setting: trackbar_use_status_window |
26 | # try to fix in a next version) | 29 | # Description: If this setting is set to OFF, Irssi won't print a trackbar |
27 | # | 30 | # in the statuswindow |
28 | # Authors: | 31 | # |
29 | # - Main maintainer & author: Peter 'kinlo' Leurs | 32 | # Setting: trackbar_ignore_windows |
30 | # - Many thanks to Timo 'cras' Sirainen for placing me on my way | 33 | # Description: A list of windows where no trackbar should be printed |
31 | # - on-upgrade-remove-line patch by Uwe Dudenhoeffer | 34 | # |
32 | # | 35 | # Setting: trackbar_print_timestamp |
33 | # Version history: | 36 | # Description: If this setting is set to ON, Irssi will print the formatted |
34 | # 1.4: - Changed our's by my's so the irssi script header is valid | 37 | # timestamp in front of the trackbar. |
35 | # - Removed utf-8 support. In theory, the script should work w/o any | 38 | # |
36 | # problems for utf-8, just set trackbar_string to a valid utf-8 character | 39 | # Setting: trackbar_require_seen |
37 | # and everything *should* work. However, this script is being plagued by | 40 | # Description: Only clear the trackbar if it has been scrolled to. |
38 | # irssi internal bugs. The function Irssi::settings_get_str does NOT handle | 41 | # |
39 | # unicode strings properly, hence you will notice problems when setting the bar | 42 | # /mark is a command that will redraw the line at the bottom. |
40 | # to a unicode char. For changing your bar to utf-8 symbols, read the line sub. | 43 | # |
41 | # 1.3: - Upgrade now removes the trackbars. | 44 | # Command: /trackbar, /trackbar goto |
42 | # - Some code cleanups, other defaults | 45 | # Description: Jump to where the trackbar is, to pick up reading |
43 | # - /mark sets the line to the bottom | 46 | # |
44 | # 1.2: - Support for utf-8 | 47 | # Command: /trackbar keep |
45 | # - How the bar looks can now be configured with trackbar_string | 48 | # Description: Keep this window's trackbar where it is the next time |
46 | # and trackbar_style | 49 | # you switch windows (then this flag is cleared again) |
47 | # 1.1: - Fixed bug when closing window | 50 | # |
48 | # 1.0: - Initial release | 51 | # Command: /mark, /trackbar mark |
49 | # | 52 | # Description: Remove the old trackbar and mark the bottom of this |
50 | # | 53 | # window with a new trackbar |
51 | # Call for help! | 54 | # |
52 | # | 55 | # Command: /trackbar markvisible |
53 | # There is a trackbar version 2.0 that properly handles resizes and immediate config change | 56 | # Description: Like mark for all visible windows |
54 | # activation. However, there is/are some bug(s) in irssi's main buffer/window code that causes | 57 | # |
55 | # irssi to 'forget' lines, which is ofcourse completly unaccepteable. I haven't found the time | 58 | # Command: /trackbar markall |
56 | # nor do I know the irssi's internals enough to find and fix this bug, if you want to help, please | 59 | # Description: Like mark for all windows |
57 | # contact me, I'll give you a copy of the 2.0 version that will immediatly show you the problems. | 60 | # |
58 | # | 61 | # Command: /trackbar remove |
59 | # Known bugs: | 62 | # Description: Remove this window's trackbar |
60 | # - if you /clear a window, it will be uncleared when returning to the window | 63 | # |
61 | # - UTF-8 characters in the trackbar_string doesnt work. This is an irssi bug. | 64 | # Command: /trackbar removeall |
62 | # - if you resize your irssi (in xterm or so) the bar is not resized | 65 | # Description: Remove all windows' trackbars |
63 | # - changing the trackbar style is only visible after returning to a window | 66 | # |
64 | # however, changing style/resize takes in effect after you left the window. | 67 | # Command: /trackbar redraw |
65 | # | 68 | # Description: Force redraw of trackbars |
66 | # Whishlist/todo: | 69 | # |
67 | # - instead of drawing a line, just invert timestamp or something, | 70 | |
68 | # to save a line (but I don't think this is possible with current irssi) | 71 | |
69 | # - some pageup keybinding possibility, to scroll up upto the trackbar | 72 | # For bugreports and other improvements contact one of the authors. |
70 | # - <@coekie> kinlo: if i switch to another window, in another split window, i | 73 | # |
71 | # want the trackbar to go down in the previouswindow in that splitwindow :) | 74 | # This program is free software; you can redistribute it and/or modify |
72 | # - < bob_2> anyway to clear the line once the window is read? | 75 | # it under the terms of the GNU General Public License as published by |
73 | # - < elho> kinlo: wishlist item: a string that gets prepended to the repeating pattern | 76 | # the Free Software Foundation; either version 2 of the License, or |
74 | # - < elho> an option to still have the timestamp in front of the bar | 77 | # (at your option) any later version. |
75 | # - < elho> oh and an option to not draw it in the status window :P | 78 | # |
76 | # | 79 | # This program is distributed in the hope that it will be useful, |
77 | # BTW: when you have feature requests, mailing a patch that works is the fastest way | 80 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
78 | # to get it added :p | 81 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
82 | # GNU General Public License for more details. | ||
83 | # | ||
84 | # You should have received a copy of the GNU General Public License | ||
85 | # along with this script; if not, write to the Free Software | ||
86 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
87 | # | ||
88 | ## | ||
79 | 89 | ||
80 | use strict; | 90 | use strict; |
81 | use 5.6.1; | 91 | use warnings; |
82 | use Irssi; | 92 | use Irssi; |
83 | use Irssi::TextUI; | 93 | use Irssi::TextUI; |
94 | use Encode; | ||
84 | 95 | ||
85 | my $VERSION = "1.4"; | 96 | use POSIX qw(strftime); |
97 | use vars qw($VERSION %IRSSI); | ||
86 | 98 | ||
87 | my %IRSSI = ( | 99 | $VERSION = "2.4"; # 1ca8fa9f28b9586 |
88 | authors => "Peter 'kinlo' Leurs", | 100 | |
89 | contact => "peter\@pfoe.be", | 101 | %IRSSI = ( |
90 | name => "trackbar", | 102 | authors => 'Peter Leurs and Geert Hauwaerts', |
91 | description => "Shows a bar where you've last read a window", | 103 | contact => 'peter@pfoe.be', |
92 | license => "GPLv2", | 104 | patchers => 'Johan Kiviniemi (UTF-8), Uwe Dudenhoeffer (on-upgrade-remove-line)', |
93 | url => "http://www.pfoe.be/~peter/trackbar/", | 105 | name => 'trackbar', |
94 | changed => "Thu Feb 20 16:18:08 2003", | 106 | description => 'Shows a bar where you have last read a window.', |
107 | license => 'GNU General Public License', | ||
108 | url => 'http://www.pfoe.be/~peter/trackbar/', | ||
109 | commands => 'trackbar', | ||
95 | ); | 110 | ); |
96 | 111 | ||
97 | my %config; | 112 | ## Comments and remarks. |
113 | # | ||
114 | # This script uses settings. | ||
115 | # Use /SET to change the value or /TOGGLE to switch it on or off. | ||
116 | # | ||
117 | # | ||
118 | # Tip: The command 'trackbar' is very usefull if you bind that to a key, | ||
119 | # so you can easily jump to the trackbar. Please see 'help bind' for | ||
120 | # more information about keybindings in Irssi. | ||
121 | # | ||
122 | # Command: /BIND meta2-P key F1 | ||
123 | # /BIND F1 command trackbar | ||
124 | # | ||
125 | ## | ||
98 | 126 | ||
99 | Irssi::settings_add_str('trackbar', 'trackbar_string' => '-'); | 127 | ## Bugfixes and new items in this rewrite. |
100 | $config{'trackbar_string'} = Irssi::settings_get_str('trackbar_string'); | 128 | # |
129 | # * Remove all the trackbars before upgrading. | ||
130 | # * New setting trackbar_use_status_window to control the statuswindow trackbar. | ||
131 | # * New setting trackbar_print_timestamp to print a timestamp or not. | ||
132 | # * New command 'trackbar' to scroll up to the trackbar. | ||
133 | # * When resizing your terminal, Irssi will update all the trackbars to the new size. | ||
134 | # * When changing trackbar settings, change all the trackbars to the new settings. | ||
135 | # * New command 'trackbar mark' to draw a new trackbar (The old '/mark'). | ||
136 | # * New command 'trackbar markall' to draw a new trackbar in each window. | ||
137 | # * New command 'trackbar remove' to remove the trackbar from the current window. | ||
138 | # * New command 'trackbar removeall' to remove all the trackbars. | ||
139 | # * Don't draw a trackbar in empty windows. | ||
140 | # * Added a version check to prevent Irssi redraw errors. | ||
141 | # * Fixed a bookmark NULL versus 0 bug. | ||
142 | # * Fixed a remove-line bug in Uwe Dudenhoeffer his patch. | ||
143 | # * New command 'help trackbar' to display the trackbar commands. | ||
144 | # * Fixed an Irssi startup bug, now processing each auto-created window. | ||
145 | # | ||
146 | ## | ||
101 | 147 | ||
102 | Irssi::settings_add_str('trackbar', 'trackbar_style' => '%K'); | 148 | ## Known bugs and the todolist. |
103 | $config{'trackbar_style'} = Irssi::settings_get_str('trackbar_style'); | 149 | # |
150 | # Todo: * Instead of drawing a line, invert the line. | ||
151 | # | ||
152 | ## | ||
104 | 153 | ||
105 | Irssi::signal_add( | 154 | sub cmd_help { |
106 | 'setup changed' => sub { | 155 | my ($args) = @_; |
107 | $config{'trackbar_string'} = Irssi::settings_get_str('trackbar_string'); | 156 | if ($args =~ /^trackbar *$/i) { |
108 | $config{'trackbar_style'} = Irssi::settings_get_str('trackbar_style'); | 157 | print CLIENTCRAP <<HELP |
109 | if ($config{'trackbar_style'} =~ /(?<!%)[^%]|%%|%$/) { | 158 | %9Syntax:%9 |
110 | Irssi::print( | 159 | |
111 | "trackbar: %RWarning!%n 'trackbar_style' seems to contain " | 160 | TRACKBAR |
112 | . "printable characters. Only use format codes (read " | 161 | TRACKBAR GOTO |
113 | . "formats.txt).", MSGLEVEL_CLIENTERROR); | 162 | TRACKBAR KEEP |
114 | } | 163 | TRACKBAR MARK |
164 | TRACKBAR MARKVISIBLE | ||
165 | TRACKBAR MARKALL | ||
166 | TRACKBAR REMOVE | ||
167 | TRACKBAR REMOVEALL | ||
168 | TRACKBAR REDRAW | ||
169 | |||
170 | %9Parameters:%9 | ||
171 | |||
172 | GOTO: Jump to where the trackbar is, to pick up reading | ||
173 | KEEP: Keep this window's trackbar where it is the next time | ||
174 | you switch windows (then this flag is cleared again) | ||
175 | MARK: Remove the old trackbar and mark the bottom of this | ||
176 | window with a new trackbar | ||
177 | MARKVISIBLE: Like mark for all visible windows | ||
178 | MARKALL: Like mark for all windows | ||
179 | REMOVE: Remove this window's trackbar | ||
180 | REMOVEALL: Remove all windows' trackbars | ||
181 | REDRAW: Force redraw of trackbars | ||
182 | |||
183 | %9Description:%9 | ||
184 | |||
185 | Manage a trackbar. Without arguments, it will scroll up to the trackbar. | ||
186 | |||
187 | %9Examples:%9 | ||
188 | |||
189 | /TRACKBAR MARK | ||
190 | /TRACKBAR REMOVE | ||
191 | HELP | ||
115 | } | 192 | } |
116 | ); | 193 | } |
117 | 194 | ||
118 | Irssi::signal_add( | 195 | Irssi::theme_register([ |
119 | 'window changed' => sub { | 196 | 'trackbar_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.', |
120 | my (undef, $oldwindow) = @_; | 197 | 'trackbar_wrong_version', '%R>>%n %_Trackbar:%_ Please upgrade your client to 0.8.17 or above if you would like to use this feature of trackbar.', |
198 | 'trackbar_all_removed', '%R>>%n %_Trackbar:%_ All the trackbars have been removed.', | ||
199 | 'trackbar_not_found', '%R>>%n %_Trackbar:%_ No trackbar found in this window.', | ||
200 | ]); | ||
121 | 201 | ||
122 | if ($oldwindow) { | 202 | my $old_irssi = Irssi::version < 20140701; |
123 | my $line = $oldwindow->view()->get_bookmark('trackbar'); | 203 | sub check_version { |
124 | $oldwindow->view()->remove_line($line) if defined $line; | 204 | if ($old_irssi) { |
125 | $oldwindow->print(line($oldwindow->{'width'}), MSGLEVEL_NEVER); | 205 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'trackbar_wrong_version'); |
126 | $oldwindow->view()->set_bookmark_bottom('trackbar'); | 206 | return; |
127 | } | 207 | } else { |
208 | return 1; | ||
128 | } | 209 | } |
129 | ); | 210 | } |
211 | |||
212 | sub is_utf8 { | ||
213 | lc Irssi::settings_get_str('term_charset') eq 'utf-8' | ||
214 | } | ||
215 | |||
216 | my (%config, %keep_trackbar, %unseen_trackbar); | ||
217 | |||
218 | sub remove_one_trackbar { | ||
219 | my $win = shift; | ||
220 | my $view = shift || $win->view; | ||
221 | my $line = $view->get_bookmark('trackbar'); | ||
222 | if (defined $line) { | ||
223 | my $bottom = $view->{bottom}; | ||
224 | $view->remove_line($line); | ||
225 | $win->command('^scrollback end') if $bottom && !$win->view->{bottom}; | ||
226 | $view->redraw; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | sub add_one_trackbar { | ||
231 | my $win = shift; | ||
232 | my $view = shift || $win->view; | ||
233 | $win->print(line($win->{width}), MSGLEVEL_NEVER); | ||
234 | $view->set_bookmark_bottom('trackbar'); | ||
235 | $unseen_trackbar{ $win->{_irssi} } = 1; | ||
236 | Irssi::signal_emit("window trackbar added", $win); | ||
237 | $view->redraw; | ||
238 | } | ||
239 | |||
240 | sub update_one_trackbar { | ||
241 | my $win = shift; | ||
242 | my $view = shift || $win->view; | ||
243 | my $force = shift; | ||
244 | my $ignored = win_ignored($win, $view); | ||
245 | remove_one_trackbar($win, $view) | ||
246 | if $force || !defined $force || !$ignored; | ||
247 | add_one_trackbar($win, $view) | ||
248 | if $force || !$ignored; | ||
249 | } | ||
250 | |||
251 | sub win_ignored { | ||
252 | my $win = shift; | ||
253 | my $view = shift || $win->view; | ||
254 | return 1 unless $view->{buffer}{lines_count}; | ||
255 | return 1 if $win->{name} eq '(status)' && !$config{use_status_window}; | ||
256 | no warnings 'uninitialized'; | ||
257 | return 1 if grep { $win->{name} eq $_ || $win->{refnum} eq $_ | ||
258 | || $win->get_active_name eq $_ } @{ $config{ignore_windows} }; | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | sub sig_window_changed { | ||
263 | my ($newwindow, $oldwindow) = @_; | ||
264 | return unless $oldwindow; | ||
265 | redraw_trackbars($newwindow); | ||
266 | trackbar_update_seen($newwindow); | ||
267 | return if delete $keep_trackbar{ $oldwindow->{_irssi} }; | ||
268 | trackbar_update_seen($oldwindow); | ||
269 | return if $config{require_seen} && $unseen_trackbar{ $oldwindow->{_irssi } }; | ||
270 | update_one_trackbar($oldwindow, undef, 0); | ||
271 | } | ||
272 | |||
273 | sub trackbar_update_seen { | ||
274 | my $win = shift; | ||
275 | return unless $win; | ||
276 | return unless $unseen_trackbar{ $win->{_irssi} }; | ||
277 | |||
278 | my $view = $win->view; | ||
279 | my $line = $view->get_bookmark('trackbar'); | ||
280 | unless ($line) { | ||
281 | delete $unseen_trackbar{ $win->{_irssi} }; | ||
282 | Irssi::signal_emit("window trackbar seen", $win); | ||
283 | return; | ||
284 | } | ||
285 | my $startline = $view->{startline}; | ||
286 | return unless $startline; | ||
287 | |||
288 | if ($startline->{info}{time} < $line->{info}{time} | ||
289 | || $startline->{_irssi} == $line->{_irssi}) { | ||
290 | delete $unseen_trackbar{ $win->{_irssi} }; | ||
291 | Irssi::signal_emit("window trackbar seen", $win); | ||
292 | } | ||
293 | } | ||
294 | |||
295 | sub screen_length; | ||
296 | { local $@; | ||
297 | eval { require Text::CharWidth; }; | ||
298 | unless ($@) { | ||
299 | *screen_length = sub { Text::CharWidth::mbswidth($_[0]) }; | ||
300 | } | ||
301 | else { | ||
302 | *screen_length = sub { | ||
303 | my $temp = shift; | ||
304 | if (is_utf8()) { | ||
305 | Encode::_utf8_on($temp); | ||
306 | } | ||
307 | length($temp) | ||
308 | }; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | { my %strip_table = ( | ||
313 | (map { $_ => '' } (split //, '04261537' . 'kbgcrmyw' . 'KBGCRMYW' . 'U9_8I:|FnN>#[' . 'pP')), | ||
314 | (map { $_ => $_ } (split //, '{}%')), | ||
315 | ); | ||
316 | sub c_length { | ||
317 | my $o = Irssi::strip_codes($_[0]); | ||
318 | $o =~ s/(%(%|Z.{6}|z.{6}|X..|x..|.))/exists $strip_table{$2} ? $strip_table{$2} : | ||
319 | $2 =~ m{x(?:0[a-f]|[1-6][0-9a-z]|7[a-x])|z[0-9a-f]{6}}i ? '' : $1/gex; | ||
320 | screen_length($o) | ||
321 | } | ||
322 | } | ||
130 | 323 | ||
131 | sub line { | 324 | sub line { |
132 | my $width = shift; | 325 | my ($width, $time) = @_; |
133 | my $string = $config{'trackbar_string'}; | 326 | my $string = $config{string}; |
134 | $string = '-' unless defined $string; | 327 | $string = ' ' unless length $string; |
135 | 328 | $time ||= time; | |
136 | # There is a bug in irssi's utf-8 handling on config file settings, as you | 329 | |
137 | # can reproduce/see yourself by the following code sniplet: | 330 | Encode::_utf8_on($string); |
138 | # | 331 | my $length = c_length($string); |
139 | # my $quake = pack 'U*', 8364; # EUR symbol | 332 | |
140 | # Irssi::settings_add_str 'temp', 'temp_foo' => $quake; | 333 | my $format = ''; |
141 | # Irssi::print length $quake; | 334 | if ($config{print_timestamp}) { |
142 | # # prints 1 | 335 | $format = $config{timestamp_str}; |
143 | # Irssi::print length Irssi::settings_get_str 'temp_foo'; | 336 | $format =~ y/%/\01/; |
144 | # # prints 3 | 337 | $format =~ s/\01\01/%/g; |
145 | # | 338 | $format = strftime($format, localtime $time); |
146 | # | 339 | $format =~ y/\01/%/; |
147 | # Trackbar used to have a workaround, but on recent versions of perl/irssi | ||
148 | # it does no longer work. Therefore, if you want your trackbar to contain | ||
149 | # unicode characters, uncomment the line below for a nice full line, or set | ||
150 | # the string to whatever char you want. | ||
151 | |||
152 | # $string = pack('U*', 0x2500); | ||
153 | |||
154 | |||
155 | my $length = length $string; | ||
156 | |||
157 | if ($length == 0) { | ||
158 | $string = '-'; | ||
159 | $length = 1; | ||
160 | } | 340 | } |
161 | 341 | ||
162 | my $times = $width / $length; | 342 | my $times = $width / $length; |
163 | $times = int(1 + $times) if $times != int($times); | 343 | $times += 1 if $times != int $times; |
164 | $string =~ s/%/%%/g; | 344 | $format .= $config{style}; |
165 | return $config{'trackbar_style'} . substr($string x $times, 0, $width); | 345 | $width -= c_length($format); |
346 | $string x= $times; | ||
347 | chop $string while length $string && c_length($string) > $width; | ||
348 | return $format . $string; | ||
166 | } | 349 | } |
167 | 350 | ||
168 | # Remove trackbars on upgrade - but this doesn't really work if the scripts are not loaded in the correct order... watch out! | 351 | sub remove_all_trackbars { |
352 | for my $window (Irssi::windows) { | ||
353 | next unless ref $window; | ||
354 | remove_one_trackbar($window); | ||
355 | } | ||
356 | } | ||
169 | 357 | ||
170 | Irssi::signal_add_first( 'session save' => sub { | 358 | sub UNLOAD { |
171 | for my $window (Irssi::windows) { | 359 | remove_all_trackbars(); |
172 | next unless defined $window; | 360 | } |
173 | my $line = $window->view()->get_bookmark('trackbar'); | 361 | |
174 | $window->view()->remove_line($line) if defined $line; | 362 | sub redraw_trackbars { |
175 | } | 363 | return unless check_version(); |
176 | } | 364 | for my $win (@_ ? @_ : Irssi::windows) { |
177 | ); | 365 | next unless ref $win; |
366 | my $view = $win->view; | ||
367 | my $line = $view->get_bookmark('trackbar'); | ||
368 | next unless $line; | ||
369 | my $bottom = $view->{bottom}; | ||
370 | $win->print_after($line, MSGLEVEL_NEVER, line($win->{width}, $line->{info}{time}), | ||
371 | $line->{info}{time}); | ||
372 | $view->set_bookmark('trackbar', $win->last_line_insert); | ||
373 | $view->redraw; | ||
374 | $view->remove_line($line); | ||
375 | $win->command('^scrollback end') if $bottom && !$win->view->{bottom}; | ||
376 | $view->redraw; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | sub goto_trackbar { | ||
381 | my $win = Irssi::active_win; | ||
382 | my $line = $win->view->get_bookmark('trackbar'); | ||
383 | |||
384 | if ($line) { | ||
385 | $win->command("scrollback goto ". strftime("%d %H:%M:%S", localtime($line->{info}{time}))); | ||
386 | } else { | ||
387 | $win->printformat(MSGLEVEL_CLIENTCRAP, 'trackbar_not_found'); | ||
388 | } | ||
389 | } | ||
178 | 390 | ||
179 | sub cmd_mark { | 391 | sub cmd_mark { |
180 | my $window = Irssi::active_win(); | 392 | update_one_trackbar(Irssi::active_win, undef, 1); |
181 | # return unless defined $window; | 393 | } |
182 | my $line = $window->view()->get_bookmark('trackbar'); | 394 | |
183 | $window->view()->remove_line($line) if defined $line; | 395 | sub cmd_markall { |
184 | $window->print(line($window->{'width'}), MSGLEVEL_NEVER); | 396 | for my $window (Irssi::windows) { |
185 | $window->view()->set_bookmark_bottom('trackbar'); | 397 | next unless ref $window; |
186 | Irssi::command("redraw"); | 398 | update_one_trackbar($window); |
399 | } | ||
400 | } | ||
401 | |||
402 | sub signal_stop { | ||
403 | Irssi::signal_stop; | ||
404 | } | ||
405 | |||
406 | sub cmd_markvisible { | ||
407 | my @wins = Irssi::windows; | ||
408 | my $awin = | ||
409 | my $bwin = Irssi::active_win; | ||
410 | my $awin_counter = 0; | ||
411 | Irssi::signal_add_priority('window changed' => 'signal_stop', -99); | ||
412 | do { | ||
413 | Irssi::active_win->command('window up'); | ||
414 | $awin = Irssi::active_win; | ||
415 | update_one_trackbar($awin); | ||
416 | ++$awin_counter; | ||
417 | } until ($awin->{refnum} == $bwin->{refnum} || $awin_counter >= @wins); | ||
418 | Irssi::signal_remove('window changed' => 'signal_stop'); | ||
419 | } | ||
420 | |||
421 | sub cmd_trackbar_remove_one { | ||
422 | remove_one_trackbar(Irssi::active_win); | ||
423 | } | ||
424 | |||
425 | sub cmd_remove_all_trackbars { | ||
426 | remove_all_trackbars(); | ||
427 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'trackbar_all_removed'); | ||
428 | } | ||
429 | |||
430 | sub cmd_keep_once { | ||
431 | $keep_trackbar{ Irssi::active_win->{_irssi} } = 1; | ||
432 | } | ||
433 | |||
434 | sub trackbar_runsub { | ||
435 | my ($data, $server, $item) = @_; | ||
436 | $data =~ s/\s+$//g; | ||
437 | |||
438 | if ($data) { | ||
439 | Irssi::command_runsub('trackbar', $data, $server, $item); | ||
440 | } else { | ||
441 | goto_trackbar(); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | sub update_config { | ||
446 | my $was_status_window = $config{use_status_window}; | ||
447 | $config{style} = Irssi::settings_get_str('trackbar_style'); | ||
448 | $config{string} = Irssi::settings_get_str('trackbar_string'); | ||
449 | $config{require_seen} = Irssi::settings_get_bool('trackbar_require_seen'); | ||
450 | $config{ignore_windows} = [ split /[,\s]+/, Irssi::settings_get_str('trackbar_ignore_windows') ]; | ||
451 | $config{use_status_window} = Irssi::settings_get_bool('trackbar_use_status_window'); | ||
452 | $config{print_timestamp} = Irssi::settings_get_bool('trackbar_print_timestamp'); | ||
453 | if (defined $was_status_window && $was_status_window != $config{use_status_window}) { | ||
454 | if (my $swin = Irssi::window_find_name('(status)')) { | ||
455 | if ($config{use_status_window}) { | ||
456 | update_one_trackbar($swin); | ||
457 | } | ||
458 | else { | ||
459 | remove_one_trackbar($swin); | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | if ($config{print_timestamp}) { | ||
464 | my $ts_format = Irssi::settings_get_str('timestamp_format'); | ||
465 | my $ts_theme = Irssi::current_theme->get_format('fe-common/core', 'timestamp'); | ||
466 | my $render_str = Irssi::current_theme->format_expand($ts_theme); | ||
467 | (my $ts_escaped = $ts_format) =~ s/([%\$])/$1$1/g; | ||
468 | $render_str =~ s/(?|\$(.)(?!\w)|\$\{(\w+)\})/$1 eq 'Z' ? $ts_escaped : $1/ge; | ||
469 | $config{timestamp_str} = $render_str; | ||
470 | } | ||
471 | redraw_trackbars() unless $old_irssi; | ||
187 | } | 472 | } |
188 | 473 | ||
189 | Irssi::command_bind('mark', 'cmd_mark'); | 474 | Irssi::settings_add_str('trackbar', 'trackbar_string', is_utf8() ? "\x{2500}" : '-'); |
475 | Irssi::settings_add_str('trackbar', 'trackbar_style', '%K'); | ||
476 | Irssi::settings_add_str('trackbar', 'trackbar_ignore_windows', ''); | ||
477 | Irssi::settings_add_bool('trackbar', 'trackbar_use_status_window', 1); | ||
478 | Irssi::settings_add_bool('trackbar', 'trackbar_print_timestamp', 0); | ||
479 | Irssi::settings_add_bool('trackbar', 'trackbar_require_seen', 0); | ||
480 | |||
481 | update_config(); | ||
482 | |||
483 | Irssi::signal_add_last( 'mainwindow resized' => 'redraw_trackbars') | ||
484 | unless $old_irssi; | ||
485 | |||
486 | Irssi::signal_register({'window trackbar added' => [qw/Irssi::UI::Window/]}); | ||
487 | Irssi::signal_register({'window trackbar seen' => [qw/Irssi::UI::Window/]}); | ||
488 | Irssi::signal_register({'gui page scrolled' => [qw/Irssi::UI::Window/]}); | ||
489 | Irssi::signal_add_last('gui page scrolled' => 'trackbar_update_seen'); | ||
490 | |||
491 | Irssi::signal_add('setup changed' => 'update_config'); | ||
492 | Irssi::signal_add_priority('session save' => 'remove_all_trackbars', Irssi::SIGNAL_PRIORITY_HIGH-1); | ||
493 | |||
494 | Irssi::signal_add('window changed' => 'sig_window_changed'); | ||
495 | |||
496 | Irssi::command_bind('trackbar goto' => 'goto_trackbar'); | ||
497 | Irssi::command_bind('trackbar keep' => 'cmd_keep_once'); | ||
498 | Irssi::command_bind('trackbar mark' => 'cmd_mark'); | ||
499 | Irssi::command_bind('trackbar markvisible' => 'cmd_markvisible'); | ||
500 | Irssi::command_bind('trackbar markall' => 'cmd_markall'); | ||
501 | Irssi::command_bind('trackbar remove' => 'cmd_trackbar_remove_one'); | ||
502 | Irssi::command_bind('trackbar removeall' => 'cmd_remove_all_trackbars'); | ||
503 | Irssi::command_bind('trackbar redraw' => 'redraw_trackbars'); | ||
504 | Irssi::command_bind('trackbar' => 'trackbar_runsub'); | ||
505 | Irssi::command_bind('mark' => 'cmd_mark'); | ||
506 | Irssi::command_bind_last('help' => 'cmd_help'); | ||
507 | |||
508 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'trackbar_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors}); | ||