2 Commits

Author SHA1 Message Date
x 4453856fd1 Use NSURL and writeObjects for pasteboard files
Create an NSURL from the path and write it to the general pasteboard
with writeObjects:. Add nil checks for the created NSURL and remove the
legacy NSFilenamesPboardType setPropertyList code.
2026-01-31 02:10:20 +01:00
x bd22ad5500 Add quick test and fix Windows clipboard check
Run `go test -v ./...` in the release workflow before GoReleaser.
In the Windows test job replace Get-Clipboard with
System.Windows.Forms::GetFileDropList(), check for "$PWD\ctx.txt" and
improve success/error output.
2026-01-31 02:00:13 +01:00
3 changed files with 15 additions and 7 deletions
+4
View File
@@ -22,6 +22,10 @@ jobs:
with:
go-version: stable
- name: Quick Sanity Check
shell: bash
run: go test -v ./...
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
+6 -5
View File
@@ -43,10 +43,11 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
./ctx.exe .
$files = Get-Clipboard -Format FileDropList
if ($files) {
Write-Host "Clipboard contains: $files"
if ($files.Name -contains "ctx.txt") { exit 0 }
Add-Type -AssemblyName System.Windows.Forms
$files = [System.Windows.Forms.Clipboard]::GetFileDropList()
if ($files.Contains("$PWD\ctx.txt")) {
Write-Host "Success: Clipboard contains ctx.txt"
exit 0
}
Write-Error "Clipboard did not contain ctx.txt"
Write-Error "Clipboard did not contain ctx.txt. Found: $files"
exit 1
+5 -2
View File
@@ -13,10 +13,13 @@ int copyFileToPasteboard(char* path) {
NSString *strPath = [NSString stringWithUTF8String:path];
if (!strPath) return 0;
NSURL *url = [NSURL fileURLWithPath:strPath];
if (!url) return 0;
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb clearContents];
[pb declareTypes:@[NSFilenamesPboardType] owner:nil];
return [pb setPropertyList:@[strPath] forType:NSFilenamesPboardType] ? 1 : 0;
return [pb writeObjects:@[url]] ? 1 : 0;
}
}
*/