Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/compare-plus-host-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ ComparePlus can continue, but there is no equivalent visible macOS UI surface ye
| `NPPM_GETCURRENTCMDLINE` | Compare.cpp (checkCmdLine) | **IMPLEMENTED** (nppm_handler.mm, returns empty command line) |
| `NPPM_GETCURRENTNATIVELANGENCODING` | NppHelpers.h | **IMPLEMENTED** (nppm_handler.mm, returns UTF-8) |
| `NPPN_GLOBALMODIFIED` | Compare.cpp | **NOT EMITTED** |
| `NPPN_DARKMODECHANGED` | Compare.cpp | **NOT EMITTED** |
| `NPPN_WORDSTYLESUPDATED` | Compare.cpp | **NOT EMITTED** |
| `NPPN_DARKMODECHANGED` | Compare.cpp | **EMITTED** (app_delegate.mm `appearanceChanged:`) |
| `NPPN_WORDSTYLESUPDATED` | Compare.cpp | **NOT EMITTED** (no host style-configurator UI yet to drive it; ComparePlus handles it identically to `NPPN_DARKMODECHANGED`, so dark-mode toggles already refresh its colors) |

## Command Alias / Navigation Surface

Expand Down Expand Up @@ -90,4 +90,5 @@ SETLINENUMBERWIDTHMODE, GETBOOKMARKID, GETNATIVELANGFILENAME, GETCURRENTCMDLINE,
GETCURRENTNATIVELANGENCODING

NPPN: NPPN_READY, NPPN_SHUTDOWN, NPPN_LANGCHANGED, NPPN_FILEBEFORECLOSE, NPPN_FILESAVED,
NPPN_FILEOPENED, NPPN_FILECLOSED, NPPN_BUFFERACTIVATED, NPPN_BEFORESHUTDOWN, NPPN_TBMODIFICATION
NPPN_FILEOPENED, NPPN_FILECLOSED, NPPN_BUFFERACTIVATED, NPPN_BEFORESHUTDOWN, NPPN_TBMODIFICATION,
NPPN_DARKMODECHANGED
5 changes: 5 additions & 0 deletions macos/platform/app_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ - (void)appearanceChanged:(NSNotification*)notification
ScintillaBridge_sendMessage(ctx().scintillaView, SCI_COLOURISE, 0, -1);
if (ctx().isSplit && ctx().scintillaView2)
ScintillaBridge_sendMessage(ctx().scintillaView2, SCI_COLOURISE, 0, -1);

SCNotification darkNotif{};
darkNotif.nmhdr.hwndFrom = ctx().mainHwnd;
darkNotif.nmhdr.code = NPPN_DARKMODECHANGED;
pluginManager().notify(&darkNotif);
});
}

Expand Down
1 change: 1 addition & 0 deletions macos/platform/appearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

bool isAppDarkMode();
void applyFoldMarkerColorsToView(void* sci, bool isDark);
void applyAppearanceToView(void* sci, int langIdx, bool isDark);
void applyAppearance();
33 changes: 19 additions & 14 deletions macos/platform/appearance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
#include "appearance.h"
#include "npp_constants.h"
#include "app_state.h"
#include "language_defs.h"
#include "lexer_styles.h"
#include "scintilla_config.h"
#include "scintilla_bridge.h"
#include "brace_match.h"
#include "smart_highlight.h"
#include "language_defs.h"
#include "lexer_styles.h"
#include "scintilla_config.h"
#include "scintilla_bridge.h"
#include "brace_match.h"
#include "smart_highlight.h"
#include "change_history.h"

bool isAppDarkMode()
{
NSAppearanceName appearanceName = [NSApp.effectiveAppearance
bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
return [appearanceName isEqualToString:NSAppearanceNameDarkAqua];
}

void applyFoldMarkerColorsToView(void* sci, bool isDark)
{
if (!sci) return;
Expand Down Expand Up @@ -68,19 +75,17 @@ void applyAppearanceToView(void* sci, int langIdx, bool isDark)
configureSmartHighlightIndicator(sci, isDark);

// Incremental search indicator colors
ScintillaBridge_sendMessage(sci, SCI_INDICSETFORE, INDIC_INCREMENTAL_SEARCH,
isDark ? 0x50C8FF : 0xFF8000);

refreshLineNumberMargin(sci);
}
ScintillaBridge_sendMessage(sci, SCI_INDICSETFORE, INDIC_INCREMENTAL_SEARCH,
isDark ? 0x50C8FF : 0xFF8000);
refreshLineNumberMargin(sci);
}

void applyAppearance()
{
if (!ctx().scintillaView) return;

NSAppearanceName appearanceName = [NSApp.effectiveAppearance
bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
bool isDark = [appearanceName isEqualToString:NSAppearanceNameDarkAqua];
bool isDark = isAppDarkMode();

int langIdx = 0;
if (ctx().activeTab >= 0 && ctx().activeTab < static_cast<int>(ctx().documents.size()))
Expand Down
23 changes: 12 additions & 11 deletions macos/platform/nppm_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "menu_builder.h"
#include "string_utils.h"
#include "compare_plus_visibility.h"
#include "appearance.h"
#include "Notepad_plus_msgs.h"
#include "Scintilla.h"

Expand Down Expand Up @@ -234,21 +235,21 @@ LRESULT handleNppmMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}

case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR:
// Returned as 0x00BBGGRR (Win32 COLORREF). White matches our
// default light-mode Scintilla background. Plugins derive
// dependent colors (ComparePlus's "blank" marker shade) from
// this; returning 0 / black made the whole diff wash read as
// near-black, hiding the actual marker colors.
// TODO Phase 5: dark-mode branch.
return 0x00FFFFFF;
// Returned as 0x00BBGGRR (Win32 COLORREF). Must match the
// background Scintilla paints for style 32 in
// applyAppearanceToView (SCI_STYLESETBACK), or plugins derive
// marker shades against the wrong base — ComparePlus's "blank"
// marker in particular.
return isAppDarkMode() ? 0x001E1E1E : 0x00FFFFFF;

case NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR:
return 0x00000000;
return isAppDarkMode() ? 0x00D4D4D4 : 0x00000000;

case NPPM_ISDARKMODEENABLED:
// Until we wire up real dark-mode detection, report light mode.
// ComparePlus picks its color palette based on this.
return FALSE;
// ComparePlus picks its color palette based on this; on TRUE
// it switches to Settings.useDarkColors() so diff backgrounds
// stay legible against a dark editor background.
return isAppDarkMode() ? TRUE : FALSE;

case NPPM_ALLOCATEMARKER:
{
Expand Down
Loading