Skip to content
Snippets Groups Projects
Commit d5fd87dc authored by George Nachman's avatar George Nachman
Browse files

Allow saving, copying, and inspecting broken images from imgcat. Issue 5971

parent 3983a3b2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4478,7 +4478,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
iTermImageInfo *imageInfo = [sender representedObject];
NSString *name = imageInfo.nameForNewSavedTempFile;
if (name) {
[[NSWorkspace sharedWorkspace] openFile:name];
[[iTermLaunchServices sharedInstance] openFile:name];
}
}
 
Loading
Loading
@@ -4618,17 +4618,30 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
// Allocate a menu
theMenu = [[[NSMenu alloc] initWithTitle:@"Contextual Menu"] autorelease];
iTermImageInfo *imageInfo = [self imageInfoAtCoord:coord];
if (imageInfo && !imageInfo.broken) {
if (imageInfo) {
// Show context menu for an image.
NSArray *entryDicts =
@[ @{ @"title": @"Save Image As…",
@"selector": @"saveImageAs:" },
@{ @"title": @"Copy Image",
@"selector": @"copyImage:" },
@{ @"title": @"Open Image",
@"selector": @"openImage:" },
@{ @"title": @"Inspect",
@"selector": @"inspectImage:" } ];
NSArray *entryDicts;
if (imageInfo.broken) {
entryDicts =
@[ @{ @"title": @"Save File As…",
@"selector": @"saveImageAs:" },
@{ @"title": @"Copy File",
@"selector": @"copyImage:" },
@{ @"title": @"Open File",
@"selector": @"openImage:" },
@{ @"title": @"Inspect",
@"selector": @"inspectImage:" } ];
} else {
entryDicts =
@[ @{ @"title": @"Save Image As…",
@"selector": @"saveImageAs:" },
@{ @"title": @"Copy Image",
@"selector": @"copyImage:" },
@{ @"title": @"Open Image",
@"selector": @"openImage:" },
@{ @"title": @"Inspect",
@"selector": @"inspectImage:" } ];
}
if (imageInfo.animated || imageInfo.paused) {
NSString *selector = @"togglePauseAnimatingImage:";
if (imageInfo.paused) {
Loading
Loading
Loading
Loading
@@ -162,7 +162,9 @@ NSString *const iTermImageDidLoad = @"iTermImageDidLoad";
(NSString *)kUTTypePNG: @(NSPNGFileType),
(NSString *)kUTTypeTIFF: @(NSTIFFFileType) };
NSString *imageType = self.imageType;
if (imageType) {
if (self.broken) {
data = self.data;
} else if (imageType) {
NSNumber *nsTypeNumber = universalTypeToCocoaMap[imageType];
if (nsTypeNumber.integerValue == fileType) {
data = self.data;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment