This commit is contained in:
radical_honesty on #flashsupport
2023-01-13 12:23:25 -08:00
committed by dupa dup
parent d65434ad64
commit a47f3f88dd
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,30 @@
{s n} {
set c [csplit $s]
if {$n > [expr [llength [lindex $c 0]]-1]} {set n [expr [llength [lindex $c 0]]-1]}
set b 0
set u 0
set cf -1
set cb -1
set r ""
foreach f [lindex $c 1] {
if {[lindex $f 0] > $n} {
if {$b eq 1} {append r "\002"}
if {$u eq 1} {append r "\037"}
if {$cf > -1} {append r [format "%s" $cf]}
if {$cb > -1} {append r [format ",%s" $cb]}
return $r
}
if {[lindex $f 1] eq "\002"} {set b [expr $b ^ 1]}
if {[lindex $f 1] eq "\037"} {set u [expr $u ^ 1]}
if {[lindex $f 1] eq "\003"} {set cf -1;set cb -1}
if {[lindex $f 1] eq "\017"} {set cf -1;set cb -1;set b 0;set u 0}
if {[lindex $f 1] eq "\026"} {set t $cb;set cb $cf;set cf $t}
if {[set m [regexp -inline {([\d]+)$} [lindex $f 1]]] ne ""} {set cf [lindex $m 1]}
if {[set m [regexp -inline {([\d]+),([\d]+)} [lindex $f 1]]] ne ""} {set cf [lindex $m 1];set cb [lindex $m 2]}
}
if {$b eq 1} {append r "\002"}
if {$u eq 1} {append r "\037"}
if {$cf > -1} {append r [format "%s" $cf]}
if {$cb > -1} {append r [format ",%s" $cb]}
return $r
}