|
Joined: Jun 2004
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: Jun 2004
Posts: 2 |
How do I replace a incomming textcolor when it is the same as my backgroud (black on black or white on a white background)
|
|
|
|
Joined: Jan 2003
Posts: 56
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 56 |
on ^*:text:*:#:{
var %n,%t = $stripblack($color(background),$strip($1-,o))
if ($gettok($readini($mircini,options,n2),30,44)) %n = $+($left($remove($nick(#,$nick).pnick,$nick),1),$nick)
else %n = $nick
echo -lcmbfti2 no # $replace(<&1> &2,&1,%n,&2,%t)
haltdef
}
alias -l stripblack {
if (!$2-) return $2-
elseif ( !isin $2-) { return $2- }
var %old = $+ $replace($2-,$chr(32),$chr(4),01 $+ $chr(44),1 $+ $chr(44)) $+
var %bg = $false
var %max = $regex(txt,%old,/(|)/g)
var %num = 1
var %reg = ^[0-9]{1,2}[,][0-9]
if ($1 isnum 0-9) { var %reg2 = ^( $+ $base($1,10,10,1) $+ [^[:digit:]]|0 $+ $base($1,10,10,1) $+ ) }
elseif ($1 isnum 10-99) { var %reg2 = ^ $+ $1 }
while (%num <= %max) {
if ($regex(check,$mid(%old,$regml(txt,%num).pos,4),%reg)) { var %strip = $false | var %bg = $true }
elseif ($regex(check,$mid(%old,$regml(txt,%num).pos,4),%reg2)) { var %strip = $true }
elseif ($regex(check,$mid(%old,$regml(txt,%num).pos,4),^[^0-9])) { var %strip = $false | var %bg = $false }
elseif ($regex(check,$mid(%old,$regml(txt,%num).pos,4),^)) { var %strip = $false | var %bg = $false }
else { var %strip = $false }
if (%strip) && (!%bg) {
if ($regex(check,$mid(%old,$regml(txt,%num).pos,4),01)) { var %txt = %txt $+ $+ $right($gettok($gettok($mid(%old,$regml(txt,%num).pos,-1),1,3),1,15),-2) }
else { var %txt = %txt $+ $+ $right($gettok($gettok($mid(%old,$regml(txt,%num).pos,-1),1,3),1,15),-1) }
}
else { var %txt = %txt $+ $regml(txt,%num) $+ $replace($gettok($gettok($mid(%old,$regml(txt,%num).pos,-1),1,3),1,15),$chr(32),$chr(44)) }
inc %num 1
}
return $replace($right(%txt,-1),$chr(4),$chr(32))
}
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Try this code:
on ^*:TEXT:**:?,#:{
var %s, %r = /\030? $+ $color(background) $+ (?!,\d{0,2}) $+ /g
%r = $regsub(,$1-,%r,,%s)
if (!$window($target)) query $target
echo -tl $target < $+ $nick $+ > %s
haltdef
}
It should remove any color codes that have a foreground color that is the same as your background color, unless there is a background color included with the color code. Example: (assuming you background color is white - 0) ([] = ctrl+k) []0TEXT = color code removed []00TEXT = color code removed []00,01TEXT = color code not removed []00,00TEXT = color code not removed []12TEXT = color code not removed []12,00TEXT = color code not removed []12,15TEXT = color code not removed -genius_at_work
|
|
|
|
Joined: Jun 2004
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: Jun 2004
Posts: 2 |
tnx folks I will give it a try.
|
|
|
|
Joined: Oct 2004
Posts: 72
Babel fish
|
Babel fish
Joined: Oct 2004
Posts: 72 |
Try this code:
on ^*:TEXT:**:?,#:{
var %s, %r = /\030? $+ $color(background) $+ (?!,\d{0,2}) $+ /g
%r = $regsub(,$1-,%r,,%s)
if (!$window($target)) query $target
echo -tl $target < $+ $nick $+ > %s
haltdef
}
This doesn't always give the same results as mIRC does, for instance, with background is black on []1,29test. The part after the comma is invalid in which case mIRC generates foreground black. But the given code doesn't resolve this and gives ,29test. Replacing %r = $regsub(,$1-,%r,,%s) by %r = $regsub(,$1-,%r, []0,%s) generates black on black Better code is:
on ^*:TEXT:**:?,#:{
var %s = $null
if ($color(background) < 10) {
var %r = /\03( $+ $color(background) $+ (?!\d)|0 $+ $color(background) $+ )(?!,(0|1[0-5]|[1-9]\D))/g
}
else {
var %r = /\03( $+ $color(background) $+ )(?!,(0|1[0-5]|[1-9]\D))/g
}
%r = $regsub(, $1-, %r, 0, %s)
if (!$window($target)) query $target
echo -tlbfmr $target < $+ $nick $+ > %s
haltdef
}
This code alsoI solves the problem of getting lines with 1 position colorcode and 2 positions color code e.g. []1test and []01test. One other problem stays: how to convert dark blue on black to a readable colorscheme??
|
|
|
|
Joined: Oct 2004
Posts: 72
Babel fish
|
Babel fish
Joined: Oct 2004
Posts: 72 |
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
|
|
|
|
|