This commit is contained in:
radical_honesty on #flashsupport 2023-01-13 15:50:10 -08:00 committed by dupa dup
parent bd13f8bd2b
commit 28db36d520
2 changed files with 36 additions and 0 deletions

View File

@ -11,6 +11,7 @@ _lex_fridman_reading_inner 9c10d20ef25f4c3fb4c51b91640338fd3629cddf
_n_r_r 61d461e02e7bcef8ea98f079a322145ce65e0754 _n_r_r 61d461e02e7bcef8ea98f079a322145ce65e0754
alex_fridman_reading bcdfd11e8c234b51147cb33c5b5ece3cf5e21758 alex_fridman_reading bcdfd11e8c234b51147cb33c5b5ece3cf5e21758
c_at_n 778ea439ab6c6ee8718b27fa17634bef1ffad57b c_at_n 778ea439ab6c6ee8718b27fa17634bef1ffad57b
c_at_n_debug a5248a7559f86ae24053f685d285219f58c35906
char 71fafc4e2fc1e47e234762a96b80512b6b5534c2 char 71fafc4e2fc1e47e234762a96b80512b6b5534c2
color 6dd0fe8001145bec4a12d0e22da711c4970d000b color 6dd0fe8001145bec4a12d0e22da711c4970d000b
csplit 9dee0e0c9de58ce43e88d97c66a4ded3761de9fd csplit 9dee0e0c9de58ce43e88d97c66a4ded3761de9fd

View File

@ -0,0 +1,35 @@
{s n} {
set debug [list];
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] {
lappend debug "working on $f";
if {[lindex $f 0] > $n} {
lappend debug "reached end of string"
if {$b eq 1} {append r "\002"; lappend debug "ending bold";}
if {$u eq 1} {append r "\037"; lappend debug "ending underline"}
if {$cf > -1} {append r [format "%s" $cf]; lappend debug "adding foreground colour at end of string"}
if {$cb > -1} {append r [format ",%s" $cb]; lappend debug "adding background colour at end of string"}
lappend debug "final result: $r";
return [join $debug "\n"]
}
if {[lindex $f 1] eq "\002"} {set b [expr $b ^ 1]; lappend debug "found bold character"}
if {[lindex $f 1] eq "\037"} {set u [expr $u ^ 1]; lappend debug "found underline"}
if {[lindex $f 1] eq "\003"} {set cf -1;set cb -1; lappend debug "found color, setting cf to -1, cb to -1"}
if {[lindex $f 1] eq "\017"} {set cf -1;set cb -1;set b 0;set u 0; lappend debug "found format reset, setting cb and cf to -1 for some reason"}
if {[lindex $f 1] eq "\026"} {set t $cb;set cb $cf;set cf $t; lappend debug "found reverse kulerz character, reversing them weirdly"}
if {[set m [regexp -inline {([\d]+)$} [lindex $f 1]]] ne ""} {set cf [lindex $m 1]; lappend debug "found a really interesting number, setting cf to $cf"}
if {[set m [regexp -inline {([\d]+),([\d]+)} [lindex $f 1]]] ne ""} {set cf [lindex $m 1];set cb [lindex $m 2]; lappend debug "found even more numbers, setting cf to $cf and cb to $cb"}
}
if {$b eq 1} {append r "\002"; lappend debug "starting bold"}
if {$u eq 1} {append r "\037"; lappend debug "starting underline"}
if {$cf > -1} {append r [format "\002%s" $cf]; lappend debug "starting color"}
if {$cb > -1} {append r [format ",%s" $cb]; lappend debug "adding background color"}
lappend debug "final result: $r"
return [join $debug "\n"]
}