Skip to content

Commit

Permalink
support =head5 and =head6
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Jan 5, 2024
1 parent 384b795 commit e739371
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
31 changes: 14 additions & 17 deletions Prima/Drawable/Pod.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ use constant STYLE_HEAD_1 => 2;
use constant STYLE_HEAD_2 => 3;
use constant STYLE_HEAD_3 => 4;
use constant STYLE_HEAD_4 => 5;
use constant STYLE_ITEM => 6;
use constant STYLE_LINK => 7;
use constant STYLE_VERBATIM => 8;
use constant STYLE_MAX_ID => 8;
use constant STYLE_HEAD_5 => 6;
use constant STYLE_HEAD_6 => 7;
use constant STYLE_ITEM => 8;
use constant STYLE_LINK => 9;
use constant STYLE_VERBATIM => 10;
use constant STYLE_MAX_ID => 10;

# model layout indices
use constant M_TYPE => 0; # T_XXXX
Expand Down Expand Up @@ -88,6 +90,8 @@ sub default_styles
{ fontSize => 2, fontStyle => fs::Bold }, # STYLE_HEAD_2
{ fontSize => 1, fontStyle => fs::Bold }, # STYLE_HEAD_3
{ fontSize => 1, fontStyle => fs::Bold }, # STYLE_HEAD_4
{ fontSize => 0, fontStyle => fs::Bold }, # STYLE_HEAD_5
{ fontSize => -1, fontStyle => fs::Bold },# STYLE_HEAD_6
{ fontStyle => fs::Bold }, # STYLE_ITEM
{ color => $colors[0]}, # STYLE_LINK
{ fontId => 1, # STYLE_VERBATIM
Expand Down Expand Up @@ -231,17 +235,8 @@ sub read_paragraph
elsif ($Cmd eq 'pod') {
$r-> {cutting} = 0;
}
elsif ($Cmd eq 'head1') {
$self-> add( $args, pod::STYLE_HEAD_1, pod::DEF_FIRST_INDENT);
}
elsif ($Cmd eq 'head2') {
$self-> add( $args, pod::STYLE_HEAD_2, pod::DEF_FIRST_INDENT);
}
elsif ($Cmd eq 'head3') {
$self-> add( $args, pod::STYLE_HEAD_3, pod::DEF_FIRST_INDENT);
}
elsif ($Cmd eq 'head4') {
$self-> add( $args, pod::STYLE_HEAD_4, pod::DEF_FIRST_INDENT);
elsif ($Cmd =~ /^head([1-6])$/) {
$self-> add( $args, pod::STYLE_HEAD_1 - 1 + $1, pod::DEF_FIRST_INDENT);
}
elsif ($Cmd eq 'over') {
push(@{$r-> {indentStack}}, $r-> {indent});
Expand Down Expand Up @@ -309,7 +304,7 @@ sub _close_topic

my $r = $self-> {read_state};
my $t = $r-> {topicStack};
my $state = ( $style >= pod::STYLE_HEAD_1 && $style <= pod::STYLE_HEAD_4) ?
my $state = ( $style >= pod::STYLE_HEAD_1 && $style <= pod::STYLE_HEAD_6) ?
0 : scalar @{$r-> {indentStack}};

if ( $state <= $$t[-1]-> [0]) {
Expand Down Expand Up @@ -863,7 +858,7 @@ sub add

# add topic
if (
( $style >= pod::STYLE_HEAD_1 && $style <= pod::STYLE_HEAD_4 ) ||
( $style >= pod::STYLE_HEAD_1 && $style <= pod::STYLE_HEAD_6 ) ||
(( $style == pod::STYLE_ITEM) && $p !~ /^[0-9*]+\.?$/)
) {
my $itemDepth = ( $style == pod::STYLE_ITEM) ?
Expand Down Expand Up @@ -1776,6 +1771,8 @@ text parts. These styles are:
pod::STYLE_HEAD_2 - =head2
pod::STYLE_HEAD_3 - =head3
pod::STYLE_HEAD_4 - =head4
pod::STYLE_HEAD_5 - =head5
pod::STYLE_HEAD_6 - =head6
pod::STYLE_ITEM - =item
pod::STYLE_LINK - style for L<> text
pod::STYLE_VERBATIM - style for pre-formatted text
Expand Down
18 changes: 9 additions & 9 deletions Prima/HelpViewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ sub load_file
return $ret;
}

sub link_click
sub on_link
{
my ( $self, $s, $btn, $mod, $x, $y) = @_;
$self-> SUPER::link_click( $s, $btn, $mod, $x, $y);
my ( $self, $link_handler, $url, $btn, $mod) = @_;
$self-> SUPER::on_link( $link_handler, $url, $btn, $mod);
return if $btn != mb::Right;

my $new = ref($self-> owner)-> create;
if ( $s =~ /^\//) {
$s = "$self->{pageName}$s";
} elsif ( $s =~ /^"(.*)"$/) {
$s = "$self->{pageName}/$1";
} elsif ( $s =~ /^topic:\/\//) {
if ( $url =~ /^\//) {
$url = "$self->{pageName}$url";
} elsif ( $url =~ /^"(.*)"$/) {
$url = "$self->{pageName}/$1";
} elsif ( $url =~ /^topic:\/\//) {
$new-> {text}-> load_link( $self-> {pageName});
}
$new-> {text}-> update_view;
$new-> {text}-> load_link( $s);
$new-> {text}-> load_link( $url);
$new-> select;
}

Expand Down
4 changes: 3 additions & 1 deletion Prima/PodView.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ sub default_styles
{ fontSize => 2, fontStyle => fs::Bold }, # STYLE_HEAD_2
{ fontSize => 1, fontStyle => fs::Bold }, # STYLE_HEAD_3
{ fontSize => 1, fontStyle => fs::Bold }, # STYLE_HEAD_4
{ fontSize => 0, fontStyle => fs::Bold }, # STYLE_HEAD_5
{ fontSize => -1, fontStyle => fs::Bold },# STYLE_HEAD_6
{ fontStyle => fs::Bold }, # STYLE_ITEM
{ color => COLOR_LINK_FOREGROUND}, # STYLE_LINK
{ fontId => 1, # STYLE_VERBATIM
Expand Down Expand Up @@ -231,7 +233,7 @@ sub make_bookmark
}

return "$self->{pageName}|0|0" unless defined $t;
if ( $$t[ pod::T_STYLE] >= pod::STYLE_HEAD_1 && $$t[ pod::T_STYLE] <= pod::STYLE_HEAD_4) {
if ( $$t[ pod::T_STYLE] >= pod::STYLE_HEAD_1 && $$t[ pod::T_STYLE] <= pod::STYLE_HEAD_6) {
$t = $topics-> [0];
return "$self->{pageName}|$$t[pod::T_MODEL_START]|0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/bidi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ =head1 FEATURES

$arabic_text =~ s/(.*?)\n//;
$pod_text = "=head1 $1\n\n" . join("\n\n", split "\n", $arabic_text) . "\n\n";
$pod-> open_read( createIndex => 0 );
$pod-> open_read( create_index => 0 );
$pod-> read($pod_text);
$pod-> close_read;

Expand Down

0 comments on commit e739371

Please sign in to comment.