mIRC Homepage
Posted By: Talon window editbox history - 15/11/06 08:42 AM
I think it would be cool to have like $editbox(window,0/1,0-x) the 0,1 is obviously 1st or second editbox, and the 0-x is 0 for total lines in memory, and 1+ would return that saved line, when you press up the previous lines up to an extent are there, so a way to access that history via script would be very practical. especially if it worked at returning like $cb, because you can modify stuff in the clipboard to preserve multiple spaces, like add a regsubex to look for multiple spaces and put a ctrl+o in between multiples so even a replacement text event preserves spaces. I dont use a text replacement method because of mulitiple space problems.. reading/pasting, it looks bad.
Posted By: Sais Re: window editbox history - 15/11/06 09:50 AM
The only comment I'd make would be to change the parameter order:

$editbox(window,N,E)

Where E (the editbox number) is optional, and defaults to 0.
Posted By: DaveC Re: window editbox history - 15/11/06 06:50 PM
agreed this would be nice, but with your adjustment, editbox number should (must) be last!
Posted By: Sais Re: window editbox history - 15/11/06 09:10 PM
That's partly why I made the change. Plus it would fit with the style of other commands of the same ilk.
Posted By: DaveC Re: window editbox history - 16/11/06 12:49 AM
i think there is some method to access the editbox history actually, or maybe im amagining that, errr actually maybe it was you can load the history up with stuff, but what ever it was it was convoluted using timers and sendkeys and stuff.
Posted By: Osah Re: window editbox history - 16/11/06 03:27 PM
Code:
/*

$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
} 
Posted By: jaytea Re: window editbox history - 16/11/06 05:29 PM
yep, i posted that inspired by talon's suggestion laugh
Posted By: b1ink Re: window editbox history - 16/11/06 06:08 PM
no $regsubex included?! :tongue: (nice code)
© mIRC Discussion Forums