App-Chart

 view release on metacpan or  search on metacpan

lib/App/Chart/Pango/Ex/ANSItoMarkup.pm  view on Meta::CPAN


        } elsif ($num == 4) {
          # single underline
          $attr->[_A_UNDERLINE] = 'underline=single';

          # 5 slow blink
          # 6 fast blink
          #    nothing for these in pango

          # 7 "negative image", reverse video
          #    would kinda need to know what the normal colours are

          # 8 concealed
          #    does this mean invisible?

        } elsif ($num == 9) {
          $attr->[_A_STRIKETHROUGH] = 'strikethrough=true';

          # 10 primary font
          # 11 first alternative font
          # ...
          # 19 ninth alternative font
          # 20 fraktur gothic

        } elsif ($num == 21) {
          # double underline
          $attr->[_A_UNDERLINE] = 'underline=double';

        } elsif ($num == 22) {
          # normal colour/intensity, ie. neither bold nor faint
          $attr->[_A_WEIGHT] = undef;

        } elsif ($num == 23) {
          # not italic
          $attr->[_A_STYLE] = undef;

        } elsif ($num == 24) {
          # not underlined
          $attr->[_A_UNDERLINE] = undef;

          # 25 not blinking
          #     nothing for blinking in pango
          # 26 reserved (for proportional spacing)
          # 27 positive image, ie. not reverse video
          # 28 revealled chars, ie. not concealed

        } elsif ($num == 29) {
          # not strikethrough
          $attr->[_A_STRIKETHROUGH] = undef;

        } elsif ($num >= 30 && $num <= 37) {
          $attr->[_A_FOREGROUND] = 'foreground=' . $colour[$num-30];

          # 38 reserved (for foreground colour)

        } elsif ($num == 39) {
          # default foreground colour
          $attr->[_A_FOREGROUND] = undef;

        } elsif ($num >= 40 && $num <= 47) {
          $attr->[_A_BACKGROUND] = 'background=' . $colour[$num-40];

          # 48 reserved (for background colour)

        } elsif ($num == 49) {
          # default background colour
          $attr->[_A_BACKGROUND] = undef;

          # 50 reserved (for cancelling 26 proportional spacing)
          # 51 framed
          # 52 encircled
          # 53 overlined
          #     no overline in pango markup
          # 54 not framed or encircled
          # 55 not overlined
          # 56-59 reserved
          # 60 ideogram underline right side line
          # 61 ideogram double underline right side line
          # 62 ideogram overline left side line
          # 63 ideogram double overline left side
          # 64 ideogram stress
          # 65 ideogram normal, ie. undo 60-64
        }
      }
    } elsif (defined $2) {
      # sub/sup rise 5000, meaning 0.5 em, same as pango-markup.c does for
      # <sub>, <sup> shorthands
      if ($2 eq 'K') {
        # PLD partial line down subscript or cancel superscript
        $self->{'rise'} -= 5000;

      } elsif ($2 eq 'L') {
        # PLU partial line up superscript or cancel subscript
        $self->{'rise'} += 5000;
      }
      $attr->[_A_RISE] = (($self->{'rise'}||0) == 0 ? undef
                          : "rise=".$self->{'rise'});

    } else {
      $part = $1;
    }

    my $span = join (' ', '<span', grep {defined} @$attr);
    if ($span eq '<span') {
      # no markup at all
      $ret .= $part;
    } elsif (my $short = $shorthand{$span}) {
      $ret .= "<$short>$part</$short>";
    } else {
      $ret .= "$span>$part</span>";
    }
  }
  return $ret;
}

# print __PACKAGE__->convert("\eKsub\eLn\eZorm\e[1mxyz\e[0mabc\e[30mxyz\e[0m");

1;
__END__



( run in 0.718 second using v1.01-cache-2.11-cpan-f56aa216473 )