ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/block-graphics-to-ascii
Revision: 1.6
Committed: Tue Sep 4 22:41:11 2012 UTC (11 years, 8 months ago) by root
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_29, rxvt-unicode-rel-9_26, rxvt-unicode-rel-9_25, rxvt-unicode-rel-9_22, rxvt-unicode-rel-9_20, rxvt-unicode-rel-9_21, rxvt-unicode-rel-9_19, rxvt-unicode-rel-9_18, rxvt-unicode-rel-9_17, rxvt-unicode-rel-9_16, rxvt-unicode-rel-9_30, HEAD
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3 root 1.4 =head1 NAME
4    
5 root 1.6 block-graphics-to-ascii - map block graphics to ascii characters
6 root 1.4
7 root 1.5 =head1 DESCRIPTION
8 root 1.4
9     A not very useful example of filtering all text output to the terminal
10     by replacing all line-drawing characters (U+2500 .. U+259F) by a
11     similar-looking ascii character.
12    
13     =cut
14    
15 root 1.3 # simple example that uses the add_lines hook to filter unicode and vt100 line/box graphics
16    
17 root 1.2 # ─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏
18     my $rep_unicode = "--||--||--||++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--||"
19     # ═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲ ╳╴╵╶╷╸╹╺╻╼╽╾╿▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
20     . "=|+++++++++++++++++++++++++++++++/\\X-|-|-|-|-|-|#____#######|||||###~###########";
21    
22     # ↑↓→←█▚ ☃HIJKLMNOPQRSTUVWXYZ[\ ]^ ◆▒␉␌␍␊°±␤␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π≠£·
23     my $rep_acs = "↑↓<>#\\☃HIJKLMNOPQRSTUVWXYZ[\\]^ ◆#␉␌␍␊°±␤␋+++++⎺⎻-⎼⎽++++!<>π≠£·";
24 root 1.1
25     sub on_add_lines {
26 root 1.2 my ($self, $str) = @_;
27    
28     $str =~ s/([\x{2500}-\x{259f}])/substr $rep_unicode, (ord $1) - 0x2500, 1/ge;
29    
30     $str =~ s/([\x41-\x7e])/substr $rep_acs, (ord $1) - 0x41, 1/ge
31     if $self->cur_charset eq "0";
32 root 1.1
33 root 1.2 $self->scr_add_lines ($str);
34 root 1.1
35     1
36     }
37