On 4/7/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
>
> Is there a way to get full information about all the windows, i.e. whether a
> window is against the left/right/top/bottom side, or to the right of another
> window, etc.etc.?

I'd do it like this. I'd write 4 functions, GetWinOnRight, GetWinOnLeft,
GetWinAbove, GetWinBelow. Each function accepts window number, or
'.' for current window, and returns window number or -1.

Here's how I'd write GetWinOnRight: we try to do "wincmd l". If window
number does not change, we return -1 (we're in rightmost window). If
window number changed, we return its winnr().

function! GetWinOnRight(winnum) " untested
     let save_winnr = winnr()
     if winnum != '.'
        exe winnum."wincmd w"
     endif
     if winnr() != winnum
        return -1
     endif
     silent! "wincmd l"
     if  winnr() == winnum
         result = -1
     else
          result = winnr()
    endif
    "restore window
    exe save_winnr."wincmd w"
    return result
endfu

Other 3 functions are similar, only use "wincmd h", "wincmd j", and
"wincmd k". Applying those functions iteratively, you can discover
full relation of windows in relation to each other.

Yakov

Reply via email to