patch 9.1.1834: MS-Windows: not possible to highlight the title bar

Problem:  MS-Windows: not possible to highlight the title bar
Solution: Make the title/caption bar configurable by introducing the
          'go-C' option value which allows to highlight it using the
          TitleBar and TitleBarNC highlighting groups (Mao-Yining).

Introduce titlebar color customization for Windows 11 GUI through
highlight groups and new 'guioptions' flag:

- Add 'C' flag to enable titlebar color customization (opt-in)
- New highlight groups: TitleBar (active) and TitleBarNC (inactive)
- Uses DWMWA_CAPTION_COLOR and DWMWA_TEXT_COLOR DWM attributes
- Dynamically loads dwmapi.dll for Windows 11 compatibility
- Defaults to system colors when set to NONE or feature disabled

closes: #18449

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Mao-Yining
2025-10-07 19:31:22 +00:00
committed by Christian Brabandt
parent f8b9251d8f
commit 2c09368273
16 changed files with 255 additions and 15 deletions

View File

@ -51,6 +51,8 @@ TabLineFill
TabLineSel TabLineSel
Terminal Terminal
Title Title
TitleBar
TitleBarNC
TOhtmlProgress TOhtmlProgress
TOhtml-progress-color TOhtml-progress-color
ToolbarButton ToolbarButton

View File

