it's not pretty but it works :tongue:

Code:
alias ex1 {
  window -c @ex1
  window -el20 @ex1
  var %i = 1
  while (%i <= 100) {
    var %line, %j = 100
    while (%j) { var %line = $+(%line,$chr(3),$calc(%j % 16) %i) | dec %j }
    aline $iif($r(0,1),-p) @ex1 Line %i ----- %line
    iline -l @ex1 1 Line %i
    inc %i
  }
}
menu @ex1 {
  lbclick : { 
    ;sline -l $active $1
    var %num = $calc(($line($active,0) + 1) - $1) ,  %rev = $chr(22), %lastsel = $fline($active,$+(%rev,*),1,0))
    echo -s as %lastsel as %num
    if (%lastsel) rline $active %lastsel $mid($line($active,%lastsel,0),2) 
    rline $active %num $+(%rev,$line($active,%num))
    ;sline $active $line($active,0,0)
    selectmiddleline %num $active
  }
}
alias selectmiddleline { 
  var %h = $window($2).dh , %x = $1 , %lineheight , %total = 0 , %wanted = $calc(%h / 2), $&
    %wf = $window($2).font , %wfs = $window($2).fontsize , %w = $window($2).dw
  while ($line($2,%x)) { 
    %lineheight = $wrap($line($2,%x), %wf, %wfs,%w,0) * %wfs
    inc %total %lineheight
    if (%total > %wanted) { sline -a $2 %x | return }
    inc %x
  }
  sline -a $2 $line($2,0)
}


there seems to be a small latency in centering though.

EDIT: I tried cleaning it up a bit to see if that was the problem but it wasn't, you can use the original lbclick and selectmiddleline %num $active at the bottom.

Last edited by Mpdreamz; 19/07/06 05:38 PM.

$maybe