All pastes #35942 Raw Edit

Something

public text v1 · immutable
#35942 ·published 2006-01-06 01:58 UTC
rendered paste body
;  +-----------------------------+
;  | Custom Aliases              |
;  +-----------------------------+

dialog caliases {
  title "Custom Aliases"
  size -1 -1 243 148
  option dbu
  icon $_zicl, 3
  text "", 1, 3 3 235 13
  text "Custom Aliases", 2, 7 6 90 8
  text "", 3, 0 0 0 0, hide result
  list 4, 3 19 236 108, size extsel
  button "ok", 8, 161 133 37 12, default ok
  button "cancel", 9, 202 133 37 12, default cancel
  box "", 7, 3 126 236 4
  button "add", 5, 4 133 37 12, default
  button "edit", 6, 45 133 37 12, default
  button "delete", 11, 86 133 37 12, default
}

dialog caliasesedit {
  title ""
  size -1 -1 124 107
  option dbu
  icon $_zicl, 3
  text "", 1, 3 3 118 13
  text "Edit", 2, 7 6 90 8
  text "Alias Name:", 3, 7 24 30 8
  edit "", 4, 43 23 75 10, autohs limit 200
  text "Alias Action:", 5, 7 39 40 8
  edit "", 6, 43 38 75 39, multi return autovs
  check "Enabled ", 11, 7 78 33 10
  button "OK", 12, 44 92 37 12, default ok
  button "Cancel", 13, 83 92 37 12, cancel
  text "", 20, 0 0 0 0, hide result
}
alias caliases::open { dialog -m caliases caliases }
alias caliases::close { dialog -x caliases caliases }
on *:dialog:caliases:init:*: {
  _mdx::load $dname
  _mdx::button $dname 6,8,9,11
  _mdx::font $dname 4,5,6,7,8,9,11
  _mdx::font $dname 2 large bold
  _mdx::border $dname 1,4,5
  _mdx SetBorderStyle $dname 4 windowedge clientedge
  var %r = $rgb($rgb(face))
  var %r = $+($iif($calc($gettok(%r,1,44) + 20) > 255,255,$v1),$chr(44),$iif($calc($gettok(%r,2,44) + 20) > 255,255,$v1),$chr(44),$iif($calc($gettok(%r,3,44) + 20) > 255,255,$v1))
  _mdx SetColor $dname 1,2 background $rgb( [ %r ] )
  _mdx SetColor $dname 1,2 textbg $rgb( [ %r ] )
  _mdx SetControlMDX $dname 4 ListView report single rowselect autoarrange infotip nohscroll checkboxes grid showsel > $_mdxviews
  did -i $dname 4 1 headerdims 120:1 332:2 
  did -i $dname 4 1 headertext Alias Name $+ $chr(9) $+ Alias Action
  caliases::fill
}
on *:dialog:caliasesedit:init:*: {
  _mdx::load $dname
  _mdx::button $dname 12,13
  _mdx::font $dname 4,6,8,10,11,12,13
  _mdx::font $dname 3,5,7,9 default bold
  _mdx::font $dname 2 large bold

  var %r = $rgb($rgb(face))
  var %r = $+($calc($gettok(%r,1,44) + 20),$chr(44),$calc($gettok(%r,2,44) + 20),$chr(44),$calc($gettok(%r,3,44) + 20))
  _mdx SetColor $dname 1,2 background $rgb( [ %r ] )
  _mdx SetColor $dname 1,2 textbg $rgb( [ %r ] )
  _mdx::border $dname 1
  did -o $dname 2 1 $iif(%caliases == add,Add,Edit) Custom Alias | dialog -t $dname $iif(%caliases == add,Add,Edit) Custom Alias
  if (%caliases == edit) {
    did -a $dname 4 $gettok($gettok($did(caliases,4).seltext,1,9),6,32)
    did -m $dname 4
    did -f $dname 12
    did -a $dname 6 $gettok($gettok($did(caliases,4).seltext,2,9),5-,32)
    $iif($gettok($gettok($did(caliases,4).seltext,1,9),5,32) == 2,did -c $dname 11,$null)
  }
  unset %caliases
}
alias cini { return $sysdir(ZioX.ini) }
alias caliases::fill {
  var %d = $dialog(caliases) 
  if (%d) {
    did -r %d 4
    var %x = 1
    while (%x <= $ini($cini,CAliases,0)) {
      var %y = $readini($cini,n,CAliases,$ini($cini,CAliases,%x)),%i = $numtok(%y,32)
      did -a %d 4 1 0 0 $iif(-e- == $gettok(%y,1,32),2,0) $ini($cini,CAliases,%x) $chr(9) $iif(-e- == $gettok(%y,1,32),$gettok(%y,2-,32),$gettok(%y,1-,32))
      inc %x
    }
  }
}
on *:dialog:caliases:sclick:4:  {
  if ($gettok($did($dname,4,1).text,1,32) == stateclick) {
    var %page = $_mdx::page($dname,$did).event
    if ($gettok(%page,1,32) == stateclick) {
      var %x = $did($dname,4,$gettok(%page,3,32)).text
      var %name = $gettok($gettok(%x,1,9),6-,32), %action = $gettok($gettok(%x,2,9),5-,32)
      writeini $cini CAliases %name $iif($gettok(%x,5,32) == 1,-e-,$null) %action 
    }
  }
}

