charset: indicate continued columns without overlap
[sheet.git] / charset.plp
index b6b61b9e5df2f22fdb29df82dbcbea25d4c6e61d..5955c390a6da4327d490972a7bc3ea585659c873 100644 (file)
@@ -48,6 +48,7 @@ print join " •\n", (
        }
        [
                iso      => 'ISO',
+               win      => 'Windows',
                dos      => 'DOS',
                mac      => 'Apple',
                ebcdic   => 'EBCDIC',
@@ -78,7 +79,7 @@ sub tabinput {
 
        state $ALIAS = {
                default    => [qw( u+0-639 utf-8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
-               unicode    => [qw( uu+cols=32 u+0-4095 u+4096-6319 u+6320-8191 )],
+               unicode    => [qw( uu+cols=32+realsize u+0-4095 u+4096-6319 u+6320-8191 )],
                us         => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )],
                ebcdic     => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )],
                iso        => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16],
@@ -345,15 +346,16 @@ sub range_cell {
                if ($len -= $rest) {
                        # continued on new row
                        my @next = ($len * $colsize, "$class joinu");
+                       my $separate = $cols - $len > $rest;  # columns not on next row
                        if ($len > $rest) {
                                # minority remains
                                push @next, $name, $title;
                                $title ||= $name;
-                               $name = '';
+                               $name = $separate && '…';
                        }
                        else {
                                # minority on next row
-                               push @next, '"', $title || $name;
+                               push @next, $separate && '"', $title || $name;
                        }
                        $table->{$offset + $colsize*$rest} //= \@next;
                        $class .= ' joind';
@@ -439,28 +441,27 @@ for my $row (@request) {
                                next;
                        }
 
+                       my $cp = $offset + $row->{offset};
                        my $glyph = ref $row->{table} eq 'ARRAY' ? $row->{table}->[$offset] :
                                substr $row->{table}, $offset, 1;
-                       if ($glyph eq $NOCHAR) {
-                               print '<td>';
-                               next;
-                       }
+                       my ($cell, $name, $class) = $glyph eq $NOCHAR ? () :
+                               $glyphs->glyph_html($glyph);
 
                        if (exists $get{compare}) {
                                state $visible = {};
-                               my $cp = $offset + $row->{offset};
-                               printf '<td class="%s" title="%3$s">%2$s',
+                               $class = (
                                        $cp == ord $glyph ? 'l4' :
                                        $row->{parent} && $glyph eq
                                                Encode::decode($row->{parent}, pack 'C', $cp) ? 'l3' :
+                                       !$class ? undef :
                                        $visible->{$glyph} ? 'l2' :
-                                       'l1',
-                                       $glyphs->glyph_html($glyph);
+                                       'l1'
+                               );
                                $visible->{$glyph}++;
-                               next;
                        }
 
-                       say $glyphs->glyph_cell($glyph);
+                       say sprintf $class ? '<td title="%s" class="X %s">%s' : '<td title="%s">',
+                               $name, $class, $cell;
                }
                continue {
                        $offset += $colsize;