gVim for Windows - Patch to fill empty space around text area

62 views
Skip to first unread message

Simon

unread,
Nov 14, 2019, 12:45:33 AM11/14/19
to vim...@vim.org
Hi.

Attached is a patch to solve a long-standing issue in gVim when
using dark backgrounds. e.g.

https://github.com/vim/vim/issues/349
https://www.reddit.com/r/vim/search/?q=gvim%20borders&restrict_sr=1

* This mini patch automatically changes the main window to the
background colour thus eliminating white-space to the right and bottom
edge - it looks great

* I have utilised the static s_brush so it will always contain the
main window background brush just as before

* The previous brush is deleted after being replaced by the new one

* I have checked for memory leaks


Thanks for everything. :)


S.
gvim_w32_background_fix.diff

Bram Moolenaar

unread,
Nov 14, 2019, 4:36:36 PM11/14/19
to vim...@googlegroups.com, vim...@vim.org
The other use of SetClassLongPtr() is inside an #ifdef.
I suppose for older compilers.
How about this:

gui_mch_new_colors(void)
{
HBRUSH prevBrush;

s_brush = CreateSolidBrush(gui.back_pixel);
#ifdef SetClassLongPtr
prevBrush = (HBRUSH)SetClassLongPtr(
s_hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)s_brush);
#else
prevBrush = (HBRUSH)SetClassLong(
s_hwnd, GCL_HBRBACKGROUND, (long_u)s_brush);
#endif
InvalidateRect(s_hwnd, NULL, TRUE);
DeleteObject(prevBrush);
}


--
From "know your smileys":
y:-) Bad toupee

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Simon Sadler

unread,
Nov 14, 2019, 6:13:46 PM11/14/19
to vim...@googlegroups.com, vim...@vim.org
On Thu, 14 Nov 2019 at 21:36, Bram Moolenaar <Br...@moolenaar.net> wrote:
The other use of SetClassLongPtr() is inside an #ifdef.
I suppose for older compilers.
How about this:

gui_mch_new_colors(void)
{
    HBRUSH prevBrush;

    s_brush = CreateSolidBrush(gui.back_pixel);
#ifdef SetClassLongPtr
    prevBrush = (HBRUSH)SetClassLongPtr(
                                s_hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)s_brush);
#else
    prevBrush = (HBRUSH)SetClassLong(
                                   s_hwnd, GCL_HBRBACKGROUND, (long_u)s_brush);
#endif
    InvalidateRect(s_hwnd, NULL, TRUE);
    DeleteObject(prevBrush);
}

Well spotted. Thanks. SetClassLongPtr should define out to SetClassLong but maybe not on really old compilers. :) Good to keep the consistency as always.

I just compiled and tested your version in 32 and 64-bit. Both working fine. Go for it.

Ken Takata

unread,
Nov 15, 2019, 4:25:48 AM11/15/19
to vim_dev
Hi Bram,
 I don't remember when SetClassLongPtr() was added. At least, VC 2008 has it, and VC 6 doesn't have it.
We already dropped support for Windows 9x, so I don't think we need to keep support old compilers
which support Win9x. I think we can drop support for VC 2005 or older.
How about always using SetClassLongPtr()?

Regards,
Ken Takata

Bram Moolenaar

unread,
Nov 15, 2019, 4:44:24 PM11/15/19
to vim...@googlegroups.com, Ken Takata
Well, using one solution in one place and another elsewhere isn't nice.
Let me keep the #ifdef in this patch, we can make another patch to
simplify the code by dropping support for old compilers.

We still aim at supporting Windows XP, not sure what the minimal
compiler is. I'm using MSVC 2015 and haven't heard that the binaries
don't work somewhere. It's a free download, thus perhaps we can use
this one as the minimum?

--
From "know your smileys":
O:-) Saint

Simon Sadler

unread,
Nov 16, 2019, 7:48:45 AM11/16/19
to vim...@googlegroups.com, vim...@vim.org
Thank you Bram for including this so quickly. It's great to see it in the wild.

On Thu, 14 Nov 2019 at 21:36, Bram Moolenaar <Br...@moolenaar.net> wrote:
--
--
You received this message from the "vim_dev" 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

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/201911142136.xAELaMDL021706%40masaka.moolenaar.net.
Reply all
Reply to author
Forward
0 new messages