… | |
… | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use Storable; |
6 | use Storable; |
7 | |
7 | |
8 | our $VERSION = 1; |
8 | our $VERSION = 1.03; |
9 | |
9 | |
10 | our $goto_document = sub { }; |
10 | our $goto_document = sub { }; |
11 | our %wiki; |
11 | our %wiki; |
12 | |
12 | |
13 | my $MA_BEG = "\x{fcd0}"; |
13 | my $MA_BEG = "\x{fcd0}"; |
… | |
… | |
23 | sub is_prefix_of($@) { |
23 | sub is_prefix_of($@) { |
24 | my ($node, @path) = @_; |
24 | my ($node, @path) = @_; |
25 | |
25 | |
26 | return 1 unless @path; |
26 | return 1 unless @path; |
27 | |
27 | |
28 | my $kw = pop @path; |
28 | my $kw = lc pop @path; |
29 | |
29 | |
30 | $node = $node->{parent} |
30 | $node = $node->{parent} |
31 | or return 0; |
31 | or return 0; |
32 | |
32 | |
33 | return ! ! grep $_ eq $kw, @{ $node->{kw} }; |
33 | return ! ! grep $_ eq $kw, @{ $node->{kw} }; |
… | |
… | |
36 | sub find(@) { |
36 | sub find(@) { |
37 | my (@path) = @_; |
37 | my (@path) = @_; |
38 | |
38 | |
39 | return unless @path; |
39 | return unless @path; |
40 | |
40 | |
41 | my $kw = pop @path; |
41 | my $kw = lc pop @path; |
42 | |
42 | |
43 | # TODO: make sure results are unique |
43 | # TODO: make sure results are unique |
44 | |
44 | |
45 | grep { is_prefix_of $_, @path } |
45 | grep { is_prefix_of $_, @path } |
46 | map @$_, |
46 | map @$_, |
47 | $kw eq "*" ? @wiki{sort keys %wiki} |
47 | $kw eq "*" ? @wiki{sort keys %wiki} |
48 | : grep $_, $wiki{$kw} |
48 | : $wiki{$kw} || () |
49 | } |
49 | } |
50 | |
50 | |
51 | sub full_path_of($) { |
51 | sub full_path_of($) { |
52 | my ($node) = @_; |
52 | my ($node) = @_; |
53 | |
53 | |
… | |
… | |
134 | $text |
134 | $text |
135 | } |
135 | } |
136 | |
136 | |
137 | my %as_paragraphs = ( |
137 | my %as_paragraphs = ( |
138 | image => sub { |
138 | image => sub { |
139 | my ($par, $path) = @_; |
139 | my ($par, $path, $flags) = @_; |
140 | |
140 | |
141 | push @{ $par->{widget} }, new CFPlus::UI::Image path => $path; |
141 | push @{ $par->{widget} }, new CFPlus::UI::Image path => $path, |
|
|
142 | $flags & 1 ? (max_h => $::FONTSIZE) : (); |
142 | |
143 | |
143 | "\x{fffc}" |
144 | "\x{fffc}" |
144 | }, |
145 | }, |
145 | link => sub { |
146 | link => sub { |
146 | my ($par, $text, $link) = @_; |
147 | my ($par, $text, $link) = @_; |
147 | |
148 | |
148 | push @{ $par->{widget} }, new CFPlus::UI::Label |
149 | push @{ $par->{widget} }, new CFPlus::UI::Label |
149 | markup => "<span foreground='#ffff00'>↺</span><span foreground='#c0c0ff' underline='single'>" . (CFPlus::asxml $text) . "</span>", |
150 | markup => "<span foreground='#ffff00'>↺</span><span foreground='#c0c0ff' underline='single'>" . (CFPlus::asxml $text) . "</span>", |
150 | size => 0.8, |
151 | fontsize => 0.8, |
151 | can_hover => 1, |
152 | can_hover => 1, |
152 | can_events => 1, |
153 | can_events => 1, |
153 | padding_x => 0, |
154 | padding_x => 0, |
154 | padding_y => 0, |
155 | padding_y => 0, |
155 | tooltip => "Go to <i>" . (CFPlus::asxml $link) . "</i>", |
156 | tooltip => "Go to <i>" . (CFPlus::asxml $link) . "</i>", |