@ -1,4 +1,4 @@
*gui_w32.txt* For Vim version 9.1. Last change: 2025 Aug 06 *gui_w32.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -488,4 +488,20 @@ VIM_KEYCODE_TRANS_STRATEGY can be set to the desired value ("experimental" or
set VIM_KEYCODE_TRANS_STRATEGY=experimental set VIM_KEYCODE_TRANS_STRATEGY=experimental
gvim.exe gvim.exe
< <
Title Bar *gui-w32-title-bar*
Starting with Windows 11, you can customize the gVim title bar (also known as
the caption bar) by enabling the |'go-C'| option.
Once enabled, the appearance is controlled by two highlighting groups:
1. |hl-TitleBar| -- Sets the color of the title bar for the active window.
2. |hl-TitleBarNC| -- Sets the color of the title bar for inactive windows.
To use the system's default title bar colors, set highlighting groups to
`NONE`: >
hi TitleBar guibg=NONE guifg=NONE
hi TitleBarNC guibg=NONE guifg=NONE
vim:tw=78:sw=4:ts=8:noet:ft=help:norl: vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

View File

@ -1,4 +1,4 @@
*options.txt* For Vim version 9.1. Last change: 2025 Oct 03 *options.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -4487,6 +4487,10 @@ A jump table for the options with a short description can be found at |Q_op|.
*'go-c'* *'go-c'*
'c' Use console dialogs instead of popup dialogs for simple 'c' Use console dialogs instead of popup dialogs for simple
choices. choices.
*'go-C'*
'C' Use |hl-TitleBar| and |hl-TitleBarNC| if available.
Currently only works for MS-Window GUI.
See |gui-w32-title-bar| for details.
*'go-d'* *'go-d'*
'd' Use dark theme variant if available. Currently only works for 'd' Use dark theme variant if available. Currently only works for
GTK+ GUI. GTK+ GUI.

View File

@ -6092,6 +6092,16 @@ TabPanelSel TabPanel, active tab page label.
Terminal |terminal| window (see |terminal-size-color|). Terminal |terminal| window (see |terminal-size-color|).
*hl-Title* *hl-Title*
Title Titles for output from ":set all", ":autocmd" etc. Title Titles for output from ":set all", ":autocmd" etc.
*hl-TitleBar*
TitleBar Title bar for the active Gui's window.
This feature is supported only in the MS-Windows GUI.
See |gui-w32-title-bar| for details
Only the `guibg` and `guifg` highlight arguments are effective.
*hl-TitleBarNC*
TitleBarNC Title bar for inactive Gui's window.
This feature is supported only in the MS-Windows GUI.
See |gui-w32-title-bar| for details
Only the `guibg` and `guifg` highlight arguments are effective.
*hl-Visual* *hl-Visual*
Visual Visual mode selection. Visual Visual mode selection.
*hl-VisualNOS* *hl-VisualNOS*

View File

@ -355,6 +355,7 @@ $quote eval.txt /*$quote*
'go' options.txt /*'go'* 'go' options.txt /*'go'*
'go-!' options.txt /*'go-!'* 'go-!' options.txt /*'go-!'*
'go-A' options.txt /*'go-A'* 'go-A' options.txt /*'go-A'*
'go-C' options.txt /*'go-C'*
'go-F' options.txt /*'go-F'* 'go-F' options.txt /*'go-F'*
'go-L' options.txt /*'go-L'* 'go-L' options.txt /*'go-L'*
'go-M' options.txt /*'go-M'* 'go-M' options.txt /*'go-M'*
@ -8224,6 +8225,7 @@ gui-w32-cmdargs gui_w32.txt /*gui-w32-cmdargs*
gui-w32-dialogs gui_w32.txt /*gui-w32-dialogs* gui-w32-dialogs gui_w32.txt /*gui-w32-dialogs*
gui-w32-printing gui_w32.txt /*gui-w32-printing* gui-w32-printing gui_w32.txt /*gui-w32-printing*
gui-w32-start gui_w32.txt /*gui-w32-start* gui-w32-start gui_w32.txt /*gui-w32-start*
gui-w32-title-bar gui_w32.txt /*gui-w32-title-bar*
gui-w32-various gui_w32.txt /*gui-w32-various* gui-w32-various gui_w32.txt /*gui-w32-various*
gui-w32-windowid gui_w32.txt /*gui-w32-windowid* gui-w32-windowid gui_w32.txt /*gui-w32-windowid*
gui-w32s os_win32.txt /*gui-w32s* gui-w32s os_win32.txt /*gui-w32s*
@ -8417,6 +8419,8 @@ hl-TabPanelFill syntax.txt /*hl-TabPanelFill*
hl-TabPanelSel syntax.txt /*hl-TabPanelSel* hl-TabPanelSel syntax.txt /*hl-TabPanelSel*
hl-Terminal syntax.txt /*hl-Terminal* hl-Terminal syntax.txt /*hl-Terminal*
hl-Title syntax.txt /*hl-Title* hl-Title syntax.txt /*hl-Title*
hl-TitleBar syntax.txt /*hl-TitleBar*
hl-TitleBarNC syntax.txt /*hl-TitleBarNC*
hl-ToolbarButton gui.txt /*hl-ToolbarButton* hl-ToolbarButton gui.txt /*hl-ToolbarButton*
hl-ToolbarLine gui.txt /*hl-ToolbarLine* hl-ToolbarLine gui.txt /*hl-ToolbarLine*
hl-Tooltip syntax.txt /*hl-Tooltip* hl-Tooltip syntax.txt /*hl-Tooltip*

View File

@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2025 Oct 05 *version9.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -41715,6 +41715,8 @@ Options: ~
- Setting 'nowrap' in a modeline could cause long lines to be hidden - Setting 'nowrap' in a modeline could cause long lines to be hidden
off-screen. To make this visible, the listchars "extend" suboption is set off-screen. To make this visible, the listchars "extend" suboption is set
to ">" by default, indicating text that extends beyond the window width. to ">" by default, indicating text that extends beyond the window width.
- 'guioptions': New value |'go-C'| to style the title/caption bar on Windows 11
(see also the below platform specific change).
Ex commands: ~ Ex commands: ~
- allow to specify a priority when defining a new sign |:sign-define| - allow to specify a priority when defining a new sign |:sign-define|
@ -41750,6 +41752,8 @@ Plugins~
Platform specific ~ Platform specific ~
- MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be - MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be
absolute paths (to the current drive) and no longer relative. absolute paths (to the current drive) and no longer relative.
- MS-Windows: The title bar follows the |hl-TitleBar| and |hl-TitleBarNC|
highlighting group |gui-w32-title-bar|.
- macOS: increase default scheduler priority to TASK_DEFAULT_APPLICATION. - macOS: increase default scheduler priority to TASK_DEFAULT_APPLICATION.
Others: ~ Others: ~
@ -41841,6 +41845,8 @@ Highlighting: ~
|hl-TabPanel| |tabpanel|: not active tab page label |hl-TabPanel| |tabpanel|: not active tab page label
|hl-TabPanelFill| |tabpanel|: filler space |hl-TabPanelFill| |tabpanel|: filler space
|hl-TabPanelSel| |tabpanel|: active tab page label |hl-TabPanelSel| |tabpanel|: active tab page label
|hl-TitleBarNC| Configure the inactive title/bar on MS-Windows 11
|hl-TitleBar| Configure the active title/bar on MS-Windows 11
Commands: ~ Commands: ~

View File

@ -2,7 +2,7 @@
" Language: Vim script " Language: Vim script
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com> " Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com> " Doug Kearns <dougkearns@gmail.com>
" Last Change: 2025 Sep 27 " Last Change: 2025 Oct 07
" Former Maintainer: Charles E. Campbell " Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY. " DO NOT CHANGE DIRECTLY.
@ -34,8 +34,8 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell
" regular vim commands {{{2 " regular vim commands {{{2
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang' " GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang'
syn keyword vimCommand contained al[l] ar[gs] arga[dd] argd[elete] argdo argded[upe] arge[dit] argg[lobal] argl[ocal] argu[ment] as[cii] b[uffer] bN[ext] ba[ll] bad[d] balt bd[elete] bf[irst] bl[ast] bm[odified] bn[ext] bp[revious] br[ewind] brea[k] breaka[dd] breakd[el] breakl[ist] bro[wse] buffers bufd[o] bun[load] bw[ipeout] c[hange] cN[ext] cNf[ile] cabo[ve] cad[dbuffer] cadde[xpr] caddf[ile] caf[ter] cb[uffer] cbe[fore] cbel[ow] cbo[ttom] cc ccl[ose] cd cdo ce[nter] cex[pr] cf[ile] cfd[o] cfir[st] cg[etfile] cgetb[uffer] cgete[xpr] changes che[ckpath] checkt[ime] chi[story] cl[ist] clip[reset] cla[st] clo[se] cle[arjumps] cn[ext] cnew[er] cnf[ile] col[der] colo[rscheme] com[mand] comc[lear] comp[iler] con[tinue] conf[irm] cons[t] cope[n] cp[revious] cpf[ile] nextgroup=vimBang syn keyword vimCommand contained al[l] ar[gs] arga[dd] argd[elete] argdo argded[upe] arge[dit] argg[lobal] argl[ocal] argu[ment] as[cii] b[uffer] bN[ext] ba[ll] bad[d] balt bd[elete] bf[irst] bl[ast] bm[odified] bn[ext] bp[revious] br[ewind] brea[k] breaka[dd] breakd[el] breakl[ist] bro[wse] buffers bufd[o] bun[load] bw[ipeout] c[hange] cN[ext] cNf[ile] cabo[ve] cad[dbuffer] cadde[xpr] caddf[ile] caf[ter] cb[uffer] cbe[fore] cbel[ow] cbo[ttom] cc ccl[ose] cd cdo ce[nter] cex[pr] cf[ile] cfd[o] cfir[st] cg[etfile] cgetb[uffer] cgete[xpr] changes che[ckpath] checkt[ime] chi[story] cl[ist] clip[reset] cla[st] clo[se] cle[arjumps] cn[ext] cnew[er] cnf[ile] col[der] colo[rscheme] comc[lear] comp[iler] con[tinue] conf[irm] cons[t] cope[n] cp[revious] cpf[ile] cq[uit] nextgroup=vimBang
syn keyword vimCommand contained cq[uit] cr[ewind] cs[cope] cst[ag] cw[indow] delm[arks] deb[ug] defc[ompile] di[splay] dif[fupdate] diffg[et] diffo[ff] diffp[atch] diffpu[t] diffs[plit] difft[his] dig[raphs] disa[ssemble] dj[ump] dli[st] dr[op] ds[earch] dsp[lit] e[dit] ea[rlier] em[enu] endfo[r] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files fin[d] fina[lly] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] foldd[oopen] folddoc[losed] foldo[pen] g[lobal] go[to] gu[i] gv[im] h[elp] helpc[lose] helpf[ind] helpt[ags] ha[rdcopy] hi[ghlight] his[tory] ij[ump] il[ist] int[ro] ip[ut] is[earch] isp[lit] ju[mps] l[ist] lN[ext] lNf[ile] la[st] lab[ove] lan[guage] lad[dexpr] laddb[uffer] laddf[ile] laf[ter] lat[er] lb[uffer] lbe[fore] lbel[ow] lbo[ttom] lc[d] lch[dir] nextgroup=vimBang syn keyword vimCommand contained cr[ewind] cs[cope] cst[ag] cw[indow] delm[arks] deb[ug] defc[ompile] di[splay] dif[fupdate] diffg[et] diffo[ff] diffp[atch] diffpu[t] diffs[plit] difft[his] dig[raphs] disa[ssemble] dj[ump] dli[st] dr[op] ds[earch] dsp[lit] e[dit] ea[rlier] em[enu] endfo[r] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files fin[d] fina[lly] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] foldd[oopen] folddoc[losed] foldo[pen] g[lobal] go[to] gu[i] gv[im] h[elp] helpc[lose] helpf[ind] helpt[ags] ha[rdcopy] hi[ghlight] his[tory] ij[ump] il[ist] int[ro] ip[ut] is[earch] isp[lit] ju[mps] l[ist] lN[ext] lNf[ile] la[st] lab[ove] lan[guage] lad[dexpr] laddb[uffer] laddf[ile] laf[ter] lat[er] lb[uffer] lbe[fore] lbel[ow] lbo[ttom] lc[d] lch[dir] nextgroup=vimBang
syn keyword vimCommand contained lcl[ose] lcs[cope] ld[o] le[ft] lex[pr] lf[ile] lfd[o] lfir[st] lg[etfile] lgetb[uffer] lgete[xpr] lgr[ep] lgrepa[dd] lhi[story] ll lla[st] lli[st] lmak[e] lne[xt] lnew[er] lnf[ile] lo[adview] lockv[ar] lol[der] lop[en] lp[revious] lpf[ile] lr[ewind] lt[ag] lw[indow] ls m[ove] marks menut[ranslate] mes[sages] mk[exrc] mks[ession] mksp[ell] mkv[imrc] mkvie[w] mod[e] n[ext] nb[key] nbc[lose] nbs[tart] noh[lsearch] nu[mber] o[pen] ol[dfiles] on[ly] opt[ions] ow[nsyntax] p[rint] pa[ckadd] packl[oadall] pb[uffer] pc[lose] ped[it] po[p] pp[op] pre[serve] prev[ious] pro[mptfind] promptr[epl] ps[earch] pt[ag] ptN[ext] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pw[d] q[uit] quita[ll] qa[ll] r[ead] rec[over] nextgroup=vimBang syn keyword vimCommand contained lcl[ose] lcs[cope] ld[o] le[ft] lex[pr] lf[ile] lfd[o] lfir[st] lg[etfile] lgetb[uffer] lgete[xpr] lgr[ep] lgrepa[dd] lhi[story] ll lla[st] lli[st] lmak[e] lne[xt] lnew[er] lnf[ile] lo[adview] lockv[ar] lol[der] lop[en] lp[revious] lpf[ile] lr[ewind] lt[ag] lw[indow] ls m[ove] marks menut[ranslate] mes[sages] mk[exrc] mks[ession] mksp[ell] mkv[imrc] mkvie[w] mod[e] n[ext] nb[key] nbc[lose] nbs[tart] noh[lsearch] nu[mber] o[pen] ol[dfiles] on[ly] opt[ions] ow[nsyntax] p[rint] pa[ckadd] packl[oadall] pb[uffer] pc[lose] ped[it] po[p] pp[op] pre[serve] prev[ious] pro[mptfind] promptr[epl] ps[earch] pt[ag] ptN[ext] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pw[d] q[uit] quita[ll] qa[ll] r[ead] rec[over] nextgroup=vimBang
syn keyword vimCommand contained red[o] redr[aw] redraws[tatus] redrawt[abline] redrawtabp[anel] reg[isters] res[ize] ret[ab] rew[ind] ri[ght] ru[ntime] rub[y] rubyd[o] rubyf[ile] rund[o] rv[iminfo] sN[ext] sa[rgument] sal[l] sav[eas] sb[uffer] sbN[ext] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbp[revious] sbr[ewind] scr[iptnames] scripte[ncoding] scriptv[ersion] scs[cope] setf[iletype] sf[ind] sfir[st] sh[ell] sim[alt] sig[n] sla[st] sn[ext] so[urce] spe[llgood] spelld[ump] spelli[nfo] spellr[epall] spellra[re] spellu[ndo] spellw[rong] spr[evious] sre[wind] st[op] sta[g] star[tinsert] startg[replace] startr[eplace] stopi[nsert] stj[ump] sts[elect] sun[hide] sus[pend] sv[iew] synti[me] sync[bind] smi[le] t tN[ext] ta[g] tags tabc[lose] tabd[o] tabe[dit] nextgroup=vimBang syn keyword vimCommand contained red[o] redr[aw] redraws[tatus] redrawt[abline] redrawtabp[anel] reg[isters] res[ize] ret[ab] rew[ind] ri[ght] ru[ntime] rub[y] rubyd[o] rubyf[ile] rund[o] rv[iminfo] sN[ext] sa[rgument] sal[l] sav[eas] sb[uffer] sbN[ext] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbp[revious] sbr[ewind] scr[iptnames] scripte[ncoding] scriptv[ersion] scs[cope] setf[iletype] sf[ind] sfir[st] sh[ell] sim[alt] sig[n] sla[st] sn[ext] so[urce] spe[llgood] spelld[ump] spelli[nfo] spellr[epall] spellra[re] spellu[ndo] spellw[rong] spr[evious] sre[wind] st[op] sta[g] star[tinsert] startg[replace] startr[eplace] stopi[nsert] stj[ump] sts[elect] sun[hide] sus[pend] sv[iew] synti[me] sync[bind] smi[le] t tN[ext] ta[g] tags tabc[lose] tabd[o] tabe[dit] nextgroup=vimBang
syn keyword vimCommand contained tabf[ind] tabfir[st] tabm[ove] tabl[ast] tabn[ext] tabnew tabo[nly] tabp[revious] tabN[ext] tabr[ewind] tabs tc[d] tch[dir] te[aroff] tf[irst] tj[ump] tl[ast] tn[ext] tp[revious] tr[ewind] try ts[elect] u[ndo] undoj[oin] undol[ist] unh[ide] unlo[ckvar] up[date] v[global] ve[rsion] vi[sual] vie[w] viu[sage] vne[w] vs[plit] w[rite] wN[ext] wa[ll] wi[nsize] wind[o] winp[os] wl[restore] wn[ext] wp[revious] wq wqa[ll] wu[ndo] wv[iminfo] x[it] xa[ll] xr[estore] y[ank] z dl dell delel deletl deletel dp dep delp delep deletp deletep a i nextgroup=vimBang syn keyword vimCommand contained tabf[ind] tabfir[st] tabm[ove] tabl[ast] tabn[ext] tabnew tabo[nly] tabp[revious] tabN[ext] tabr[ewind] tabs tc[d] tch[dir] te[aroff] tf[irst] tj[ump] tl[ast] tn[ext] tp[revious] tr[ewind] try ts[elect] u[ndo] undoj[oin] undol[ist] unh[ide] unlo[ckvar] up[date] v[global] ve[rsion] vi[sual] vie[w] viu[sage] vne[w] vs[plit] w[rite] wN[ext] wa[ll] wi[nsize] wind[o] winp[os] wl[restore] wn[ext] wp[revious] wq wqa[ll] wu[ndo] wv[iminfo] x[it] xa[ll] xr[estore] y[ank] z dl dell delel deletl deletel dp dep delp delep deletp deletep a i nextgroup=vimBang
@ -146,8 +146,8 @@ syn keyword vimGroup contained Added Bold BoldItalic Boolean Changed Character C
" Default highlighting groups {{{2 " Default highlighting groups {{{2
" GEN_SYN_VIM: vimHLGroup, START_STR='syn keyword vimHLGroup contained', END_STR='' " GEN_SYN_VIM: vimHLGroup, START_STR='syn keyword vimHLGroup contained', END_STR=''
syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor QuickFixLine CursorLineSign CursorLineFold CurSearch PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel PopupSelected MessageWindow PopupNotification PreInsert Normal Directory LineNr CursorLineNr MoreMsg Question Search SpellBad SpellCap SpellRare SpellLocal PmenuThumb Pmenu PmenuSel SpecialKey Title WarningMsg WildMenu Folded FoldColumn SignColumn Visual DiffAdd DiffChange DiffDelete TabLine CursorColumn CursorLine ColorColumn MatchParen StatusLineTerm StatusLineTermNC ToolbarLine ToolbarButton Menu Tooltip Scrollbar syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor TitleBar TitleBarNC QuickFixLine CursorLineSign CursorLineFold CurSearch PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel PopupSelected MessageWindow PopupNotification PreInsert Normal Directory LineNr CursorLineNr MoreMsg Question Search SpellBad SpellCap SpellRare SpellLocal PmenuThumb Pmenu PmenuSel SpecialKey Title WarningMsg WildMenu Folded FoldColumn SignColumn Visual DiffAdd DiffChange DiffDelete TabLine CursorColumn CursorLine ColorColumn MatchParen StatusLineTerm StatusLineTermNC ToolbarLine ToolbarButton
syn keyword vimHLGroup contained CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea Terminal User1 User2 User3 User4 User5 User6 User7 User8 User9 syn keyword vimHLGroup contained TitleBar TitleBarNC Menu Tooltip Scrollbar CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea Terminal User1 User2 User3 User4 User5 User6 User7 User8 User9
syn match vimHLGroup contained "\<Conceal\>" syn match vimHLGroup contained "\<Conceal\>"
syn case match syn case match
@ -1368,7 +1368,7 @@ syn region vimEval
\ end="\ze|" \ end="\ze|"
\ excludenl end="$" \ excludenl end="$"
\ nextgroup=vimCmdSep \ nextgroup=vimCmdSep
\ contains=@vimContinue,@vimExprList,vimComment,vim9Comment \ contains=@vimContinue,@vimExprList,vim9Comment
\ transparent \ transparent
" Filter: {{{2 " Filter: {{{2

View File

@ -3491,6 +3491,10 @@ gui_init_which_components(char_u *oldval UNUSED)
#ifdef FEAT_GUI_TABLINE #ifdef FEAT_GUI_TABLINE
int using_tabline; int using_tabline;
#endif #endif
#ifdef FEAT_GUI_MSWIN
static int prev_titlebar = -1;
int using_titlebar = FALSE;
#endif
#if defined(FEAT_MENU) #if defined(FEAT_MENU)
static int prev_tearoff = -1; static int prev_tearoff = -1;
int using_tearoff = FALSE; int using_tearoff = FALSE;
@ -3560,6 +3564,11 @@ gui_init_which_components(char_u *oldval UNUSED)
case GO_GREY: case GO_GREY:
// make menu's have grey items, ignored here // make menu's have grey items, ignored here
break; break;
#ifdef FEAT_GUI_MSWIN
case GO_TITLEBAR:
using_titlebar = TRUE;
break;
#endif
#ifdef FEAT_TOOLBAR #ifdef FEAT_TOOLBAR
case GO_TOOLBAR: case GO_TOOLBAR:
using_toolbar = TRUE; using_toolbar = TRUE;
@ -3581,6 +3590,14 @@ gui_init_which_components(char_u *oldval UNUSED)
need_set_size = 0; need_set_size = 0;
fix_size = FALSE; fix_size = FALSE;
#ifdef FEAT_GUI_MSWIN
if (using_titlebar != prev_titlebar)
{
gui_mch_set_titlebar_colors();
prev_titlebar = using_titlebar;
}
#endif
#ifdef FEAT_GUI_DARKTHEME #ifdef FEAT_GUI_DARKTHEME
if (using_dark_theme != prev_dark_theme) if (using_dark_theme != prev_dark_theme)
{ {
@ -4751,6 +4768,10 @@ gui_focus_change(int in_focus)
gui.in_focus = in_focus; gui.in_focus = in_focus;
out_flush_cursor(TRUE, FALSE); out_flush_cursor(TRUE, FALSE);
# ifdef FEAT_GUI_MSWIN
gui_mch_set_titlebar_colors();
# endif
# ifdef FEAT_XIM # ifdef FEAT_XIM
xim_set_focus(in_focus); xim_set_focus(in_focus);
# endif # endif

View File

@ -422,6 +422,11 @@ typedef struct Gui
guicolor_T currFgColor; // Current foreground text color guicolor_T currFgColor; // Current foreground text color
guicolor_T currBgColor; // Current background text color guicolor_T currBgColor; // Current background text color
guicolor_T currSpColor; // Current special text color guicolor_T currSpColor; // Current special text color
guicolor_T title_bg_pixel; // window title bar color
guicolor_T title_fg_pixel; // window title bar's text color
guicolor_T titlenc_bg_pixel; // window title bar color not current
guicolor_T titlenc_fg_pixel; // window title bar's text color not current
#endif #endif
#ifdef FEAT_GUI_HAIKU #ifdef FEAT_GUI_HAIKU

View File

@ -318,6 +318,14 @@ gui_mch_set_rendering_options(char_u *s)
# define SPI_SETWHEELSCROLLCHARS 0x006D # define SPI_SETWHEELSCROLLCHARS 0x006D
#endif #endif
#ifndef DWMWA_CAPTION_COLOR
# define DWMWA_CAPTION_COLOR 35
#endif
#ifndef DWMWA_TEXT_COLOR
# define DWMWA_TEXT_COLOR 36
#endif
#ifdef PROTO #ifdef PROTO
/* /*
* Define a few things for generating prototypes. This is just to avoid * Define a few things for generating prototypes. This is just to avoid
@ -468,6 +476,10 @@ static int (WINAPI *pGetSystemMetricsForDpi)(int, UINT) = NULL;
static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL; static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL;
static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL; static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL;
static HINSTANCE hLibDwm = NULL;
static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
static void dyn_dwm_load(void);
static int WINAPI static int WINAPI
stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED) stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED)
{ {
@ -1591,6 +1603,67 @@ _TextAreaWndProc(
} }
} }
static void
dyn_dwm_load(void)
{
hLibDwm = vimLoadLib("dwmapi.dll");
if (hLibDwm == NULL)
return;
pDwmSetWindowAttribute = (HRESULT (WINAPI *)(HWND, DWORD, LPCVOID, DWORD))
GetProcAddress(hLibDwm, "DwmSetWindowAttribute");
if (pDwmSetWindowAttribute == NULL)
{
FreeLibrary(hLibDwm);
hLibDwm = NULL;
return;
}
}
extern BOOL win11_or_later; // this is in os_win32.c
/*
* Set TitleBar's color. Handle hl-TitleBar and hl-TitleBarNC.
*
* Only enabled when 'guioptions' has 'C'.
* if "TitleBar guibg=NONE guifg=NONE" reset the window back to using the
* system's default behavior for the border color.
*/
void
gui_mch_set_titlebar_colors(void)
{
if (pDwmSetWindowAttribute == NULL || !win11_or_later)
return;
guicolor_T captionColor = 0xFFFFFFFF;
guicolor_T textColor = 0xFFFFFFFF;
if (vim_strchr(p_go, GO_TITLEBAR) != NULL)
{
if (gui.in_focus)
{
captionColor = gui.title_bg_pixel;
textColor = gui.title_fg_pixel;
}
else
{
captionColor = gui.titlenc_bg_pixel;
textColor = gui.titlenc_fg_pixel;
}
if (captionColor == INVALCOLOR)
captionColor = 0xFFFFFFFF;
if (textColor == INVALCOLOR)
textColor = 0xFFFFFFFF;
}
pDwmSetWindowAttribute(s_hwnd, DWMWA_CAPTION_COLOR,
&captionColor, sizeof(captionColor));
pDwmSetWindowAttribute(s_hwnd, DWMWA_TEXT_COLOR,
&textColor, sizeof(textColor));
}
/* /*
* Called when the foreground or background color has been changed. * Called when the foreground or background color has been changed.
*/ */
@ -5636,6 +5709,8 @@ gui_mch_init(void)
load_dpi_func(); load_dpi_func();
dyn_dwm_load();
s_dpi = pGetDpiForSystem(); s_dpi = pGetDpiForSystem();
update_scrollbar_size(); update_scrollbar_size();

View File

@ -255,6 +255,10 @@ static char *(highlight_init_both[]) = {
#ifdef FEAT_GUI #ifdef FEAT_GUI
"Cursor guibg=fg guifg=bg", "Cursor guibg=fg guifg=bg",
"lCursor guibg=fg guifg=bg", // should be different, but what? "lCursor guibg=fg guifg=bg", // should be different, but what?
#endif
#ifdef FEAT_GUI_MSWIN
"TitleBar guibg=bg guifg=fg",
"TitleBarNC guibg=NONE guifg=NONE",
#endif #endif
"default link QuickFixLine Search", "default link QuickFixLine Search",
"default link CursorLineSign SignColumn", "default link CursorLineSign SignColumn",
@ -817,6 +821,10 @@ highlight_reset_all(void)
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_X11) # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_X11)
gui_mch_def_colors(); gui_mch_def_colors();
# endif # endif
# ifdef FEAT_GUI_MSWIN
if (gui.in_use)
gui_mch_set_titlebar_colors();
# endif
# ifdef FEAT_GUI_X11 # ifdef FEAT_GUI_X11
# ifdef FEAT_MENU # ifdef FEAT_MENU
@ -1272,6 +1280,8 @@ highlight_set_guifg(
int is_menu_group UNUSED, int is_menu_group UNUSED,
int is_scrollbar_group UNUSED, int is_scrollbar_group UNUSED,
int is_tooltip_group UNUSED, int is_tooltip_group UNUSED,
int is_titlebar_group UNUSED,
int is_titlebarnc_group UNUSED,
int *do_colors UNUSED, int *do_colors UNUSED,
int init) int init)
{ {
@ -1305,6 +1315,18 @@ highlight_set_guifg(
did_change = TRUE; did_change = TRUE;
} }
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_MSWIN
if (is_titlebar_group && gui.title_fg_pixel != i)
{
gui.title_fg_pixel = i;
*do_colors = TRUE;
}
if (is_titlebarnc_group && gui.titlenc_fg_pixel != i)
{
gui.titlenc_fg_pixel = i;
*do_colors = TRUE;
}
# endif
# ifdef FEAT_GUI_X11 # ifdef FEAT_GUI_X11
if (is_menu_group && gui.menu_fg_pixel != i) if (is_menu_group && gui.menu_fg_pixel != i)
{ {
@ -1341,6 +1363,8 @@ highlight_set_guibg(
int is_menu_group UNUSED, int is_menu_group UNUSED,
int is_scrollbar_group UNUSED, int is_scrollbar_group UNUSED,
int is_tooltip_group UNUSED, int is_tooltip_group UNUSED,
int is_titlebar_group UNUSED,
int is_titlebarnc_group UNUSED,
int *do_colors UNUSED, int *do_colors UNUSED,
int init) int init)
{ {
@ -1374,6 +1398,18 @@ highlight_set_guibg(
did_change = TRUE; did_change = TRUE;
} }
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_MSWIN
if (is_titlebar_group && gui.title_bg_pixel != i)
{
gui.title_bg_pixel = i;
*do_colors = TRUE;
}
if (is_titlebarnc_group && gui.titlenc_bg_pixel != i)
{
gui.titlenc_bg_pixel = i;
*do_colors = TRUE;
}
# endif
# ifdef FEAT_GUI_X11 # ifdef FEAT_GUI_X11
if (is_menu_group && gui.menu_bg_pixel != i) if (is_menu_group && gui.menu_bg_pixel != i)
{ {
@ -1551,6 +1587,13 @@ do_highlight(
int dolink = FALSE; int dolink = FALSE;
int error = FALSE; int error = FALSE;
int is_normal_group = FALSE; // "Normal" group int is_normal_group = FALSE; // "Normal" group
#ifdef FEAT_GUI_MSWIN
int is_titlebar_group = FALSE; // "TitleBar" group
int is_titlebarnc_group = FALSE; // "TitleBarNC" group
#else
# define is_titlebar_group 0
# define is_titlebarnc_group 0
#endif
#ifdef FEAT_GUI_X11 #ifdef FEAT_GUI_X11
int is_menu_group = FALSE; // "Menu" group int is_menu_group = FALSE; // "Menu" group
int is_scrollbar_group = FALSE; // "Scrollbar" group int is_scrollbar_group = FALSE; // "Scrollbar" group
@ -1668,6 +1711,12 @@ do_highlight(
if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0)
is_normal_group = TRUE; is_normal_group = TRUE;
#ifdef FEAT_GUI_MSWIN
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TITLEBAR") == 0)
is_titlebar_group = TRUE;
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TITLEBARNC") == 0)
is_titlebarnc_group = TRUE;
#endif
#ifdef FEAT_GUI_X11 #ifdef FEAT_GUI_X11
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0) else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0)
is_menu_group = TRUE; is_menu_group = TRUE;
@ -1808,8 +1857,9 @@ do_highlight(
{ {
#if defined(FEAT_GUI) || defined(FEAT_EVAL) #if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (highlight_set_guifg(idx, arg, is_menu_group, if (highlight_set_guifg(idx, arg, is_menu_group,
is_scrollbar_group, is_tooltip_group, is_scrollbar_group, is_tooltip_group,
&do_colors, init)) is_titlebar_group, is_titlebarnc_group,
&do_colors, init))
did_change = TRUE; did_change = TRUE;
#endif #endif
} }
@ -1818,6 +1868,7 @@ do_highlight(
#if defined(FEAT_GUI) || defined(FEAT_EVAL) #if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (highlight_set_guibg(idx, arg, is_menu_group, if (highlight_set_guibg(idx, arg, is_menu_group,
is_scrollbar_group, is_tooltip_group, is_scrollbar_group, is_tooltip_group,
is_titlebar_group, is_titlebarnc_group,
&do_colors, init)) &do_colors, init))
did_change = TRUE; did_change = TRUE;
#endif #endif
@ -1879,6 +1930,18 @@ do_highlight(
control_console_color_rgb(); control_console_color_rgb();
#endif #endif
} }
#ifdef FEAT_GUI_MSWIN
else if (is_titlebar_group)
{
if (gui.in_use && do_colors)
gui_mch_set_titlebar_colors();
}
else if (is_titlebarnc_group)
{
if (gui.in_use && do_colors)
gui_mch_set_titlebar_colors();
}
#endif
#ifdef FEAT_GUI_X11 #ifdef FEAT_GUI_X11
# ifdef FEAT_MENU # ifdef FEAT_MENU
else if (is_menu_group) else if (is_menu_group)
@ -2052,8 +2115,8 @@ highlight_clear(int idx)
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO) #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
/* /*
* Set the normal foreground and background colors according to the "Normal" * Set the normal foreground and background colors according to the "Normal"
* highlighting group. For X11 also set "Menu", "Scrollbar", and * highlighting group. For X11 also set "Menu", "Scrollbar" and "Tooltip"
* "Tooltip" colors. * colors. For MS-Windows also set "TitleBar" and "TitleBarNC" colors.
*/ */
void void
set_normal_colors(void) set_normal_colors(void)
@ -2070,6 +2133,22 @@ set_normal_colors(void)
gui_mch_new_colors(); gui_mch_new_colors();
set_must_redraw(UPD_CLEAR); set_must_redraw(UPD_CLEAR);
} }
# ifdef FEAT_GUI_MSWIN
if (set_group_colors((char_u *)"TitleBar",
&gui.title_fg_pixel, &gui.title_bg_pixel,
FALSE, FALSE, FALSE))
{
gui_mch_set_titlebar_colors();
set_must_redraw(UPD_CLEAR);
}
if (set_group_colors((char_u *)"TitleBarNC",
&gui.titlenc_fg_pixel, &gui.titlenc_bg_pixel,
FALSE, FALSE, FALSE))
{
gui_mch_set_titlebar_colors();
set_must_redraw(UPD_CLEAR);
}
# endif
# ifdef FEAT_GUI_X11 # ifdef FEAT_GUI_X11
if (set_group_colors((char_u *)"Menu", if (set_group_colors((char_u *)"Menu",
&gui.menu_fg_pixel, &gui.menu_bg_pixel, &gui.menu_fg_pixel, &gui.menu_bg_pixel,
@ -2132,7 +2211,8 @@ set_normal_colors(void)
#if defined(FEAT_GUI) || defined(PROTO) #if defined(FEAT_GUI) || defined(PROTO)
/* /*
* Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". * Set the colors for "Normal", "Menu", "TitleBar", "TitleBarNC", "Tooltip" or
* "Scrollbar".
*/ */
static int static int
set_group_colors( set_group_colors(

View File

@ -288,6 +288,7 @@ typedef enum {
#define GO_ASELML 'A' // autoselect modeless selection #define GO_ASELML 'A' // autoselect modeless selection
#define GO_BOT 'b' // use bottom scrollbar #define GO_BOT 'b' // use bottom scrollbar
#define GO_CONDIALOG 'c' // use console dialog #define GO_CONDIALOG 'c' // use console dialog
#define GO_TITLEBAR 'C' // use 'hl-TitleBar'
#define GO_DARKTHEME 'd' // use dark theme variant #define GO_DARKTHEME 'd' // use dark theme variant
#define GO_TABLINE 'e' // may show tabline #define GO_TABLINE 'e' // may show tabline
#define GO_FORG 'f' // start GUI in foreground #define GO_FORG 'f' // start GUI in foreground
@ -308,7 +309,7 @@ typedef enum {
#define GO_VERTICAL 'v' // arrange dialog buttons vertically #define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size #define GO_KEEPWINSIZE 'k' // keep GUI window size
// all possible flags for 'go' // all possible flags for 'go'
#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk" #define GO_ALL "!aAbcCdefFghilLmMpPrRtTvk"
// flags for 'comments' option // flags for 'comments' option
#define COM_NEST 'n' // comments strings nest #define COM_NEST 'n' // comments strings nest

View File

@ -224,6 +224,8 @@ static WCHAR *exe_pathw = NULL;
static BOOL win8_or_later = FALSE; static BOOL win8_or_later = FALSE;
static BOOL win10_22H2_or_later = FALSE; static BOOL win10_22H2_or_later = FALSE;
BOOL win11_or_later = FALSE; // used in gui_mch_set_titlebar_colors(void)
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
static BOOL use_alternate_screen_buffer = FALSE; static BOOL use_alternate_screen_buffer = FALSE;
#endif #endif
@ -1010,6 +1012,10 @@ PlatformId(void)
|| ovi.dwMajorVersion > 10) || ovi.dwMajorVersion > 10)
win10_22H2_or_later = TRUE; win10_22H2_or_later = TRUE;
if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 22000)
|| ovi.dwMajorVersion > 10)
win11_or_later = TRUE;
#ifdef HAVE_ACL #ifdef HAVE_ACL
// Enable privilege for getting or setting SACLs. // Enable privilege for getting or setting SACLs.
if (!win32_enable_privilege(SE_SECURITY_NAME)) if (!win32_enable_privilege(SE_SECURITY_NAME))

View File

@ -5,6 +5,7 @@ int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off); void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_stop_blink(int may_call_gui_update_cursor); void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
void gui_mch_set_titlebar_colors(void);
void gui_mch_new_colors(void); void gui_mch_new_colors(void);
void gui_mch_def_colors(void); void gui_mch_def_colors(void);
int gui_mch_open(void); int gui_mch_open(void);

View File

@ -664,6 +664,13 @@ func Test_set_guioptions()
set guioptions& set guioptions&
call assert_equal('egmrLtT', &guioptions) call assert_equal('egmrLtT', &guioptions)
set guioptions+=C
exec 'sleep' . duration
call assert_equal('egmrLtTC', &guioptions)
set guioptions-=C
exec 'sleep' . duration
call assert_equal('egmrLtT', &guioptions)
else else
" Default Value " Default Value
set guioptions& set guioptions&

View File

@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1834,
/**/ /**/
1833, 1833,
/**/ /**/