Skip to content

Commit 55b6545

Browse files
Brian Taboneclaude
andcommitted
fix: address PR review feedback
- print_support.mm: use initWithBytes:length:encoding: to avoid truncation at embedded NUL bytes in document text - print_support.mm: size print view from NSPrintInfo imageablePageBounds instead of hardcoded US Letter dimensions - scintilla_config.mm: clarify BGR byte order comment on caret color - wndproc.mm: fix indentation alignment on IDM_FILE_PRINT case Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 479ea73 commit 55b6545

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

macos/platform/print_support.mm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ void showPrintDialog(NSWindow* parentWindow)
1919

2020
std::vector<char> buf(len + 1, 0);
2121
ScintillaBridge_sendMessage(sci, SCI_GETTEXT, len + 1, reinterpret_cast<intptr_t>(buf.data()));
22-
NSString* text = [NSString stringWithUTF8String:buf.data()];
22+
NSString* text = [[NSString alloc] initWithBytes:buf.data()
23+
length:static_cast<NSUInteger>(len)
24+
encoding:NSUTF8StringEncoding];
2325
if (!text || text.length == 0) return;
2426

2527
// Use the editor's current font
@@ -28,12 +30,14 @@ void showPrintDialog(NSWindow* parentWindow)
2830
if (!font)
2931
font = [NSFont monospacedSystemFontOfSize:ctx().fontSize weight:NSFontWeightRegular];
3032

31-
// Create an NSTextView for built-in print pagination
32-
NSTextView* printView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 612, 792)];
33+
// Size the print view from the printable area to match selected paper/margins
34+
NSPrintInfo* printInfo = [NSPrintInfo sharedPrintInfo];
35+
NSRect printableRect = [printInfo imageablePageBounds];
36+
NSTextView* printView = [[NSTextView alloc] initWithFrame:printableRect];
3337
[printView setFont:font];
3438
[printView setString:text];
3539

36-
NSPrintOperation* op = [NSPrintOperation printOperationWithView:printView];
40+
NSPrintOperation* op = [NSPrintOperation printOperationWithView:printView printInfo:printInfo];
3741
[op setShowsPrintPanel:YES];
3842
[op setShowsProgressPanel:YES];
3943

macos/platform/scintilla_config.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void configureScintilla(void* sci)
5353
ScintillaBridge_sendMessage(sci, SCI_SETMULTIPASTE, SC_MULTIPASTE_EACH, 0);
5454
ScintillaBridge_sendMessage(sci, SCI_SETADDITIONALCARETSVISIBLE, 1, 0);
5555

56-
// Multi-cursor visual styling (BGR colors)
57-
ScintillaBridge_sendMessage(sci, SCI_SETADDITIONALCARETFORE, 0xCC0000, 0); // dark blue caret
56+
// Multi-cursor visual styling (Scintilla uses BGR byte order)
57+
ScintillaBridge_sendMessage(sci, SCI_SETADDITIONALCARETFORE, 0xCC0000, 0); // BGR 0xCC0000 = blue
5858
ScintillaBridge_sendMessage(sci, SCI_SETADDITIONALSELALPHA, 80, 0); // semi-transparent selections
5959

6060
// Whitespace / EOL / indent guide visibility

macos/platform/wndproc.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
9999
return 0;
100100

101101
case IDM_FILE_PRINT:
102-
showPrintDialog(ctx().mainWindow);
103-
return 0;
102+
showPrintDialog(ctx().mainWindow);
103+
return 0;
104104

105-
case IDM_FILE_REVEAL_FINDER:
105+
case IDM_FILE_REVEAL_FINDER:
106106
doRevealInFinder();
107107
return 0;
108108
case IDM_FILE_COPY_FULL_PATH:

0 commit comments

Comments
 (0)