From 7777aa28b5e293ce0b85da2746f338b97c1ea974 Mon Sep 17 00:00:00 2001 From: Derick Payne Date: Sun, 18 Jan 2026 03:15:28 +0200 Subject: [PATCH] docs: add EditorConfig integration research and update TODO - Created todo/research/editorconfig-integration.md with detailed plan - Added EditorConfig feature to Medium Priority in TODO.md - Marked DirectWrite Font Variant Bug as fixed --- todo/TODO.md | 12 ++- todo/research/editorconfig-integration.md | 89 +++++++++++++++++++++++ 2 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 todo/research/editorconfig-integration.md diff --git a/todo/TODO.md b/todo/TODO.md index d6aef3234..87622b463 100644 --- a/todo/TODO.md +++ b/todo/TODO.md @@ -7,15 +7,19 @@ ## Medium Priority -- [ ] **DirectWrite Font Variant Bug** - Cascadia Mono Light breaks rendering - - Known Scintilla limitation with WSS font family model - - Not fixed in 5.5.8 - may need custom patch - - See: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12602 +- [x] **DirectWrite Font Variant Bug** - ✅ Fixed with ResolveFontFace() patch + - Uses IDWriteGdiInterop to resolve font face → family + weight/style/stretch + - See [scintilla/np3_patches/001_directwrite_font_resolution.md](../scintilla/np3_patches/001_directwrite_font_resolution.md) - [ ] **SVG Toolbar Icons** - Resolution-independent toolbar with dark/light mode - Auto-adapts to any DPI (100%-300%) - Dark/light mode color switching - Keep classic bitmap as fallback (ToolBarTheme 0/1) - See [research/svg-toolbar.md](research/svg-toolbar.md) +- [ ] **EditorConfig Integration** - Apply `.editorconfig` settings on file open + - Use [editorconfig-core-c](https://github.com/editorconfig/editorconfig-core-c) library + - Support: indent_style, indent_size, tab_width, end_of_line, charset + - Effort: ~2-4 weeks + - See [research/editorconfig-integration.md](research/editorconfig-integration.md) - [ ] Installer testing on various Windows versions - [ ] Language file updates diff --git a/todo/research/editorconfig-integration.md b/todo/research/editorconfig-integration.md new file mode 100644 index 000000000..637dc7a24 --- /dev/null +++ b/todo/research/editorconfig-integration.md @@ -0,0 +1,89 @@ +# EditorConfig Integration Research + +## Overview + +**EditorConfig** maintains consistent coding styles across editors and IDEs by reading `.editorconfig` files from the project directory tree. + +- Website: https://editorconfig.org/ +- Spec: https://spec.editorconfig.org/ +- C Library: https://github.com/editorconfig/editorconfig-core-c + +## Supported Properties + +| Property | Values | NP3 Scintilla API | +|----------|--------|-------------------| +| `indent_style` | `tab`, `space` | `SCI_SETUSETABS` | +| `indent_size` | integer | `SCI_SETINDENT` | +| `tab_width` | integer | `SCI_SETTABWIDTH` | +| `end_of_line` | `lf`, `cr`, `crlf` | `SCI_SETEOLMODE` | +| `charset` | `utf-8`, `latin1`, etc. | Encoding system | +| `trim_trailing_whitespace` | `true`, `false` | On-save hook | +| `insert_final_newline` | `true`, `false` | On-save hook | + +## Implementation Approach: editorconfig-core-c + +### Dependencies + +``` +editorconfig-core-c (BSD-2-Clause) +├── PCRE2 (for glob matching) - Already in NP3 via Oniguruma? Check compatibility +└── CMake (build only) +``` + +### Integration Points + +1. **On File Open** (`Notepad3.c` → `FileLoad()`) + - Walk up directory tree to find `.editorconfig` files + - Call `editorconfig_parse()` with full file path + - Apply settings via `Style_*` and `SciCall_*` functions + +2. **Settings Application** (`Styles.c` or new `EditorConfig.c`) + ```c + void ApplyEditorConfig(LPCWSTR filePath) { + editorconfig_handle eh = editorconfig_handle_init(); + int err = editorconfig_parse(filePath, eh); + if (!err) { + int count = editorconfig_handle_get_name_value_count(eh); + for (int i = 0; i < count; i++) { + const char *name, *value; + editorconfig_handle_get_name_value(eh, i, &name, &value); + // Map to NP3 settings... + } + } + editorconfig_handle_destroy(eh); + } + ``` + +3. **User Toggle** (Settings2 INI option) + - `EditorConfigSupport = 1` (default enabled) + - Menu: View → Apply EditorConfig (toggle) + +### Build Integration + +- Add `editorconfig-core-c` as Git submodule or NuGet package +- Modify `scintilla.vcxproj` or create `editorconfig.vcxproj` +- Link statically to avoid DLL dependency + +## Effort Estimate + +| Phase | Days | Description | +|-------|------|-------------| +| Library integration | 3-5 | Build editorconfig-core-c with MSVC, link to NP3 | +| Core parsing | 2-3 | Hook file-open, call parser, get properties | +| Settings mapping | 2-3 | Map EC properties to Scintilla/NP3 APIs | +| On-save hooks | 1-2 | trim_trailing_whitespace, insert_final_newline | +| UI/Settings | 1 | Toggle option, status bar indicator | +| Testing | 2-3 | Various project structures, edge cases | +| **Total** | **11-17** | ~2-4 weeks | + +## Current State + +- ✅ `.editorconfig` files syntax highlighted (`styleLexPROPS.c`) +- ❌ Settings not applied when opening files +- 📋 GitHub feature request: Consider filing issue + +## References + +- Notepad++ EditorConfig plugin: https://github.com/editorconfig/editorconfig-notepad-plus-plus +- VS Code native support (built-in) +- Sublime Text: EditorConfig package