mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-22 21:23:02 +01:00
* Stage clipboard-preserving capture insertion for Paste Last on Mac * Update Rune and its Nix source hash for the picker work * Select the latest ready paste by owner identity and revalidate it * Exercise a held mixed paste picker with real bundles and a private Mac pasteboard * Publish ready Annotate identity and queue owner-specific paste requests * Wire the existing Mac paste shortcut and controls to the opt-in mixed picker * Recheck the selected field and cover Paste Last with a disposable Mac receiver * Refresh the Rune revision for the unified History pane * Unify Mac History and keep only spoken words after a deliberate dictation cancel * History and Paste Last call a Hex capture an annotation (t1612) A finished Hex capture is an Annotation in History, its details and the Paste Last picker, and the type filter is Annotations. The Captures pane no longer rewrites its own label when the unified History is on, and the search index drops the old synonym. Scrawl stays only as Scrawl.app and the on-disk .scrawl format; a Hex-owned format is separate file and engine work. * Gate the unified History behind a Labs toggle and give it one row shape (t1612) Labs › Paste Last picker (labs.paste_last_picker; macOS, Dev audience, off by default) replaces HEX_EXPERIMENTAL_PASTE_LAST and is read where the work starts: the picker and its gesture, History's unified list, and the cancel path's word writer. Off, Paste Last and History behave exactly as before. History's rows now share one shape for dictations, annotations, screenshots and recordings; a capture's detail card carries its picture, words, facts and actions; a search or the type filter never leaves a stale card open; an empty History has one empty state; and the type filter shows only when there is more than one kind to filter. The picker's rows sit on its title's left edge. * Show the Paste Last picker card on macOS only (t1612) * Refresh the Labs goldens for the Paste Last picker card (t1612) * Keep the unified History's capture helpers to macOS builds (t1612) * Keep the unified History's fixture pictures behind the Mac capture gate (t1612) * Point the docs at the Paste Last picker lab (t1612)
65 lines
3.4 KiB
Objective-C
65 lines
3.4 KiB
Objective-C
// A disposable AppKit receiver. No event tap, AX grants or input injection.
|
|
// Build with clang -fobjc-arc -framework AppKit Receiver.m -o Receiver.
|
|
#import <AppKit/AppKit.h>
|
|
#import <sys/sysctl.h>
|
|
|
|
static NSString *const root = @"/Users/admin/lab";
|
|
static NSTextView *other;
|
|
|
|
static void record(NSString *label) {
|
|
NSString *path = [root stringByAppendingPathComponent:@"received.log"];
|
|
FILE *file = fopen(path.fileSystemRepresentation, "a");
|
|
if (!file) abort();
|
|
fprintf(file, "%s\n", label.UTF8String);
|
|
fclose(file);
|
|
}
|
|
|
|
@interface Receiver : NSTextView
|
|
@end
|
|
@implementation Receiver
|
|
- (BOOL)validateMenuItem:(NSMenuItem *)item {
|
|
// This fixture explicitly accepts PNG, even when a plain NSTextView's
|
|
// built-in Paste would be disabled for a clipboard with no text.
|
|
if (item.action == @selector(paste:)) return YES;
|
|
return [super validateMenuItem:item];
|
|
}
|
|
- (void)paste:(id)sender {
|
|
NSPasteboard *board = NSPasteboard.generalPasteboard;
|
|
NSString *value = [board stringForType:NSPasteboardTypeString];
|
|
BOOL png = [board dataForType:NSPasteboardTypePNG] != nil;
|
|
NSString *label = png ? @"Image attached" : [value containsString:@"Move the caption below the chart."] ? @"Move the caption below the chart." : value;
|
|
if (!label) label = @"Unexpected format";
|
|
record(label);
|
|
[self insertText:[label stringByAppendingString:@"\n"] replacementRange:self.selectedRange];
|
|
if (!png) return;
|
|
NSString *mode = [NSString stringWithContentsOfFile:[root stringByAppendingPathComponent:@"mode"] encoding:NSUTF8StringEncoding error:nil];
|
|
if ([mode isEqual:@"change-focus"]) [self.window makeFirstResponder:other];
|
|
if ([mode isEqual:@"external-copy"]) {
|
|
[board clearContents];
|
|
[board setString:@"https://example.org/new-copy" forType:NSPasteboardTypeString];
|
|
}
|
|
}
|
|
- (void)insertNewline:(id)sender { record(@"Unexpected Return"); [super insertNewline:sender]; }
|
|
@end
|
|
|
|
int main(void) { @autoreleasepool {
|
|
int guest = 0; size_t size = sizeof guest;
|
|
if (sysctlbyname("kern.hv_vmm_present", &guest, &size, NULL, 0) || !guest ||
|
|
![[NSFileManager defaultManager] fileExistsAtPath:[root stringByAppendingPathComponent:@"silence.wav"]]) return 2;
|
|
NSApplication *app = NSApplication.sharedApplication;
|
|
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
NSMenu *bar = [NSMenu new], *edit = [[NSMenu alloc] initWithTitle:@"Edit"];
|
|
[bar addItemWithTitle:@"Receiver" action:NULL keyEquivalent:@""].submenu = [NSMenu new];
|
|
[bar addItemWithTitle:@"Edit" action:NULL keyEquivalent:@""].submenu = edit;
|
|
[edit addItemWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"];
|
|
app.mainMenu = bar;
|
|
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,700,460) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:NO];
|
|
window.title = @"Paste Last — sample document";
|
|
Receiver *notes = [[Receiver alloc] initWithFrame:NSMakeRect(20,100,660,320)];
|
|
notes.font = [NSFont systemFontOfSize:20]; notes.string = @"Design review\n\n";
|
|
notes.selectedRange = NSMakeRange(notes.string.length,0);
|
|
other = [[Receiver alloc] initWithFrame:NSMakeRect(20,15,660,60)];
|
|
[window.contentView addSubview:other]; [window.contentView addSubview:notes];
|
|
[window center]; [window makeKeyAndOrderFront:nil]; [window makeFirstResponder:notes];
|
|
[app activateIgnoringOtherApps:YES]; [app run];
|
|
} }
|