Skip to content

Commit 6bc8de5

Browse files
committed
fixed caret problem for filename
1 parent 50f8b2a commit 6bc8de5

File tree

1 file changed

+31
-58
lines changed

1 file changed

+31
-58
lines changed

src/ResultDock.cpp

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -616,31 +616,24 @@ void ResultDock::applyTheme()
616616
if (!_hSci)
617617
return;
618618

619-
// helper: send message to the dock Scintilla --------------------
619+
// Helper: send message to the Scintilla dock
620620
auto S = [this](UINT m, WPARAM w = 0, LPARAM l = 0) -> LRESULT
621621
{ return ::SendMessage(_hSci, m, w, l); };
622622

623-
/* ----------------------------------------------------------------
624-
* 0) Base editor colours from Notepad++
625-
* ---------------------------------------------------------------- */
626-
const bool dark = ::SendMessage(
627-
nppData._nppHandle, NPPM_ISDARKMODEENABLED, 0, 0) != 0;
623+
// 0. Retrieve base editor colors from Notepad++
624+
const bool dark = ::SendMessage(nppData._nppHandle, NPPM_ISDARKMODEENABLED, 0, 0) != 0;
628625

629-
COLORREF editorBg = (COLORREF)::SendMessage(
630-
nppData._nppHandle, NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
631-
COLORREF editorFg = (COLORREF)::SendMessage(
632-
nppData._nppHandle, NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, 0);
626+
COLORREF editorBg = (COLORREF)::SendMessage(nppData._nppHandle, NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
627+
COLORREF editorFg = (COLORREF)::SendMessage(nppData._nppHandle, NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, 0);
633628

634-
635-
// 1) Reset Scintilla styles and set global font
629+
// 1. Reset styles and set global font
636630
S(SCI_STYLESETBACK, STYLE_DEFAULT, editorBg);
637631
S(SCI_STYLESETFORE, STYLE_DEFAULT, editorFg);
638632
S(SCI_STYLECLEARALL);
639-
640633
S(SCI_STYLESETFONT, STYLE_DEFAULT, (LPARAM)"Consolas");
641634
S(SCI_STYLESETSIZE, STYLE_DEFAULT, 10);
642635

643-
// 2) Margin (0=line #, 1=symbol, 2=fold) – always pitch‑black
636+
// 2. Configure margins (0=line number, 1=symbol, 2=fold)
644637
COLORREF marginBg = dark ? RGB(0, 0, 0) : editorBg;
645638
COLORREF marginFg = dark ? RGB(200, 200, 200) : RGB(80, 80, 80);
646639

@@ -653,7 +646,7 @@ void ResultDock::applyTheme()
653646
S(SCI_SETFOLDMARGINCOLOUR, TRUE, marginBg);
654647
S(SCI_SETFOLDMARGINHICOLOUR, TRUE, marginBg);
655648

656-
// 3) Selection & additional selection colours
649+
// 3. Selection colors
657650
COLORREF selBg = dark ? RGB(96, 96, 96) : RGB(0xE0, 0xE0, 0xE0);
658651
COLORREF selFg = dark ? RGB(255, 255, 255) : editorFg;
659652

@@ -668,90 +661,70 @@ void ResultDock::applyTheme()
668661
S(SCI_SETADDITIONALSELBACK, selBg);
669662
S(SCI_SETADDITIONALSELALPHA, 256, 0);
670663

671-
// 4) Fold markers
664+
// 4. Fold marker colors
672665
const COLORREF markerGlyph = dark ? RDColors::FoldGlyphDark : RDColors::FoldGlyphLight;
673666

674-
for (int id : {
675-
SC_MARKNUM_FOLDER,
676-
SC_MARKNUM_FOLDEREND,
677-
SC_MARKNUM_FOLDEROPEN,
678-
SC_MARKNUM_FOLDEROPENMID,
679-
SC_MARKNUM_FOLDERSUB,
680-
SC_MARKNUM_FOLDERMIDTAIL,
681-
SC_MARKNUM_FOLDERTAIL
682-
})
667+
for (int id : {SC_MARKNUM_FOLDER, SC_MARKNUM_FOLDEREND, SC_MARKNUM_FOLDEROPEN,
668+
SC_MARKNUM_FOLDEROPENMID, SC_MARKNUM_FOLDERSUB,
669+
SC_MARKNUM_FOLDERMIDTAIL, SC_MARKNUM_FOLDERTAIL})
683670
{
684671
S(SCI_MARKERSETBACK, id, markerGlyph);
685672
S(SCI_MARKERSETFORE, id, marginBg);
686-
S( SCI_MARKERSETBACKSELECTED, id, dark ? RDColors::FoldHiDark : RDColors::FoldHiLight );
673+
S(SCI_MARKERSETBACKSELECTED, id, dark ? RDColors::FoldHiDark : RDColors::FoldHiLight);
687674
}
688675

689-
/* ----------------------------------------------------------------
690-
* 5) Caret‑line highlight (indicator 0) – grey stripe
691-
* ---------------------------------------------------------------- */
676+
// 5. Caret line indicator (indicator 0)
692677
S(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX);
693678
S(SCI_INDICSETFORE, 0, selBg);
694-
// use per‑mode alpha from RDColors
695679
S(SCI_INDICSETALPHA, 0, dark ? RDColors::CaretLineAlphaDark : RDColors::CaretLineAlphaLight);
696680
S(SCI_INDICSETUNDER, 0, TRUE);
697681

698-
// keep visible (was missing in earlier patch)
699682
S(SCI_SETCARETLINEVISIBLE, TRUE, 0);
700683
S(SCI_SETCARETLINEBACK, dark ? selBg : RDColors::CaretLineBackLight, 0);
684+
S(SCI_SETCARETLINEBACKALPHA, dark ? RDColors::CaretLineAlphaDark : RDColors::CaretLineAlphaLight);
701685

702-
// 6) Custom indicators and styles
686+
// 6. Custom indicators and styles
703687
COLORREF hitLineBg = dark ? RDColors::LineBgDark : RDColors::LineBgLight;
704688
COLORREF lineNrFg = dark ? RDColors::LineNrDark : RDColors::LineNrLight;
705689
COLORREF matchFg = dark ? RDColors::MatchDark : RDColors::MatchLight;
706690
COLORREF matchBg = RDColors::MatchBgLight;
707691
COLORREF headerBg = dark ? RDColors::HeaderBgDark : RDColors::HeaderBgLight;
708692
COLORREF filePathFg = dark ? RDColors::FilePathFgDark : RDColors::FilePathFgLight;
709693

710-
// 6‑a) Grey background for entire hit line
694+
// 6-a Hit line background
711695
S(SCI_INDICSETSTYLE, INDIC_LINE_BACKGROUND, INDIC_STRAIGHTBOX);
712696
S(SCI_INDICSETFORE, INDIC_LINE_BACKGROUND, hitLineBg);
713697
S(SCI_INDICSETALPHA, INDIC_LINE_BACKGROUND, 100);
714698
S(SCI_INDICSETUNDER, INDIC_LINE_BACKGROUND, TRUE);
715699

716-
// 6‑b) Coloured digits (line number)
700+
// 6-b Line number color
717701
S(SCI_INDICSETSTYLE, INDIC_LINENUMBER_FORE, INDIC_TEXTFORE);
718702
S(SCI_INDICSETFORE, INDIC_LINENUMBER_FORE, lineNrFg);
719703

720-
// 6‑c) Match substrings
721-
if (!dark) {
722-
// configure yellow‑box indicator under the text
723-
S(SCI_INDICSETSTYLE, INDIC_MATCH_BG, INDIC_FULLBOX);
724-
S(SCI_INDICSETFORE, INDIC_MATCH_BG, matchBg);
725-
S(SCI_INDICSETALPHA, INDIC_MATCH_BG, 255);
726-
S(SCI_INDICSETUNDER, INDIC_MATCH_BG, TRUE);
727-
728-
// configure red‑text indicator
729-
S(SCI_INDICSETSTYLE, INDIC_MATCH_FORE, INDIC_TEXTFORE);
730-
S(SCI_INDICSETFORE, INDIC_MATCH_FORE, matchFg);
731-
}
732-
else {
733-
// in Dark‑mode: disable the BG indicator explicitly
734-
S(SCI_INDICSETALPHA, INDIC_MATCH_BG, 0);
735-
// still draw the text in the dark‑mode color
736-
S(SCI_INDICSETSTYLE, INDIC_MATCH_FORE, INDIC_TEXTFORE);
737-
S(SCI_INDICSETFORE, INDIC_MATCH_FORE, matchFg);
738-
}
704+
// 6-c Match indicators
705+
S(SCI_INDICSETSTYLE, INDIC_MATCH_BG, INDIC_FULLBOX);
706+
S(SCI_INDICSETFORE, INDIC_MATCH_BG, matchBg);
707+
S(SCI_INDICSETALPHA, INDIC_MATCH_BG, dark ? 0 : 255);
708+
S(SCI_INDICSETUNDER, INDIC_MATCH_BG, TRUE);
709+
710+
S(SCI_INDICSETSTYLE, INDIC_MATCH_FORE, INDIC_TEXTFORE);
711+
S(SCI_INDICSETFORE, INDIC_MATCH_FORE, matchFg);
739712

740-
// 6-d) Style for header lines ("Search ...")
741-
// Inherits font name and size from STYLE_DEFAULT. We just change color and weight.
713+
// 6-d Header line style
742714
S(SCI_STYLESETFORE, STYLE_HEADER, RDColors::HeaderFg);
743715
S(SCI_STYLESETBACK, STYLE_HEADER, headerBg);
744716
S(SCI_STYLESETBOLD, STYLE_HEADER, TRUE);
745717
S(SCI_STYLESETEOLFILLED, STYLE_HEADER, TRUE);
746718

747-
// 6-e) Style for file path lines (4-space indent)
748-
// Inherits font, size, and background from STYLE_DEFAULT. We change foreground and weight.
719+
// 6-e File path style
749720
S(SCI_STYLESETFORE, STYLE_FILEPATH, filePathFg);
750-
S(SCI_STYLESETBACK, STYLE_FILEPATH, editorBg); // Use default editor background
721+
S(SCI_STYLESETBACK, STYLE_FILEPATH, -1);
751722
S(SCI_STYLESETBOLD, STYLE_FILEPATH, TRUE);
752723
S(SCI_STYLESETITALIC, STYLE_FILEPATH, TRUE);
724+
S(SCI_STYLESETEOLFILLED, STYLE_FILEPATH, TRUE);
753725
}
754726

727+
755728
void ResultDock::applyStyling() const
756729
{
757730
if (!_hSci) return;

0 commit comments

Comments
 (0)