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

Re: how to center items on statusline

Expand Messages
  • Tony Mechelynck
    ... If it s so, then I think the only way to center something (but is the game worth the candle?) would be set stl=%!MyStatusLine() function MyStatusLine() ...
    Message 1 of 4 , Apr 1, 2010
    • 0 Attachment
      On 01/04/10 20:00, viki wrote:
      > On Apr 1, 4:53 am, Tony Mechelynck<antoine.mechely...@...>
      > wrote:
      >> On 31/03/10 22:45, viki wrote:
      >>
      >>> Hello,
      >>
      >>> How do I center-align some items on statusline ?
      >>
      >>> Thanks.
      >>> Viki
      >>
      >> Hm. The status lines allows a "left-side group" and a "right-side group"
      >> of items, separated by %= and in addition you may have one %< item to
      >> define where to truncate the line if too long.
      >>
      >> I haven't tried bracketing an item (or a set of items) between two %=
      >> markers. If it doesn't give an error, it might be what you want.
      >
      > Everything after 1st %= is right aligned. 2nd %= is ignored.
      >
      > Viki
      >

      If it's so, then I think the only way to center something (but is the
      game worth the candle?) would be

      set stl=%!MyStatusLine()
      function MyStatusLine()
      ...
      endfunction

      and painstakingly assemble the desired string there while tallying the
      _resulting display length_ of anything included, then subtract from
      &columns the total thus obtained, and add half of that number of spaces
      on each side (or if odd, half of it minus one-half on one side and plus
      one-half on the other side). The _return value_ of the function must be
      the string to be evaluated by the 'statusline' logic.

      The reason a function is used is that the length of any variable part
      (such as the pathfilename, or of anything that can be displayed or not,
      or that can have variable display length depending on its value) must be
      determined on the fly whenever the status line is evaluated. Looks like
      rather than %x items in the function result, precomputing the values and
      returning a literal string could be more efficient.

      Me, I don't see what's wrong with having some stuff (file name, flags,
      etc.) on the left side, some other stuff (keymap, line, col,
      virtcol-if-different, All/Top/Bot/nn%, etc.) on the right side, and
      empty space in the middle.


      Best regards,
      Tony.
      --
      Flugg's Law:
      When you need to knock on wood is when you realize that the
      world is composed of vinyl, naugahyde and aluminum.

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      To unsubscribe, reply using "remove me" as the subject.
    Your message has been successfully submitted and would be delivered to recipients shortly.