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

Re: How to add Tooltips in VIM

Expand Messages
  • Eric Arnold
    Hmm. In :help balloon-eval which brings up debugger.txt it says: Balloon evaluation is only available when compiled with the ... and :help
    Message 1 of 14 , Jun 1, 2005
    • 0 Attachment
      Hmm. In :help balloon-eval which brings up debugger.txt it says:
      Balloon evaluation is only available when compiled with the
      |+balloon_eval| and |+sun_workshop| features.

      and :help ballooneval describing the option setting it also says,
      {only available when compiled with the |+balloon_eval|
      and |+sun_workshop| or |+netbeans_intg| features}


      I didn't find much about how to actually use "balloons", except in
      netbeans.txt, which requires the sun compile options. There is, however,
      information on using Tooltips, via "tmenu" etc. The tooltips seem to
      be used and defined for the W32 and X11 GUI vim toolbar with tmenu
      (and for other popup menus, but I haven't tried that yet). However, the
      functions from netbeans.txt seem to imply the ability to create
      balloons in general text areas (sort of, but "not implemented"?):

      showBalloon text
      Show a balloon (popup window) at the mouse pointer position,
      containing "text", a string argument. The balloon should
      disappear when the mouse is moved more than a few pixels.


      balloonEval off len type
      The mouse pointer rests on text for a short while. When "len"
      is zero, there is no selection and the pointer is at position
      "off". When "len" is non-zero the text from position "off" to
      "off" + "len" is selected.
      Not implemented yet.


      So, I think balloons and tooltips aren't exactly synonymous. Even though
      has("balloon_eval")

      returns "1" the actual balloon commands aren't accessible, though the
      tooltips (and "tmenu") which apparently use some of the balloon
      functionality are? Is any of this correct?

      What would be cool would be to create a tooltip for a text region, as with
      syntax highlighting, but I don't see anything for that. This would make
      scripted applications which rely on "normal" mode (as opposed to
      [tear-off]menus) much easier to provide hints and help.



      --- "A. J. Mechelynck" <antoine.mechelynck@...> wrote:

      > Eric Arnold wrote:
      > > All the WinXP versions I have don't include the sun workshop, which seems
      > to be
      > > where the balloons are. Is it true that you need to have a Unix version or
      > > compile your own to use the balloons?
      > >
      > > --- "A. J. Mechelynck" <antoine.mechelynck@...> wrote:
      >
      > AFAIK, all you need is a version compiled with the +balloon_eval
      > feature, i.e.,
      >
      > :version
      >
      > includes +balloon_eval ;
      >
      > :echo has("balloon_eval")
      >
      > answers 1.
      >
      >
      > For Windows, see my Vim page
      > http://users.skynet.be/antoine.mechelynck/vim/ from which recent
      > versions of both gvim 6.3 and gvim 7.00aa can be downloaded. My GUI
      > versions (gvim.exe and gvimd.exe) but not my console versions (vim.exe
      > and vimd.exe) have +balloon_eval compiled-in.
      >
      > Please read the accompanying text before downloading.
      >
      >
      > Best regards,
      > Tony.
      >
      >
    • A. J. Mechelynck
      ... *options.txt* For Vim version 6.3. Last change: 2004 Dec 09 ... * balloondelay * * bdlay * balloondelay bdlay number (default: 600) global {not in Vi}
      Message 2 of 14 , Jun 1, 2005
      • 0 Attachment
        Eric Arnold wrote:
        > Hmm. In :help balloon-eval which brings up debugger.txt it says:
        > Balloon evaluation is only available when compiled with the
        > |+balloon_eval| and |+sun_workshop| features.
        >
        > and :help ballooneval describing the option setting it also says,
        > {only available when compiled with the |+balloon_eval|
        > and |+sun_workshop| or |+netbeans_intg| features}
        >
        >
        > I didn't find much about how to actually use "balloons", except in
        > netbeans.txt, which requires the sun compile options. There is, however,
        > information on using Tooltips, via "tmenu" etc. The tooltips seem to
        > be used and defined for the W32 and X11 GUI vim toolbar with tmenu
        > (and for other popup menus, but I haven't tried that yet). However, the
        > functions from netbeans.txt seem to imply the ability to create
        > balloons in general text areas (sort of, but "not implemented"?):
        >
        > showBalloon text
        > Show a balloon (popup window) at the mouse pointer position,
        > containing "text", a string argument. The balloon should
        > disappear when the mouse is moved more than a few pixels.
        >
        >
        > balloonEval off len type
        > The mouse pointer rests on text for a short while. When "len"
        > is zero, there is no selection and the pointer is at position
        > "off". When "len" is non-zero the text from position "off" to
        > "off" + "len" is selected.
        > Not implemented yet.
        >
        >
        > So, I think balloons and tooltips aren't exactly synonymous. Even though
        > has("balloon_eval")
        >
        > returns "1" the actual balloon commands aren't accessible, though the
        > tooltips (and "tmenu") which apparently use some of the balloon
        > functionality are? Is any of this correct?
        >
        > What would be cool would be to create a tooltip for a text region, as with
        > syntax highlighting, but I don't see anything for that. This would make
        > scripted applications which rely on "normal" mode (as opposed to
        > [tear-off]menus) much easier to provide hints and help.
        >
        >
        >

        *options.txt* For Vim version 6.3. Last change: 2004 Dec 09
        --- 967,981 ---
        *'balloondelay'* *'bdlay'*
        'balloondelay' 'bdlay' number (default: 600)
        global
        {not in Vi}
        {only available when compiled with the |+balloon_eval|
        feature}
        Delay in milliseconds before a balloon may pop up. See |balloon-eval|.

        *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'*
        'ballooneval' 'beval' boolean (default off)
        global
        {not in Vi}
        {only available when compiled with the |+balloon_eval|
        and |+sun_workshop| or |+netbeans_intg| features}
        Switch on the |balloon-eval| functionality.
        ---
        *debugger.txt* For Vim version 6.3. Last change: 2001 Dec 22
        --- 85,105 ---
        1.5 Balloon Evaluation *balloon-eval*

        This feature allows a debugger, or other external tool, to display dynamic
        information based on where the mouse is pointing. The purpose of this
        feature
        was to allow Sun's Visual WorkShop debugger to display expression
        evaluations.
        However, the feature was implemented in as general a manner as possible and
        could be used for displaying other information as well.

        The Balloon Evaluation has some settable parameters too. The font list and
        colors can be set via X resources (XmNballoonEvalFontList,
        XmNballoonEvalBackground, and XmNballoonEvalForeground).
        The 'balloondelay' option sets the delay before an attempt is made to show a
        balloon.
        The 'ballooneval' option needs to be set to switch it on.

        Balloon evaluation is only available when compiled with the |+balloon_eval|
        and |+sun_workshop| features.

        The Balloon evaluation functions are also used to show a tooltip for the
        toolbar. The 'ballooneval' option does not need to be set for this.
        But the
        other settings apply.
        ---

        My gvim 6.3 has +balloon_eval +netbeans_intg -sun_workshop.

        But things have changed between releases 6 and 7:

        *options.txt* For Vim version 7.0aa. Last change: 2005 May 31
        --- 982,1027 ---
        *'balloondelay'* *'bdlay'*
        'balloondelay' 'bdlay' number (default: 600)
        global
        {not in Vi}
        {only available when compiled with the |+balloon_eval|
        feature}
        Delay in milliseconds before a balloon may pop up. See |balloon-eval|.

        *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'*
        'ballooneval' 'beval' boolean (default off)
        global
        {not in Vi}
        {only available when compiled with the |+balloon_eval|
        feature}
        Switch on the |balloon-eval| functionality.

        *'balloonexpr'* *'bexpr'*
        'balloonexpr' 'bexpr' string (default "")
        global
        {not in Vi}
        {only available when compiled with the |+balloon_eval|
        feature}
        Expression to show in evaluation balloon. It is only used when
        'ballooneval' is on. These variables can be used:

        v:beval_bufnr number of the buffer in which balloon is going to show
        v:beval_winnr number of the window
        v:beval_lnum line number
        v:beval_col column number (byte index)
        v:beval_text word under or after the mouse pointer

        The evaluation of the expression must not have side effects!
        Example: >
        function! MyBalloonExpr()
        return 'Cursor is at line ' . v:beval_lnum .
        \', column ' . v:beval_col .
        \ ' of file ' . bufname(v:beval_bufnr) .
        \ ' on word "' . v:beval_text . '"'
        endfunction
        set bexpr=MyBalloonExpr()
        set ballooneval
        <
        NOTE: The balloon is displayed only if the cursor is on a text
        character. If the result of evaluating 'balloonexpr' is not empty,
        Vim does not try to send a message to an external debugger (Netbeans
        or Sun Workshop).
        ---
        *debugger.txt* For Vim version 7.0aa. Last change: 2005 Mar 29
        --- 85,108 ---
        1.5 Balloon Evaluation *balloon-eval*

        This feature allows a debugger, or other external tool, to display dynamic
        information based on where the mouse is pointing. The purpose of this
        feature
        was to allow Sun's Visual WorkShop debugger to display expression
        evaluations.
        However, the feature was implemented in as general a manner as possible and
        could be used for displaying other information as well.

        The Balloon Evaluation has some settable parameters too. For Motif the font
        list and colors can be set via X resources (XmNballoonEvalFontList,
        XmNballoonEvalBackground, and XmNballoonEvalForeground).
        The 'balloondelay' option sets the delay before an attempt is made to show a
        balloon.
        The 'ballooneval' option needs to be set to switch it on.

        Balloon evaluation is only available when compiled with the |+balloon_eval|
        feature.

        The Balloon evaluation functions are also used to show a tooltip for the
        toolbar. The 'ballooneval' option does not need to be set for this.
        But the
        other settings apply.

        Another way to use the balloon is with the 'balloonexpr' option. This is
        completely user definable.
        ---



        Note that in version 7, features other than +balloon_eval are no more
        required to make it work; and a new option, 'balloonexpr', has been
        introduced.


        Best regards,
        Tony.
      • Eric Arnold
        I just tried balloonexpr in Vim7, and it s almost exactly what I was hoping it would be. I.e. the example shows how straightforward it is: function!
        Message 3 of 14 , Jun 2, 2005
        • 0 Attachment
          I just tried balloonexpr in Vim7, and it's almost exactly what I was
          hoping it would be. I.e. the example shows how straightforward it is:

          function! MyBalloonExpr()
          let s = 'Cursor is at line ' . v:beval_lnum .
          \', column ' . v:beval_col .
          \ ' of file ' . bufname(v:beval_bufnr) .
          \ ' on word "' . v:beval_text . '"'
          return s
          endfunction
          set bexpr=MyBalloonExpr()
          set ballooneval


          It would be nice if there were an option to have the balloon displayed
          for the regular non-mouse cursor, that way hints could be assured to get
          to the user whether he's using "normal" Vim commands or mousing.




          --- "A. J. Mechelynck" <antoine.mechelynck@...> wrote:
          ....
          >
          >
          > Note that in version 7, features other than +balloon_eval are no more
          > required to make it work; and a new option, 'balloonexpr', has been
          > introduced.
        • drchip@campbellfamily.biz
          ... May I suggest that you check into Decho.vim -- http://vim.sourceforge.net/scripts/script.php?script_id=120 You ll need to instrument your code (ie. insert
          Message 4 of 14 , Jun 2, 2005
          • 0 Attachment
            Quoting "A. J. Mechelynck" <antoine.mechelynck@...>:

            > Eric Arnold wrote:
            > > As I understand it, buffer variables are local and persistent to each Vim
            > > buffer in which the script is executed, so once defined, they should be
            > > valid until the buffer is unloaded/deleted/wiped.
            ...
            >
            > The above omits the part where b:restore_cmdheight is created; we see
            > s:Init_buffer_variables() called from s:Restore_origin_window() but we
            > don't see where s:Restore_origin_window() is called.
            >
            > See ":help debug-scripts" about finding out what happens within Vim,
            > what is executed by sourced scripts, etc.

            May I suggest that you check into Decho.vim --
            http://vim.sourceforge.net/scripts/script.php?script_id=120

            You'll need to instrument your code (ie. insert calls to Dfunc(), Decho(),
            and Dret()), but then you'll get an activity trace.

            Regards,
            Chip Campbell
          • Hari Krishna Dara
            ... I use buffer variables too but never observed this problem. The only reason I can think of is that your script temporarily jumps to a different buffer in
            Message 5 of 14 , Jun 2, 2005
            • 0 Attachment
              On Wed, 1 Jun 2005 at 10:03pm, Eric Arnold wrote:

              > As I understand it, buffer variables are local and persistent to each Vim
              > buffer in which the script is executed, so once defined, they should be
              > valid until the buffer is unloaded/deleted/wiped.
              > I have a couple of functions like:
              >
              > function! s:Init_buffer_variables()
              > if exists( 'b:initialized_RH_buf_vars' )
              > return
              > endif
              > let b:initialized_RH_buf_vars = 1
              > ...
              > if b:restore_cmdheight > 0
              > let &cmdheight = b:restore_cmdheight
              > endif
              > ...
              > endfunction
              >
              > ... do lots of stuff, including setting b:restore_cmdheight ...
              >
              > function! s:Restore_origin_window()
              > call s:Init_buffer_variables()
              > ...
              > let &cmdheight = b:restore_cmdheight
              > endfunction
              >
              > It usually works fine, but there is some rare case I can't track down
              > where I get an error saying that b:restore_cmdheight is not defined.
              > When I restart the process, without quitting, the error is gone. At first
              > glance, it doesn't seem possible, since the init function is called a few
              > lines before the variable is referenced. I think it might have something to
              > do with re-"source"ing the file a few times, but I can't make it happen at
              > will.

              I use buffer variables too but never observed this problem. The only
              reason I can think of is that your script temporarily jumps to a
              different buffer in the same window or in a different window (which
              doesn't have the variable defined) when the code gets executed and that
              is what is causing the error. Put some :echomsg or :Decho (using
              Dr.Chip's plugin) calls with the current buffer number right before
              using the buffer variable in the problem area, and verify that you are
              actually in the right buffer.

              --
              HTH,
              Hari



              __________________________________
              Discover Yahoo!
              Use Yahoo! to plan a weekend, have fun online and more. Check it out!
              http://discover.yahoo.com/
            • David Fishburn
              ... Yes, I had a similar issue in the past which took sometime to figure out. Turned out one of my own autocmds was changing buffers and didn t change it back
              Message 6 of 14 , Jun 3, 2005
              • 0 Attachment
                > -----Original Message-----
                > From: Hari Krishna Dara [mailto:hari_vim@...]
                > Sent: Thursday, June 02, 2005 1:38 PM
                > To: Eric Arnold
                > Cc: vim@...
                > Subject: Re: When do buffer variables become undefined?
                >
                >
                > On Wed, 1 Jun 2005 at 10:03pm, Eric Arnold wrote:
                >
                > > As I understand it, buffer variables are local and
                > persistent to each
                > > Vim buffer in which the script is executed, so once defined, they
                > > should be valid until the buffer is unloaded/deleted/wiped.
                > > I have a couple of functions like:
                > >
                > > function! s:Init_buffer_variables()
                > > if exists( 'b:initialized_RH_buf_vars' )
                > > return
                > > endif
                > > let b:initialized_RH_buf_vars = 1
                > > ...
                > > if b:restore_cmdheight > 0
                > > let &cmdheight = b:restore_cmdheight
                > > endif
                > > ...
                > > endfunction
                > >
                > > ... do lots of stuff, including setting b:restore_cmdheight ...
                > >
                > > function! s:Restore_origin_window()
                > > call s:Init_buffer_variables()
                > > ...
                > > let &cmdheight = b:restore_cmdheight
                > > endfunction
                > >
                > > It usually works fine, but there is some rare case I can't
                > track down
                > > where I get an error saying that b:restore_cmdheight is
                > not defined.
                > > When I restart the process, without quitting, the error is
                > gone. At
                > > first glance, it doesn't seem possible, since the init function is
                > > called a few lines before the variable is referenced. I think it
                > > might have something to do with re-"source"ing the file a
                > few times,
                > > but I can't make it happen at will.
                >
                > I use buffer variables too but never observed this problem.
                > The only reason I can think of is that your script
                > temporarily jumps to a different buffer in the same window or
                > in a different window (which doesn't have the variable
                > defined) when the code gets executed and that is what is
                > causing the error. Put some :echomsg or :Decho (using
                > Dr.Chip's plugin) calls with the current buffer number right
                > before using the buffer variable in the problem area, and
                > verify that you are actually in the right buffer.

                Yes, I had a similar issue in the past which took sometime to figure out.
                Turned out one of my own autocmds was changing buffers and didn't change it
                back at the end of the function.

                HTH,
                Dave
              • Eric Arnold
                That s something to check out. I ve got a lot of autocommands, and I m jumping between buffers a lot. I m beginning to wonder if is has something to with the
                Message 7 of 14 , Jun 3, 2005
                • 0 Attachment
                  That's something to check out. I've got a lot of autocommands, and I'm
                  jumping between buffers a lot. I'm beginning to wonder if is has something
                  to with the behaviour of

                  BufHidden Just after a buffer has become hidden. That
                  ...
                  NOTE: When this autocommand is executed, the
                  current buffer "%" may be different from the
                  buffer being unloaded "<afile>".

                  which is also true for bufunload, bufdelete, etc. I guess I need to
                  understand exactly when 'current buffer "%" may be different' from
                  what I'm expecting.




                  --- David Fishburn <fishburn@...> wrote:

                  >
                  >
                  > > -----Original Message-----
                  > > From: Hari Krishna Dara [mailto:hari_vim@...]
                  > > Sent: Thursday, June 02, 2005 1:38 PM
                  > > To: Eric Arnold
                  > > Cc: vim@...
                  > > Subject: Re: When do buffer variables become undefined?
                  > >
                  > >
                  > > On Wed, 1 Jun 2005 at 10:03pm, Eric Arnold wrote:
                  > >
                  > > > As I understand it, buffer variables are local and
                  > > persistent to each
                  > > > Vim buffer in which the script is executed, so once defined, they
                  > > > should be valid until the buffer is unloaded/deleted/wiped.
                  > > > I have a couple of functions like:
                  > > >
                  ...
                  > > >
                  > > > It usually works fine, but there is some rare case I can't
                  > > track down
                  > > > where I get an error saying that b:restore_cmdheight is
                  > > not defined.
                  > > > When I restart the process, without quitting, the error is
                  > > gone. At
                  > > > first glance, it doesn't seem possible, since the init function is
                  > > > called a few lines before the variable is referenced. I think it
                  > > > might have something to do with re-"source"ing the file a
                  > > few times,
                  > > > but I can't make it happen at will.
                  > >
                  > > I use buffer variables too but never observed this problem.
                  > > The only reason I can think of is that your script
                  > > temporarily jumps to a different buffer in the same window or
                  > > in a different window (which doesn't have the variable
                  > > defined) when the code gets executed and that is what is
                  > > causing the error. Put some :echomsg or :Decho (using
                  > > Dr.Chip's plugin) calls with the current buffer number right
                  > > before using the buffer variable in the problem area, and
                  > > verify that you are actually in the right buffer.
                  >
                  > Yes, I had a similar issue in the past which took sometime to figure out.
                  > Turned out one of my own autocmds was changing buffers and didn't change it
                  > back at the end of the function.
                  >
                  > HTH,
                  > Dave
                  >
                  >
                • A. J. Mechelynck
                  ... I suppose that one case is if hidden is set and you execute :only . There may be other cases. The morality is that anything invoked by an autocommand
                  Message 8 of 14 , Jun 3, 2005
                  • 0 Attachment
                    Eric Arnold wrote:
                    > That's something to check out. I've got a lot of autocommands, and I'm
                    > jumping between buffers a lot. I'm beginning to wonder if is has something
                    > to with the behaviour of
                    >
                    > BufHidden Just after a buffer has become hidden. That
                    > ...
                    > NOTE: When this autocommand is executed, the
                    > current buffer "%" may be different from the
                    > buffer being unloaded "<afile>".
                    >
                    > which is also true for bufunload, bufdelete, etc. I guess I need to
                    > understand exactly when 'current buffer "%" may be different' from
                    > what I'm expecting.

                    I suppose that one case is if 'hidden' is set and you execute ":only".
                    There may be other cases. The morality is that anything invoked by an
                    autocommand from BufHidden, BufUnload, BufDelete, etc., shouldn't rely
                    of what the current buffer is. (And remember: if at that point you
                    switch buffers back and forth, autocommands such as WinEnter or BufEnter
                    won't be triggered unless "nested".)

                    Best regards,
                    Tony.
                  Your message has been successfully submitted and would be delivered to recipients shortly.