#(This is a potential conflict because we use nul as a filler to mean empty column in overtype rendering) REVIEW
#(This is a potential conflict because we use nul as a filler to mean empty column in overtype rendering) REVIEW
dict set cp437_map \u0000 " " ;#space
dict set cp437_map \u0000 " " ;#space
dict set cp437_map \u0001 \u263A ;#smiley
dict set cp437_map \u0001 \u263A ;#smiley
dict set cp437_map \u0003 \u263B ;#smiley-filled
dict set cp437_map \u0002 \u263B ;#smiley-filled
dict set cp437_map \u0003 \u2665 ;#heart
dict set cp437_map \u0003 \u2665 ;#heart
dict set cp437_map \u0004 \u2666 ;#diamond
dict set cp437_map \u0004 \u2666 ;#diamond
dict set cp437_map \u0005 \u2663 ;#club
dict set cp437_map \u0005 \u2663 ;#club
@ -252,6 +252,41 @@ namespace eval punk::ansi {
dict set cp437_map \u001E \u25B2 ;#up arrow triangle
dict set cp437_map \u001E \u25B2 ;#up arrow triangle
dict set cp437_map \u001F \u25BC ;#down arrow triangle
dict set cp437_map \u001F \u25BC ;#down arrow triangle
variable map_special_graphics
#DEC Special Graphics set https://en.wikipedia.org/wiki/DEC_Special_Graphics
#AKA IBM Code page 1090
dict set map_special_graphics _ \u00a0 ;#no-break space
dict set map_special_graphics "`" \u25c6 ;#black diamond
dict set map_special_graphics a \u2592 ;#shaded block (checkerboard stipple), medium shade - Block Elements
dict set map_special_graphics b \u2409 ;#symbol for HT
dict set map_special_graphics c \u240c ;#symbol for FF
dict set map_special_graphics d \u240d ;#symbol for CR
dict set map_special_graphics e \u240a ;#symbol for LF
dict set map_special_graphics f \u00b0 ;#degree sign
dict set map_special_graphics g \u00b1 ;#plus-minus sign
dict set map_special_graphics h \u2424 ;#symbol for NL
dict set map_special_graphics i \u240b ;#symbol for VT
dict set map_special_graphics j \u2518 ;#brc, light up and left - box drawing
dict set map_special_graphics k \u2510 ;#trc, light down and left - box drawing
dict set map_special_graphics l \u250c ;#tlc, light down and right - box drawing
dict set map_special_graphics m \u2514 ;#blc, light up and right - box drawing
dict set map_special_graphics n \u253c ;#light vertical and horizontal - box drawing
dict set map_special_graphics o \u23ba ;#horizontal scan line-1
dict set map_special_graphics p \u23bb ;#horizontal scan line-3
dict set map_special_graphics q \u2500 ;#light horizontal - box drawing
dict set map_special_graphics r \u23bc ;#horizontal scan line-7
dict set map_special_graphics s \u23bd ;#horizontal scan line-9
dict set map_special_graphics t \u251c ;#light vertical and right - box drawing
dict set map_special_graphics u \u2524 ;#light vertical and left - box drawing
dict set map_special_graphics v \u2534 ;#light up and horizontal - box drawing
dict set map_special_graphics w \u252c ;#light down and horizontal - box drawing
dict set map_special_graphics x \u2502 ;#light vertical - box drawing
dict set map_special_graphics y \u2264 ;#less than or equal
dict set map_special_graphics z \u2265 ;#greater than or equal
dict set map_special_graphics "\{" \u03c0 ;#greek small letter pi
dict set map_special_graphics "|" \u2260 ;#not equal to
dict set map_special_graphics "\}" \u00a3 ;#pound sign
dict set map_special_graphics ~ \u00b7 ;#middle dot
#see also ansicolor page on wiki https://wiki.tcl-lang.org/page/ANSI+color+control
#see also ansicolor page on wiki https://wiki.tcl-lang.org/page/ANSI+color+control
@ -577,17 +612,17 @@ namespace eval punk::ansi {
}
}
#review - what happens when no terminator?
#review - what happens when no terminator?
#todo - map other chars to unicode equivs
#todo - map other character sets to unicode equivs? There seems to be little support for other than the DEC special graphics set.. ISO2022 character switching not widely supported - may be best considered deprecated(?)
# convert esc(0 -> esc(B graphics sequences to single char unicode equivalents e.g box drawing set
# convert esc(0 -> esc(B graphics sequences to single char unicode equivalents e.g box drawing set
# esc) ??
# esc) ??
proc convert_g0 {text} {
proc convert_g0 {text} {
variable map_special_graphics
#using not \033 inside to stop greediness - review how does it compare to ".*?"
#using not \033 inside to stop greediness - review how does it compare to ".*?"
append out [string map $map_special_graphics $inner_plaintext] $inner_codes
append out $innercodes ;#Simplifying assumption - ST codes, titlesets etc don't require/use g0 content
#Simplifying assumption: no mapping required on any inner_codes - ST codes, titlesets etc don't require/use g0 content
}
}
} else {
} else {
append out $pt ;#may include other codes - put it all through.
append out $other ;#may be a mix of plaintext and other ansi codes - put it all through.
}
}
if {$g ne ""} {
#trust our splitting regex has done the work to leave us with only \x1b\(0 or \x1b(B - test last char rather than use punk::ansi::codetype::is_gx_open/is_gx_close