;IRcap8 a440820dee8869177b2746f9b426d866

on 1:load: leelog %tmp.ss1

alias LEELOG {
  if (!$s(1)) { .hmake -s tool | .hload tool "lng\ $+ %idioma $+ \tool.lnh" }
  if (!$window(@logs)) { cvent 90 90 % | window -ekSl18 @LOGS %vent.x %vent.y %vent.w %vent.h @logs }
  var %i = 1 , %c , %s | clear -l @logs
  :L1
  var %n = $findfile($logdir,*.*,%i) | if (%n) {
    if ($1 == C) && ($left($nopath(%n),1) != $chr(35)) goto L3
    if ($1 == P) && ($chr(35) isin %n) goto L3
    aline -l @LOGS $nopath(%n) | inc %c | inc %s $file(%n).size
    :L3
    inc %i | goto L1
  }
  echo @logs $logo $mg(leelog,%c,$findfile($logdir,*.log,0))
  if ($1) sacalog $mklogfn($$1)
}

alias sacalog {
  clear @logs | var %a = " $+ $logdir $+ $$1 $+ " | if ($exists(%a)) loadbuf -p @LOGS %a
  titlebar @LOGS >>> $$1 ( $file(%a).size bytes, $lines(%a) l. )
  %log.actual = $$1
}

alias VEOLOG   {
  var %a = " $+ $logdir $+ $mklogfn($$1) $+ " | if !$exists(%a) { echo -se $logo $mg(nolog,$1) | sss fallo | .timer 1 1 .unload -rs g-leelog.mrc | return }
  leelog | sacalog $nopath($mklogfn($$1))
}

alias BORRALOGS {
  clear @logs
  :L1
  if $sline(@LOGS,1) == $null return
  remove -b " $+ $logdir $+ $sline(@LOGS,1) $+ "
  dline -l @LOGS $sline(@LOGS,1).ln
  goto L1
}

alias SUMALOGS {
  set %log.conf $?!=" $mg(unelog,$sline(@logs,1),%log.actual) "
  if %log.conf == $false { unset %log.conf | halt } | unset %log.conf
  loadbuf -p @LOGS " $+ $logdir $+ $sline(@logs,1) $+ "
  savebuf @LOGS " $+ $logdir $+ %log.actual $+ "
  remove -b " $+ $logdir $+ $sline(@logs,1) $+ "
  dline -l @LOGS $sline(@LOGS,1).ln
  sacalog %log.actual
}

alias BORRALOGTAM {
  var %i = 1
  :L1
  var %n = $findfile($logdir,*.*,%i) | if %n == $null { leelog | return }
  if ($$1 == C) {
    if ($chr(35) isin %n) { remove -b " $+ %n $+ " | %i = 1 | goto L1 }
    goto L2
  }
  if $file(%n).size < $$1 { remove -b " $+ %n $+ " | %i = 1 | goto L1 }
  :L2 | inc %i | goto L1
}

on 1:CLOSE:@LOGS: .timer 1 2 tolhfree | .unload -rs g-leelog.mrc

menu @logs {
  dclick { sacalog $sline(@logs,1) }
  $s(91): sacalog $sline(@logs,1)
  -
  $s(92): leelog  
  $s(93): leelog P
  $s(94): leelog C
  -
  $s(95): run notepad $logdir $+ $sline(@logs,1)
  -
  $s(96)
  .$s(97): borralogs
  .-
  .$s(98): borralogtam 3072
  .$s(99): var %log.ta = $$?=" $mg(log1) " | borralogtam $calc(%log.ta * 1024)
  .-
  .$s(100): borralogtam C
  -
  $s(101): sumalogs
  -
  $s(102): findtext $$?=" $mg(tbusc) "
}
alias -l S return $hget(tool,$1)

;EOF-dt
