From b9c78d8344bb5063ecfbc7600291783d7ee0ab53 Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Mon, 6 Apr 2026 23:46:00 +0200 Subject: [PATCH] Revert "fix: try to fix flickering issue" --- .github/copilot-instructions.md | 45 +------------------------ Build/Notepad3.ini | 8 ----- CLAUDE.md | 45 ++----------------------- lexilla/Lexilla.vcxproj | 11 +++--- np3portableapp/build_np3portableapp.cmd | 5 ++- scintilla/win32/SciLexer.vcxproj | 10 ++---- scintilla/win32/Scintilla.vcxproj | 10 ++---- src/Config/Config.cpp | 6 ---- src/DarkMode/ListViewUtil.hpp | 4 +-- src/Notepad3.c | 15 +-------- src/Notepad3.vcxproj | 5 +-- src/TypeDefs.h | 8 ----- 12 files changed, 19 insertions(+), 153 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 77a44e032..8f0d9d49d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -48,7 +48,7 @@ GitHub Actions workflow at `.github/workflows/build.yml` builds all four platfor ## Architecture -Notepad3 is a Win32 desktop text editor built on the **Scintilla** editing component with **Lexilla** for syntax highlighting. It ships with the companion tool **MiniPath** (file browser) and integrates with the external **grepWin** tool (file search/grep) via pre-built portable executables. +Notepad3 is a Win32 desktop text editor built on the **Scintilla** editing component with **Lexilla** for syntax highlighting. It ships with the companion tool **MiniPath** (file browser) and integrates with the external **grepWin** tool (file search/grep). ### Core modules (in `src\`) @@ -75,22 +75,6 @@ Notepad3 is a Win32 desktop text editor built on the **Scintilla** editing compo - **`src\uthash\`** — Hash table library (C macros) - **`src\crypto\`** — Rijndael/SHA-256 for AES-256 encryption -### grepWin Integration (`grepWin\`) - -grepWin is an **external** file search/grep tool — it is **not** built from source as part of Notepad3. Pre-built portable executables and translation files are stored in the repository: - -- **`grepWin\portables\`** — `grepWin-x86_portable.exe`, `grepWin-x64_portable.exe`, `LICENSE.txt` -- **`grepWin\translations\`** — `*.lang` translation files (e.g. `German.lang`, `French.lang`) - -At runtime (`src\Dialogs.c`), Notepad3 searches for grepWin in this order: -1. `Settings2.GrepWinPath` (user-configured INI setting) -2. `\grepWin\grepWin-x64_portable.exe` (or x86) — portable layout -3. `%APPDATA%\Rizonesoft\Notepad3\grepWin\` — installed layout - -Language mapping (`src\MuiLanguage.c`): `grepWinLangResName[]` maps Notepad3 locale names (e.g. `de-DE`) to grepWin `.lang` filenames (e.g. `German.lang`). The language file path is written to `grepwin.ini` before launching. - -Portable build scripts (`Build\make_portable_*.cmd`) package grepWin into a `grepWin\` subdirectory in the archive containing both portable executables, the license, and all `*.lang` translations. - ### Syntax highlighting lexers (`src\StyleLexers\`) Each language has its own `styleLexXXX.c` file (~50+ languages). All lexers follow the `EDITLEXER` struct pattern defined in `EditLexer.h`: @@ -154,33 +138,6 @@ URL hotspot regex is defined at `src\Edit.c:108` (`HYPLNK_REGEX_FULL` macro). It Windows 10/11 dark mode via IAT (Import Address Table) hooks. Includes stub DLLs for uxtheme and user32. -### ARM64 Platform Considerations - -**Supported platforms**: Win32 (x86), x64, x64_AVX2, ARM64. ARM 32-bit is **not** supported (the `Release|ARM` solution config maps to Win32). - -#### Architecture detection - -Use `#if defined(_M_ARM64)` or the helper macro `NP3_BUILD_ARM64` (defined in `src\TypeDefs.h`) for ARM64-specific code paths. **Important**: both ARM64 and x64 define `_WIN64`, so use `_M_ARM64` when you need to distinguish ARM64 from x64. - -#### ARM64 rendering defaults - -ARM64 defaults to `SC_TECHNOLOGY_DIRECTWRITERETAIN` (value 2) instead of `SC_TECHNOLOGY_DIRECTWRITE` (value 1) to preserve the Direct2D back buffer between frames. This avoids flickering on Qualcomm Adreno GPUs and the Win11 25H2 DWM compositor. The main window also uses `WS_EX_COMPOSITED` on ARM64 for system-level double-buffering. Users can override via `RenderingTechnology` in the INI file or the View menu. - -#### ARM64 build configuration - -- `CETCompat` must be `false` for ARM64 (CET is x86/x64 only) -- `TargetMachine` must be `MachineARM64` in all ARM64 linker sections -- `_WIN64` must be defined in preprocessor definitions for all ARM64 configurations -- Build fix scripts in `Build\scripts\`: `FixARM64CETCompat.ps1`, `FixARM64CrossCompile.ps1`, `FixARM64OutDir.ps1` - -#### GrepWin on ARM64 - -No native ARM64 grepWin build exists. The ARM64 build uses `grepWin-x64_portable.exe` which runs via x64 emulation on Windows ARM64. The binary selection in `src\Notepad3.c` uses `#if defined(_M_ARM64)` to handle this explicitly. - -#### Theme change flickering prevention - -`MsgThemeChanged()` in `src\Notepad3.c` wraps all heavy operations (bar recreation, lexer reset, restyling) in `WM_SETREDRAW FALSE/TRUE` to suppress intermediate repaints and performs a single `RedrawWindow()` at the end. DarkMode `RedrawWindow()` calls in `ListViewUtil.hpp` omit `RDW_ERASE` to avoid background erase flashes during theme transitions. - ## Conventions ### Code style diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index cc64bc96a..6aa76fd97 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -35,14 +35,6 @@ SettingsVersion=5 ;RelativeFileMRU=1 ;ReuseWindow=0 ;SaveBlankNewFile=true -;RenderingTechnology=1 -; Scintilla Rendering Technology: -; 0 = GDI (default Win32 rendering) -; 1 = DirectWrite (default) - Direct2D -; 2 = DirectWriteRetain (preserves back buffer, default on ARM64) -; 3 = DirectWriteDC (DC-based Direct2D) -; Tip: On ARM64 with rendering issues, try 0 (GDI) or 3 (DirectWriteDC) -; Per-resolution override in [Window]: e.g. 1920x1080 RenderingTechnology=0 ;SciFontQuality=3 ;SimpleIndentGuides=0 ;SingleFileInstance=1 diff --git a/CLAUDE.md b/CLAUDE.md index 8acf004bc..2ef416c24 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -Notepad3 is a Windows-only Win32 desktop text editor (C/C++) built on **Scintilla** (editing component) and **Lexilla** (syntax highlighting). It ships with the companion tool **MiniPath** (file browser, Ctrl+M) and integrates with the external **grepWin** tool (file search/grep, Ctrl+Shift+F) via pre-built portable executables. Licensed under BSD 3-Clause. +Notepad3 is a Windows-only Win32 desktop text editor (C/C++) built on **Scintilla** (editing component) and **Lexilla** (syntax highlighting). It ships with the companion tool **MiniPath** (file browser, Ctrl+M) and integrates with the external **grepWin** tool (file search/grep, Ctrl+Shift+F). Licensed under BSD 3-Clause. ## Build Commands @@ -85,22 +85,6 @@ MainWndProc (Notepad3.c) | `src\uthash\` | uthash | Hash table / dynamic array macros | | `src\crypto\` | Rijndael/SHA-256 | AES-256 encryption | -### grepWin Integration (`grepWin\`) - -grepWin is an **external** file search/grep tool — it is **not** built from source as part of Notepad3. Pre-built portable executables and translation files are stored in the repository: - -- **`grepWin\portables\`** — `grepWin-x86_portable.exe`, `grepWin-x64_portable.exe`, `LICENSE.txt` -- **`grepWin\translations\`** — `*.lang` translation files (e.g. `German.lang`, `French.lang`) - -At runtime (`src\Dialogs.c`), Notepad3 searches for grepWin in this order: -1. `Settings2.GrepWinPath` (user-configured INI setting) -2. `\grepWin\grepWin-x64_portable.exe` (or x86) — portable layout -3. `%APPDATA%\Rizonesoft\Notepad3\grepWin\` — installed layout - -Language mapping (`src\MuiLanguage.c`): `grepWinLangResName[]` maps Notepad3 locale names (e.g. `de-DE`) to grepWin `.lang` filenames (e.g. `German.lang`). The language file path is written to `grepwin.ini` before launching. - -Portable build scripts (`Build\make_portable_*.cmd`) package grepWin into a `grepWin\` subdirectory in the archive containing both portable executables, the license, and all `*.lang` translations. - ### Syntax Lexers (`src\StyleLexers\`) 50+ languages, each in a `styleLexXXX.c` file. All follow the `EDITLEXER` struct pattern from `EditLexer.h`: @@ -206,32 +190,7 @@ URL hotspot regex is defined at `src\Edit.c:108` (`HYPLNK_REGEX_FULL` macro). It Windows 10/11 dark mode via IAT (Import Address Table) hooks. Includes stub DLLs for uxtheme and user32. -### ARM64 Platform Considerations - -**Supported platforms**: Win32 (x86), x64, x64_AVX2, ARM64. ARM 32-bit is **not** supported (the `Release|ARM` solution config maps to Win32). - -#### Architecture detection - -Use `#if defined(_M_ARM64)` or the helper macro `NP3_BUILD_ARM64` (defined in `src\TypeDefs.h`) for ARM64-specific code paths. **Important**: both ARM64 and x64 define `_WIN64`, so use `_M_ARM64` when you need to distinguish ARM64 from x64. - -#### ARM64 rendering defaults - -ARM64 defaults to `SC_TECHNOLOGY_DIRECTWRITERETAIN` (value 2) instead of `SC_TECHNOLOGY_DIRECTWRITE` (value 1) to preserve the Direct2D back buffer between frames. This avoids flickering on Qualcomm Adreno GPUs and the Win11 25H2 DWM compositor. The main window also uses `WS_EX_COMPOSITED` on ARM64 for system-level double-buffering. Users can override via `RenderingTechnology` in the INI file or the View menu. - -#### ARM64 build configuration - -- `CETCompat` must be `false` for ARM64 (CET is x86/x64 only) -- `TargetMachine` must be `MachineARM64` in all ARM64 linker sections -- `_WIN64` must be defined in preprocessor definitions for all ARM64 configurations -- Build fix scripts in `Build\scripts\`: `FixARM64CETCompat.ps1`, `FixARM64CrossCompile.ps1`, `FixARM64OutDir.ps1` - -#### GrepWin on ARM64 - -No native ARM64 grepWin build exists. The ARM64 build uses `grepWin-x64_portable.exe` which runs via x64 emulation on Windows ARM64. The binary selection in `src\Notepad3.c` uses `#if defined(_M_ARM64)` to handle this explicitly. - -#### Theme change flickering prevention - -`MsgThemeChanged()` in `src\Notepad3.c` wraps all heavy operations (bar recreation, lexer reset, restyling) in `WM_SETREDRAW FALSE/TRUE` to suppress intermediate repaints and performs a single `RedrawWindow()` at the end. DarkMode `RedrawWindow()` calls in `ListViewUtil.hpp` omit `RDW_ERASE` to avoid background erase flashes during theme transitions. +## Code Conventions ### Formatting diff --git a/lexilla/Lexilla.vcxproj b/lexilla/Lexilla.vcxproj index dab667c3e..72c31b614 100644 --- a/lexilla/Lexilla.vcxproj +++ b/lexilla/Lexilla.vcxproj @@ -477,7 +477,7 @@ Level4 - _WIN64;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 true @@ -502,7 +502,6 @@ Console true false - MachineARM64 true @@ -599,7 +598,7 @@ true - _WIN64;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + _WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 true @@ -627,7 +626,6 @@ true true false - MachineARM64 true @@ -643,7 +641,7 @@ true - _WIN64;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + _WIN32_WINNT=0x0A00;WINVER=0x0A00;NTDDI_VERSION=0x0A000006;SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 true @@ -671,7 +669,6 @@ true true false - MachineARM64 true @@ -683,4 +680,4 @@ - + \ No newline at end of file diff --git a/np3portableapp/build_np3portableapp.cmd b/np3portableapp/build_np3portableapp.cmd index 0072afea3..4793f885d 100644 --- a/np3portableapp/build_np3portableapp.cmd +++ b/np3portableapp/build_np3portableapp.cmd @@ -324,15 +324,14 @@ if errorlevel 1 ( :: call %SCRIPT_DIR%Signing_for_NP3P_2nd_EXE.cmd :: --------------------------------------------------------------------------------------------------- -:: Step 11: report result +:: Step 11: Create .7z copy and report result :: --------------------------------------------------------------------------------------------------- echo. echo --- Step 11: Finalize --- set Notepad3Portable.paf.exe=%SCRIPT_DIR%Notepad3Portable_%VERSION%%DEVNAME%.paf.exe if exist %Notepad3Portable.paf.exe% ( - rem ~ PAF can be extracted using 7-ZIP, but it is not supposed for this issue - rem ~ DON't DO: copy /B %Notepad3Portable.paf.exe% %Notepad3Portable.paf.exe%.7z /Y /V + copy /B %Notepad3Portable.paf.exe% %Notepad3Portable.paf.exe%.7z /Y /V echo. echo === PortableApps Package Built Successfully! === echo Output: %Notepad3Portable.paf.exe% diff --git a/scintilla/win32/SciLexer.vcxproj b/scintilla/win32/SciLexer.vcxproj index 34e134fb9..fc12e80dc 100644 --- a/scintilla/win32/SciLexer.vcxproj +++ b/scintilla/win32/SciLexer.vcxproj @@ -119,13 +119,11 @@ - _WIN64;_DEBUG;%(PreprocessorDefinitions) + _DEBUG;%(PreprocessorDefinitions) stdcpp17 Default - MachineARM64 - false @@ -158,14 +156,12 @@ true true - _WIN64;NDEBUG;%(PreprocessorDefinitions) + NDEBUG;%(PreprocessorDefinitions) stdcpp17 true true - MachineARM64 - false @@ -186,4 +182,4 @@ - + \ No newline at end of file diff --git a/scintilla/win32/Scintilla.vcxproj b/scintilla/win32/Scintilla.vcxproj index 038525342..7b33211de 100644 --- a/scintilla/win32/Scintilla.vcxproj +++ b/scintilla/win32/Scintilla.vcxproj @@ -120,13 +120,11 @@ - _WIN64;_DEBUG;%(PreprocessorDefinitions) + _DEBUG;%(PreprocessorDefinitions) stdcpp17 Default - MachineARM64 - false @@ -159,14 +157,12 @@ true true - _WIN64;NDEBUG;%(PreprocessorDefinitions) + NDEBUG;%(PreprocessorDefinitions) stdcpp17 true true - MachineARM64 - false @@ -190,4 +186,4 @@ - + \ No newline at end of file diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 8c3767408..d89e24dca 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1325,13 +1325,7 @@ void LoadSettings() Defaults.RenderingTechnology = clampi(Defaults.RenderingTechnology, SC_TECHNOLOGY_DEFAULT, SC_TECHNOLOGY_DIRECTWRITEDC); } else { -#if defined(_M_ARM64) - // ARM64: use DirectWriteRetain to preserve back buffer between frames, - // avoiding flicker with Qualcomm Adreno GPUs and Win11 25H2 DWM compositor - Defaults.RenderingTechnology = SC_TECHNOLOGY_DIRECTWRITERETAIN; -#else Defaults.RenderingTechnology = SC_TECHNOLOGY_DIRECTWRITE; // new default DirectWrite (D2D) -#endif } // Settings2 EnableBidirectionalSupport deprecated diff --git a/src/DarkMode/ListViewUtil.hpp b/src/DarkMode/ListViewUtil.hpp index dfec7102b..9878c83f4 100644 --- a/src/DarkMode/ListViewUtil.hpp +++ b/src/DarkMode/ListViewUtil.hpp @@ -61,7 +61,7 @@ extern "C" void InitListView(HWND hListView) SendMessage(hHeader, WM_THEMECHANGED, wParam, lParam); - RedrawWindow(hWnd, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE | RDW_INTERNALPAINT); + RedrawWindow(hWnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_INTERNALPAINT); } } break; @@ -123,7 +123,7 @@ extern "C" void InitTreeView(HWND hTreeView) } CloseThemeData(hTheme); } - RedrawWindow(hWnd, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE | RDW_INTERNALPAINT); + RedrawWindow(hWnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_INTERNALPAINT); } } break; diff --git a/src/Notepad3.c b/src/Notepad3.c index 01916a898..168e92642 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -81,9 +81,7 @@ LPCWSTR WordBookMarks[MARKER_NP3_BOOKMARK] = { CONSTANTS_T const Constants = { 2 // StdDefaultLexerID , L"minipath.exe" // FileBrowserMiniPath -#if defined(_M_ARM64) - , L"grepWin-x64_portable.exe" // FileSearchGrepWin (x64 via emulation on ARM64) -#elif defined(_WIN64) +#ifdef _WIN64 , L"grepWin-x64_portable.exe" // FileSearchGrepWin #else , L"grepWin-x86_portable.exe" // FileSearchGrepWin @@ -1820,11 +1818,7 @@ HWND InitInstance(const HINSTANCE hInstance, int nCmdShow) DWORD const dwStyle = ((WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN) & ~WS_VISIBLE); // | (g_IniWinInfo.max ? WS_MAXIMIZE : 0); HWND const hwndMain = CreateWindowEx( -#if defined(_M_ARM64) - WS_EX_ACCEPTFILES | WS_EX_COMPOSITED, // double-buffering reduces flicker on ARM64 -#else WS_EX_ACCEPTFILES, -#endif s_wchWndClass, _W(SAPPNAME), dwStyle, @@ -3599,9 +3593,6 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam,LPARAM lParam) if (Globals.hwndMain) { - // suppress intermediate redraws during heavy theme update to prevent flickering - SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); - #ifdef D_NP3_WIN10_DARK_MODE RefreshTitleBarThemeColor(hwnd); #endif @@ -3631,10 +3622,6 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam,LPARAM lParam) EditUpdateVisibleIndicators(); UpdateUI(hwnd); - - // re-enable drawing and force a single - SendMessage(hwnd, WM_SETREDRAW, TRUE, 0); - RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } UpdateWindowEx(hwnd); diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index ce22703de..7b505f33b 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -426,7 +426,6 @@ false true clang_rt.asan-i386.lib - MachineARM64 @@ -854,7 +853,6 @@ true - MachineARM64 @@ -940,7 +938,6 @@ true - MachineARM64 @@ -1280,4 +1277,4 @@ - + \ No newline at end of file diff --git a/src/TypeDefs.h b/src/TypeDefs.h index a9d789429..8c3a29cbd 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -65,14 +65,6 @@ // no Analyze warning "prefer: enum class" #pragma warning(disable : 26812) -// --- Platform Architecture Detection --- -// Use NP3_BUILD_ARM64 for ARM64-specific code paths -#if defined(_M_ARM64) -#define NP3_BUILD_ARM64 1 -#else -#define NP3_BUILD_ARM64 0 -#endif - /**************************************************/ /* Declared in WINNT.H */ /* */