Thursday, August 24, 2006

Gui Tabline

Note: The patch for the drawer version is available at macvim.org.

Vim7 added support for tabs. However, the mac version doesn't have gui tabs.

There are several ways to implement gui tabs in mac vim:

Segmented view

Pros:

  • Tabs like you expect them
  • Doesn't need much space

Cons:

  • Needs OS X 10.3
  • needs compositing enabled
  • seems that this needs a standard event handler on the main window, which makes resizing and maximizing choke. Without the standard handler, clicking the tab bar doesn't work...perhaps this can be fixed without a standard handler?

There are two ways this can be implemented:

  1. Put the segmented view in the root view of the window. This has the advantage that it works with less effort and gives more vertical room for vim (but makes moving the window with the mouse somewhat harder). Another problem is that no title bar text is available, this is annoying if you use Expose for example. Additionally, it looks really ugly.
  2. Put the segmented view in the content view of the window. This requires more changes (vim's text window has to be converted to a view, which are only supported from 10.2 on), but it's what you'd normally expect. Plus, if the text area is a view, this gives us the ability to add a toolbar as well; it should also improve drawing performance and is recommended by apple as the "future".

The segmented view should change its size when the window is resized, if there are a lot of tabs, they should be made smaller so that they are all visible. Alternatively, left/right arrows can be added after a certain minimal tab size (see this page for an example).

It looks like this:

Vim with a segment view tabline

todo: make tabs clickable ( gui_mac_doMouseDownEvent ?), make tabs smaller if they don't fit otherwise, resize max toolbar size when window is resized

Drawer

Pros:

  • works with older mac os x versions (10.2)
  • Doesn't need vertical screen space
  • has room for a lot of tabs. the drawer could display tabs hierarchically, this way you could have whole trees open.
  • other gui stuff could be added to the drawer

Cons:

  • unexpected
  • needs some horizontal screen space
  • according to this, data browser doesn't work with compositing on 10.2, but drawers need compositing. so this might not really work on 10.2 :-(

It looks like this:

Vim with a drawer "tabline"

todo:
crashes when -p *.h is used (stl=1, close all but the first tab, open new tab) (might be fixed by now, was unable to reproduce this), crashes when doing sta=1, set lines=20, set lines=40, tabe . q, tabe . (fixed in v4), if the window size is set to a smaller than minmal
height with :set lines=10 the display looks really strange, scrollbar flashes black on tab change, context menu close is only applied after mouse move (probably some event stuff)

One window for each tab

Use a separate window for each tab. This would be very maccy, but has probably some problems because the windows can have different sizes.

External tab lib

Use this tab control.

Pros

  • Looks good, is what you'd expect
  • maintained by others, and used in other apps (iterm,colloquy, adium
    want to use it too)

Cons

  • The lib is in cocoa, so we need a wrapper to call it from C.
  • Needs views as well

Stuff to test
  • :tabe รครถ (this killed a few of my vims)
  • :tabe aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (check what happens with long file names...should be shortened somehow)

I've implemented the segmented view and the drawer variants. I like the drawer version so much that I'll keep it for now. You really get used to having 20+ tabs open, and only the drawer version supports that.

0 Comments:

Post a Comment

<< Home