how to center a specific line in a custom window? - 19/07/06 06:48 AM
Ok I wrote some code to illistrate what i want, the true code has less lines in the mainwindow than listbox lines (multiple listbox lines map to one line in the mainwindow, how i do this isnt really important for what i need tho)
The mainwindow has some lines that are wrapped and some that are not, any line might be or might not be. In my example I have simply randomized them.
They are liekly to be mostly one way or the other, but could potentially be mixed.
OK what im after is to get the mainwindow highlighted line vertically centered in the window, rather than near the bottom like the code does currently
I would like it to work fullscreen and windowed, i not concerned if it goes crappy if someone makes the window so small the line cant be shown, thats just being annoying
Any help anyone?
PS: If all the lines are not wrapped the code was pretty simple...
//sline $active $calc(%num + ($window($active).dh / ($height([],$window($active).font,$window($active).fontsize) + 1) / 2 ))
The mainwindow has some lines that are wrapped and some that are not, any line might be or might not be. In my example I have simply randomized them.
They are liekly to be mostly one way or the other, but could potentially be mixed.
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 : { ///echo -st LBCLICK $active : $1- : $line($active,$1,1) sline -l $active $1 ;^ activate the select the listbox line ; var %num = $gettok($line($active,$1,1),2,32) ;^ get the correct mainwindow linenumber (true code this is more complexe but results the same with %num being the line) ; var %rev = $chr(22) while ($fline($active,$+(%rev,*),1,0)) { rline $active $v1 $mid($line($active,$v1,0),2) } ;^ this removes any and all highlighted (reversed) lines in the mainwindow ; rline $active %num $+(%rev,$line($active,%num,0)) ;^ highlight (reverse) the selected line in the mainwindow ; sline $active $line($active,0,0) ;^ This line is a patch to make the following line work correctly each time ; sline $active $calc(%num + 1) ;^ This line selects the line following the highlighted line, thus makes the highlighted line appear near the bottom of the mainwindow ; } }
OK what im after is to get the mainwindow highlighted line vertically centered in the window, rather than near the bottom like the code does currently
I would like it to work fullscreen and windowed, i not concerned if it goes crappy if someone makes the window so small the line cant be shown, thats just being annoying
Any help anyone?
PS: If all the lines are not wrapped the code was pretty simple...
//sline $active $calc(%num + ($window($active).dh / ($height([],$window($active).font,$window($active).fontsize) + 1) / 2 ))