… | |
… | |
27 | ); |
27 | ); |
28 | |
28 | |
29 | $self->{map_widget}->clr_commands; |
29 | $self->{map_widget}->clr_commands; |
30 | |
30 | |
31 | my @cmd_help = map { |
31 | my @cmd_help = map { |
32 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
32 | $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
33 | or die "unparseable command help: $_->{kw}[0]"; |
33 | or die "unparseable command help: $_->[DC::Pod::N_KW][0]"; |
34 | |
34 | |
35 | my $cmd = $1; |
35 | my $cmd = $1; |
36 | my @args = split /\|/, $2; |
36 | my @args = split /\|/, $2; |
37 | @args = (".*") unless @args; |
37 | @args = (".*") unless @args; |
38 | |
38 | |
… | |
… | |
43 | for @args; |
43 | for @args; |
44 | |
44 | |
45 | map ["$cmd$_", $text], |
45 | map ["$cmd$_", $text], |
46 | sort { (length $a) <=> (length $b) } |
46 | sort { (length $a) <=> (length $b) } |
47 | @args |
47 | @args |
48 | } sort { $a->{par} <=> $b->{par} } |
48 | } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] } |
49 | DC::Pod::find command => "*"; |
49 | DC::Pod::find command => "*"; |
50 | |
50 | |
51 | $self->{json_coder} |
51 | $self->{json_coder} |
52 | ->convert_blessed |
52 | ->convert_blessed |
53 | ->filter_json_single_key_object ("\fw" => sub { |
53 | ->filter_json_single_key_object ("\fw" => sub { |
… | |
… | |
1466 | DC::weaken $self; |
1466 | DC::weaken $self; |
1467 | |
1467 | |
1468 | $self->{options}->clear; |
1468 | $self->{options}->clear; |
1469 | $self->{options}->add ($self->{bye_button}); |
1469 | $self->{options}->add ($self->{bye_button}); |
1470 | |
1470 | |
1471 | for my $kw (sort keys %{ $self->{kw} }) { |
1471 | for my $kw (sort keys %{ $self->[DC::Pod::N_KW] }) { |
1472 | $self->{options}->add (new DC::UI::Button |
1472 | $self->{options}->add (new DC::UI::Button |
1473 | text => $kw, |
1473 | text => $kw, |
1474 | on_activate => sub { |
1474 | on_activate => sub { |
1475 | $self->send ($kw); |
1475 | $self->send ($kw); |
1476 | 0 |
1476 | 0 |
… | |
… | |
1485 | DC::weaken $self; |
1485 | DC::weaken $self; |
1486 | |
1486 | |
1487 | if ($type eq "update") { |
1487 | if ($type eq "update") { |
1488 | my (%info) = @arg; |
1488 | my (%info) = @arg; |
1489 | |
1489 | |
1490 | $self->{kw}{$_} = 1 for @{$info{add_topics} || []}; |
1490 | $self->[DC::Pod::N_KW]{$_} = 1 for @{$info{add_topics} || []}; |
1491 | $self->{kw}{$_} = 0 for @{$info{del_topics} || []}; |
1491 | $self->[DC::Pod::N_KW]{$_} = 0 for @{$info{del_topics} || []}; |
1492 | |
1492 | |
1493 | if (exists $info{msg}) { |
1493 | if (exists $info{msg}) { |
1494 | my $text = "\n" . DC::Protocol::sanitise_xml $info{msg}; |
1494 | my $text = "\n" . DC::Protocol::sanitise_xml $info{msg}; |
1495 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; |
1495 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->[DC::Pod::N_KW] }; |
1496 | my @link; |
1496 | my @link; |
1497 | $text =~ s{ |
1497 | $text =~ s{ |
1498 | ($match) |
1498 | ($match) |
1499 | }{ |
1499 | }{ |
1500 | my $kw = $1; |
1500 | my $kw = $1; |