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

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.104 by root, Sun Jul 23 11:09:57 2006 UTC vs.
Revision 1.105 by root, Sun Jul 23 16:11:12 2006 UTC

59 59
60sub CFClient::Guard::DESTROY { 60sub CFClient::Guard::DESTROY {
61 ${$_[0]}->() 61 ${$_[0]}->()
62} 62}
63 63
64package CFClient::PodToPango; 64sub asxml($) {
65 local $_ = $_[0];
65 66
66use base Pod::POM::View::Text; 67 s/&/&/g;
68 s/>/>/g;
69 s/</&lt;/g;
67 70
68our $VERSION = 1; # bump if resultant formatting changes 71 $_
69
70our $indent = 0;
71
72*view_seq_code =
73*view_seq_bold = sub { "<b>$_[1]</b>" };
74*view_seq_italic = sub { "<i>$_[1]</i>" };
75*view_seq_space =
76*view_seq_link =
77*view_seq_index = sub { CFClient::UI::Label::escape ($_[1]) };
78
79sub view_seq_text {
80 my $text = $_[1];
81 $text =~ s/\s+/ /g;
82 CFClient::UI::Label::escape ($text)
83}
84
85sub view_item {
86 ("\t" x ($indent / 4))
87 . $_[1]->title->present ($_[0])
88 . "\n\n"
89 . $_[1]->content->present ($_[0])
90}
91
92sub view_verbatim {
93 (join "",
94 map +("\t" x ($indent / 2)) . "<tt>$_</tt>\n",
95 split /\n/, CFClient::UI::Label::escape ($_[1]))
96 . "\n"
97}
98
99sub view_textblock {
100 ("\t" x ($indent / 2)) . "$_[1]\n\n"
101}
102
103sub view_head1 {
104 "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n"
105 . $_[1]->content->present ($_[0])
106};
107
108sub view_head2 {
109 "\n<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n"
110 . $_[1]->content->present ($_[0])
111};
112
113sub view_head3 {
114 "\n<span size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n"
115 . $_[1]->content->present ($_[0])
116};
117
118sub view_over {
119 local $indent = $indent + $_[1]->indent;
120 $_[1]->content->present ($_[0])
121} 72}
122 73
123package CFClient::Database; 74package CFClient::Database;
124 75
125our @ISA = BerkeleyDB::Btree::; 76our @ISA = BerkeleyDB::Btree::;
219# -Filename => "database", 170# -Filename => "database",
220# -Subname => $table, 171# -Subname => $table,
221 -Property => DB_CHKSUM, 172 -Property => DB_CHKSUM,
222 -Flags => DB_CREATE | DB_UPGRADE, 173 -Flags => DB_CREATE | DB_UPGRADE,
223 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error" 174 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"
224}
225
226my $pod_cache = db_table "pod_cache";
227
228sub load_pod($$$$) {
229 my ($path, $filtertype, $filterversion, $filtercb) = @_;
230
231 stat $path
232 or die "$path: $!";
233
234 my $phash = join ",", $filterversion, $CFClient::PodToPango::VERSION, (stat _)[7,9];
235
236 my ($chash, $pom) = eval { @{ Storable::thaw $pod_cache->get ("$path/$filtertype") } };
237
238 return $pom if $chash eq $phash;
239
240 my $pod = do {
241 local $/;
242 open my $pod, "<:utf8", $_[0]
243 or die "$_[0]: $!";
244 <$pod>
245 };
246
247 #utf8::downgrade $pod;
248
249 $pom = $filtercb-> (Pod::POM->new->parse_text ($pod));
250
251 $pod_cache->put ("$path/$filtertype" => Storable::nfreeze [$phash, $pom]);
252
253 $pom
254}
255
256sub pod_to_pango($) {
257 my ($pom) = @_;
258
259 $pom->present ("CFClient::PodToPango")
260}
261
262sub pod_to_pango_list($) {
263 my ($pom) = @_;
264
265 [
266 map s/^(\s*)// && [40 * length $1, length $_ ? $_ : " "],
267 split /\n/, $pom->present ("CFClient::PodToPango")
268 ]
269} 175}
270 176
271package CFClient::Layout; 177package CFClient::Layout;
272 178
273$CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Layout"} = sub { 179$CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Layout"} = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines