Acronym Manager — File Browser

AcronymManagerv2.2 / AcronymManagerv2.2 / acros.mrc

acros.mrc — 13.91 KB — Download this file

alias acros {
  var %x = $iif(!$show,.) $+ acrosmsg2
  if ($isid) {
    if (!$0) return $group(#acros)
    elseif ($0 > 2) acrosmsg Too many parameters: $!acros
    elseif ($prop == acro) return $hfind(acros,$1,$iif($0 > 1,$2,0)).data
    elseif ($hget(acros,$1)) return $v1
    return
  }
  elseif ($1 == on) {
    .enable #acros
    %x Acronyms are on
  }
  elseif ($1 == off) {
    .disable #acros
    %x Acronyms are off
  }
  elseif ($1 == -a) && ($0 > 2) {
    if ($hget(acros,$2) == $null) {
      hadd -m acros $2-
      %x Added $2 to acronym list
    }
    else %x Updated long form for acronym $2
  }
  elseif ($1 == -c) {
    if ($hget(acros)) hfree acros
    if ($hget(acroschan)) hfree acroschan
    hmake acros
    hmake acroschan
    %x Acronym list cleared
  }
  elseif ($1 == -r) {
    if ($hget(acros,$2) != $null) {
      hdel acros $2
      %x Removed $2 from acronym list
    }
    else %x $2 is not in acronym list
  }
  else dialog $iif($dialog(acros),-v,-m acros) acros
}
alias acrostab {
  if ($isid) return $group(#acrostab)
  elseif ($1 == on) {
    .enable #acrostab
    if ($show) acrosmsg2 Acronym tab completion is on
  }
  elseif ($1 == off) {
    .disable #acrostab
    if ($show) acrosmsg2 Acronym tab completion is off
  }
}
alias -l dcxpath return $scriptdirdcx.dll
alias -l hsh return $scriptdiracros.hsh
alias -l hsh2 return $scriptdiracroschan.hsh
alias -l win return @acrospreview
alias -l acrosmsg echo $colour(info) $iif($istok(channel chat fserve query,$window($active).type,32),-a,-es) * $$1-
alias -l acrosmsg2 {
  if ($show) echo $colour(info2) -ea * $$1-
}
alias -l dcx {
  if ($isid) return $dll($dcxpath,$1,$2-)
  dll $qt($dcxpath) $1-
}
alias -l udcx $iif($menu,.timer 1 0) dll -u $qt($dcxpath)
alias -l xdid {
  if ($isid) return $dcx(_xdid,$1 $2 $prop $3-)
  dcx xdid $2 $3 $1 $4-
}
alias -l xdialog {
  if ($isid) return $dcx(_xdialog,$1 $prop $2-)
  dcx xdialog $2 $1 $3-
}
on *:START: {
  if ($hget(acros)) hfree acros
  if ($hget(acroschan)) hfree acroschan
  hmake acros
  hmake acroschan
  if ($isfile($hsh)) hload -b acros $qt($hsh)
  if ($isfile($hsh2)) hload -b acroschan $qt($hsh2)
}
on *:LOAD: {
  if ($version < 6.2) {
    acrosmsg Acronym Manager 2.2 will not work in mIRC versions lower than 6.2. This script will now be unloaded. Please download the latest copy of mIRC at http://www.mirc.com
    .unload -nrs $qt($script)
  }
  elseif (!$isfile($dcxpath)) {
    acrosmsg Acronym Manager 2.2 cannot find dcx.dll. This script will now be unloaded. Please place dcx.dll in $qt($nofile($dcxpath)) before loading this script again.
    .unload -nrs $qt($script)
  }
  elseif ($gettok($dcx(Version),4,32) < 1.3.1) {
    acrosmsg Acronym Manager 2.2 will not work in dcx.dll versions lower than 1.3.1. This script will now be unloaded. Please download the latest copy of dcx.dll at http://dcx.scriptsdb.org
    .unload -nrs $qt($script)
  }
  else acrosmsg Acronym Manager 2.2 has been successfully loaded. Trigger: /acros
}
on *:UNLOAD: {
  if ($hget(acros)) {
    hsave -bo acros $qt($hsh)
    hfree acros
  }
  if ($hget(acroschan)) {
    hsave -bo acroschan $qt($hsh2)
    hfree acroschan
  }
  tokenize 32 $dialog(acros) $dialog(acrosedit) $dialog(acroschan)
  dialog -x $*
  if ($window($win)) window -c $win
  unset %acros.*
  udcx
  acrosmsg Acronym Manager 2.2 has been successfully unloaded.
}
on *:EXIT: {
  udcx
  if ($hget(acros)) hsave -bo acros $qt($hsh)
  if ($hget(acroschan)) hsave -bo acroschan $qt($hsh2)
}
dialog acrosedit {
  title "Acronym Editor"
  size -1 -1 90 43
  option dbu
  edit "", 1, 3 13 32 10, autohs
  edit "", 2, 37 13 50 10, autohs
  button "OK", 3, 10 28 32 10, default
  button "Cancel", 4, 47 28 32 10, cancel
  text "Acronym", 5, 8 4 30 8
  text "Long Form", 6, 49 4 25 8
}
on *:DIALOG:acrosedit:*:*: {
  if ($devent == init) && ($xdid(acros,3).selnum) {
    did -o $dname 1 1 %acros.acro
    did -o $dname 2 1 %acros.long
  }
  elseif ($devent == close) {
    unset %acros.acro %acros.long
    if ($dialog(acros)) dialog -v acros
  }
  elseif ($devent == edit) && ($istok(1 2,$did,32)) did $iif($numtok($did(1),32) == 1 && $did(2) != $null,-e,-b) $dname 3
  elseif ($devent == sclick) {
    if ($did == 3) {
      if ($did(1) != $null) && ($did(2) != $null) {
        if ($hget(acros,%acros.acro)) && ($numtok($did(1),32) == 1) {
          hdel acros %acros.acro
          hadd -m acros $did(1) $did(2)
          if ($dialog(acros)) {
            xdid -u acros 3
            if ($xdid(acros,3,$+($chr(9),%acros.acro,$chr(9)),W,0,1).find) xdid -d acros 3 $gettok($v1,1,32)
            xdid -a acros 3 0 0 +s 0 0 0 0 -1 -1 $did(1) $chr(9) + 0 $did(2)
            xdid -F acros 3
          }
          unset %acros.acro %acros.long
          dialog -x $dname
        }
        elseif ($numtok($did(1),32) > 1) noop $input(Acronym has to be 1 word!,o,Error!)
        else noop $input(Edited acronym doesn't exist!,o,Error!)
      }
      else noop $input(Not enough information inputed!,o,Error!)
    }
  }
}
dialog acroschan {
  title "Acronym Channel Exclusions"
  size -1 -1 128 182
  option dbu
  text "Channel", 1, 24 4 20 8
  edit "", 2, 2 14 66 10
  check "Disallow acronyms", 3, 71 3 54 10
  check "Strip control codes", 4, 71 14 54 10
  button "Add/Edit", 5, 27 29 32 10, disable
  button "Delete", 6, 67 29 32 10, disable
  box "Channels", 8, 2 100 123 26
  radio "Allow All", 9, 5 110 30 10, group
  radio "Allowed Only", 10, 37 110 40 10
  radio "No Disallowed", 11, 79 110 43 10
  box "Control Codes", 12, 2 127 123 38
  radio "Allow All", 13, 5 137 30 10, group
  radio "Allowed Only", 14, 37 137 40 10
  radio "No Disallowed", 15, 79 137 43 10
  check "Strip when +c is set", 16, 5 150 58 10
  button "OK", 17, 48 169 32 10, ok
}
on *:DIALOG:acroschan:*:*: {
  if ($devent == init) {
    dcx Mark $dname acroschan_cb
    xdialog -b $dname +mntyz
    xdialog -c $dname 7 listview 5 88 241 105 fullrow report tooltip showsel nolabelwrap tabstop sortasc
    xdid -t $dname 7 +l 0 85 Channel $chr(9) +l 0 58 Acronyms $chr(9) +l 0 78 Control Codes
    var %x = 1, %y
    while (%x <= $hget(acroschan,0).item) {
      %y = $hget(acroschan,%x).item
      xdid -a $dname 7 0 0 + 0 0 0 0 -1 -1 %y $chr(9) + 0 $iif($gettok($hget(acroschan,%y),1,32) == 1,No,Yes) $chr(9) + 0 $iif($gettok($hget(acroschan,%y),2,32) == 1,No,Yes)
      inc %x
    }
    if (%acros.settings) did -c $dname $v1
    else {
      did -c $dname 11,15,16
      set %acros.settings 11,15,16
    }
  }
  elseif ($devent == edit) && ($did == 2) did $iif($numtok($did(2),32) == 1,-e,-b) $dname 5
  elseif ($devent == sclick) {
    if ($istok(9 10 11 13 14 15 16,$did,32)) {
      set %acros.settings
      var %x = 9 10 11 13 14 15 16, %y = 1
      while (%y <= 7) {
        if ($did($gettok(%x,%y,32)).state) set %acros.settings $addtok(%acros.settings,$gettok(%x,%y,32),44)
        inc %y
      }
    }
    elseif ($did == 5) {
      if ($numtok($did(2),32) == 1) {
        hadd -m acroschan $did(2) $did(3).state $did(4).state
        if ($xdid($dname,7,$+($chr(9),$did(2),$chr(9)),W,0,1).find) xdid -d $dname 7 $gettok($v1,1,32)
        xdid -u $dname 7
        xdid -a $dname 7 0 0 +s 0 0 0 0 -1 -1 $did(2) $chr(9) + 0 $iif($did(3).state,No,Yes) $chr(9) + 0 $iif($did(4).state,No,Yes)
        xdid -F $dname 7
        did -e $dname 6
      }
      elseif ($v1 > 1) noop $input(Channel has to be 1 word!,o,Error!)
      else noop $input(Not enough information inputed!,o,Error!)
    }
    elseif ($did == 6) && ($xdid($dname,7).selnum) {
      var %x = $v1
      while (%x) {
        hdel acroschan $xdid($dname,7,0).seltext
        xdid -d $dname 7 $gettok($xdid($dname,7).sel,1,44)
        dec %x
      }
      did -b $dname 6
    }
  }
}
alias acroschan_cb {
  if ($1 $3 == acroschan 7) && ($istok(sclick rclick begindrag,$2,32)) {
    did $iif($xdid($1,7).selnum,-e,-b) $1 5,6
    did -o $1 2 1 $xdid($1,7,0).seltext
    did $iif($xdid($1,7,1).seltext == No,-c,-u) $1 3
    did $iif($xdid($1,7,2).seltext == No,-c,-u) $1 4
  }
}
menu status,channel,menubar,query {
  -
  Acronym Manager:/acros
  -
}
dialog acros {
  title "Acronym Manager [/acros]"
  size -1 -1 126 106
  option dbu
  edit "", 1, 2 13 32 10, autohs
  edit "", 2, 37 13 50 10, autohs
  text "Acronym", 4, 7 4 22 8
  text "Long Form", 5, 49 4 25 8
  button "Add", 6, 91 13 32 10, disable
  check "Enable Acronyms", 7, 2 83 52 10
  check "Enable Tabbing", 12, 2 93 50 10
  button "Edit", 8, 59 83 32 10, disable
  button "Delete", 9, 91 83 32 10, disable
  button "Preview", 10, 59 93 32 10
  button "Channels", 11, 91 93 32 10
}
on *:DIALOG:acros:*:*: {
  if ($devent == init) {
    dcx Mark $dname acros_cb
    xdialog -b $dname +mntyz
    xdialog -c $dname 3 listview 5 54 241 105 fullrow report tooltip showsel nolabelwrap tabstop sortasc
    xdid -t $dname 3 +l 0 55 Acronym $chr(9) +l 0 166 Long Form
    var %x = 1, %y
    while (%x <= $hget(acros,0).item) {
      %y = $hget(acros,%x).item
      xdid -a $dname 3 0 0 + 0 0 0 0 -1 -1 %y $chr(9) + 0 $hget(acros,%y)
      inc %x
    }
    if ($group(#acros) == on) did -c $dname 7
    if ($group(#acrostab) == on) did -c $dname 12
  }
  elseif ($devent == edit) && ($istok(1 2,$did,32)) did $iif($numtok($did(1),32) == 1 && $did(2) != $null,-e,-b) $dname 6
  elseif ($devent == sclick) {
    if ($did == 6) {
      if ($did(1) != $null) && ($did(2) != $null) {
        if (!$hget(acros,$did(1))) && ($numtok($did(1),32) == 1) {
          hadd -m acros $did(1) $did(2)
          xdid -u $dname 3
          xdid -a $dname 3 0 0 +s 0 0 0 0 -1 -1 $did(1) $chr(9) + 0 $did(2)
          xdid -F $dname 3
          did -r $dname 1,2
          did -e $dname 8,9
        }
        elseif ($numtok($did(1),32) > 1) noop $input(Acronym has to be 1 word!,o,Error!)
        else noop $input(Acronym already exists!,o,Error!)
      }
      else noop $input(Not enough information inputed!,o,Error!)
    }
    elseif ($did == 7) $iif($did(7).state,.enable,.disable) #acros
    elseif ($did == 8) {
      if ($dialog(acrosedit)) dialog -v acrosedit
      else {
        set %acros.acro $xdid($dname,3,0).seltext
        set %acros.long $xdid($dname,3,1).seltext
        dialog -m acrosedit acrosedit
      }
    }
    elseif ($did == 9) && ($xdid($dname,3).selnum) {
      var %x = $v1
      while (%x) {
        hdel acros $xdid($dname,3,0).seltext
        xdid -d $dname 3 $gettok($xdid($dname,3).sel,1,44)
        dec %x
      }
      did -b $dname 8,9
    }
    elseif ($did == 10) {
      if ($window($win)) window -c $win
      window -aCdf $win 0 0 400 300
      var %x = 1, %y
      while (%x <= $hget(acros,0).item) {
        %y = $hget(acros,%x).item
        echo $win %y $chr(9) $hget(acros,%y)
        inc %x
      }
      filter -wwctu 1 32 $win $win *
      iline $win 1 Acronym $chr(9) Long Form
    }
    elseif ($did == 11) dialog $iif($dialog(acroschan),-v,-m acroschan) acroschan
    elseif ($did == 12) $iif($did(12).state,.enable,.disable) #acrostab
  }
}
alias acros_cb {
  if ($1 $3 == acros 3) {
    if ($istok(sclick rclick begindrag,$2,32)) did $iif($xdid($1,3).selnum,-e,-b) $1 8,9
    elseif ($2 == dclick) && ($xdid($1,3).selnum) {
      if ($dialog(acrosedit)) dialog -v acrosedit
      else {
        set %acros.acro $xdid($1,3,0).seltext
        set %acros.long $xdid($1,3,1).seltext
        dialog -m acrosedit acrosedit
      }
    }
  }
}
#acrostab off
on *:TABCOMP:*: {
  if ($istok(channel chat fserve query,$window($active).type,32)) && ($gettok($editbox($active),1-,32) === $1-) {
    if (!%acros.settings) set %acros.settings 11,15,16
    var %x = $editbox($active).selstart, %y, %z, %s
    if ($mid($editbox($active),%x,1) == $chr(32)) || ($v1 == $null) {
      %y = $left($editbox($active),$calc(%x - 1))
      if ($hget(acros,$gettok(%y,-1,32)) != $null) {
        %z = $v1
        %s = $calc($len($deltok(%y,-1,32) %z) + 1)
        editbox $+(-a,$iif($right($editbox($active),1) == $chr(32),p),b,%s,e,%s) $puttok($editbox($active),$iif(($active ischan) && ((($istok(%acros.settings,16,44)) && (c isincs $chan(#).mode)) || (($gettok($hget(acroschan,#),2,32) == 1) && (!$istok(%acros.settings,13,44))) || ((!$hget(acroschan,#)) && ($istok(%acros.settings,14,44)))),$strip(%z),%z),$numtok(%y,32),32)
        halt
      }
    }
    else {
      %y = $right($editbox($active),- $+ $calc(%x - 1))
      var %a = $numtok($editbox($active),32), %b = $numtok(%y,32)
      if ($hget(acros,$gettok($editbox($active),- $+ %b,32)) != $null) {
        %z = $v1
        %s = $calc($len($deltok($editbox($active),$+($calc(%a - %b + 1),-,%a),32) %z) + 1)
        editbox $+(-a,$iif($right($editbox($active),1) == $chr(32),p),b,%s,e,%s) $puttok($editbox($active),$iif(($active ischan) && ((($istok(%acros.settings,16,44)) && (c isincs $chan(#).mode)) || (($gettok($hget(acroschan,#),2,32) == 1) && (!$istok(%acros.settings,13,44))) || ((!$hget(acroschan,#)) && ($istok(%acros.settings,14,44)))),$strip(%z),%z),$calc(%a - %b + 1),32)
        halt
      }
    }
  }
}
#acrostab end
#acros off
on *:INPUT:*: {
  if (!%acros.settings) set %acros.settings 11,15,16
  if (!$istok(/ $readini(mirc.ini,text,commandchar),$left($1,1),32)) && ($istok(channel chat fserve query,$window($active).type,32)) && ($status == connected) && (!$ctrlenter) && (!$inpaste) && (($istok(%acros.settings,9,44)) || (($istok(%acros.settings,10,44)) && ($gettok($hget(acroschan,#),1,32) == 0)) || (($istok(%acros.settings,11,44)) && ($gettok($hget(acroschan,#),1,32) != 1))) {
    var %x
    while ($0) {
      set -ln %x %x $iif($hget(acros,$1),$v1,$1)
      tokenize 32 $2-
    }
    if ($active ischan) && ((($istok(%acros.settings,16,44)) && (c isincs $chan(#).mode)) || (($gettok($hget(acroschan,#),2,32) == 1) && (!$istok(%acros.settings,13,44))) || ((!$hget(acroschan,#)) && ($istok(%acros.settings,14,44)))) say $strip(%x)
    else say %x
    halt
  }
}
#acros end