Loading ...
Sorry, an error occurred while loading the content.
 

Re: Vertical-Split GUI-window resize not intuitive...could _almost_ call it a bug.

Expand Messages
  • Andy Wokula
    ... The VimResized autocmd allows Vim scripts to handle the situation. ... As a start, here is an attempt to keep the position of vertical window bars on
    Message 1 of 9 , May 4, 2008
      Linda W schrieb:
      > Let me preface this by saying that I this is a minor "nit", and one
      > could probably argue its correctness based on artifactual behavior
      > based on how the windows are split and handled by the windowing
      > system, BUT, but on an intuitive, human level, it doesn't seem like
      > natural behavior. (though it may be the case that I have my head
      > buried especially deep in my paradigm and can't see a different forest
      > view for the trees :-) (it's always the darn trees! :-))).
      >
      > I split the screen vertically, and wanted to adjust each window to 80
      > columns. I started on the ->right-> and went to the _right_-frame on
      > the _right_ exterior of the _right_ window. I grabbed the frame and
      > moved it to the ->right->. The center-split (where the window was
      > vertically split) stayed stationery, while the _right_ edge of the
      > _right window_ moved away from the center-line (toward the right),
      > widening the right sub-window (screen split).
      >
      > When done with the right side I went to repeat the actions on the
      > <-left<- window, with left substituted, 'above' for all the 'right'
      > words.
      >
      > Except that it doesn't work that way.
      >
      > When I move the left-outer edge of the left window, 'left', instead of
      > moving the left edge away from the center line, the entire left window
      > shifts to the left -- not widening the left window as I desired and
      > would have reciprocally expected, but instead, having the effect of
      > widening the right window again!
      > ACK!
      >
      > Um...does this seem "natural"? Maybe from a computer "rule" of
      > "always resize the right-most window" when moving an outer, vertical
      > window border, but, that's a 'computer' rule perspective, not an
      > intuitive, human-interface perspective. It doesn't behave by
      > consistent rules with respect to the individual sub-windows. If I
      > move to a non-shared, outer edge of a sub-window, I'd feel it was more
      > 'natural' to have the window whose outer side I was moving be the
      > window that resizes -- not, always, the right-most window which seems
      > more. Always do the 'right' seems like an arbitrary behavior based on
      > how the underlying window system happened to work works and the
      > happenstance of how vim's sub-windows are built on top of the native
      > windowing system widgets.
      >
      > Am I being reasonably lucid and clear? :-) It's an "asymmetry" in how
      > the GUI works.
      >
      > Anyway, it's obviously not that big of a deal, but more a
      > design-'preference', like one might have a preference for some
      > symmetry in art or engineering design.
      >
      > Perhaps this behavior is controllable with some configuration setting,
      > or is this one of those hard-coded limitations like forgotten support
      > for setting 'very magic' in your vimrc for the default, interactive
      > search/replace mode?
      >
      > Thanks,
      > Linda

      The VimResized autocmd allows Vim scripts to handle the situation.
      :h VimResized

      As a start, here is an attempt to keep the position of vertical window
      bars on screen:


      if getwinposx() == -1
      finish
      endif

      let s:columns = &columns
      let s:winposx = getwinposx()

      " find windows adjacent to the Vim window's left border AND that have
      " other windows to the right
      func! s:LeftWindowNums()
      let wnrlist = []
      for wnr in range(1, winnr("$"))
      exec wnr."wincmd w"
      wincmd h
      if winnr() == wnr
      wincmd l
      if winnr() != wnr
      call add(wnrlist, wnr)
      endif
      endif
      endfor
      return wnrlist
      endfunc

      " find windows with other windows to the left AND right
      func! s:MidWindowNums()
      let wnrlist = []
      for wnr in range(1, winnr("$"))
      exec wnr."wincmd w"
      wincmd h
      if winnr() == wnr
      continue
      endif
      exec wnr."wincmd w"
      wincmd l
      if winnr() == wnr
      continue
      endif
      call add(wnrlist, wnr)
      endfor
      return wnrlist
      endfunc

      func! s:UpdateWinWidths()
      let dcolumns = &columns - s:columns

      " Linda W schrieb:
      " And herein lies the solution. If vim sees that the "X" position
      " is changing *and* the "X" size is changing, then it can logically
      " deduce that the left edge of the screen is moving.
      if s:winposx == getwinposx() || dcolumns == 0
      return
      endif

      let savwnr = winnr()
      let sav_ei = &ei
      set eventignore=all

      let g:midwinsresizecmd = ""
      for wnr in s:MidWindowNums()
      let g:midwinsresizecmd .= "|". wnr. "wincmd w"
      \. "|vert resize ". winwidth(wnr)
      endfor

      let g:leftwinsresizecmd = ""
      for wnr in s:LeftWindowNums()
      let g:leftwinsresizecmd .= "|". wnr. "wincmd w"
      \. "|vert resize ". (winwidth(wnr) + dcolumns)
      endfor

      exec g:leftwinsresizecmd[1:] . g:midwinsresizecmd

      exec savwnr."wincmd w"
      let &ei = sav_ei

      let s:columns = &columns
      let s:winposx = getwinposx()
      endfunc

      augroup appwinresize
      au!
      au VimResized * call s:UpdateWinWidths()
      augroup end


      Ok, just found a bug: move the right edge, then move the left edge --
      this somehow restores the size of rightmost windows.

      Also to be tested with combinations of relevant options.

      No matter, it's just meant as a little demo.

      --
      Andy


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.