From 4e051d54eec34ed62a4fa8982c2b34493a61e016 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 6 Apr 2017 01:48:37 +0200 Subject: [PATCH] charset: divide and append row offset label --- base.css | 6 +++--- charset.plp | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/base.css b/base.css index d014b61..f3c0355 100644 --- a/base.css +++ b/base.css @@ -354,18 +354,18 @@ table.dimap { padding-bottom: 1.1ex; /* reserve space for label */ vertical-align: bottom; } -.glyphs small { +.glyphs.dilabel small { font-size: 50%; display: block; margin-top: 0.2ex; margin-bottom: -2.2ex; /* take cell padding */ } -.glyphs small.digraph { +.glyphs.dilabel small.digraph { background: #000; color: #FFF; opacity: 0.3; } -.glyphs small.value { +.glyphs.dilabel small.value { background: #600; color: #FFF; opacity: 0.3; diff --git a/charset.plp b/charset.plp index 1186585..73b3740 100644 --- a/charset.plp +++ b/charset.plp @@ -158,12 +158,14 @@ sub range_cell { for my $row (@request) { my $colsize = $row->{cell} && $row->{cell}->{colsize} || 1; + my $coldigits = ceil(log($colsize * $cols) / log(16)); # uniform length of hexadecimal header + my $rowdiv = 16 ** $coldigits; # divider of row headers + printf '
', !$row->{cell} && ' charmap'; my $title = $row->{set}; $title .= " " for $row->{setnote} // (); printf '', $title; print '' x ($cols + 1); - my $coldigits = ceil(log($colsize * $cols) / log(16)); # uniform length of hexadecimal header for my $section (qw{thead}) { print "<$section>'; for my $msb (0 .. ((length($row->{table}) || 256) - 1) / $cols) { - printf '
%s
↱"; printf '%0*X', $coldigits, $_ * $colsize for 0 .. $cols - 1; @@ -171,7 +173,18 @@ for my $row (@request) { } print '
%X', ($msb + int($row->{offset} / $cols)) * $cols * $colsize; + print '
'; + { + my $rowlabel = ($msb + int($row->{offset} / $cols)) * $cols * $colsize; + if (my $rowmod = $rowlabel % $rowdiv) { + # offset in column units + printf '+%X', $rowmod; + } + else { + # divided row offset + printf '%X', $rowlabel / $rowdiv; + } + } for my $lsb (0 .. $cols - 1) { my $val = ( ($msb * $cols) + $lsb ) * $colsize; if ($row->{cell}) { -- 2.30.0