Merge ~hloeung/matterircd/+git/irssi-matterircd-complete:lpcraft into ~hloeung/matterircd/+git/irssi-matterircd-complete:master

Proposed by Haw Loeung
Status: Merged
Merged at revision: c55db5d1b715cf945075b2f2807615feb5692ec1
Proposed branch: ~hloeung/matterircd/+git/irssi-matterircd-complete:lpcraft
Merge into: ~hloeung/matterircd/+git/irssi-matterircd-complete:master
Diff against target: 683 lines (+138/-125)
2 files modified
.launchpad.yaml (+12/-0)
matterircd_complete.pl (+126/-125)
Reviewer Review Type Date Requested Status
Haw Loeung Pending
Review via email: mp+433327@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.launchpad.yaml b/.launchpad.yaml
0new file mode 1006440new file mode 100644
index 0000000..5cf3b69
--- /dev/null
+++ b/.launchpad.yaml
@@ -0,0 +1,12 @@
1pipeline:
2 - lint
3
4jobs:
5 lint:
6 architectures: amd64
7 series: focal
8 packages:
9 - irssi
10 - perl-base
11 run: |
12 perl -Mstrict -Mdiagnostics -cw /build/lpcraft/project/matterircd_complete.pl
diff --git a/matterircd_complete.pl b/matterircd_complete.pl
index 723ff16..cf5f37a 100755
--- a/matterircd_complete.pl
+++ b/matterircd_complete.pl
@@ -56,23 +56,8 @@ use strict;
56use warnings;56use warnings;
57use experimental 'smartmatch';57use experimental 'smartmatch';
5858
59use Irssi::TextUI;59require Irssi::TextUI;
60use Irssi qw(60require Irssi;
61 command_bind
62 gui_input_get_pos
63 gui_input_set
64 gui_input_set_pos
65 parse_special
66 settings_add_bool
67 settings_add_int
68 settings_add_str
69 settings_get_bool
70 settings_get_int
71 settings_get_str
72 signal_add
73 signal_add_last
74 signal_continue
75);
7661
77# Enable for debugging purposes only.62# Enable for debugging purposes only.
78# use Data::Dumper;63# use Data::Dumper;
@@ -94,24 +79,24 @@ my $KEY_SPC = 32;
94my $KEY_B = 66;79my $KEY_B = 66;
95my $KEY_O = 79;80my $KEY_O = 79;
9681
97settings_add_str('matterircd_complete', 'matterircd_complete_networks', '');82Irssi::settings_add_str('matterircd_complete', 'matterircd_complete_networks', '');
98settings_add_str('matterircd_complete', 'matterircd_complete_nick_ignore', '');83Irssi::settings_add_str('matterircd_complete', 'matterircd_complete_nick_ignore', '');
99settings_add_str('matterircd_complete', 'matterircd_complete_channel_dont_ignore', '');84Irssi::settings_add_str('matterircd_complete', 'matterircd_complete_channel_dont_ignore', '');
10085
10186
102#==============================================================================87#==============================================================================
10388
104settings_add_int('matterircd_complete', 'matterircd_complete_reply_msg_thread_id_color', 10);89Irssi::settings_add_int('matterircd_complete', 'matterircd_complete_reply_msg_thread_id_color', 10);
10590
106# Rely on message/thread IDs stored in message cache so we can shorten91# Rely on message/thread IDs stored in message cache so we can shorten
107# to save on screen real-estate.92# to save on screen real-estate.
108settings_add_int('matterircd_complete', 'matterircd_complete_shorten_message_thread_id', 5);93Irssi::settings_add_int('matterircd_complete', 'matterircd_complete_shorten_message_thread_id', 5);
109settings_add_bool('matterircd_complete', 'matterircd_complete_shorten_message_thread_id_hide_prefix', 1);94Irssi::settings_add_bool('matterircd_complete', 'matterircd_complete_shorten_message_thread_id_hide_prefix', 1);
110sub update_msgthreadid {95sub update_msgthreadid {
111 my($server, $msg, $nick, $address, $target) = @_;96 my($server, $msg, $nick, $address, $target) = @_;
11297
113 return unless settings_get_int('matterircd_complete_shorten_message_thread_id');98 return unless Irssi::settings_get_int('matterircd_complete_shorten_message_thread_id');
114 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));99 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
115 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};100 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
116101
117 my $prefix = '';102 my $prefix = '';
@@ -131,11 +116,11 @@ sub update_msgthreadid {
131 $prefix = '↪';116 $prefix = '↪';
132 }117 }
133118
134 if (not settings_get_bool('matterircd_complete_shorten_message_thread_id_hide_prefix')) {119 if (not Irssi::settings_get_bool('matterircd_complete_shorten_message_thread_id_hide_prefix')) {
135 $prefix = "${prefix}\@\@";120 $prefix = "${prefix}\@\@";
136 }121 }
137122
138 my $len = settings_get_int('matterircd_complete_shorten_message_thread_id');123 my $len = Irssi::settings_get_int('matterircd_complete_shorten_message_thread_id');
139 if ($len < 25) {124 if ($len < 25) {
140 # Shorten to length configured. We use unicode ellipsis (...)125 # Shorten to length configured. We use unicode ellipsis (...)
141 # here to both allow word selection to just select parts of126 # here to both allow word selection to just select parts of
@@ -146,19 +131,19 @@ sub update_msgthreadid {
146 $msgpostid = substr($msgpostid, 0, $len) . '…';131 $msgpostid = substr($msgpostid, 0, $len) . '…';
147 }132 }
148 }133 }
149 my $thread_color = settings_get_int('matterircd_complete_reply_msg_thread_id_color');134 my $thread_color = Irssi::settings_get_int('matterircd_complete_reply_msg_thread_id_color');
150 if ($msgpostid eq '') {135 if ($msgpostid eq '') {
151 $msg =~ s/\@\@PLACEHOLDER\@\@/\x03${thread_color}[${prefix}${msgthreadid}]\x0f/;136 $msg =~ s/\@\@PLACEHOLDER\@\@/\x03${thread_color}[${prefix}${msgthreadid}]\x0f/;
152 } else {137 } else {
153 $msg =~ s/\@\@PLACEHOLDER\@\@/\x03${thread_color}[${prefix}${msgthreadid},${msgpostid}]\x0f/;138 $msg =~ s/\@\@PLACEHOLDER\@\@/\x03${thread_color}[${prefix}${msgthreadid},${msgpostid}]\x0f/;
154 }139 }
155140
156 signal_continue($server, $msg, $nick, $address, $target);141 Irssi::signal_continue($server, $msg, $nick, $address, $target);
157}142}
158signal_add_last('message irc action', 'update_msgthreadid');143Irssi::signal_add_last('message irc action', 'update_msgthreadid');
159signal_add_last('message irc notice', 'update_msgthreadid');144Irssi::signal_add_last('message irc notice', 'update_msgthreadid');
160signal_add_last('message private', 'update_msgthreadid');145Irssi::signal_add_last('message private', 'update_msgthreadid');
161signal_add_last('message public', 'update_msgthreadid');146Irssi::signal_add_last('message public', 'update_msgthreadid');
162147
163sub cache_store {148sub cache_store {
164 my ($cache_ref, $item, $cache_size) = @_;149 my ($cache_ref, $item, $cache_size) = @_;
@@ -200,15 +185,15 @@ sub cache_store {
200185
201186
202my %MSGTHREADID_CACHE;187my %MSGTHREADID_CACHE;
203settings_add_int('matterircd_complete', 'matterircd_complete_message_thread_id_cache_size', 50);188Irssi::settings_add_int('matterircd_complete', 'matterircd_complete_message_thread_id_cache_size', 50);
204command_bind 'matterircd_complete_msgthreadid_cache_dump' => sub {189sub cmd_matterircd_complete_msgthreadid_cache_dump {
205 my ($data, $server, $wi) = @_;190 my ($data, $server, $wi) = @_;
206191
207 if (not $data) {192 if (not $data) {
208 return unless ref $wi and ($wi->{type} eq 'CHANNEL' or $wi->{type} eq 'QUERY');193 return unless ref $wi and ($wi->{type} eq 'CHANNEL' or $wi->{type} eq 'QUERY');
209 }194 }
210195
211 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));196 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
212 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};197 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
213198
214 my $channel = $data ? $data : $wi->{name};199 my $channel = $data ? $data : $wi->{name};
@@ -227,17 +212,18 @@ command_bind 'matterircd_complete_msgthreadid_cache_dump' => sub {
227 }212 }
228 Irssi::print("${channel}: Total: " . scalar @{$MSGTHREADID_CACHE{$channel}});213 Irssi::print("${channel}: Total: " . scalar @{$MSGTHREADID_CACHE{$channel}});
229};214};
215Irssi::command_bind('matterircd_complete_msgthreadid_cache_dump', 'cmd_matterircd_complete_msgthreadid_cache_dump');
230216
231my $MSGTHREADID_CACHE_SEARCH_ENABLED = 0;217my $MSGTHREADID_CACHE_SEARCH_ENABLED = 0;
232my $MSGTHREADID_CACHE_INDEX = 0;218my $MSGTHREADID_CACHE_INDEX = 0;
233command_bind 'message_thread_id_search' => sub {219sub cmd_message_thread_id_search {
234 my ($data, $server, $wi) = @_;220 my ($data, $server, $wi) = @_;
235221
236 return unless settings_get_int('matterircd_complete_message_thread_id_cache_size');222 return unless Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
237 return unless ref $wi and ($wi->{type} eq 'CHANNEL' or $wi->{type} eq 'QUERY');223 return unless ref $wi and ($wi->{type} eq 'CHANNEL' or $wi->{type} eq 'QUERY');
238 return unless exists($MSGTHREADID_CACHE{$wi->{name}});224 return unless exists($MSGTHREADID_CACHE{$wi->{name}});
239225
240 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));226 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
241 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};227 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
242228
243 $MSGTHREADID_CACHE_SEARCH_ENABLED = 1;229 $MSGTHREADID_CACHE_SEARCH_ENABLED = 1;
@@ -250,24 +236,25 @@ command_bind 'message_thread_id_search' => sub {
250236
251 if ($msgthreadid) {237 if ($msgthreadid) {
252 # Save input text.238 # Save input text.
253 my $input = parse_special('$L');239 my $input = Irssi::parse_special('$L');
254 # Remove existing thread.240 # Remove existing thread.
255 $input =~ s/^@@(?:[0-9a-z]{26}|[0-9a-f]{3}) //;241 $input =~ s/^@@(?:[0-9a-z]{26}|[0-9a-f]{3}) //;
256 # Insert message/thread ID from cache.242 # Insert message/thread ID from cache.
257 gui_input_set_pos(0);243 Irssi::gui_input_set_pos(0);
258 gui_input_set("\@\@${msgthreadid} ${input}");244 Irssi::gui_input_set("\@\@${msgthreadid} ${input}");
259 }245 }
260};246};
247Irssi::command_bind('message_thread_id_search', 'cmd_message_thread_id_search');
261248
262my $ESC_PRESSED = 0;249my $ESC_PRESSED = 0;
263my $O_PRESSED = 0;250my $O_PRESSED = 0;
264signal_add_last 'gui key pressed' => sub {251sub signal_gui_key_pressed_msgthreadid {
265 my ($key) = @_;252 my ($key) = @_;
266253
267 return unless $MSGTHREADID_CACHE_SEARCH_ENABLED;254 return unless $MSGTHREADID_CACHE_SEARCH_ENABLED;
268255
269 my $server = Irssi::active_server();256 my $server = Irssi::active_server();
270 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));257 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
271 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};258 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
272259
273 if (($key == $KEY_RET) || ($key == $KEY_CTRL_U)) {260 if (($key == $KEY_RET) || ($key == $KEY_CTRL_U)) {
@@ -280,14 +267,14 @@ signal_add_last 'gui key pressed' => sub {
280267
281 # Cancel/abort, so remove thread stuff.268 # Cancel/abort, so remove thread stuff.
282 elsif ($key == $KEY_CTRL_C) {269 elsif ($key == $KEY_CTRL_C) {
283 my $input = parse_special('$L');270 my $input = Irssi::parse_special('$L');
284271
285 # Remove the Ctrl+C character.272 # Remove the Ctrl+C character.
286 $input =~ tr///d;273 $input =~ tr///d;
287274
288 my $pos = 0;275 my $pos = 0;
289 if ($input =~ s/^(@@(?:[0-9a-z]{26}|[0-9a-f]{3}) )//) {276 if ($input =~ s/^(@@(?:[0-9a-z]{26}|[0-9a-f]{3}) )//) {
290 $pos = gui_input_get_pos() - length($1);277 $pos = Irssi::gui_input_get_pos() - length($1);
291 }278 }
292279
293 # We also want to move the input position back one for Ctrl+C280 # We also want to move the input position back one for Ctrl+C
@@ -297,8 +284,8 @@ signal_add_last 'gui key pressed' => sub {
297 # Replace the text in the input box with our modified version,284 # Replace the text in the input box with our modified version,
298 # then move cursor positon to where it was without the285 # then move cursor positon to where it was without the
299 # message/thread ID.286 # message/thread ID.
300 gui_input_set($input);287 Irssi::gui_input_set($input);
301 gui_input_set_pos($pos);288 Irssi::gui_input_set_pos($pos);
302289
303 $MSGTHREADID_CACHE_INDEX = 0;290 $MSGTHREADID_CACHE_INDEX = 0;
304 $MSGTHREADID_CACHE_SEARCH_ENABLED = 0;291 $MSGTHREADID_CACHE_SEARCH_ENABLED = 0;
@@ -327,19 +314,20 @@ signal_add_last 'gui key pressed' => sub {
327 $O_PRESSED = 0;314 $O_PRESSED = 0;
328 }315 }
329};316};
317Irssi::signal_add_last('gui key pressed', 'signal_gui_key_pressed_msgthreadid');
330318
331signal_add_last 'complete word' => sub {319sub signal_complete_word_msgthread_id {
332 my ($complist, $window, $word, $linestart, $want_space) = @_;320 my ($complist, $window, $word, $linestart, $want_space) = @_;
333321
334 # We only want to tab-complete message/thread if this is the first322 # We only want to tab-complete message/thread if this is the first
335 # word on the line.323 # word on the line.
336 return if $linestart;324 return if $linestart;
337 return unless settings_get_int('matterircd_complete_message_thread_id_cache_size');325 return unless Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
338 return if (substr($word, 0, 1) eq '@' and substr($word, 0, 2) ne '@@');326 return if (substr($word, 0, 1) eq '@' and substr($word, 0, 2) ne '@@');
339 return unless $window->{active} and ($window->{active}->{type} eq 'CHANNEL' || $window->{active}->{type} eq 'QUERY');327 return unless $window->{active} and ($window->{active}->{type} eq 'CHANNEL' || $window->{active}->{type} eq 'QUERY');
340 return unless exists($MSGTHREADID_CACHE{$window->{active}->{name}});328 return unless exists($MSGTHREADID_CACHE{$window->{active}->{name}});
341329
342 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));330 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
343 return unless exists $chatnets{'*'} || exists $chatnets{$window->{active_server}->{chatnet}};331 return unless exists $chatnets{'*'} || exists $chatnets{$window->{active_server}->{chatnet}};
344332
345 if (substr($word, 0, 2) eq '@@') {333 if (substr($word, 0, 2) eq '@@') {
@@ -352,21 +340,22 @@ signal_add_last 'complete word' => sub {
352 }340 }
353 }341 }
354};342};
343Irssi::signal_add_last('complete word', 'signal_complete_word_msgthread_id');
355344
356sub cache_msgthreadid {345sub cache_msgthreadid {
357 my($server, $msg, $nick, $address, $target) = @_;346 my($server, $msg, $nick, $address, $target) = @_;
358347
359 return unless settings_get_int('matterircd_complete_message_thread_id_cache_size');348 return unless Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
360 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));349 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
361 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};350 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
362351
363 my @msgids = ();352 my @msgids = ();
364353
365 my @ignore_nicks = split(/\s+/, settings_get_str('matterircd_complete_nick_ignore'));354 my @ignore_nicks = split(/\s+/, Irssi::settings_get_str('matterircd_complete_nick_ignore'));
366 # Ignore nicks configured to be ignored such as bots.355 # Ignore nicks configured to be ignored such as bots.
367 if ($nick ~~ @ignore_nicks) {356 if ($nick ~~ @ignore_nicks) {
368 # But not if the channel is in matterircd_complete_channel_dont_ignore.357 # But not if the channel is in matterircd_complete_channel_dont_ignore.
369 my @channel_dont_ignore = split(/\s+/, settings_get_str('matterircd_complete_channel_dont_ignore'));358 my @channel_dont_ignore = split(/\s+/, Irssi::settings_get_str('matterircd_complete_channel_dont_ignore'));
370 if ($target !~ @channel_dont_ignore) {359 if ($target !~ @channel_dont_ignore) {
371 return;360 return;
372 }361 }
@@ -409,25 +398,25 @@ sub cache_msgthreadid {
409 $key = $nick398 $key = $nick
410 }399 }
411400
412 my $cache_size = settings_get_int('matterircd_complete_message_thread_id_cache_size');401 my $cache_size = Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
413 for my $msgid (@msgids) {402 for my $msgid (@msgids) {
414 if (cache_store(\@{$MSGTHREADID_CACHE{$key}}, $msgid, $cache_size)) {403 if (cache_store(\@{$MSGTHREADID_CACHE{$key}}, $msgid, $cache_size)) {
415 $MSGTHREADID_CACHE_INDEX = 0;404 $MSGTHREADID_CACHE_INDEX = 0;
416 }405 }
417 }406 }
418}407}
419signal_add('message irc action', 'cache_msgthreadid');408Irssi::signal_add('message irc action', 'cache_msgthreadid');
420signal_add('message irc notice', 'cache_msgthreadid');409Irssi::signal_add('message irc notice', 'cache_msgthreadid');
421signal_add('message private', 'cache_msgthreadid');410Irssi::signal_add('message private', 'cache_msgthreadid');
422signal_add('message public', 'cache_msgthreadid');411Irssi::signal_add('message public', 'cache_msgthreadid');
423412
424settings_add_bool('matterircd_complete', 'matterircd_complete_reply_msg_thread_id_at_start', 1);413Irssi::settings_add_bool('matterircd_complete', 'matterircd_complete_reply_msg_thread_id_at_start', 1);
425414
426signal_add_last 'message own_public' => sub {415sub signal_message_own_public_msgthreadid {
427 my($server, $msg, $target) = @_;416 my($server, $msg, $target) = @_;
428417
429 return unless settings_get_int('matterircd_complete_message_thread_id_cache_size');418 return unless Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
430 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));419 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
431 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};420 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
432421
433 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {422 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {
@@ -435,14 +424,14 @@ signal_add_last 'message own_public' => sub {
435 }424 }
436 my $msgid = $1;425 my $msgid = $1;
437426
438 my $cache_size = settings_get_int('matterircd_complete_message_thread_id_cache_size');427 my $cache_size = Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
439 if (cache_store(\@{$MSGTHREADID_CACHE{$target}}, $msgid, $cache_size)) {428 if (cache_store(\@{$MSGTHREADID_CACHE{$target}}, $msgid, $cache_size)) {
440 $MSGTHREADID_CACHE_INDEX = 0;429 $MSGTHREADID_CACHE_INDEX = 0;
441 }430 }
442431
443 my $msgthreadid = $1;432 my $msgthreadid = $1;
444433
445 my $len = settings_get_int('matterircd_complete_shorten_message_thread_id');434 my $len = Irssi::settings_get_int('matterircd_complete_shorten_message_thread_id');
446 if ($len < 25) {435 if ($len < 25) {
447 # Shorten to length configured. We use unicode ellipsis (...)436 # Shorten to length configured. We use unicode ellipsis (...)
448 # here to both allow word selection to just select parts of437 # here to both allow word selection to just select parts of
@@ -451,22 +440,23 @@ signal_add_last 'message own_public' => sub {
451 $msgthreadid = substr($msgid, 0, $len) . "…";440 $msgthreadid = substr($msgid, 0, $len) . "…";
452 }441 }
453442
454 my $thread_color = settings_get_int('matterircd_complete_reply_msg_thread_id_color');443 my $thread_color = Irssi::settings_get_int('matterircd_complete_reply_msg_thread_id_color');
455 if (settings_get_bool('matterircd_complete_reply_msg_thread_id_at_start')) {444 if (Irssi::settings_get_bool('matterircd_complete_reply_msg_thread_id_at_start')) {
456 $msg =~ s/^@@[0-9a-z]{26} /\x03${thread_color}[↪${msgthreadid}]\x0f /;445 $msg =~ s/^@@[0-9a-z]{26} /\x03${thread_color}[↪${msgthreadid}]\x0f /;
457 } else {446 } else {
458 $msg =~ s/^@@[0-9a-z]{26} //;447 $msg =~ s/^@@[0-9a-z]{26} //;
459 $msg =~ s/$/ \x03${thread_color}[↪${msgthreadid}]\x0f/;448 $msg =~ s/$/ \x03${thread_color}[↪${msgthreadid}]\x0f/;
460 }449 }
461450
462 signal_continue($server, $msg, $target);451 Irssi::signal_continue($server, $msg, $target);
463};452};
453Irssi::signal_add_last('message own_public', 'signal_message_own_public_msgthreadid');
464454
465signal_add_last 'message own_private' => sub {455sub signal_message_own_private {
466 my($server, $msg, $target, $orig_target) = @_;456 my($server, $msg, $target, $orig_target) = @_;
467457
468 return unless settings_get_int('matterircd_complete_message_thread_id_cache_size');458 return unless Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
469 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));459 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
470 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};460 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
471461
472 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {462 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {
@@ -474,14 +464,14 @@ signal_add_last 'message own_private' => sub {
474 }464 }
475 my $msgid = $1;465 my $msgid = $1;
476466
477 my $cache_size = settings_get_int('matterircd_complete_message_thread_id_cache_size');467 my $cache_size = Irssi::settings_get_int('matterircd_complete_message_thread_id_cache_size');
478 if (cache_store(\@{$MSGTHREADID_CACHE{$target}}, $msgid, $cache_size)) {468 if (cache_store(\@{$MSGTHREADID_CACHE{$target}}, $msgid, $cache_size)) {
479 $MSGTHREADID_CACHE_INDEX = 0;469 $MSGTHREADID_CACHE_INDEX = 0;
480 }470 }
481471
482 my $msgthreadid = $1;472 my $msgthreadid = $1;
483473
484 my $len = settings_get_int('matterircd_complete_shorten_message_thread_id');474 my $len = Irssi::settings_get_int('matterircd_complete_shorten_message_thread_id');
485 if ($len < 25) {475 if ($len < 25) {
486 # Shorten to length configured. We use unicode ellipsis (...)476 # Shorten to length configured. We use unicode ellipsis (...)
487 # here to both allow word selection to just select parts of477 # here to both allow word selection to just select parts of
@@ -490,16 +480,17 @@ signal_add_last 'message own_private' => sub {
490 $msgthreadid = substr($msgid, 0, $len) . "…";480 $msgthreadid = substr($msgid, 0, $len) . "…";
491 }481 }
492482
493 my $thread_color = settings_get_int('matterircd_complete_reply_msg_thread_id_color');483 my $thread_color = Irssi::settings_get_int('matterircd_complete_reply_msg_thread_id_color');
494 if (settings_get_bool('matterircd_complete_reply_msg_thread_id_at_start')) {484 if (Irssi::settings_get_bool('matterircd_complete_reply_msg_thread_id_at_start')) {
495 $msg =~ s/^@@[0-9a-z]{26} /\x03${thread_color}[↪${msgthreadid}]\x0f /;485 $msg =~ s/^@@[0-9a-z]{26} /\x03${thread_color}[↪${msgthreadid}]\x0f /;
496 } else {486 } else {
497 $msg =~ s/^@@[0-9a-z]{26} //;487 $msg =~ s/^@@[0-9a-z]{26} //;
498 $msg =~ s/$/ \x03${thread_color}[↪${msgthreadid}]\x0f/;488 $msg =~ s/$/ \x03${thread_color}[↪${msgthreadid}]\x0f/;
499 }489 }
500490
501 signal_continue($server, $msg, $target, $orig_target);491 Irssi::signal_continue($server, $msg, $target, $orig_target);
502};492};
493Irssi::signal_add_last('message own_private', 'signal_message_own_private');
503494
504495
505#==============================================================================496#==============================================================================
@@ -510,15 +501,15 @@ signal_add_last 'message own_private' => sub {
510501
511502
512my %NICKNAMES_CACHE;503my %NICKNAMES_CACHE;
513settings_add_int('matterircd_complete', 'matterircd_complete_nick_cache_size', 20);504Irssi::settings_add_int('matterircd_complete', 'matterircd_complete_nick_cache_size', 20);
514command_bind 'matterircd_complete_nick_cache_dump' => sub {505sub cmd_matterircd_complete_nick_cache_dump {
515 my ($data, $server, $wi) = @_;506 my ($data, $server, $wi) = @_;
516507
517 if (not $data) {508 if (not $data) {
518 return unless ref $wi and $wi->{type} eq 'CHANNEL';509 return unless ref $wi and $wi->{type} eq 'CHANNEL';
519 }510 }
520511
521 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));512 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
522 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};513 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
523514
524 my $channel = $data ? $data : $wi->{name};515 my $channel = $data ? $data : $wi->{name};
@@ -537,22 +528,23 @@ command_bind 'matterircd_complete_nick_cache_dump' => sub {
537 }528 }
538 Irssi::print("${channel}: Total: " . scalar @{$NICKNAMES_CACHE{$channel}});529 Irssi::print("${channel}: Total: " . scalar @{$NICKNAMES_CACHE{$channel}});
539};530};
531Irssi::command_bind('matterircd_complete_nick_cache_dump', 'cmd_matterircd_complete_nick_cache_dump');
540532
541signal_add 'complete word' => sub {533sub signal_complete_word_nicks {
542 my ($complist, $window, $word, $linestart, $want_space) = @_;534 my ($complist, $window, $word, $linestart, $want_space) = @_;
543535
544 return if substr($word, 0, 2) eq '@@';536 return if substr($word, 0, 2) eq '@@';
545 return unless $window->{active} and $window->{active}->{type} eq 'CHANNEL';537 return unless $window->{active} and $window->{active}->{type} eq 'CHANNEL';
546538
547 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));539 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
548 return unless exists $chatnets{'*'} || exists $chatnets{$window->{active_server}->{chatnet}};540 return unless exists $chatnets{'*'} || exists $chatnets{$window->{active_server}->{chatnet}};
549541
550 if (substr($word, 0, 1) eq '@') {542 if (substr($word, 0, 1) eq '@') {
551 $word = substr($word, 1);543 $word = substr($word, 1);
552 }544 }
553 my $compl_char = settings_get_str('completion_char');545 my $compl_char = Irssi::settings_get_str('completion_char');
554 my $own_nick = $window->{active}->{ownnick}->{nick};546 my $own_nick = $window->{active}->{ownnick}->{nick};
555 my @ignore_nicks = split(/\s+/, settings_get_str('matterircd_complete_nick_ignore'));547 my @ignore_nicks = split(/\s+/, Irssi::settings_get_str('matterircd_complete_nick_ignore'));
556548
557 # We need to store the results in a temporary array so we can549 # We need to store the results in a temporary array so we can
558 # sort.550 # sort.
@@ -612,30 +604,31 @@ signal_add 'complete word' => sub {
612 }604 }
613 }605 }
614};606};
607Irssi::signal_add('complete word', 'signal_complete_word_nicks');
615608
616sub cache_ircnick {609sub cache_ircnick {
617 my($server, $msg, $nick, $address, $target) = @_;610 my($server, $msg, $nick, $address, $target) = @_;
618611
619 return unless settings_get_int('matterircd_complete_nick_cache_size');612 return unless Irssi::settings_get_int('matterircd_complete_nick_cache_size');
620 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));613 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
621 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};614 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
622615
623 my $cache_size = settings_get_int('matterircd_complete_nick_cache_size');616 my $cache_size = Irssi::settings_get_int('matterircd_complete_nick_cache_size');
624 my @ignore_nicks = split(/\s+/, settings_get_str('matterircd_complete_nick_ignore'));617 my @ignore_nicks = split(/\s+/, Irssi::settings_get_str('matterircd_complete_nick_ignore'));
625 # Ignore nicks configured to be ignored such as bots.618 # Ignore nicks configured to be ignored such as bots.
626 if ($nick !~ @ignore_nicks) {619 if ($nick !~ @ignore_nicks) {
627 cache_store(\@{$NICKNAMES_CACHE{$target}}, $nick, $cache_size);620 cache_store(\@{$NICKNAMES_CACHE{$target}}, $nick, $cache_size);
628 }621 }
629}622}
630signal_add('message irc action', 'cache_ircnick');623Irssi::signal_add('message irc action', 'cache_ircnick');
631signal_add('message irc notice', 'cache_ircnick');624Irssi::signal_add('message irc notice', 'cache_ircnick');
632signal_add('message public', 'cache_ircnick');625Irssi::signal_add('message public', 'cache_ircnick');
633626
634signal_add_last 'message own_public' => sub {627sub signal_message_own_public_nicks {
635 my($server, $msg, $target) = @_;628 my($server, $msg, $target) = @_;
636629
637 return unless settings_get_int('matterircd_complete_nick_cache_size');630 return unless Irssi::settings_get_int('matterircd_complete_nick_cache_size');
638 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));631 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
639 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};632 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
640633
641 if ($msg !~ /^@([^@ \t:,\)]+)/) {634 if ($msg !~ /^@([^@ \t:,\)]+)/) {
@@ -643,7 +636,7 @@ signal_add_last 'message own_public' => sub {
643 }636 }
644 my $nick = $1;637 my $nick = $1;
645638
646 my $cache_size = settings_get_int('matterircd_complete_nick_cache_size');639 my $cache_size = Irssi::settings_get_int('matterircd_complete_nick_cache_size');
647 # We want to make sure that the nick or user is still online and640 # We want to make sure that the nick or user is still online and
648 # in the channel.641 # in the channel.
649 my $wi = Irssi::active_win()->{active};642 my $wi = Irssi::active_win()->{active};
@@ -657,20 +650,21 @@ signal_add_last 'message own_public' => sub {
657 }650 }
658 }651 }
659};652};
653Irssi::signal_add_last('message own_public', 'signal_message_own_public_nicks');
660654
661my @NICKNAMES_CACHE_SEARCH;655my @NICKNAMES_CACHE_SEARCH;
662my $NICKNAMES_CACHE_SEARCH_ENABLED = 0;656my $NICKNAMES_CACHE_SEARCH_ENABLED = 0;
663my $NICKNAMES_CACHE_INDEX = 0;657my $NICKNAMES_CACHE_INDEX = 0;
664command_bind 'nicknames_search' => sub {658sub cmd_nicknames_search {
665 my ($data, $server, $wi) = @_;659 my ($data, $server, $wi) = @_;
666660
667 return unless ref $wi and $wi->{type} eq 'CHANNEL';661 return unless ref $wi and $wi->{type} eq 'CHANNEL';
668662
669 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));663 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
670 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};664 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
671665
672 my $own_nick = $wi->{ownnick}->{nick};666 my $own_nick = $wi->{ownnick}->{nick};
673 my @ignore_nicks = split(/\s+/, settings_get_str('matterircd_complete_nick_ignore'));667 my @ignore_nicks = split(/\s+/, Irssi::settings_get_str('matterircd_complete_nick_ignore'));
674668
675 @NICKNAMES_CACHE_SEARCH = ();669 @NICKNAMES_CACHE_SEARCH = ();
676 foreach my $cur ($wi->nicks()) {670 foreach my $cur ($wi->nicks()) {
@@ -716,26 +710,27 @@ command_bind 'nicknames_search' => sub {
716710
717 if ($nickname) {711 if ($nickname) {
718 # Save input text.712 # Save input text.
719 my $input = parse_special('$L');713 my $input = Irssi::parse_special('$L');
720 my $compl_char = settings_get_str('completion_char');714 my $compl_char = Irssi::settings_get_str('completion_char');
721 # Remove any existing nickname and insert one from the cache.715 # Remove any existing nickname and insert one from the cache.
722 my $msgid = "";716 my $msgid = "";
723 if ($input =~ s/^(\@\@(?:[0-9a-z]{26}|[0-9a-f]{3}) )//) {717 if ($input =~ s/^(\@\@(?:[0-9a-z]{26}|[0-9a-f]{3}) )//) {
724 $msgid = $1;718 $msgid = $1;
725 }719 }
726 $input =~ s/^\@[^${compl_char}]+$compl_char //;720 $input =~ s/^\@[^${compl_char}]+$compl_char //;
727 gui_input_set_pos(0);721 Irssi::gui_input_set_pos(0);
728 gui_input_set("${msgid}\@${nickname}${compl_char} ${input}");722 Irssi::gui_input_set("${msgid}\@${nickname}${compl_char} ${input}");
729 }723 }
730};724};
725Irssi::command_bind('nicknames_search', 'cmd_nicknames_search');
731726
732signal_add_last 'gui key pressed' => sub {727sub signal_gui_key_pressed_nicks {
733 my ($key) = @_;728 my ($key) = @_;
734729
735 return unless $NICKNAMES_CACHE_SEARCH_ENABLED;730 return unless $NICKNAMES_CACHE_SEARCH_ENABLED;
736731
737 my $server = Irssi::active_server();732 my $server = Irssi::active_server();
738 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));733 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
739 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};734 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
740735
741 if (($key == $KEY_RET) || ($key == $KEY_CTRL_U)) {736 if (($key == $KEY_RET) || ($key == $KEY_CTRL_U)) {
@@ -746,15 +741,15 @@ signal_add_last 'gui key pressed' => sub {
746741
747 # Cancel/abort, so remove current nickname.742 # Cancel/abort, so remove current nickname.
748 elsif ($key == $KEY_CTRL_C) {743 elsif ($key == $KEY_CTRL_C) {
749 my $input = parse_special('$L');744 my $input = Irssi::parse_special('$L');
750745
751 # Remove the Ctrl+C character.746 # Remove the Ctrl+C character.
752 $input =~ tr///d;747 $input =~ tr///d;
753748
754 my $compl_char = settings_get_str('completion_char');749 my $compl_char = Irssi::settings_get_str('completion_char');
755 my $pos = 0;750 my $pos = 0;
756 if ($input =~ s/^(\@[^${compl_char}]+$compl_char )//) {751 if ($input =~ s/^(\@[^${compl_char}]+$compl_char )//) {
757 $pos = gui_input_get_pos() - length($1);752 $pos = Irssi::gui_input_get_pos() - length($1);
758 }753 }
759754
760 # We also want to move the input position back one for Ctrl+C755 # We also want to move the input position back one for Ctrl+C
@@ -764,14 +759,15 @@ signal_add_last 'gui key pressed' => sub {
764 # Replace the text in the input box with our modified version,759 # Replace the text in the input box with our modified version,
765 # then move cursor positon to where it was without the760 # then move cursor positon to where it was without the
766 # current nickname.761 # current nickname.
767 gui_input_set($input);762 Irssi::gui_input_set($input);
768 gui_input_set_pos($pos);763 Irssi::gui_input_set_pos($pos);
769764
770 $NICKNAMES_CACHE_INDEX = 0;765 $NICKNAMES_CACHE_INDEX = 0;
771 $NICKNAMES_CACHE_SEARCH_ENABLED = 0;766 $NICKNAMES_CACHE_SEARCH_ENABLED = 0;
772 @NICKNAMES_CACHE_SEARCH = ();767 @NICKNAMES_CACHE_SEARCH = ();
773 }768 }
774};769};
770Irssi::signal_add_last('gui key pressed', 'signal_gui_key_pressed_nicks');
775771
776772
777#==============================================================================773#==============================================================================
@@ -782,15 +778,15 @@ signal_add_last 'gui key pressed' => sub {
782778
783779
784my %REPLIED_CACHE;780my %REPLIED_CACHE;
785settings_add_int('matterircd_complete', 'matterircd_complete_replied_cache_size', 50);781Irssi::settings_add_int('matterircd_complete', 'matterircd_complete_replied_cache_size', 50);
786command_bind 'matterircd_complete_replied_cache_dump' => sub {782sub cmd_matterircd_complete_replied_cache_dump {
787 my ($data, $server, $wi) = @_;783 my ($data, $server, $wi) = @_;
788784
789 if (not $data) {785 if (not $data) {
790 return unless ref $wi and $wi->{type} eq 'CHANNEL';786 return unless ref $wi and $wi->{type} eq 'CHANNEL';
791 }787 }
792788
793 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));789 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
794 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};790 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
795791
796 my $channel = $data ? $data : $wi->{name};792 my $channel = $data ? $data : $wi->{name};
@@ -809,18 +805,20 @@ command_bind 'matterircd_complete_replied_cache_dump' => sub {
809 }805 }
810 Irssi::print("${channel}: Total: " . scalar @{$REPLIED_CACHE{$channel}});806 Irssi::print("${channel}: Total: " . scalar @{$REPLIED_CACHE{$channel}});
811};807};
808Irssi::command_bind('matterircd_complete_replied_cache_dump', 'cmd_matterircd_complete_replied_cache_dump');
812809
813command_bind 'matterircd_complete_replied_cache_clear' => sub {810sub cmd_matterircd_complete_replied_cache_clear {
814 %REPLIED_CACHE = ();811 %REPLIED_CACHE = ();
815 Irssi::print("matterircd_complete replied cache cleared");812 Irssi::print("matterircd_complete replied cache cleared");
816};813};
814Irssi::command_bind('matterircd_complete_replied_cache_clear', 'cmd_cmd_matterircd_complete_replied_cache_clear');
817815
818my $REPLIED_CACHE_CLEARED = 0;816my $REPLIED_CACHE_CLEARED = 0;
819settings_add_bool('matterircd_complete', 'matterircd_complete_clear_replied_cache_on_away', 0);817Irssi::settings_add_bool('matterircd_complete', 'matterircd_complete_clear_replied_cache_on_away', 0);
820signal_add 'away mode changed' => sub {818sub signal_away_mode_changed {
821 my ($server) = @_;819 my ($server) = @_;
822820
823 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));821 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
824 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};822 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
825823
826 # When you visit the web UI when marked away, it retriggers this824 # When you visit the web UI when marked away, it retriggers this
@@ -829,18 +827,19 @@ signal_add 'away mode changed' => sub {
829 $REPLIED_CACHE_CLEARED = 0;827 $REPLIED_CACHE_CLEARED = 0;
830 }828 }
831829
832 if (settings_get_bool('matterircd_complete_clear_replied_cache_on_away') && $server->{usermode_away} && (! $REPLIED_CACHE_CLEARED)) {830 if (Irssi::settings_get_bool('matterircd_complete_clear_replied_cache_on_away') && $server->{usermode_away} && (! $REPLIED_CACHE_CLEARED)) {
833 %REPLIED_CACHE = ();831 %REPLIED_CACHE = ();
834 $REPLIED_CACHE_CLEARED = 1;832 $REPLIED_CACHE_CLEARED = 1;
835 Irssi::print("matterircd_complete replied cache cleared");833 Irssi::print("matterircd_complete replied cache cleared");
836 }834 }
837};835};
836Irssi::signal_add('away mode changed', 'signal_away_mode_changed');
838837
839signal_add 'message own_public' => sub {838sub signal_message_own_public_replied {
840 my($server, $msg, $target) = @_;839 my($server, $msg, $target) = @_;
841840
842 return unless settings_get_int('matterircd_complete_replied_cache_size');841 return unless Irssi::settings_get_int('matterircd_complete_replied_cache_size');
843 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));842 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
844 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};843 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
845844
846 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {845 if ($msg !~ /^@@((?:[0-9a-z]{26})|(?:[0-9a-f]{3}))/) {
@@ -848,15 +847,16 @@ signal_add 'message own_public' => sub {
848 }847 }
849 my $msgid = $1;848 my $msgid = $1;
850849
851 my $cache_size = settings_get_int('matterircd_complete_replied_cache_size');850 my $cache_size = Irssi::settings_get_int('matterircd_complete_replied_cache_size');
852 cache_store(\@{$REPLIED_CACHE{$target}}, $msgid, $cache_size);851 cache_store(\@{$REPLIED_CACHE{$target}}, $msgid, $cache_size);
853};852};
853Irssi::signal_add('message own_public', 'signal_message_own_public_replied');
854854
855signal_add 'message public' => sub {855sub signal_message_public {
856 my($server, $msg, $nick, $address, $target) = @_;856 my($server, $msg, $nick, $address, $target) = @_;
857857
858 return unless settings_get_int('matterircd_complete_replied_cache_size');858 return unless Irssi::settings_get_int('matterircd_complete_replied_cache_size');
859 my %chatnets = map { $_ => 1 } split(/\s+/, settings_get_str('matterircd_complete_networks'));859 my %chatnets = map { $_ => 1 } split(/\s+/, Irssi::settings_get_str('matterircd_complete_networks'));
860 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};860 return unless exists $chatnets{'*'} || exists $chatnets{$server->{chatnet}};
861861
862 # For '/me' actions, it has trailing space so we need to use862 # For '/me' actions, it has trailing space so we need to use
@@ -873,5 +873,6 @@ signal_add 'message public' => sub {
873 }873 }
874 }874 }
875875
876 signal_continue($server, $msg, $nick, $address, $target);876 Irssi::signal_continue($server, $msg, $nick, $address, $target);
877};877};
878Irssi::signal_add('message public', 'signal_message_public');

Subscribers

People subscribed via source and target branches

to all changes: