git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ffd2c45
)
charset: support variable number of columns
author
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 5 Apr 2017 21:26:04 +0000
(23:26 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000
(
01:51
+0200)
charset.plp
patch
|
blob
|
history
diff --git
a/charset.plp
b/charset.plp
index d3b27b5df1c9513bffbde53de22307f642f3f2e1..d954e321ff130c194673e02184ad17788f211c12 100644
(file)
--- a/
charset.plp
+++ b/
charset.plp
@@
-116,9
+116,9
@@
sub range_cell {
$len /= $nibsize;
$name //= $len <= 2 ? 'res' : 'reserved';
$len /= $nibsize;
$name //= $len <= 2 ? 'res' : 'reserved';
- if (my $part = $offset/$nibsize %
16
) {
+ if (my $part = $offset/$nibsize %
@nibble
) {
# continued row
# continued row
- my $cols =
16
- $part; # remaining
+ my $cols =
@nibble
- $part; # remaining
$cols = $len if $len < $cols; #TODO: optimise
if ($len -= $cols) {
# continued on new row
$cols = $len if $len < $cols; #TODO: optimise
if ($len -= $cols) {
# continued on new row
@@
-128,15
+128,15
@@
sub range_cell {
}
$len = $cols;
}
}
$len = $cols;
}
- elsif (my $rows =
$len >> 4
) {
+ elsif (my $rows =
int($len / @nibble)
) {
# multiple full rows
# multiple full rows
- if ($len -= $rows
<< 4
) {
+ if ($len -= $rows
* @nibble
) {
# partial row remains
# partial row remains
- $table->{$offset + $nibsize*$rows *
16
} //= [$len*$nibsize, "$class joinu", '', $title];
+ $table->{$offset + $nibsize*$rows *
@nibble
} //= [$len*$nibsize, "$class joinu", '', $title];
$class .= ' joind';
}
$attr .= sprintf ' rowspan=%d', $rows;
$class .= ' joind';
}
$attr .= sprintf ' rowspan=%d', $rows;
- $len =
16
;
+ $len =
scalar @nibble
;
}
$attr .= sprintf ' colspan=%d', $len unless $len == 1;
}
$attr .= sprintf ' colspan=%d', $len unless $len == 1;
@@
-151,17
+151,17
@@
for my $row (@request) {
my $title = $row->{set};
$title .= " <aside>($_)</aside>" for $row->{setnote} // ();
printf '<caption>%s</caption>', $title;
my $title = $row->{set};
$title .= " <aside>($_)</aside>" for $row->{setnote} // ();
printf '<caption>%s</caption>', $title;
- print '<col>' x
17
;
+ print '<col>' x
(@nibble + 1)
;
for my $section (qw{thead}) {
print "<$section><tr><th>↱";
print '<th>', $_ for @nibble;
print "\n";
}
print '<tbody>';
for my $section (qw{thead}) {
print "<$section><tr><th>↱";
print '<th>', $_ for @nibble;
print "\n";
}
print '<tbody>';
- for my $msb (0 .. (
length($row->{table}) || 256) - 1 >> 4
) {
- printf '<tr><th>%X', ($msb +
($row->{offset} >> 4))
* $nibsize;
+ for my $msb (0 .. (
(length($row->{table}) || 256) - 1) / @nibble
) {
+ printf '<tr><th>%X', ($msb +
int($row->{offset} / @nibble)) * @nibble
* $nibsize;
for my $lsb (0 .. $#nibble) {
for my $lsb (0 .. $#nibble) {
- my $val = ( ($msb
<<4
) + $lsb ) * $nibsize;
+ my $val = ( ($msb
* @nibble
) + $lsb ) * $nibsize;
if ($row->{cell}) {
if (ref $row->{cell} eq 'CODE') {
print $row->{cell}->($val);
if ($row->{cell}) {
if (ref $row->{cell} eq 'CODE') {
print $row->{cell}->($val);