summaryrefslogtreecommitdiffstats
path: root/src/perl/block-graphics-to-ascii
diff options
context:
space:
mode:
authorroot <root>2012-09-04 22:41:11 +0000
committerroot <root>2012-09-04 22:41:11 +0000
commitd50a22a63f36f3d4fb5bd2f4d7d0f89f36d84e8f (patch)
tree64566414b54ff274345437c2b02a4f1e73b80e72 /src/perl/block-graphics-to-ascii
parent5ee396e7ac453f939e8ec74546756dba45906827 (diff)
*** empty log message ***
Diffstat (limited to 'src/perl/block-graphics-to-ascii')
-rw-r--r--src/perl/block-graphics-to-ascii37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/perl/block-graphics-to-ascii b/src/perl/block-graphics-to-ascii
new file mode 100644
index 0000000..3d6e71a
--- /dev/null
+++ b/src/perl/block-graphics-to-ascii
@@ -0,0 +1,37 @@
+#! perl
+
+=head1 NAME
+
+block-graphics-to-ascii - map block graphics to ascii characters
+
+=head1 DESCRIPTION
+
+A not very useful example of filtering all text output to the terminal
+by replacing all line-drawing characters (U+2500 .. U+259F) by a
+similar-looking ascii character.
+
+=cut
+
+# simple example that uses the add_lines hook to filter unicode and vt100 line/box graphics
+
+# ─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏
+my $rep_unicode = "--||--||--||++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--||"
+# ═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲ ╳╴╵╶╷╸╹╺╻╼╽╾╿▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
+ . "=|+++++++++++++++++++++++++++++++/\\X-|-|-|-|-|-|#____#######|||||###~###########";
+
+# ↑↓→←█▚ ☃HIJKLMNOPQRSTUVWXYZ[\ ]^ ◆▒␉␌␍␊°±␤␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥π≠£·
+my $rep_acs = "↑↓<>#\\☃HIJKLMNOPQRSTUVWXYZ[\\]^ ◆#␉␌␍␊°±␤␋+++++⎺⎻-⎼⎽++++!<>π≠£·";
+
+sub on_add_lines {
+ my ($self, $str) = @_;
+
+ $str =~ s/([\x{2500}-\x{259f}])/substr $rep_unicode, (ord $1) - 0x2500, 1/ge;
+
+ $str =~ s/([\x41-\x7e])/substr $rep_acs, (ord $1) - 0x41, 1/ge
+ if $self->cur_charset eq "0";
+
+ $self->scr_add_lines ($str);
+
+ 1
+}
+