docs: Add np3_patches folder with Scintilla.h patch archive

- Created scintilla/np3_patches/ for tracking NP3 customizations
- Added README.md with patch registry and upgrade instructions
- Added 001_scintilla_h_np3_exports.patch (all Scintilla.h mods)
- Added orig/Scintilla.h.558.orig for clean upstream reference
- Updated scintilla-lexilla-upgrade.md with patch management strategy
This commit is contained in:
Derick Payne 2026-01-17 22:31:12 +02:00
parent 2e4889e82a
commit c869371213
4 changed files with 1785 additions and 0 deletions

View File

@ -0,0 +1,99 @@
diff --git "a/r:\\GitHub\\Notepad3\\scintilla\\np3_patches\\orig\\Scintilla.h.558.orig" "b/r:\\GitHub\\Notepad3\\scintilla\\include\\Scintilla.h"
index f7afa4f50..0d9169572 100644
--- "a/r:\\GitHub\\Notepad3\\scintilla\\np3_patches\\orig\\Scintilla.h.558.orig"
+++ "b/r:\\GitHub\\Notepad3\\scintilla\\include\\Scintilla.h"
@@ -15,18 +15,30 @@
extern "C" {
#endif
-#if defined(_WIN32)
-/* Return false on failure: */
-int Scintilla_RegisterClasses(void *hInstance);
-int Scintilla_ReleaseResources(void);
-#endif
+// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
+// ==============================================================
+// --- needed to bind Scintilla as dynamic link library (DLL) ---
+// ==============================================================
+typedef struct _wrct_t { long left; long top; long right; long bottom; } WRECT, *LPWRECT; // Windows RECT
+__declspec(dllexport) int Scintilla_RegisterClasses(void *hInstance);
+__declspec(dllexport) int Scintilla_ReleaseResources(void);
+__declspec(dllexport) int Scintilla_InputCodePage(void);
+__declspec(dllexport) unsigned Scintilla_GetWindowDPI(void* hwnd);
+__declspec(dllexport) int Scintilla_GetSystemMetricsForDpi(int nIndex, unsigned dpi);
+__declspec(dllexport) int Scintilla_GetSystemMetricsForDpi(int nIndex, unsigned dpi);
+__declspec(dllexport) int Scintilla_AdjustWindowRectForDpi(LPWRECT lpRect, unsigned long dwStyle, unsigned long dwExStyle, unsigned dpi);
+// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
#ifdef __cplusplus
}
#endif
// Include header that defines basic numeric types.
+#if defined(__cplusplus)
+#include <cstdint>
+#else
#include <stdint.h>
+#endif
// Define uptr_t, an unsigned integer type large enough to hold a pointer.
typedef uintptr_t uptr_t;
@@ -45,6 +57,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_START 2000
#define SCI_OPTIONAL_START 3000
#define SCI_LEXER_START 4000
+#define SCI_DEV_USER_DEFINED 6000
#define SCI_ADDTEXT 2001
#define SCI_ADDSTYLEDTEXT 2002
#define SCI_INSERTTEXT 2003
@@ -112,6 +125,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SC_IME_INLINE 1
#define SCI_GETIMEINTERACTION 2678
#define SCI_SETIMEINTERACTION 2679
+#define SCI_ISIMEOPEN 6003
+#define SCI_ISIMEMODECJK 6004
#define SC_ALPHA_TRANSPARENT 0
#define SC_ALPHA_OPAQUE 255
#define SC_ALPHA_NOALPHA 256
@@ -252,6 +267,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_STYLESETEOLFILLED 2057
#define SCI_STYLERESETDEFAULT 2058
#define SCI_STYLESETUNDERLINE 2059
+#define SCI_STYLESETSTRIKE 6001
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
@@ -264,6 +280,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_STYLEGETFONT 2486
#define SCI_STYLEGETEOLFILLED 2487
#define SCI_STYLEGETUNDERLINE 2488
+#define SCI_STYLEGETSTRIKE 6002
#define SCI_STYLEGETCASE 2489
#define SCI_STYLEGETCHARACTERSET 2490
#define SCI_STYLEGETVISIBLE 2491
@@ -520,6 +537,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCFIND_NONE 0x0
#define SCFIND_WHOLEWORD 0x2
#define SCFIND_MATCHCASE 0x4
+#define SCFIND_DOT_MATCH_ALL 0x1000
#define SCFIND_WORDSTART 0x00100000
#define SCFIND_REGEXP 0x00200000
#define SCFIND_POSIX 0x00400000
@@ -845,6 +863,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SC_POPUP_TEXT 2
#define SCI_USEPOPUP 2371
#define SCI_SELECTIONISRECTANGLE 2372
+#define SC_MIN_ZOOM_LEVEL 10
+#define SC_MAX_ZOOM_LEVEL 1000
#define SCI_SETZOOM 2373
#define SCI_GETZOOM 2374
#define SC_DOCUMENTOPTION_DEFAULT 0
@@ -1199,7 +1219,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_GETLEXER 4002
#define SCI_COLOURISE 4003
#define SCI_SETPROPERTY 4004
-#define KEYWORDSET_MAX 8
+#define KEYWORDSET_MAX 15
#define SCI_SETKEYWORDS 4005
#define SCI_GETPROPERTY 4008
#define SCI_GETPROPERTYEXPANDED 4009

