/*
$history() by jaytea
returns information about a specific window's editboxes' history
$history(name/@wid,n,c).prop
properties: ctrlenter, inpaste
name is either the window name or window ID
n refers to the nth line in the history of the editbox, n = 0 is the total
c is an optional parameter, if c = 1 it looks at the command editbox
the 'ctrlenter' prop returns $true or $false depending on whether the line
was input with the control key held. with n = 0 it returns the total number
of lines that were input with control held. the other 'inpaste' prop obviously
works in a similar manner
n can also be a negative number, n = 1 is the oldest line and n = -1 is the
most recently input line
note that this only captures lines you press enter for, it doesn't intercept
lines that were typed but were not deleted and not input (even though mirc
still keeps those in the internal history). also, leading/trailing and
duplicate spaces are removed when adding to the hidden window, so clearly
the alias won't return them as they were originally input
*/
on *:input:*:{
var %max = 50 | ; max number of lines to store per editbox
var %x = @editboxhistory
if (!$window(%x)) window -lh %x
elseif ($fline(%x,$+(/^,$wid \,$cmdbox \S+ \S+ \Q,$replacecs($1-,\E,\E\\E\Q),\E$/),1,2)) dline %x $v1
elseif ($fline(%x,$wid $cmdbox *,0) == %max) dline %x $fline(%x,$wid $cmdbox *,1)
aline %x $wid $cmdbox $inpaste $ctrlenter $1-
}
alias history {
var %wid = $window($iif($1 isnum,@ $+ $1,$1)).wid
if (%wid) {
if ($regex($2,/^-?\d+$/)) && ($0 < 4) {
var %cmd = $istok(1,$3,1), $&
%x = @editboxhistory
if ($2) {
tokenize 32 $line(%x,$fline(%x,%wid %cmd *,$iif($2 < 0,$iif($calc(1 + $fline(%x,%wid %cmd *,0) + $2) > 0,$v1),$2)))
return $iif($prop == inpaste,$3,$iif($prop == ctrlenter,$4,$5-))
}
return $fline(%x,%wid %cmd $iif($prop == inpaste,$true *,$iif($prop == ctrlenter,& $true *,*)),0)
}
echo -eac i * Invalid parameters: $!history
}
else echo -eac i * $!history: invalid window
}