ehm ... the 0 in %r = $regsub(, $1-, %r, 0, %s))
should be replaced bij an $iif asking whether background color is black or white ...
To be honest I think to make real good code that takes any colorscheme into account, you need to use some $replace commands, using $regsub is far too complex :S