aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / help.mrc

help.mrc — 6 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Help System
; *
; **********************************************************************/

alias _airchelp {
  var %d = airchelp,%l,%search = 0,%w
  tokenize 32 $1-
  _dialog -m %d %d
  if ($1- != $null) {
    if (/* iswm $1-) {
      %w = $right($1-,-1)
      %l = $didwm(%d,1203,%w,1)
      if ($did(%d,1203,%l) == %w) { did -c %d 1002,1203 %l }
      else { %search = 1 }
    }
    else {
      %w = $1-
      if ($istok(about faq installing upgrading,%w,32)) { %w = - %w }
      %l = $didwm(%d,1103,%w,1)
      if ($did(%d,1103,%l) == %w) { did -c %d 1001,1103 %l }
      else {
        %l = $didwm(%d,1203,%w,1)
        if ($did(%d,1203,%l) == %w) { did -c %d 1002,1203 %l }
        else { %search = 1 }
      }
    }
    if (%search) {
      did -c %d 1003
      did -o %d 1301 1 $1-
      _airchelp.dialogsearch
    }
  }
  _helpdialog.dialogrefresh
}
dialog airchelp {
  size -1 -1 320 190
  title "Help!"
  option dbu

  tab "Index",1001,5 3 95 160
  tab "Commands",1002
  tab "Search",1003

  list 1103,10 25 85 140,tab 1001 sort
  list 1104,10 25 85 140,tab 1001 sort hide

  list 1203,10 25 85 140,tab 1002 sort
  list 1204,10 25 85 140,tab 1002 sort hide

  edit "",1301,10 25 64 10,tab 1003 autohs
  button "Search",1302,75 25 20 10,tab 1003
  list 1303,10 38 85 130,tab 1003 sort hide
  list 1304,10 38 85 130,tab 1003 sort hide
  text "",1305,10 38 85 120,tab 1003 hide

  edit "",1501,105 15 210 150,multi autovs vsbar read

  button "&Close",2991,150 170 35 15,cancel
}
ON *:DIALOG:airchelp:init:0:{
  _mdx.init $_icofile(help.ico)
  _mdx.SetFont $dname 1501 + 10 400 Lucida Console
  _airchelp.dialoginit
_dummy $_lang.loaddialog($dname,_airchelp,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:airchelp:sclick:1103,1203,1303,:{ .timer_HELPSELECTITEM -mo 1 50 _helpdialog.dialogrefresh }
ON *:DIALOG:airchelp:sclick:1001,1002,1003:{ .timer_HELPSELECTITEM -mo 1 50 _helpdialog.dialogrefresh }
ON *:DIALOG:airchelp:sclick:1302:{ _airchelp.dialogsearch }
ON *:DIALOG:airchelp:sclick:2991:{ _unloadhelpmrc }

alias -l _mainhelpfile { return etc/help/main.help }
alias -l _comshelpfile { return etc/help/coms.help }
alias -l _helpdialog.dialogrefresh {
  var %d = airchelp,%line,%ran,%id1,%id2,%sel,%file,%topic,%fline
  if ($dialog(%d)) {
    did -r %d 1501
    if ($dialog(%d).tab == 1001) { var %id1 = 1103,%id2 = 1104 }
    elseif ($dialog(%d).tab == 1002) { var %id1 = 1203,%id2 = 1204 }
    elseif ($did(%d,1303).lines) {
      did -v %d 1303
      var %id1 = 1303,%id2 = 1304
    }
    else { return }

    %sel = $did(%d,%id1,1).sel
    if (%sel == $null) && ($did(%d,%id1).lines) {
      %sel = 1
      did -c %d %id1 1
    }
    %ran = $calc($numtok($did(%d,%id1,%sel),32) + 1) $+ -
    %line = $gettok($did(%d,%id2,%sel),%ran,32)
    %topic = $gettok(%line,2,32)
    %fline = $gettok(%line,3,32)
    %file = $gettok(%line,4-,32)
    if (%line != $null) && ($isfile(%file)) && ($ini(%file,%topic)) {
      did -o %d 1501 1 $cr
      loadbuf -ot $+ %topic %d 1501 %file
      did -z %d 1501
      if (%fline > 15) {
        did -c %d 1501 $did(%d,1501).lines
        did -c %d 1501 %fline
      }
    }
  }
}
alias _airchelp.comaddonfile { return $_chfile($_tmpdir(c_addons.help)) }
alias -l _airchelp.dialoginit {
  _airchelp.helpfilesloop _airchelp.dialogfileinit
  did -c $dname 1103,1203 1
}
alias -l _airchelp.dialogfileinit {
  var %d = airchelp,%file = $1-,%i = 1,%n = $ini(%file,0),%topic,%replace,%id1,%id2
  while (%i <= %n) {
    var %id1,%id2,%topic = $ini(%file,%i)
    if (help_/?* iswm %topic) { var %id1 = 1203,%id2 = 1204 }
    elseif (help_?* iswm %topic) { var %id1 = 1103,%id2 = 1104 }
    if (%id1 != $null) {
      %replace = $replace($gettok(%topic,2-,95),\_,$chr(1),_,$chr(32),$chr(1),_)
      if (%id1 == 1203) && (/* iswm %replace) { %replace = $right(%replace,-1) }
      if (%replace != $null) {
        did -a %d %id1 %replace
        did -a %d %id2 %replace - %topic 0 %file
      }
    }
    inc %i
  }
}
alias -l _airchelp.dialogsearch {
  var %d = airchelp,%line,%search
  if ($dialog(%d) == $null) { return }
  %search = $did(%d,1301)
  did -rh %d 1303,1304
  if (%search != $null) && ($len($remove(%search,*,?,$chr(32))) >= 3) {
    did -ov %d 1305 1 Searching...
    %~helpdialogsearch = %search
    _airchelp.helpfilesloop _airchelp.dialogfilesearch
    unset %~helpdialogsearch
    if ($did(%d,1303).lines) {
      did -v %d 1303
      did -rh %d 1305
    }
    else {
      did -h %d 1303
      did -ov %d 1305 1 No matches: %search
    }
  }
  else { did -ov %d 1305 1 Please use at least 3 characters }
  _helpdialog.dialogrefresh
}
alias -l _airchelp.dialogfilesearch {
  var %d = airchelp,%file = $1-,%search = * $+ %~helpdialogsearch $+ *,%win = @__helpdialogsearch,%i = 1,%n,%topic,%tmpread,%foundline,%replace
  %tmpread = $read -nw" $+ %search $+ " " $+ %file $+ "
  if (%tmpread != $null) {
    _openwins %win
    %n = $ini(%file,0)
    while (%i <= %n) {
      %topic = $ini(%file,%i)
      if (help_?* iswm %topic) {
        clear %win
        loadbuf -t $+ %topic %win " $+ %file $+ "
        if ($fline(%win,%search,1)) {
          %foundline = $ifmatch
          %replace = $gettok(%topic,2-,95)
          if (/* !iswm %replace) { %replace = $replace(%replace,_,$chr(32)) }
          if (%replace != $null) {
            did -a %d 1303 %replace
            did -a %d 1304 %replace - %topic %foundline %file
          }
        }
      }
      inc %i
    }
    close -@ %win
  }
}
alias -l _airchelp.helpfilesloop {
  var %file,%helpfiles = $_mainhelpfile $+ * $+ $_comshelpfile,%x = 1,%y
  if ($_getsetup(help,helpfiles) != $null) { %helpfiles = %helpfiles $+ * $+ $ifmatch }
  %y = $numtok(%helpfiles,$asc(*))
  while (%x <= %y) {
    %file = $gettok(%helpfiles,%x,$asc(*))
    if ($isfile(%file)) { $1- %file }
    inc %x
  }
}


alias -l _unloadhelpmrc { _quickunload airchelp $script }