Skip to content

Commit d1ee3bd

Browse files
committed
fix word wrap theme issues
1 parent 02b59da commit d1ee3bd

2 files changed

Lines changed: 53 additions & 88 deletions

File tree

RELEASE_NOTES.md

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,9 @@
1-
# Release Notes - Legacy Notepad Code Cleanup
2-
3-
## Summary
4-
51
This release consolidates and merges changes from three CodeQL-related commits (8ea227d, 028710b, 437b76e) and includes a major code refactoring effort to improve maintainability.
62

7-
---
8-
9-
## Changes
10-
11-
### 🔧 Build System Fixes
12-
13-
- **Fixed .gitignore**: Added `_codeql_build_dir/` and `_codeql_detected_source_root` to prevent accidental commits of CodeQL analysis artifacts
14-
- These entries prevent CI/CD build artifacts from polluting the repository
15-
16-
### 🏗️ Code Refactoring
17-
18-
- **Reduced main.cpp from 2,518 lines to 530 lines** (79% reduction)
19-
- **Eliminated all duplicate symbol definitions** that existed in both `main.cpp` and the modules
20-
- Fixed linker errors caused by multiple definitions of:
21-
- Global variables (`g_hwndMain`, `g_hwndEditor`, `g_state`, etc.)
22-
- Functions (`UpdateTitle`, `UpdateStatus`, `ApplyTheme`, etc.)
23-
24-
### 📐 Architecture Improvements
25-
26-
- `main.cpp` now properly uses the modular architecture:
27-
- `core/globals.h` - Global variable declarations
28-
- `core/types.h` - Type definitions
29-
- `modules/theme.h` - Theme management
30-
- `modules/editor.h` - Editor control functions
31-
- `modules/file.h` - File I/O operations
32-
- `modules/ui.h` - UI functions
33-
- `modules/background.h` - Background image support
34-
- `modules/dialog.h` - Dialog implementations
35-
- `modules/commands.h` - Menu command handlers
36-
37-
### 🎨 Code Style (SKILL.md compliance)
38-
39-
- Added ASCII art header to `main.cpp`
40-
- Removed redundant comments
41-
- Cleaner code organization with imports at top, followed by function definitions
42-
43-
---
44-
45-
## Technical Details
46-
473
### Commits Merged
484

495
| Commit | Author | Description |
506
|--------|--------|-------------|
517
| 8ea227d | copilot-swe-agent[bot] | Accidentally added _codeql_build_dir/ |
528
| 028710b | copilot-swe-agent[bot] | Fixed by removing build dir and updating .gitignore |
539
| 437b76e | copilot-swe-agent[bot] | Similar cleanup of build artifacts |
54-
55-
### Build Verification
56-
57-
- ✅ CMake configuration successful
58-
- ✅ MinGW build completed (warnings only, no errors)
59-
- ✅ Executable size: 284 KB (statically linked)
60-
- ✅ Application launches and functions correctly
61-
62-
---
63-
64-
## Files Changed
65-
66-
| File | Change |
67-
|------|--------|
68-
| `.gitignore` | Added CodeQL build directory exclusions |
69-
| `src/main.cpp` | Complete rewrite to use modules (2518 → 530 lines) |
70-
71-
---
72-
73-
## Breaking Changes
74-
75-
None. The application functions identically to before.
76-
77-
---
78-
79-
## Migration Notes
80-
81-
No migration required. This is an internal code cleanup that improves maintainability without changing functionality.

