From 28db36d520f562980dd2ca57f7726605feec3a6e Mon Sep 17 00:00:00 2001 From: radical_honesty on #flashsupport Date: Fri, 13 Jan 2023 15:50:10 -0800 Subject: [PATCH] Evaluated eval [wget https://dpaste.com/8HLF79NYP.txt] --- procs/_index | 1 + .../a5248a7559f86ae24053f685d285219f58c35906 | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 procs/a5248a7559f86ae24053f685d285219f58c35906 diff --git a/procs/_index b/procs/_index index ef4fe15..1c5465e 100644 --- a/procs/_index +++ b/procs/_index @@ -11,6 +11,7 @@ _lex_fridman_reading_inner 9c10d20ef25f4c3fb4c51b91640338fd3629cddf _n_r_r 61d461e02e7bcef8ea98f079a322145ce65e0754 alex_fridman_reading bcdfd11e8c234b51147cb33c5b5ece3cf5e21758 c_at_n 778ea439ab6c6ee8718b27fa17634bef1ffad57b +c_at_n_debug a5248a7559f86ae24053f685d285219f58c35906 char 71fafc4e2fc1e47e234762a96b80512b6b5534c2 color 6dd0fe8001145bec4a12d0e22da711c4970d000b csplit 9dee0e0c9de58ce43e88d97c66a4ded3761de9fd diff --git a/procs/a5248a7559f86ae24053f685d285219f58c35906 b/procs/a5248a7559f86ae24053f685d285219f58c35906 new file mode 100644 index 0000000..4fb8a7a --- /dev/null +++ b/procs/a5248a7559f86ae24053f685d285219f58c35906 @@ -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"] +}