fuzzball-muck/fuzzball

Array Version of textattr (SF issue)

tanabi opened this issue · 0 comments

It would be useful to be able to use textattr on an array
of paired plain text strings and attributes. For instance,
if I want to be able to display a single line of multi-
coloured text I have to use textattr each time for each
part of the string or try to use a loop.

(Example code to print out multi-coloured 'Nicetry!'
string)
: main
(Either do it by building an array using textattr many
times...)
{ "N" "bold,red" textattr
"i" "bold,yellow" textattr
"c" "bold,green" textattr
"e" "bold,cyan" textattr
"t" "bold,blue" textattr
"r" "bold,magenta" textattr
"y" "bold,white" textattr
"!" "bold,yellow" textattr }join
me @ swap notify

(or use 3 nested arrays and a foreeach loop.)
{
{
{ "N" "bold,red" }list
{ "i" "bold,yellow" }list
{ "c" "bold,green" }list
{ "e" "bold,cyan" }list
{ "t" "bold,blue" }list
{ "r" "bold,magenta" }list
{ "y" "bold,white" }list
{ "!" "bold,yellow" }list
}list
foreach
array_vals pop textattr swap pop
repeat
}join
me @ swap notify

(Better way would be to have
{ "N" "bold,red" "i" "bold,yellow"
"c" "bold,green" "e" "bold,cyan"
"t" "bold,blue" "r" "bold,magenta"
"y" "bold,white" "!" "bold,yellow"
}textattr array_join me @ swap notify )

( }textattr could be a muf compiler macro to
' } array_textattr '. 'array_textattr' could be a muf
compiler macro to the first method shown above. Either
way it is easier to code with the array versions of
textattr. Changing colours in a single line of text to
denote different fields or columns is common practice
and simplifying applying text attibutes would be great. )
;