; FKeys Config
; By: PeeTeR <PeeTeR@Cia.Hu>
;
; /fkeys

alias -l error echo $colour(info) -at ::: $1-
alias -l d if (!$1) return | elseif (!$dialog($1)) dialog -m $1 $1
alias -l cfg .writeini -n $scriptdirconfig.ini $$1 $$2 $3-
alias -l _cfg return $readini $scriptdirconfig.ini $$1 $$2
alias -l configini return $scriptdirconfig.ini
alias -l mdx if ($lock(dll)) return | if ($isid) return $dll($mdx.udll,$1,$iif($2- != $null,$2-,.)) | dll $shortfn($mdx.udll) $1-
alias -l mdx.udll return $scriptdirmdx.dll
alias -l mdx.vdll return $scriptdirviews.mdx
alias -l popup.dll return $scriptdirpopups.dll
alias -l mdx.set mdx SetDialog $dname $1-
alias -l headersizes did -i $dname $1 1 header $2-
alias -l new.popup dll $popup.dll New $1-
alias -l popup.destroy dll $popup.dll Destroy $$1
alias -l popup.newitem dll $popup.dll AddItem $1 end $2-
alias -l popup tokenize 32 $dll($popup.dll,Popup,$1-) | if ($isid) return $1- | $iif($4- != did not select a menu item,$4-)
alias -l mdx.start mdx MarkDialog $dname | mdx SetMircVersion $version | var %a = 1,%x = 0 | while (%a <= 205) { var %b = $dll($mdx.udll,SetFont,$dname %a + 13 400 Tahoma) | if (ERROR isin %b) { inc %x } | if (%x == 6) { break } | inc %a }
alias -l tab if ($1- == $null) return $chr(9) | var %list | var %a = 1 | while ( $ [ $+ [ %a ] ] != $null ) { set %list $instok(%list, $ [ $+ [ %a ] ] ,0,9) | inc %a } | return %list