View File

@ -0,0 +1,94 @@
# Notepad3 Scintilla Patches
This folder contains NP3-specific patches applied to the upstream Scintilla library.
## Folder Structure
```
np3_patches/
├── README.md # This file
├── 001_scintilla_h_np3_exports.patch # All Scintilla.h customizations
└── orig/
└── Scintilla.h.558.orig # Clean upstream Scintilla 5.5.8
```
## Patch Registry
| ID | Patch File | Description | Status |
|-----|------------|-------------|--------|
| 001 | `001_scintilla_h_np3_exports.patch` | DLL exports, IME, Strikethrough, etc. | ✅ Applied |
| 008 | (pending) | DirectWrite font fix (#2080, #2262) | ⏳ Not applied |
## Applied Patches Detail
### Patch 001: Scintilla.h NP3 Exports
**File:** `include/Scintilla.h`
Contains all NP3-specific modifications to Scintilla.h:
1. **DLL Export Functions** (lines 18-30)
- `WRECT` typedef for DPI handling
- `Scintilla_RegisterClasses()` with `__declspec(dllexport)`
- `Scintilla_ReleaseResources()`
- `Scintilla_InputCodePage()`
- `Scintilla_GetWindowDPI()`
- `Scintilla_GetSystemMetricsForDpi()`
- `Scintilla_AdjustWindowRectForDpi()`
2. **C++ Header Include** (lines 37-41)
- Conditional `<cstdint>` vs `<stdint.h>`
3. **User-Defined Message Range**
- `SCI_DEV_USER_DEFINED 6000`
4. **IME Detection Functions**
- `SCI_ISIMEOPEN 6003`
- `SCI_ISIMEMODECJK 6004`
5. **Strikethrough Style**
- `SCI_STYLESETSTRIKE 6001`
- `SCI_STYLEGETSTRIKE 6002`
6. **Regex Enhancement**
- `SCFIND_DOT_MATCH_ALL 0x1000`
7. **Keyword Set Maximum**
- Changed `KEYWORDSET_MAX` from 8 to 15
## Pending Patches
### Patch 008: DirectWrite Font Fix (NOT YET APPLIED)
**Upstream Bugs:** #2080, #2262, #2356
**Merge Request:** [MR #36](https://sourceforge.net/p/scintilla/code/merge-requests/36/)
**Files:** `win32/ScintillaWin.cxx`, `win32/PlatWin.cxx`
Fixes variable font and non-regular font style issues (Cascadia Mono Light, Iosevka, etc.)
**Related NP3 Issues:** #4150, #5455
## How to Apply Patches
```bash
# From scintilla/ directory:
git apply np3_patches/001_scintilla_h_np3_exports.patch
```
## How to Regenerate Patches
```bash
# After modifying Scintilla.h:
git diff --no-index np3_patches/orig/Scintilla.h.558.orig include/Scintilla.h > np3_patches/001_scintilla_h_np3_exports.patch
```
## Upgrade Process
See `todo/research/scintilla-lexilla-upgrade.md` for the complete upgrade checklist.
Quick steps:
1. Download new Scintilla
2. Copy new `include/Scintilla.h` to `np3_patches/orig/Scintilla.h.XXX.orig`
3. Apply patches or manually merge
4. Regenerate patch files
5. Update this README with new version numbers

File diff suppressed because it is too large Load Diff

View File

@ -225,3 +225,104 @@ The main complexity is preserving the **Oniguruma regex integration**:
- Location: `scintilla/oniguruma/scintilla/OnigurumaRegExEngine.cxx`
- Purpose: Unicode-aware regex with extended syntax
- Activated via `SCI_OWNREGEX` preprocessor define
---
## Custom Patches Management
### Patch Folder Structure
All NP3-specific patches should be stored in `scintilla/np3_patches/` for tracking:
```
scintilla/
├── np3_patches/ # NEW: Track all NP3 customizations
│ ├── README.md # Index of all patches
│ ├── 001_scintilla_h_exports.patch
│ ├── 002_directwrite_font_fix.patch
│ └── orig/ # Original upstream files for diffing
│ └── ScintillaWin.cxx.orig
├── include/
│ └── Scintilla.h # Contains NP3 exports patch
├── win32/
│ └── ScintillaWin.cxx # May contain DirectWrite fix
└── oniguruma/ # Existing - regex engine
```
### Patch Registry
| ID | Patch Name | Files Modified | Scintilla Bug | Status |
|----|------------|----------------|---------------|--------|
| 001 | DLL Export Functions | `include/Scintilla.h` | N/A (NP3-specific) | ✅ Applied |
| 002 | C++ Header Include | `include/Scintilla.h` | N/A | ✅ Applied |
| 003 | User-Defined Messages | `include/Scintilla.h` | N/A | ✅ Applied |
| 004 | IME Detection | `include/Scintilla.h` | N/A | ✅ Applied |
| 005 | Strikethrough Style | `include/Scintilla.h` | N/A | ✅ Applied |
| 006 | SCFIND_DOT_MATCH_ALL | `include/Scintilla.h` | N/A | ✅ Applied |
| 007 | KEYWORDSET_MAX=15 | `include/Scintilla.h` | N/A | ✅ Applied |
| 008 | DirectWrite Font Fix | `win32/ScintillaWin.cxx`, `win32/PlatWin.cxx` | #2080, #2262 | ⏳ Pending |
### Upstream Scintilla Bugs (Pending Fixes)
| Bug # | Title | MR | Impact |
|-------|-------|-------|--------|
| **#2080** | D2D font family/face name confusion | [MR #36](https://sourceforge.net/p/scintilla/code/merge-requests/36/) | Variable fonts fail |
| **#2262** | Inability to display some fonts | Related to #2080 | Non-regular styles fail |
| **#2356** | Font weight issues | Related to #2080 | Light/SemiBold fail |
**NP3 Issues Waiting on Fix:** #4150, #5455
---
## Future Upgrade Checklist
When upgrading Scintilla/Lexilla:
### Pre-Upgrade
```
[ ] 1. Create backup of entire scintilla/ and lexilla/ folders
[ ] 2. Note current version numbers in version.txt
[ ] 3. Check Scintilla release notes for breaking changes
[ ] 4. Check if upstream bugs #2080/#2262 are fixed in new version
```
### During Upgrade
```
[ ] 1. Download new Scintilla/Lexilla
[ ] 2. Replace src/, win32/, doc/, scripts/ (NOT include/)
[ ] 3. PRESERVE these folders:
- scintilla/oniguruma/ (entire folder)
- scintilla/np3_patches/ (if exists)
- scintilla/*.vcxproj
- lexilla/lexers_x/
- lexilla/*.vcxproj
[ ] 4. Merge Scintilla.h patches manually:
- Compare new include/Scintilla.h with backup
- Re-apply patches 001-007 from Patch Registry
[ ] 5. Re-apply Patch 008 (DirectWrite) if not yet in upstream
[ ] 6. Update version.txt
```
### Post-Upgrade Verification
```
[ ] 1. Build Debug x64
[ ] 2. Build Release x64
[ ] 3. Test: Basic text editing
[ ] 4. Test: Regex search/replace (Oniguruma)
[ ] 5. Test: Font selection (try Cascadia Mono Light)
[ ] 6. Test: Variable fonts (try Iosevka)
[ ] 7. Test: DPI scaling (100%, 150%, 200%)
[ ] 8. Test: Syntax highlighting
[ ] 9. Commit with message: "deps: Upgrade Scintilla X.Y.Z, Lexilla A.B.C"
```
### If Upstream Fixes Our Bugs
When Scintilla merges #2080/#2262 fix:
```
[ ] 1. Remove Patch 008 from np3_patches/
[ ] 2. Update Patch Registry (mark as "Upstreamed")
[ ] 3. Close NP3 issues #4150, #5455
[ ] 4. Test font selection thoroughly
```