1

I'm trying to use balloon text for my C macros, say, true and false as follows in the terminal version.

function! MyBalloonExpr()
  let macros = {
\ 'true':"true\n1",
\ 'false':"false\n0",
\ }
  return get(macros, v:beval_text, '')
endfunction
set balloonexpr=MyBalloonExpr()
set ballooneval
set balloonevalterm

The idea is to display a two-line balloon, with the first line the macro name and the second line the macro value, e.g.

true
1

However, it gets displayed as true^@1 as if the newline were a NUL byte (^@). What am I missing? Are multi-line balloon texts possible in the terminal (they do work in the GUI version)? Is this a bug? I'm using vim 8.1.2269 compiled today.

1

2 Answers 2

2

I'm not sure you've seen this, but :help 'balloonexpr' says this:

To check whether line breaks in the balloon text work use this check:

 if has("balloon_multiline")

When they are supported "\n" characters will start a new line. If the expression evaluates to a |List| this is equal to using each List item as a string and putting "\n" in between them.

So if :echo has("balloon_multiline") returns 0 in your terminal, you're outta luck. If it returns 1, works in normal windows, but not in terminal windows, that looks like a bug; please report this, see :help bugs. Basically, open an issue at the bug tracker, or directly discuss this on the vim_dev mailing list.

3
  • :echo has("balloon_multiline") says 1, so I'm going to file the report as recommended.
    – Jens
    Commented Nov 8, 2019 at 10:36
  • 1
    If it only affects terminal windows, it's likely an oversight; the terminal stuff was only introduced recently. Commented Nov 8, 2019 at 10:39
  • 2
    For those interested: github.com/vim/vim/issues/5193
    – Jens
    Commented Nov 8, 2019 at 10:53
0

You may use list instead of string. For example, balloon_show(['line1', 'line2']).

See also :help balloon_show:

balloon_show({expr})                    *balloon_show()*
        Show {expr} inside the balloon.  For the GUI {expr} is used as
        a string.  For a terminal {expr} can be a list, which contains
        the lines of the balloon.  If {expr} is not a list it will be
        split with |balloon_split()|.
        If {expr} is an empty string any existing balloon is removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.