alias F1 $iif($_cfg(fkeys,F1),$_cfg(fkeys,F1),error No Command Set For 'F1'. Type /fkeys To Configure)
alias F2 $iif($_cfg(fkeys,F2),$_cfg(fkeys,F2),error No Command Set For 'F2'. Type /fkeys To Configure)
alias F3 $iif($_cfg(fkeys,F3),$_cfg(fkeys,F3),error No Command Set For 'F3'. Type /fkeys To Configure)
alias F4 $iif($_cfg(fkeys,F4),$_cfg(fkeys,F4),error No Command Set For 'F4'. Type /fkeys To Configure)
alias F5 $iif($_cfg(fkeys,F5),$_cfg(fkeys,F5),error No Command Set For 'F5'. Type /fkeys To Configure)
alias F6 $iif($_cfg(fkeys,F6),$_cfg(fkeys,F6),error No Command Set For 'F6'. Type /fkeys To Configure)
alias F7 $iif($_cfg(fkeys,F7),$_cfg(fkeys,F7),error No Command Set For 'F7'. Type /fkeys To Configure)
alias F8 $iif($_cfg(fkeys,F8),$_cfg(fkeys,F8),error No Command Set For 'F8'. Type /fkeys To Configure)
alias F9 $iif($_cfg(fkeys,F9),$_cfg(fkeys,F9),error No Command Set For 'F9'. Type /fkeys To Configure)
alias F10 $iif($_cfg(fkeys,F10),$_cfg(fkeys,F10),error No Command Set For 'F10'. Type /fkeys To Configure)
alias F11 $iif($_cfg(fkeys,F11),$_cfg(fkeys,F11),error No Command Set For 'F11'. Type /fkeys To Configure)
alias F12 $iif($_cfg(fkeys,F12),$_cfg(fkeys,F12),error No Command Set For 'F12'. Type /fkeys To Configure)
alias cF1 $iif($_cfg(fkeys,cF1),$_cfg(fkeys,cF1),error No Command Set For 'cF1'. Type /fkeys To Configure)
alias cF2 $iif($_cfg(fkeys,cF2),$_cfg(fkeys,cF2),error No Command Set For 'cF2'. Type /fkeys To Configure)
alias cF3 $iif($_cfg(fkeys,cF3),$_cfg(fkeys,cF3),error No Command Set For 'cF3'. Type /fkeys To Configure)
alias cF4 $iif($_cfg(fkeys,cF4),$_cfg(fkeys,cF4),error No Command Set For 'cF4'. Type /fkeys To Configure)
alias cF5 $iif($_cfg(fkeys,cF5),$_cfg(fkeys,cF5),error No Command Set For 'cF5'. Type /fkeys To Configure)
alias cF6 $iif($_cfg(fkeys,cF6),$_cfg(fkeys,cF6),error No Command Set For 'cF6'. Type /fkeys To Configure)
alias cF7 $iif($_cfg(fkeys,cF7),$_cfg(fkeys,cF7),error No Command Set For 'cF7'. Type /fkeys To Configure)
alias cF8 $iif($_cfg(fkeys,cF8),$_cfg(fkeys,cF8),error No Command Set For 'cF8'. Type /fkeys To Configure)
alias cF9 $iif($_cfg(fkeys,cF9),$_cfg(fkeys,cF9),error No Command Set For 'cF9'. Type /fkeys To Configure)
alias cF10 $iif($_cfg(fkeys,cF10),$_cfg(fkeys,cF10),error No Command Set For 'cF10'. Type /fkeys To Configure)
alias cF11 $iif($_cfg(fkeys,cF11),$_cfg(fkeys,cF11),error No Command Set For 'cF11'. Type /fkeys To Configure)
alias cF12 $iif($_cfg(fkeys,cF12),$_cfg(fkeys,cF12),error No Command Set For 'cF12'. Type /fkeys To Configure)
alias sF1 $iif($_cfg(fkeys,sF1),$_cfg(fkeys,sF1),error No Command Set For 'sF1'. Type /fkeys To Configure)
alias sF2 $iif($_cfg(fkeys,sF2),$_cfg(fkeys,sF2),error No Command Set For 'sF2'. Type /fkeys To Configure)
alias sF3 $iif($_cfg(fkeys,sF3),$_cfg(fkeys,sF3),error No Command Set For 'sF3'. Type /fkeys To Configure)
alias sF4 $iif($_cfg(fkeys,sF4),$_cfg(fkeys,sF4),error No Command Set For 'sF4'. Type /fkeys To Configure)
alias sF5 $iif($_cfg(fkeys,sF5),$_cfg(fkeys,sF5),error No Command Set For 'sF5'. Type /fkeys To Configure)
alias sF6 $iif($_cfg(fkeys,sF6),$_cfg(fkeys,sF6),error No Command Set For 'sF6'. Type /fkeys To Configure)
alias sF7 $iif($_cfg(fkeys,sF7),$_cfg(fkeys,sF7),error No Command Set For 'sF7'. Type /fkeys To Configure)
alias sF8 $iif($_cfg(fkeys,sF8),$_cfg(fkeys,sF8),error No Command Set For 'sF8'. Type /fkeys To Configure)
alias sF9 $iif($_cfg(fkeys,sF9),$_cfg(fkeys,sF9),error No Command Set For 'sF9'. Type /fkeys To Configure)
alias sF10 $iif($_cfg(fkeys,sF10),$_cfg(fkeys,sF10),error No Command Set For 'sF10'. Type /fkeys To Configure)
alias sF11 $iif($_cfg(fkeys,sF11),$_cfg(fkeys,sF11),error No Command Set For 'sF11'. Type /fkeys To Configure)
alias sF12 $iif($_cfg(fkeys,sF12),$_cfg(fkeys,sF12),error No Command Set For 'sF12'. Type /fkeys To Configure)
alias check.fkeys did -r fkeys 1 | var %a = 1,%b = 1,%c = 1 | while %a <= 12 { did -a fkeys 1 $tab(F $+ %a,$iif($readini($configini,fkeys,F $+ %a),$readini($configini,fkeys,F $+ %a))) | inc %a } | while %b <= 12 { did -a fkeys 1 $tab(cF $+ %b,$iif($readini($configini,fkeys,cF $+ %b),$readini($configini,fkeys,cF $+ %b))) | inc %b } | while %c <= 12 { did -a fkeys 1 $tab(sF $+ %c,$iif($readini($configini,fkeys,sF $+ %c),$readini($configini,fkeys,sF $+ %c))) | inc %c }
alias add.fkey var %a = $$?="New Command For $right($gettok($did(1).seltext,1,9),-4) $+ ?" | if (%a) { cfg fkeys $right($gettok($did(1).seltext,1,9),-4) %a } | check.fkeys
alias rem.fkey var %a = $gettok($gettok($did($dname,1).seltext,1,3),5-,32) | cfg fkeys $right($gettok($did(1).seltext,1,9),-4) "" | check.fkeys
alias edit.fkey var %a = $gettok($gettok($did($dname,1).seltext,1,3),4-,32) | did -ra $dname 2 %a | did -v $dname 6 | var %d 1 | while (%d <= 20) { dialog -s fkeys $dialog(fkeys).x $dialog(fkeys).y 280 $calc(234 + %d * 2.4) | inc %d }
alias clear.fkeys var %a = 1 | while %a < 13 { cfg fkeys F $+ %a "" | cfg fkeys cF $+ %a "" | cfg fkeys sF $+ %a "" | inc %a } | check.fkeys
alias fkeys d fkeys
alias fabout d about
dialog fkeys {
  title Function Keys Config
  size -1 -1 280 254
  list 1, 5 10 270 236, size
  edit ,2, 5 254 249 20, autohs
  button !, 3, 255 254 20 20
  button , 4, 0 0 0 0, cancel
  box  ,5, 2 0 276 250
  box  ,6, 2 242 276 37, hide
}
on *:dialog:fkeys:*:*:{
  if ($devent == init) {
    mdx.start | mdx.set icon $scriptdir01.ico
    var %a = $mdx(SetControlMDX,1 listview flatsb nosortheader rowselect grid showsel single headerdrag labeltip report > [ $mdx.vdll ] ), %a = $mdx(SetBorderStyle,3 clientedge) > [ $mdx.bdll ] )
    headersizes 1 @39,211 $tab(FKey, Commands) | check.fkeys
  }
  if ($devent == sclick) {
    if ($did == 1) {
      var %a = $gettok($gettok($did($dname,1).seltext,1,3),4-,32)
      if ($gettok($did($dname,1,1),1,32) != rclick) halt
      new.popup fkeys 0 8
      popup.newitem fkeys 1 1 Add $cr add.fkey
      if (%a) {
        popup.newitem fkeys 2 2 Remove $cr rem.fkey
        popup.newitem fkeys 3 3 Edit $cr edit.fkey
      }
      popup.newitem fkeys
      popup.newitem fkeys 3 3 Clear $cr clear.fkeys
      popup.newitem fkeys 4 4 Refresh $cr check.fkeys
      popup.newitem fkeys
      popup.newitem fkeys 5 5 About $cr fabout
      popup.newitem fkeys
      popup.newitem fkeys 6 6 Close $cr dialog -c $dname
      popup fkeys $mouse.dx $mouse.dy
    }
    if ($did == 3) {
      var %a 1 | while (%a <= 20) { dialog -s fkeys $dialog(fkeys).x $dialog(fkeys).y 280 $calc(206 + %a * 2.4) | inc %a }
      var %b 1 | var %c | while (%b <= $did($dname,1).lines) { var %c %c $did($dname,1, $+ %b $+ ) | inc %b }
      if (!$did(2)) { var %a = $gettok($gettok($did($dname,1).seltext,1,3),5-,32) | cfg fkeys $right($gettok($did(1).seltext,1,9),-4) "" | check.fkeys }
      else { var %a = $gettok($gettok($did($dname,1).seltext,1,3),5-,32) | cfg fkeys $right($gettok($did(1).seltext,1,9),-4) $did(2).text | did -h $dname 6 | check.fkeys }
    }
  }
}
dialog about {
  title About - FKeys Config
  size -1 -1 166 128
  button "Done",1, 112 100 50 23, ok
  box "" 2, 4 1 157 93
  box "" 3, 10 49 144 8
  icon 4,2 95 32 32, $scriptdir02.ico
  text mIRCŪ v5.91+ Addon,15,5 20 150 15, center
  text Author: PeeTeR (DALnet),16,5 35 150 15, center
  text E-Mail:,17,23 65 30 15, center
  link PeeTeR@Cia.Hu,18,58 65 88 15
}
on *:dialog:about:init:0:{ mdx.start | mdx.set icon $scriptdir02.ico | var %a = $mdx(SetBorderStyle,1 clientedge) > [ $mdx.bdll ] ) }
menu menubar {
  .-
  &fkeys config: fkeys
}
;EOF
