@@ -170,8 +170,8 @@ - (void)awakeFromNib {
170
170
[super awakeFromNib ];
171
171
172
172
[self updateFont ];
173
-
174
- NSUserDefaults * defaults = NSUserDefaults .standardUserDefaults ;
173
+
174
+ NSUserDefaults * defaults = NSUserDefaults .standardUserDefaults ;
175
175
self.continuousSpellCheckingEnabled = [defaults boolForKey: GICommitMessageViewUserDefaultKey_EnableSpellChecking];
176
176
self.automaticSpellingCorrectionEnabled = NO ; // Don't trust IB
177
177
self.grammarCheckingEnabled = NO ; // Don't trust IB
@@ -184,7 +184,7 @@ - (void)awakeFromNib {
184
184
self.textColor = NSColor .textColor ; // Don't trust IB
185
185
self.backgroundColor = NSColor .textBackgroundColor ; // Don't trust IB
186
186
[self .textContainer replaceLayoutManager: [[GILayoutManager alloc ] init ]];
187
-
187
+
188
188
self.layoutManager .showsInvisibleCharacters = [defaults boolForKey: GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters];
189
189
190
190
[defaults addObserver: self forKeyPath: GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters options: 0 context: (__bridge void *)[GICommitMessageView class ]];
@@ -326,7 +326,7 @@ - (void)keyDown:(NSEvent*)event {
326
326
327
327
@end
328
328
329
- @interface GILayoutManager () <NSLayoutManagerDelegate >
329
+ @interface GILayoutManager () <NSLayoutManagerDelegate >
330
330
@end
331
331
332
332
@implementation GILayoutManager
@@ -336,45 +336,44 @@ - (instancetype)init {
336
336
if (self) {
337
337
self.delegate = self;
338
338
}
339
-
339
+
340
340
return self;
341
341
}
342
342
343
- - (NSUInteger )layoutManager : (NSLayoutManager *)layoutManager shouldGenerateGlyphs : (const CGGlyph *)glyphs properties : (const NSGlyphProperty *)props characterIndexes : (const NSUInteger *)charIndexes font : (NSFont *)aFont forGlyphRange : (NSRange )glyphRange {
344
-
343
+ - (NSUInteger )layoutManager : (NSLayoutManager *)layoutManager shouldGenerateGlyphs : (const CGGlyph *)glyphs properties : (const NSGlyphProperty *)props characterIndexes : (const NSUInteger *)charIndexes font : (NSFont *)aFont forGlyphRange : (NSRange )glyphRange {
345
344
XLOG_DEBUG_CHECK ([aFont.fontName isEqualToString: @" Menlo-Regular" ]);
346
-
345
+
347
346
if (layoutManager.showsInvisibleCharacters ) {
348
- NSTextStorage * textStorage = layoutManager.textStorage ;
347
+ NSTextStorage * textStorage = layoutManager.textStorage ;
349
348
size_t glyphSize = sizeof (CGGlyph ) * glyphRange.length ;
350
349
size_t propertySize = sizeof (NSGlyphProperty ) * glyphRange.length ;
351
- CGGlyph * replacementGlyphs = malloc (glyphSize);
352
- NSGlyphProperty * replacementProperties = malloc (propertySize);
350
+ CGGlyph * replacementGlyphs = malloc (glyphSize);
351
+ NSGlyphProperty * replacementProperties = malloc (propertySize);
353
352
memcpy (replacementGlyphs, glyphs, glyphSize);
354
353
memcpy (replacementProperties, props, propertySize);
355
- NSString * string = textStorage.string ;
356
-
357
- NSCharacterSet * spaceCharacterSet = [NSCharacterSet characterSetWithCharactersInString: @" " ];
358
- NSCharacterSet * newlineCharacterSet = [NSCharacterSet characterSetWithCharactersInString: @" \n " ];
359
-
354
+ NSString * string = textStorage.string ;
355
+
356
+ NSCharacterSet * spaceCharacterSet = [NSCharacterSet characterSetWithCharactersInString: @" " ];
357
+ NSCharacterSet * newlineCharacterSet = [NSCharacterSet characterSetWithCharactersInString: @" \n " ];
358
+
360
359
NSUInteger i = 0 ;
361
360
while (i < glyphRange.length ) {
362
361
NSUInteger characterIndex = charIndexes[i];
363
362
unichar character = [string characterAtIndex: characterIndex];
364
-
363
+
365
364
if ([spaceCharacterSet characterIsMember: character]) {
366
365
replacementGlyphs[i] = (CGGlyph )[aFont glyphWithName: @" periodcentered" ];
367
-
366
+
368
367
} else if ([newlineCharacterSet characterIsMember: character]) {
369
368
replacementGlyphs[i] = (CGGlyph )[aFont glyphWithName: @" carriagereturn" ];
370
369
replacementProperties[i] = 0 ;
371
370
}
372
-
371
+
373
372
i += [string rangeOfComposedCharacterSequenceAtIndex: characterIndex].length ;
374
373
}
375
-
374
+
376
375
[self setGlyphs: replacementGlyphs properties: replacementProperties characterIndexes: charIndexes font: aFont forGlyphRange: glyphRange];
377
-
376
+
378
377
free (replacementGlyphs);
379
378
free (replacementProperties);
380
379
} else {
@@ -384,7 +383,7 @@ - (NSUInteger)layoutManager:(NSLayoutManager *)layoutManager shouldGenerateGlyph
384
383
return glyphRange.length ;
385
384
}
386
385
387
- - (NSControlCharacterAction )layoutManager : (NSLayoutManager *)layoutManager shouldUseAction : (NSControlCharacterAction )action forControlCharacterAtIndex : (NSUInteger )characterIndex {
386
+ - (NSControlCharacterAction )layoutManager : (NSLayoutManager *)layoutManager shouldUseAction : (NSControlCharacterAction )action forControlCharacterAtIndex : (NSUInteger )characterIndex {
388
387
if (layoutManager.showsInvisibleCharacters && action & NSControlCharacterActionLineBreak ) {
389
388
[layoutManager setNotShownAttribute: NO forGlyphAtIndex: [layoutManager glyphIndexForCharacterAtIndex: characterIndex]];
390
389
}
0 commit comments