2022-06-25 10:19:59 +00:00
|
|
|
#if defined(OS_MACOS)
|
|
|
|
|
|
|
|
#include <CoreFoundation/CFBundle.h>
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2022-06-30 13:28:51 +00:00
|
|
|
#include <Foundation/NSUserDefaults.h>
|
2022-06-30 13:20:13 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
2023-02-08 12:51:56 +00:00
|
|
|
#include <AppKit/NSScreen.h>
|
2022-06-25 10:19:59 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
2023-05-14 20:53:52 +00:00
|
|
|
|
2023-05-14 19:50:58 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2023-05-14 18:20:22 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2023-05-27 15:45:41 +00:00
|
|
|
void errorMessageMacos(const char *cMessage) {
|
|
|
|
CFStringRef strMessage = CFStringCreateWithCString(NULL, cMessage, kCFStringEncodingUTF8);
|
|
|
|
CFUserNotificationDisplayAlert(0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL, strMessage, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2023-05-14 20:03:04 +00:00
|
|
|
void openFile(const char *path);
|
2023-05-14 18:20:22 +00:00
|
|
|
|
2023-05-14 20:03:04 +00:00
|
|
|
void openWebpageMacos(const char *url) {
|
2022-06-25 10:19:59 +00:00
|
|
|
CFURLRef urlRef = CFURLCreateWithBytes(NULL, (uint8_t*)(url), strlen(url), kCFStringEncodingASCII, NULL);
|
|
|
|
LSOpenCFURLRef(urlRef, NULL);
|
|
|
|
CFRelease(urlRef);
|
|
|
|
}
|
|
|
|
|
2023-05-14 20:03:04 +00:00
|
|
|
bool isMacosSystemDarkModeEnabled(void) {
|
2022-06-30 13:09:57 +00:00
|
|
|
NSString * appleInterfaceStyle = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
|
|
|
|
|
|
|
|
if (appleInterfaceStyle && [appleInterfaceStyle length] > 0) {
|
|
|
|
return [[appleInterfaceStyle lowercaseString] containsString:@"dark"];
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-14 20:03:04 +00:00
|
|
|
float getBackingScaleFactor(void) {
|
2023-02-08 12:51:56 +00:00
|
|
|
return [[NSScreen mainScreen] backingScaleFactor];
|
|
|
|
}
|
|
|
|
|
2023-05-14 16:35:35 +00:00
|
|
|
@interface HexDocument : NSDocument
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation HexDocument
|
|
|
|
|
2023-05-14 18:20:22 +00:00
|
|
|
- (BOOL) readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
2023-05-14 20:03:04 +00:00
|
|
|
NSString* urlString = [url absoluteString];
|
|
|
|
const char* utf8String = [urlString UTF8String];
|
|
|
|
|
|
|
|
openFile(utf8String);
|
2023-05-14 18:20:22 +00:00
|
|
|
|
2023-05-14 16:35:35 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2023-01-04 13:55:58 +00:00
|
|
|
#endif
|