Better Highlight V2

By smilinbob on May 03, 2011

Screenshots

This is my completely re-done Better Highlight script. Instead of an entire line of test being highlighted, only the word that fits the highlight will be highlighted.
All options are accessed through a more user-friendly Dialog.
Right now it supports up to 5 separate highlights, all with their own options. (see screen shot)
The color preview updates instantly. Also error checking in implemented, so it won't let you save invalid settings.
Multiple highlights may be triggered in the same line
The pop-up window also has options, and can be completely turned off.
if you have any ideas for other pop-up options, let me know and I'll try to implement them,

on ^*:TEXT:*:#: {
  var %c = 1
  var %h = $1-
  while (%c <= 5) {
    var %hln = $readini(bhl.ini,%c,2)
    if ($readini(bhl.ini,%c,1) == 1) {
      if (%hln isin %h) {
        var %hd = 1
        var %h2 = $eval(* $+ %hln $+ *)
        var %hh = 1
        while (%hh <= $wildtok(%h,%h2,0,32)) {
          var %h = $reptok(%h,$wildtok(%h,%h2,%hh,32),$+  $+ $readini(bhl.ini,%c,3) $+ $wildtok(%h,%h2,%hh,32) $+ ,1,32)
          inc %hh 
        }   
      }
    }
    inc %c
  }
  if (%hd == 1) {
    echo -t $chan $chr(60) $+ $nick $+ $chr(62) %h
    var %c = 1
    while (%c <= 5) {
      if ($readini(bhl.ini,%c,1) == 1) {
        if ($readini(bhl.ini,%c,5) == 2) || ($readini(bhl.ini,%c,5) == 4) {
          var %b = 1
        }
        if ($readini(bhl.ini,%c,5) == 3) || ($readini(bhl.ini,%c,5) == 4) {
          var %f = 1
        }
        if ($readini(bhl.ini,%c,6) == 1) {
          var %p = 1
        }
      }
      inc %c
    }
    if (%b == 1) {
      beep 2
    }
    if (%f == 1) {
      flash $chan
    }
    if (%p == 1) {
      window $readini(bhl.ini,d,d) @Highlight
      echo -t @HIGHLIGHT $chr(123) $+ $network $+ $chr(125) $chr(91) $+ $chan $+ $chr(93) $chr(60) $+ $nick $+ $chr(62) %h
    }
    halt
  }
}
;-------------------------------------------
dialog -l better {
  title "Hilight Options"
  size -1 -1 496 215
  option pixels notheme
  box "Enable", 1, 12 14 55 150
  box "Text", 2, 64 14 125 150
  box "Color", 3, 187 14 124 150
  box "Action", 4, 308 14 124 150
  box "Popup", 5, 430 14 55 150
  button "Save", 6, 179 175 65 25
  button "Close", 7, 252 175 65 25
  check "", 11, 32 37 17 17
  edit "", 12, 73 37 100 20
  edit "01,00", 13, 196 37 48 20
  icon 14, 255 37 40 15
  combo 15, 319 37 100 68, drop
  check "", 16, 448 37 17 17
  check "", 21, 32 62 17 17
  edit "", 22, 73 62 100 20
  edit "01,00", 23, 196 62 48 20
  icon 24, 255 62 40 15
  combo 25, 319 62 100 68, drop
  check "", 26, 448 62 17 17
  check "", 31, 32 87 17 17
  edit "", 32, 73 87 100 20
  edit "01,00", 33, 196 87 48 20
  icon 34, 255 87 40 15
  combo 35, 319 87 100 68, drop
  check "", 36, 448 87 17 17
  check "", 41, 32 112 17 17
  edit "", 42, 73 112 100 20
  edit "01,00", 43, 196 112 48 20
  icon 44, 255 112 40 15
  combo 45, 319 112 100 68, drop
  check "", 46, 448 112 17 17
  check "", 51, 32 137 17 17
  edit "", 52, 73 137 100 20
  edit "01,00", 53, 196 137 48 20
  icon 54, 255 137 40 15
  combo 55, 319 137 100 68, drop
  check "", 56, 448 137 17 17
  button "Pop-up Options", 8, 430 172 55 31, multi
}
ON *:dialog:better:edit:13,23,33,43,53: {
  bhlpre $left($did,1)
}
alias -l bhlpre {
  var %id = $$1 $+ 3
  var %pre =  $$1 $+ 4
  if ($chr(44) isin $did(better,%id)) {
    tokenize 44 $did(better,%id)
    if ($2 isnum) {
      window -pnw0 +d @pre 0 0 35 20
      drawrect -f @pre $2 1 0 0 35 20
      drawtext -c @pre $1 4 4 35 20 Text
      drawsave @pre pre.bmp
      window -c @pre
      did -g better %pre pre.bmp
    }
  }
  else {
    if ($did(better,%id) isnum) {
      window -pnw0 +d @pre 0 0 35 20
      drawrect -f @pre $color(background).dd 1 0 0 35 20
      drawtext -c @pre $did(better,%id) 4 4 35 20 Text
      drawsave @pre pre.bmp
      window -c @pre
      did -g better %pre pre.bmp
    }
  }
}
ON *:dialog:better:init:0: {
  did -a better 15,25,35,45,55 None
  did -a better 15,25,35,45,55 Beep
  did -a better 15,25,35,45,55 Flash
  did -a better 15,25,35,45,55 Beep and Flash
  var %c = 1
  while (%c <= 5) {
    if ($readini(bhl.ini,%c,1) == 1) {
      did -c better %c $+ 1
    }
    if ($readini(bhl.ini,%c,6) == 1) {
      did -c better %c $+ 6
    }
    if ($did(better,%c $+ 1).state == 0) {
      did -b better %c $+ 2- $+ %c $+ 6
    }
    did -a better %c $+ 2 $readini(bhl.ini,%c,2)
    did -o better %c $+ 3 1 $readini(bhl.ini,%c,3)
    did -cu better %c $+ 5 $readini(bhl.ini,%c,5)
    bhlpre %c
    inc %c
  }
}
ON *:dialog:better:sclick:*: {
  if ($did == 6) {
    var %c = 1
    while (%c <= 5) {
      if ($did(better,%c $+ 1).state == 1) {
        if (!$did(better,%c $+ 2)) {
          bhlnot Error: Plaese enter "Text" in line %c
          halt
        }
        if (!$did(better,%c $+ 3)) {
          bhlnot Error: Plaese enter "Color" in line %c
          halt
        }
        if ($did(better,%c $+ 3) !isnum) {
          if ($chr(44) !isin $did(better,%c $+ 3)) {
            bhlnot Error: Invalid Color in line %c 
            halt
          }
          else {
            tokenize $did(better,%c $+ 3) 44
            if ($1 !isnum) || ($2 !isnum) {
              bhlnot Error: Invalid Color in line %c 
              halt
            }
          }
        }
      }
      inc %c
    }
    var %c = 1
    while (%c <= 5) {
      writeini bhl.ini %c 1 $did(better,%c $+ 1).state
      if ($did(better,%c $+ 2).text) writeini bhl.ini %c 2 $v1
      if ($did(better,%c $+ 3).text) writeini bhl.ini %c 3 $v1
      writeini bhl.ini %c 5 $did(better,%c $+ 5).sel
      writeini bhl.ini %c 6 $did(better,%c $+ 6).state
      inc %c
    }
    bhlnot Save Successful
  }
  elseif ($did == 7) { 
    dialog -c better
  }
  elseif ($right($did,1) == 1) {
    var %c = $left($did,1)
    if ($did(better,$did).state == 0) {
      did -b better %c $+ 2- $+ %c $+ 6
    }
    elseif ($did(better,$did).state == 1) {
      did -e better %c $+ 2- $+ %c $+ 6
    }
  }
  elseif ($did == 8) {
    dialog -m poo poo
  }
}
dialog -l bhlnot {
  title "Notice"
  size -1 -1 259 68
  option pixels notheme
  button "OK", 1, 97 36 65 25, ok
  text "", 2, 4 8 251 22, center
}
alias -l bhlnot {
  dialog -ma bhlnot bhlnot
  did -a bhlnot 2 $$1-
  beep 1 1
}
menu channel,status {
  Better Highlight options: /dialog -m better better
}
menu @highlight {
  Close: /window -c @highlight
}
dialog poo {
  title "Pop-up Options"
  size -1 -1 124 185
  option pixels notheme
  check "On Desktop", 1, 12 16 100 17
  check "On Top", 2, 26 38 100 17
  check "Title Bar", 3, 12 60 100 17
  combo 4, 12 100 100 70, drop
  button "OK", 5, 28 149 65 25, ok
  text "Show in:", 6, 12 82 100 17
}
on *:dialog:poo:init:0: {
  did -a poo 4 Switchbar
  did -a poo 4 Treebar
  did -a poo 4 Both
  did -a poo 4 Neither
  var %c = 1
  while (%c <= 3 ) {
    if ($readini(bhl.ini,d,%c)) {
      did -c poo %c 
    }
    inc %C
  }
  did -c poo 4 $readini(bhl.ini,d,4)
  if (!$did(poo,1).state) {
    did -b poo 2
  }
}
on *:dialog:poo:sclick:*: {
  if ($did == 1) {
    if ($did(1).state) did -e poo 2
    else did -b poo 2
  }
  if ($did == 5) {
    var %c = 1
    while (%c <= 3) {
      writeini bhl.ini d %c $did(%c).state
      inc %c
    }
    writeini bhl.ini d 4 $did(4).sel
    var %d = -k0
    if ($did(poo,1).state == 1) {
      var %d = %d $+ d
      if ($did(poo,2).state == 1) { 
        var %d = %d $+ o
      }
    }
    if ($did(poo,4).sel == 1) {
      var %d = %d $+ w1
    }
    elseif ($did(poo,4).sel == 2) {
      var %d = %d $+ w2
    }
    elseif ($did(poo,4).sel == 3) {
      var %d = %d $+ w3
    }
    elseif ($did(poo,4).sel == 4) {
      var %d = %d $+ w0
    }
    if ($did(poo,3).state == 0) {
      var %d = %d +b

    } 
    writeini bhl.ini d d %d 
    dialog -x poo   
  }
}

Comments

Sign in to comment.
ytuio9   -  May 23, 2011

You can't trigger on TEXT events yourself - others will need to do it. You can just tell a bot to do it if you're an op on a channel.

 Respond  
Person   -  May 20, 2011

I copied the script && filled out the options form,but when i highlighted myself, nothing happened. :s

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.