on *:dialog:caliases:sclick:5: {
  set %caliases add
  var %d = $dialog(caliasesedit,caliasesedit)
}
on *:dialog:caliases:sclick:6: {
  if ($did($dname,4).seltext) {
    set %caliases edit
    var %d = $dialog(caliasesedit,caliasesedit)
  }
}
on *:dialog:caliases:sclick:11: {
  if ($did($dname,4).seltext) {
    remini $cini CAliases $gettok($gettok($did(caliases,4).seltext,1,9),6,32)
    caliases::fill
  }
}
on *:dialog:caliasesedit:sclick:12: {
  if ($isalias($remove($didtok($dname,4,32),/)) == $true) { var %x = $input(This alias already exists as a part of mIRC or another custom alias.  Please choose another.,auow,Error) | did -r $dname 4,6 | did -f $dname 4 | halt }
  writeini $cini CAliases $remove($didtok($dname,4,32),/) $iif($did($dname,11).state == 1,-e-,$null) $didtok($dname,6,32)
  caliases::fill
}
on *:input:*: {
  if ($iscalias($1)) { $($ifmatch,2) | halt }   
}
alias iscalias {
  if (/* iswm $1) && ($isalias($remove($1,/)) == $false) && ($ismirc(/ $+ $remove($1,/)) == 0) && ($readini($cini,n,CAliases,$remove($1,/))) && ($gettok($readini($cini,n,CAliases,$remove($1,/)),1,32) == -e-) { return $gettok($readini($cini,n,CAliases,$remove($1,/)),2-,32) }
  else { return $null }
}
alias ismirc {
  ; Declare local variables for storing list of undocumented identifiers/commands
  var %f $+(",$findfile($mircdir,mirc.hlp,1),"),%r return,%e echo $color(i) -ea,%i $iif($!* iswm $1,1),%s $iif($!* iswm $&
    $1,identifier.,command.),%c $eval($remote $beta $nopnick $nvnick  $nhopnick $* $r $colour $nickmode $true $false $yes $no  $ok $&
    $cancel $hfile $lof $bits $evalnext $initopic $dir $auto $banlist $token  $rnick $mp3 $wavedir $mp3dir $mididir $addtokcs  $findtokcs $&
    $istokcs $matchtokcs $remtokcs $reptokcs $sorttokcs $wildtokcs  $getdir $inpaste $trust $! $? /xyzzy /colour /closemsg  /clearial $&
    /quote /auto /leave /registration /action /else /elseif  /setlayer /notice /username,0),%l %e ** $1 is a built in %s
  ; If it's an identifier such as $1-2 or an undocumented command/identifier then proceed
  if ((i* iswm %s) && ($regex($mid($1,2),^\d+-*\d*$))) || ($istok(%c $!&,$1,32)) { goto y }
  if (!$1) || (!$regex($1,^\$|/)) {
    %e Specify a command/identifier to search for $iif(!$1,(remember to use ! in identifiers to keep them from evaluating))
    %r
  }
  if (!%f) { %e Help file missing | %r }
  if ($version < 6.1) { %e mIRC version 6.1 or greater required.  | %r }
  ; Read the contents of the help file into a binary variable and search for the requested command/identifier within it
  bread %f 1 $lof(%f) &t
  var %p = $bfind(&t,1,$1)
  if (%p && !$bvar(&t,$calc(%p -1))) && (!$bvar(&t,$calc($len($1)+%p))) {
    :y
    if ($isid) { %r 1 }
    %l
    %r
  }
  ; Output results
  if ($isid) { %r 0 }
  $instok(%l,not,7,32)
}