;--[ auto color 1.0 ]-----------------------------
; autor: diffusi0n 
; email: diffusi0n@brasnet.org
; website: www.diffusi0n.f2s.com
; contacts: BRASnet Network(irc.brasnet.org) on #scriptx #scripts #ircz
;---------------------------------------------------------------------------------------------

on *:load: {
  echo $color(info) *** auto color 1.0 by diffusi0n loaded!
  echo $color(info) *** command: /acolor
  set %ac.status off
  set %ac.text 1
  set %ac.back 0
}

alias acolor { dialog -m acolor acolor }
dialog acolor {
  title "auto color 1.0"
  size -1 -1 169 109
  box "setup", 1, 6 5 80 69
  text "text:", 2, 16 27 22 13
  edit "", 3, 51 20 25 22, center multi return
  text "back:", 4, 16 50 29 13
  edit "", 5, 51 43 25 22, center multi return
  box "additional", 6, 84 5 79 69
  check "bold", 7, 94 27 43 13
  check "underline", 8, 94 49 61 13
  button "preview", 9, 21 82 55 20
  button "done", 10, 93 82 55 20, ok
  box "", 11, -1 -6 171 116
}
on *:dialog:acolor:*:*: {
  if $devent = init { 
    did -a $dname 3 %ac.text
    did -a $dname 5 %ac.back
    if (%ac.bold == on) { did -c $dname 7 }
    if (%ac.underline == on) { did -c $dname 8 }
  }
  if $devent = edit {
    if $did = 3 { set %ac.text $did(3).text }
    if $did = 5 { set %ac.back $did(5).text }
  }
  if $devent = sclick {
    if $did = 7 {
      if ($did(7).state = 1) { set %ac.bold on | set %ac.bold2  } 
      if ($did(7).state = 0) { set %ac.bold off | set %ac.bold2 } 
    }
    if $did = 8 {
      if ($did(8).state = 1) { set %ac.underline on | set %ac.underline2  } 
      if ($did(8).state = 0) { set %ac.underline off | set %ac.underline2 } 
    }
    if $did = 9 { echo -a  $+ %ac.text $+ , $+ %ac.back $+ %ac.bold2 $+ %ac.underline2 $+ test! }
  }
}

#acolor off
on *:input:*:if (/* !iswm $1) && (*: !iswm $1) { say  $+ %ac.text $+ , $+ %ac.back $+ %ac.bold2 $+ %ac.underline2 $+ $1- | halt }
#acolor end

alias ac.on { set %ac.status on | .enable #acolor }
alias ac.off { set %ac.status off | .disable #acolor }

menu status,menubar,channel {
  auto color 1.0
  .config:acolor
  .-
  .set on:ac.on
  .set off:ac.off
  .status - %ac.status:echo -a Status: %ac.status
  .-
  .about:echo $color(info) *** auto color 1.0 by diffusi0n
}
