forked from macvim-dev/macvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMacVim.h
More file actions
585 lines (510 loc) · 19.2 KB
/
MacVim.h
File metadata and controls
585 lines (510 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/* vi:set ts=8 sts=4 sw=4 ft=objc fdm=syntax:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
// This file contains root-level commonly used definitions that both Vim and
// MacVim processes need access to.
#import <Cocoa/Cocoa.h>
#pragma region Backward compatibility defines
// Taken from /usr/include/AvailabilityMacros.h
#ifndef MAC_OS_X_VERSION_10_7
# define MAC_OS_X_VERSION_10_7 1070
#endif
#ifndef MAC_OS_X_VERSION_10_8
# define MAC_OS_X_VERSION_10_8 1080
#endif
#ifndef MAC_OS_X_VERSION_10_9
# define MAC_OS_X_VERSION_10_9 1090
#endif
#ifndef MAC_OS_X_VERSION_10_10
# define MAC_OS_X_VERSION_10_10 101000
#endif
#ifndef MAC_OS_X_VERSION_10_11
# define MAC_OS_X_VERSION_10_11 101100
#endif
#ifndef MAC_OS_X_VERSION_10_12
# define MAC_OS_X_VERSION_10_12 101200
#endif
#ifndef MAC_OS_X_VERSION_10_12_2
# define MAC_OS_X_VERSION_10_12_2 101202
#endif
#ifndef MAC_OS_X_VERSION_10_13
# define MAC_OS_X_VERSION_10_13 101300
#endif
#ifndef MAC_OS_X_VERSION_10_14
# define MAC_OS_X_VERSION_10_14 101400
#endif
#ifndef MAC_OS_X_VERSION_10_15
# define MAC_OS_X_VERSION_10_15 101500
#endif
#ifndef MAC_OS_VERSION_11_0
# define MAC_OS_VERSION_11_0 110000
#endif
#ifndef MAC_OS_VERSION_12_0
# define MAC_OS_VERSION_12_0 120000
#endif
#ifndef MAC_OS_VERSION_13_0
# define MAC_OS_VERSION_13_0 130000
#endif
#ifndef MAC_OS_VERSION_14_0
# define MAC_OS_VERSION_14_0 140000
#endif
#ifndef MAC_OS_VERSION_15_0
# define MAC_OS_VERSION_15_0 150000
#endif
#ifndef NSAppKitVersionNumber10_10
# define NSAppKitVersionNumber10_10 1343
#endif
#ifndef NSAppKitVersionNumber10_10_Max
# define NSAppKitVersionNumber10_10_Max 1349
#endif
#ifndef NSAppKitVersionNumber10_11
# define NSAppKitVersionNumber10_11 1404
#endif
#ifndef NSAppKitVersionNumber10_12
# define NSAppKitVersionNumber10_12 1504
#endif
#ifndef NSAppKitVersionNumber10_12_2
# define NSAppKitVersionNumber10_12_2 1504.76
#endif
#ifndef NSAppKitVersionNumber10_13
# define NSAppKitVersionNumber10_13 1561
#endif
#ifndef NSAppKitVersionNumber10_14
# define NSAppKitVersionNumber10_14 1671
#endif
#ifndef NSAppKitVersionNumber10_15
# define NSAppKitVersionNumber10_15 1894
#endif
#ifndef NSAppKitVersionNumber11_0
# define NSAppKitVersionNumber11_0 2022
#endif
// Macro to detect runtime OS version. Ideally, we would just like to use
// @available to test for this because the compiler can optimize it out
// depending on your min/max OS configuration. However, it was added in Xcode 9
// (macOS 10.13 SDK). For any code that we want to be compilable for Xcode 8
// (macOS 10.12) or below, we need to use the macro below which will
// selectively use NSAppKitVersionNumber instead.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
// Xcode 9+, can use @available, which is more efficient.
# define AVAILABLE_MAC_OS(MAJOR, MINOR) @available(macos MAJOR##.##MINOR, *)
# define AVAILABLE_MAC_OS_PATCH(MAJOR, MINOR, PATCH) @available(macos MAJOR##.##MINOR##.##PATCH, *)
#else
// Xcode 8 or below. Use the old-school NSAppKitVersionNumber check.
# define AVAILABLE_MAC_OS(MAJOR, MINOR) NSAppKitVersionNumber >= NSAppKitVersionNumber##MAJOR##_##MINOR
# define AVAILABLE_MAC_OS_PATCH(MAJOR, MINOR, PATCH) NSAppKitVersionNumber >= NSAppKitVersionNumber##MAJOR##_##MINOR##_##PATCH
#endif
// Deprecated constants. Since these are constants, we just need the compiler,
// not the runtime to know about them. As such, we can use MAX_ALLOWED to
// determine if we need to map or not.
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
// Deprecated constants in 10.12 SDK
# define NSAlertStyleCritical NSCriticalAlertStyle
# define NSAlertStyleInformational NSInformationalAlertStyle
# define NSAlertStyleWarning NSWarningAlertStyle
# define NSButtonTypeSwitch NSSwitchButton
# define NSCompositingOperationSourceOver NSCompositeSourceOver
# define NSCompositingOperationDifference NSCompositeDifference
# define NSControlSizeRegular NSRegularControlSize
# define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
# define NSEventModifierFlagCommand NSCommandKeyMask
# define NSEventModifierFlagControl NSControlKeyMask
# define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
# define NSEventModifierFlagHelp NSHelpKeyMask
# define NSEventModifierFlagNumericPad NSNumericPadKeyMask
# define NSEventModifierFlagOption NSAlternateKeyMask
# define NSEventModifierFlagShift NSShiftKeyMask
# define NSEventTypeApplicationDefined NSApplicationDefined
# define NSEventTypeKeyDown NSKeyDown
# define NSEventTypeKeyUp NSKeyUp
# define NSEventTypeLeftMouseUp NSLeftMouseUp
# define NSEventTypeMouseEntered NSMouseEntered
# define NSEventTypeMouseExited NSMouseExited
# define NSEventTypeRightMouseDown NSRightMouseDown
# define NSWindowStyleMaskBorderless NSBorderlessWindowMask
# define NSWindowStyleMaskClosable NSClosableWindowMask
# define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
# define NSWindowStyleMaskResizable NSResizableWindowMask
# define NSWindowStyleMaskTexturedBackground NSTexturedBackgroundWindowMask
# define NSWindowStyleMaskTitled NSTitledWindowMask
# define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
// Deprecated constants in 10.13 SDK
#define NSControlStateValueOn NSOnState
#define NSControlStateValueOff NSOffState
// Newly introduced symbols in 10.13 SDK
typedef NSString* NSPasteboardType;
typedef NSString* NSAttributedStringKey;
#endif
// Deprecated runtime values. Since these are runtime values, we need to use the
// minimum required OS as determining factor. Otherwise it would crash.
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
// Deprecated runtime values in 10.13 SDK.
# define NSPasteboardNameFind NSFindPboard
#endif
#pragma endregion
#import <asl.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
# define MM_USE_ASL
#else
# import <os/log.h>
#endif
#pragma region Shared protocols
//
// This is the protocol MMBackend implements.
//
// Only processInput:data: is allowed to cause state changes in Vim; all other
// messages should only read the Vim state. (Note that setDialogReturn: is an
// exception to this rule; there really is no other way to deal with dialogs
// since they work with callbacks, so we cannot wait for them to return.)
//
// Be careful with messages with return type other than 'oneway void' -- there
// is a reply timeout set in MMAppController, if a message fails to get a
// response within the given timeout an exception will be thrown. Use
// @try/@catch/@finally to deal with timeouts.
//
@protocol MMBackendProtocol
- (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data;
- (oneway void)setDialogReturn:(in bycopy id)obj;
- (NSString *)evaluateExpression:(in bycopy NSString *)expr;
- (id)evaluateExpressionCocoa:(in bycopy NSString *)expr
errorString:(out bycopy NSString **)errstr;
- (BOOL)selectedTextToPasteboard:(byref NSPasteboard *)pboard;
- (NSString *)selectedText;
- (BOOL)mouseScreenposIsSelection:(int)row column:(int)column selRow:(byref int *)startRow selCol:(byref int *)startCol;
- (oneway void)acknowledgeConnection;
@end
//
// This is the protocol MMAppController implements.
//
// It handles connections between MacVim and Vim and communication from Vim to
// MacVim.
//
// Do not add methods to this interface without a _very_ good reason (if
// possible, instead add a new message to the *MsgID enum below and pass it via
// processInput:forIdentifier). Methods should not modify the state directly
// but should instead delay any potential modifications (see
// connectBackend:pid: and processInput:forIdentifier:).
//
@protocol MMAppProtocol
- (unsigned long)connectBackend:(byref in id <MMBackendProtocol>)proxy pid:(int)pid;
- (oneway void)processInput:(in bycopy NSArray *)queue
forIdentifier:(unsigned long)identifier;
- (NSArray *)serverList;
@end
@protocol MMVimServerProtocol;
//
// The Vim client protocol (implemented by MMBackend).
//
// The client needs to keep track of server replies. Take a look at MMBackend
// if you want to implement this protocol in another program.
//
@protocol MMVimClientProtocol
- (oneway void)addReply:(in bycopy NSString *)reply
server:(in byref id <MMVimServerProtocol>)server;
@end
//
// The Vim server protocol (implemented by MMBackend).
//
// Note that addInput:client: is not asynchronous, because otherwise Vim might
// quit before the message has been passed (e.g. if --remote was used on the
// command line).
//
@protocol MMVimServerProtocol
- (void)addInput:(in bycopy NSString *)input
client:(in byref id <MMVimClientProtocol>)client;
- (NSString *)evaluateExpression:(in bycopy NSString *)expr
client:(in byref id <MMVimClientProtocol>)client;
@end
#pragma endregion
#pragma region IPC messages
//
// The following enum lists all messages that are passed between MacVim and
// Vim. These can be sent in processInput:data: and in processCommandQueue:.
//
extern const char * const MMVimMsgIDStrings[];
#define FOREACH_MMVimMsgID(MSG) \
MSG(NullMsgID) \
MSG(OpenWindowMsgID) \
MSG(KeyDownMsgID) \
MSG(BatchDrawMsgID) \
MSG(SelectTabMsgID) \
MSG(CloseTabMsgID) \
MSG(AddNewTabMsgID) \
MSG(DraggedTabMsgID) \
MSG(UpdateTabBarMsgID) \
MSG(ShowTabBarMsgID) \
MSG(HideTabBarMsgID) \
MSG(SetTextRowsMsgID) \
MSG(SetTextColumnsMsgID) \
MSG(SetTextDimensionsMsgID) \
MSG(SetTextDimensionsNoResizeWindowMsgID) \
MSG(LiveResizeMsgID) \
MSG(SetTextDimensionsReplyMsgID) \
MSG(ResizeViewMsgID) \
MSG(SetWindowTitleMsgID) \
MSG(ScrollWheelMsgID) \
MSG(MouseDownMsgID) \
MSG(MouseUpMsgID) \
MSG(MouseDraggedMsgID) \
MSG(FlushQueueMsgID) \
MSG(AddMenuMsgID) \
MSG(AddMenuItemMsgID) \
MSG(RemoveMenuItemMsgID) \
MSG(EnableMenuItemMsgID) \
MSG(ExecuteMenuMsgID) \
MSG(UpdateMenuItemTooltipMsgID) \
MSG(ShowToolbarMsgID) \
MSG(ToggleToolbarMsgID) \
MSG(CreateScrollbarMsgID) \
MSG(DestroyScrollbarMsgID) \
MSG(ShowScrollbarMsgID) \
MSG(SetScrollbarPositionMsgID) \
MSG(SetScrollbarThumbMsgID) \
MSG(ScrollbarEventMsgID) \
MSG(SetFontMsgID) \
MSG(SetWideFontMsgID) \
MSG(VimShouldCloseMsgID) \
MSG(SetDefaultColorsMsgID) \
MSG(SetTablineColorsMsgID) \
MSG(ExecuteActionMsgID) \
MSG(DropFilesMsgID) \
MSG(DropStringMsgID) \
MSG(ShowPopupMenuMsgID) \
MSG(GotFocusMsgID) \
MSG(LostFocusMsgID) \
MSG(MouseMovedMsgID) \
MSG(SetMouseShapeMsgID) \
MSG(AdjustLinespaceMsgID) \
MSG(AdjustColumnspaceMsgID) \
MSG(ActivateMsgID) \
MSG(SetServerNameMsgID) \
MSG(EnterFullScreenMsgID) \
MSG(LeaveFullScreenMsgID) \
MSG(SetBuffersModifiedMsgID) \
MSG(AddInputMsgID) \
MSG(SetPreEditPositionMsgID) \
MSG(TerminateNowMsgID) \
MSG(XcodeModMsgID) \
MSG(EnableAntialiasMsgID) \
MSG(DisableAntialiasMsgID) \
MSG(SetVimStateMsgID) \
MSG(SetDocumentFilenameMsgID) \
MSG(OpenWithArgumentsMsgID) \
MSG(SelectAndFocusOpenedFileMsgID) \
MSG(NewFileHereMsgID) \
MSG(CloseWindowMsgID) \
MSG(SetFullScreenColorMsgID) \
MSG(ShowFindReplaceDialogMsgID) \
MSG(FindReplaceMsgID) \
MSG(UseSelectionForFindMsgID) \
MSG(ActivateKeyScriptMsgID) \
MSG(DeactivateKeyScriptMsgID) \
MSG(EnableImControlMsgID) \
MSG(DisableImControlMsgID) \
MSG(ActivatedImMsgID) \
MSG(DeactivatedImMsgID) \
MSG(BrowseForFileMsgID) \
MSG(ShowDialogMsgID) \
MSG(SetMarkedTextMsgID) \
MSG(ZoomMsgID) \
MSG(SetWindowPositionMsgID) \
MSG(DeleteSignMsgID) \
MSG(SetTooltipMsgID) \
MSG(GestureMsgID) \
MSG(AddToMRUMsgID) \
MSG(BackingPropertiesChangedMsgID) \
MSG(SetBlurRadiusMsgID) \
MSG(SetBackgroundOptionMsgID) \
MSG(NotifyAppearanceChangeMsgID) \
MSG(EnableLigaturesMsgID) \
MSG(DisableLigaturesMsgID) \
MSG(EnableThinStrokesMsgID) \
MSG(DisableThinStrokesMsgID) \
MSG(ShowDefinitionMsgID) \
MSG(LoopBackMsgID) /* Simple message that Vim will reflect back to MacVim */ \
MSG(LastMsgID) \
enum {
#define ENUM_ENTRY(X) X,
FOREACH_MMVimMsgID(ENUM_ENTRY)
#undef ENUM_ENTRY
};
enum {
ClearAllDrawType = 1,
ClearBlockDrawType,
DeleteLinesDrawType,
DrawStringDrawType,
InsertLinesDrawType,
DrawCursorDrawType,
SetCursorPosDrawType,
DrawInvertedRectDrawType,
DrawSignDrawType,
InvalidDrawType = -1
};
enum {
MMInsertionPointBlock,
MMInsertionPointHorizontal,
MMInsertionPointVertical,
MMInsertionPointHollow,
MMInsertionPointVerticalRight,
};
enum {
ToolbarLabelFlag = 1,
ToolbarIconFlag = 2,
ToolbarSizeRegularFlag = 4
};
enum {
MMTabLabel = 0,
MMTabToolTip,
MMTabInfoCount
};
enum {
MMGestureSwipeLeft = 0,
MMGestureSwipeRight,
MMGestureSwipeUp,
MMGestureSwipeDown,
MMGestureForceClick,
};
#pragma endregion
// Create a string holding the labels of all messages in message queue for
// debugging purposes (condense some messages since there may typically be LOTS
// of them on a queue).
NSString *debugStringForMessageQueue(NSArray *queue);
// Shared user defaults (most user defaults are in Miscellaneous.h).
// Contrary to the user defaults in Miscellaneous.h these defaults are not
// initialized to any default values. That is, unless the user sets them
// these keys will not be present in the user default database.
extern NSString *MMLogLevelKey;
extern NSString *MMLogToStdErrKey;
// Argument used to stop MacVim from opening an empty window on startup
// (technically this is a user default but should not be used as such).
extern NSString *MMNoWindowKey;
// Argument used to control MacVim sharing search text via the Find Pasteboard.
extern NSString *MMShareFindPboardKey;
extern NSString *MMAutosaveRowsKey;
extern NSString *MMAutosaveColumnsKey;
extern NSString *MMRendererKey; // Deprecated: Non-CoreText renderer
enum {
MMRendererDefault = 0,
MMRendererCoreText
};
extern NSString *VimFindPboardType;
/// Alias for system monospace font name
extern NSString *MMSystemFontAlias;
@interface NSString (MMExtras)
- (NSString *)stringByRemovingFindPatterns;
- (NSString *)stringBySanitizingSpotlightSearch;
@end
@interface NSColor (MMExtras)
@property(readonly) unsigned argbInt;
+ (NSColor *)colorWithRgbInt:(unsigned)rgb;
+ (NSColor *)colorWithArgbInt:(unsigned)argb;
@end
@interface NSDictionary (MMExtras)
+ (id)dictionaryWithData:(NSData *)data;
- (NSData *)dictionaryAsData;
@end
@interface NSMutableDictionary (MMExtras)
+ (id)dictionaryWithData:(NSData *)data;
@end
// ODB Editor Suite Constants (taken from ODBEditorSuite.h)
#define keyFileSender 'FSnd'
#define keyFileSenderToken 'FTok'
#define keyFileCustomPath 'Burl'
#define kODBEditorSuite 'R*ch'
#define kAEModifiedFile 'FMod'
#define keyNewLocation 'New?'
#define kAEClosedFile 'FCls'
#define keySenderToken 'Tokn'
// MacVim Apple Event Constants
#define keyMMUntitledWindow 'MMuw'
#pragma region Logging
// Logging related functions and macros.
//
// This is a very simplistic logging facility built on top of ASL. Two user
// defaults allow for changing the local log filter level (MMLogLevel) and
// whether logs should be sent to stderr (MMLogToStdErr). (These user defaults
// are only checked during startup.) The default is to block level 6 (info)
// and 7 (debug) logs and _not_ to send logs to stderr. Apart from this
// "syslog" (see "man syslog") can be used to modify the ASL filters (it is
// currently not possible to change the local filter at runtime). For example:
// Enable all logs to reach the ASL database (by default 'debug' and 'info'
// are filtered out, see "man syslogd"):
// $ sudo syslog -c syslogd -d
// Reset the ASL database filter:
// $ sudo syslog -c syslogd off
// Change the master filter to block logs less severe than errors:
// $ sudo syslog -c 0 -e
// Change per-process filter for running MacVim process to block logs less
// severe than warnings:
// $ syslog -c MacVim -w
//
// Note that there are four ASL filters:
// 1) The ASL database filter (syslog -c syslogd ...)
// 2) The master filter (syslog -c 0 ...)
// 3) The per-process filter (syslog -c PID ...)
// 4) The local filter (MMLogLevel)
//
// To view the logs, either use "Console.app" or the "syslog" command:
// $ syslog -w | grep Vim
// To get the logs to show up in Xcode enable the MMLogToStdErr user default.
extern int ASLogLevel;
void ASLInit(void);
#if defined(MM_USE_ASL)
# define MM_ASL_LEVEL_DEFAULT ASL_LEVEL_NOTICE
# define ASLog(level, fmt, ...) \
if (level <= ASLogLevel) { \
asl_log(NULL, NULL, level, "%s@%d: %s", \
__PRETTY_FUNCTION__, __LINE__, \
[[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \
}
// Note: These macros are used like ASLogErr(@"text num=%d", 42). Objective-C
// style specifiers (%@) are supported.
# define ASLogCrit(fmt, ...) ASLog(ASL_LEVEL_CRIT, fmt, ##__VA_ARGS__)
# define ASLogErr(fmt, ...) ASLog(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
# define ASLogWarn(fmt, ...) ASLog(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
# define ASLogNotice(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
# define ASLogInfo(fmt, ...) ASLog(ASL_LEVEL_INFO, fmt, ##__VA_ARGS__)
# define ASLogDebug(fmt, ...) ASLog(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
# define ASLogTmp(fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
#else
# define MM_ASL_LEVEL_DEFAULT OS_LOG_TYPE_DEFAULT
# define ASLog(level, fmt, ...) \
if (level <= ASLogLevel) { \
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { \
os_log_with_type(OS_LOG_DEFAULT, level, "%s@%d: %s", \
__PRETTY_FUNCTION__, __LINE__, \
[[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \
} else { \
int logLevel; \
switch (level) { \
case OS_LOG_TYPE_FAULT: logLevel = ASL_LEVEL_CRIT; break; \
case OS_LOG_TYPE_ERROR: logLevel = ASL_LEVEL_ERR; break; \
case OS_LOG_TYPE_INFO: logLevel = ASL_LEVEL_INFO; break; \
case OS_LOG_TYPE_DEBUG: logLevel = ASL_LEVEL_DEBUG; break; \
default: logLevel = ASL_LEVEL_NOTICE; break; \
} \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
asl_log(NULL, NULL, logLevel, "%s@%d: %s", \
__PRETTY_FUNCTION__, __LINE__, \
[[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \
_Pragma("clang diagnostic pop") \
} \
}
# define ASLogCrit(fmt, ...) ASLog(OS_LOG_TYPE_FAULT, fmt, ##__VA_ARGS__)
# define ASLogErr(fmt, ...) ASLog(OS_LOG_TYPE_ERROR, fmt, ##__VA_ARGS__)
# define ASLogWarn(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
# define ASLogNotice(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
# define ASLogInfo(fmt, ...) ASLog(OS_LOG_TYPE_INFO, fmt, ##__VA_ARGS__)
# define ASLogDebug(fmt, ...) ASLog(OS_LOG_TYPE_DEBUG, fmt, ##__VA_ARGS__)
# define ASLogTmp(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
#endif
#pragma endregion