ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Pod.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Pod.pm (file contents):
Revision 1.8 by root, Sun Aug 13 19:47:05 2006 UTC vs.
Revision 1.13 by root, Mon Aug 14 19:17:09 2006 UTC

5 5
6use Storable; 6use Storable;
7 7
8our $VERSION = 1; 8our $VERSION = 1;
9 9
10our $on_link = sub { }; 10our $goto_document = sub { };
11our %wiki; 11our %wiki;
12 12
13my $MA_BEG = "\x{fcd0}"; 13my $MA_BEG = "\x{fcd0}";
14my $MA_SEP = "\x{fcd1}"; 14my $MA_SEP = "\x{fcd1}";
15my $MA_END = "\x{fcd2}"; 15my $MA_END = "\x{fcd2}";
16 16
17*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst"; 17*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst";
18 18
19sub goto_document($) {
20 $goto_document->(split /\//, $_[0]);
21}
22
19sub is_prefix_of($@) { 23sub is_prefix_of($@) {
20 my ($node, @path) = @_; 24 my ($node, @path) = @_;
21 25
22 return 1 unless @path; 26 return 1 unless @path;
23 27
24 my $kw = pop @path; 28 my $kw = lc pop @path;
25 29
26 $node = $node->{parent} 30 $node = $node->{parent}
27 or return 0; 31 or return 0;
28 32
29 return ! ! grep $_ eq $kw, @{ $node->{kw} }; 33 return ! ! grep $_ eq $kw, @{ $node->{kw} };
32sub find(@) { 36sub find(@) {
33 my (@path) = @_; 37 my (@path) = @_;
34 38
35 return unless @path; 39 return unless @path;
36 40
37 my $kw = pop @path; 41 my $kw = lc pop @path;
38 42
39 # TODO: make sure results are unique 43 # TODO: make sure results are unique
40 44
41 grep { is_prefix_of $_, @path } 45 grep { is_prefix_of $_, @path }
42 map @$_, 46 map @$_,
45} 49}
46 50
47sub full_path_of($) { 51sub full_path_of($) {
48 my ($node) = @_; 52 my ($node) = @_;
49 53
50 my $path = $node->{kw}[0]; 54 my @path;
51 $path = "$node->{kw}[0]/$path" while $node = $node->{parent}; 55
56 # skip toplevel hierarchy pod/, because its not a document
57 while ($node->{parent}) {
58 unshift @path, $node;
59 $node = $node->{parent};
60 }
61
52 $path 62 @path
63}
64
65sub full_path($) {
66 join "/", map $_->{kw}[0], &full_path_of
53} 67}
54 68
55sub section_of($) { 69sub section_of($) {
56 my ($node) = @_; 70 my ($node) = @_;
57 71
120 $text 134 $text
121} 135}
122 136
123my %as_paragraphs = ( 137my %as_paragraphs = (
124 image => sub { 138 image => sub {
125 my ($par, $path) = @_; 139 my ($par, $path, $flags) = @_;
126 140
127 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) : ();
128 143
129 "\x{fffc}" 144 "\x{fffc}"
130 }, 145 },
131 link => sub { 146 link => sub {
132 my ($par, $text, $link) = @_; 147 my ($par, $text, $link) = @_;
133 148
134 push @{ $par->{widget} }, new CFPlus::UI::Label 149 push @{ $par->{widget} }, new CFPlus::UI::Label
135 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>",
136 size => 0.8, 151 fontsize => 0.8,
137 can_hover => 1, 152 can_hover => 1,
138 can_events => 1, 153 can_events => 1,
139 padding_x => 0, 154 padding_x => 0,
140 padding_y => 0, 155 padding_y => 0,
156 tooltip => "Go to <i>" . (CFPlus::asxml $link) . "</i>",
141 on_button_up => sub { 157 on_button_up => sub {
142 $on_link->(split /\//, $link); 158 goto_document $link;
143 }; 159 };
144 160
145 "\x{fffc}" 161 "\x{fffc}"
146 }, 162 },
147); 163);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines