Bug: Win32 guitabtooltip doesn't respect backslash-escaped special chars

6 views
Skip to first unread message

Erik Falor

unread,
Jan 2, 2008, 4:13:54 PM1/2/08
to vim...@googlegroups.com
While writing a guitabtooltip function, I discovered that the tooltips in Win32 don't properly handle backslash-escaped chars.
In particular, '\n' comes out as a box, and '\t' appears to terminate the string like '\0'.

The GTK gui on Linux, however, works as expected.

I have attached a sample .gvimrc-like start-up script which illustrates the problem.
When gvim is invoked like so:

gvim -u NONE -U guitab.vim

two unnamed gui tabs are displayed.  When you hover over them, you should see a tooltip window that looks something like this:

+------+
|1     |
|2    3|
|4     |
+------+

In the Win32 gui, it looks like this instead:

1<box>2

Regards,
Erik

--
Registered Linux User #445632
http://counter.li.org
guitab.vim

Ben Schmidt

unread,
Jan 2, 2008, 4:34:58 PM1/2/08
to vim...@googlegroups.com
Erik Falor wrote:
> While writing a guitabtooltip function, I discovered that the
> tooltips in Win32 don't properly handle backslash-escaped chars.
> In particular, '\n' comes out as a box, and '\t' appears to terminate
> the string like '\0'.
>
> The GTK gui on Linux, however, works as expected.

I for one would be interested in knowing what actually is 'expected' in this
circumstance. I personally think that's quite unclear and am not at all surprised
there is a difference between platforms.

I guess it's obvious that \n should be a newline. But should they be left
justified? Or centered? Or...?

If tabs are used, should they line up, given the proportional font? What width
should they be? Etc.?

Cheers,

Ben.


Send instant messages to your online friends http://au.messenger.yahoo.com

Tony Mechelynck

unread,
Jan 2, 2008, 4:46:50 PM1/2/08
to vim...@googlegroups.com

On Windows, where the OS-standard line break is \r\n, shouldn't _that_ also be
used to break lines in a tooltip? And what about Mac?

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
204. You're being audited because you mailed your tax return to the IRC.

Erik Falor

unread,
Jan 2, 2008, 5:09:47 PM1/2/08
to vim...@googlegroups.com
Well, I suppose by 'works as expected' I meant that the string escapes didn't blow up :)

What I think should be acceptable behavior is for the guitabtooltips to behave the same as the tooltips given by the balloon-eval feature.

From debugger.txt line 103:

"The Balloon evaluation functions are also used to show a tooltip for the toolbar."

Well, if the tooltips on the toolbar are supposed to use the same functions as ballooneval, then why not the guitab tooltips?

I realize that the 'toolbar' option doesn't apply to Win32, and so the toolbar settings, including "tooltips" maybe don't, either.  I'm sure there is a prefectly reasonable explanation for why they weren't implemented the same way on Windows.  At any rate, it would be nice if the text displayed by 'guitabtooltip' was given the same treatment as 'balloonexpr'  text.

Erik Falor

unread,
Jan 2, 2008, 5:13:07 PM1/2/08
to vim...@googlegroups.com


On 02/01/2008, Tony Mechelynck <antoine.m...@gmail.com> wrote:

On Windows, where the OS-standard line break is \r\n, shouldn't _that_ also be
used to break lines in a tooltip? And what about Mac?

Best regards,
Tony.

"\r\n" results in two boxes.

ap

unread,
Jan 2, 2008, 6:25:33 PM1/2/08
to vim_dev
I think this information from 'h balloonexpr' applies.

"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."

I think there are no references in the docs, other than this one,
about
evaluating escape-sequences in tooltips.

-ap


Erik Falor

unread,
Jan 2, 2008, 6:45:07 PM1/2/08
to vim...@googlegroups.com
FWIW, the Win32 build does have balloon_multiline.

According to gui_w32.c, George V. Reilly was the original author of the Windows GUI code.  Robert Webb later reworked much of it.
However, the source file doesn't have Robert's email address.  Does anybody know how to contact Mr. Webb?  Have there been any other maintainers since Mr. Webb worked on it?

Regards,
Erik

Bram Moolenaar

unread,
Jan 3, 2008, 6:40:00 AM1/3/08
to Erik Falor, vim...@googlegroups.com

Erik Falor wrote:

This was a known problem for some time. It looks like I found a
solution, see the patch below. Let me know if this works for you.


*** ../vim-7.1.188/src/gui_w32.c Thu Aug 30 12:24:21 2007
--- src/gui_w32.c Thu Jan 3 12:35:52 2008
***************
*** 987,992 ****
--- 987,997 ----
{
LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;

+ /* Set the maximum width, this also enables using
+ * \n for line break. */
+ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
+ 0, 500);
+
tt_text = enc_to_ucs2(str, NULL);
lpdi->lpszText = tt_text;
/* can't show tooltip if failed */
***************
*** 995,1000 ****
--- 1000,1010 ----
# endif
{
LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam;
+
+ /* Set the maximum width, this also enables using
+ * \n for line break. */
+ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
+ 0, 500);

if (STRLEN(str) < sizeof(lpdi->szText)
|| ((tt_text = vim_strsave(str)) == NULL))


--
FATHER: Did you kill all those guards?
LAUNCELOT: Yes ... I'm very sorry ...
FATHER: They cost fifty pounds each!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Reply all
Reply to author
Forward
0 new messages