src/modules/editor.cpp

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "core/types.h"
1818
#include "core/globals.h"
1919
#include "theme.h"
20+
#include "ui.h"
2021
#include "background.h"
2122
#include "resource.h"
2223
#include <richedit.h>
@@ -76,8 +77,6 @@ void ApplyFont()
7677
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY,
7778
DEFAULT_PITCH | FF_DONTCARE, g_state.fontName.c_str());
7879
SendMessageW(g_hwndEditor, WM_SETFONT, reinterpret_cast<WPARAM>(g_state.hFont), TRUE);
79-
80-
// Ensure correct text color in dark mode after font change
8180
COLORREF textColor = IsDarkMode() ? RGB(255, 255, 255) : GetSysColor(COLOR_WINDOWTEXT);
8281
CHARFORMAT2W cf = {sizeof(cf)};
8382
cf.dwMask = CFM_COLOR;
@@ -100,21 +99,16 @@ void ApplyWordWrap()
10099
DWORD style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_NOHIDESEL;
101100
if (!g_state.wordWrap)
102101
style |= WS_HSCROLL | ES_AUTOHSCROLL;
103-
g_hwndEditor = CreateWindowExW(0, L"EDIT", nullptr, style,
102+
g_hwndEditor = CreateWindowExW(0, MSFTEDIT_CLASS, nullptr, style,
104103
0, 0, 100, 100, g_hwndMain, reinterpret_cast<HMENU>(IDC_EDITOR), GetModuleHandleW(nullptr), nullptr);
104+
g_origEditorProc = reinterpret_cast<WNDPROC>(SetWindowLongPtrW(g_hwndEditor, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditorSubclassProc)));
105+
SendMessageW(g_hwndEditor, EM_SETLIMITTEXT, 0, 0);
106+
SendMessageW(g_hwndEditor, EM_SETEVENTMASK, 0, ENM_CHANGE);
105107
ApplyFont();
108+
ApplyTheme();
106109
SetEditorText(text);
107110
SendMessageW(g_hwndEditor, EM_SETSEL, start, end);
108-
RECT rc;
109-
GetClientRect(g_hwndMain, &rc);
110-
int statusH = 0;
111-
if (g_state.showStatusBar)
112-
{
113-
RECT rs;
114-
GetWindowRect(g_hwndStatus, &rs);
115-
statusH = rs.bottom - rs.top;
116-
}
117-
MoveWindow(g_hwndEditor, 0, 0, rc.right, rc.bottom - statusH, TRUE);
111+
ResizeControls();
118112
SetFocus(g_hwndEditor);
119113
}
120114

@@ -189,10 +183,20 @@ LRESULT CALLBACK EditorSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
189183
}
190184
break;
191185
case WM_CHAR:
192-
if (wParam == 127)
186+
if (wParam == 3)
187+
break;
188+
if (wParam == 22)
189+
break;
190+
if (wParam == 24)
191+
break;
192+
if (wParam == 26)
193+
break;
194+
if (wParam == 25)
195+
break;
196+
if (wParam == 127 || wParam == 8)
193197
{
194-
DeleteWordBackward();
195-
return 0;
198+
if (GetKeyState(VK_CONTROL) & 0x8000)
199+
return 0;
196200
}
197201
if (g_state.background.enabled && g_bgImage)
198202
{
@@ -222,6 +226,39 @@ LRESULT CALLBACK EditorSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
222226
return result;
223227
}
224228
break;
229+
case WM_MOUSEWHEEL:
230+
{
231+
if (LOWORD(wParam) & MK_SHIFT)
232+
{
233+
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
234+
UINT scrollLines = 3;
235+
SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
236+
if (scrollLines == (UINT)WHEEL_PAGESCROLL)
237+
{
238+
SendMessageW(hwnd, WM_HSCROLL, (delta > 0) ? SB_PAGELEFT : SB_PAGERIGHT, 0);
239+
}
240+
else
241+
{
242+
for (UINT i = 0; i < scrollLines; ++i)
243+
SendMessageW(hwnd, WM_HSCROLL, (delta > 0) ? SB_LINELEFT : SB_LINERIGHT, 0);
244+
}
245+
return 0;
246+
}
247+
break;
248+
}
249+
case WM_MOUSEHWHEEL:
250+
{
251+
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
252+
UINT scrollChars = 3;
253+
SystemParametersInfoW(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0);
254+
if (delta != 0)
255+
{
256+
for (UINT i = 0; i < scrollChars; ++i)
257+
SendMessageW(hwnd, WM_HSCROLL, (delta > 0) ? SB_LINERIGHT : SB_LINELEFT, 0);
258+
return 0;
259+
}
260+
break;
261+
}
225262
}
226263
return CallWindowProcW(g_origEditorProc, hwnd, msg, wParam, lParam);
227264
}

0 commit comments

Comments
 (0)