* Headers/Additions/GNUstepGUI/GSLayoutManager.h,

Source/GSLayoutManager.m: new method -typingAttributes returns default typing
  attributes of NSTextView.
* Source/NSLayoutManager.m: override GSLayoutManager's -typingAttributes - primitive
  method - provides access to _typingAttributes ivar.
* Source/GSHorizontalTypesetter.m: use new GSLayoutManager's -typingAttributes method
  to get paragraph style and font of new empty text container. Normally `curLayoutManager`
  is a NSLayoutManager object so actually we get NSLayoutManager's _typingAttributes.
This commit is contained in:
Sergii Stoian 2019-12-10 19:23:04 +02:00
parent 5415783c56
commit fcee2e2c63
5 changed files with 31 additions and 18 deletions

View file

@ -1,8 +1,18 @@
2019-12-10 Sergii Stoian <stoyan255@gmail.com>
* Source/GSHorizontalTypesetter.m: (_addExtraLineFragment) get paragraph style and
font from NSLayoutManager's typing attributes. Fixes insertion point height for empty
text objects (NSTextView, NSTexField etc.).
* Headers/Additions/GNUstepGUI/GSLayoutManager.h,
* Source/GSLayoutManager.m: new method -typingAttributes returns default
typing attributes of NSTextView.
* Source/NSLayoutManager.m: override GSLayoutManager's -typingAttributes
- primitive method - provides access to _typingAttributes ivar.
* Source/GSHorizontalTypesetter.m: use new GSLayoutManager's
-typingAttributes method to get paragraph style and font of new empty text
container. Normally `curLayoutManager` is a NSLayoutManager object so,
actually, we get NSLayoutManager's _typingAttributes.
* Source/GSHorizontalTypesetter.m: (_addExtraLineFragment) get paragraph
style and font from NSLayoutManager's typing attributes. Fixes insertion
point height for empty text objects (NSTextView, NSTexField etc.).
2019-12-09 Sergii Stoian <stoyan255@gmail.com>

View file

@ -168,6 +168,7 @@ If characters have been edited, lengthChange has the text length delta.
forStartingGlyphAtIndex: (NSUInteger)glyph
characterIndex: (NSUInteger)index;
- (NSDictionary *) typingAttributes;
@end

View file

@ -536,20 +536,10 @@ For bigger values the width gets ignored.
}
else
{
NSLayoutManager *layoutManager = [[curTextContainer textView] layoutManager];
if (layoutManager)
{
NSDictionary *typingAttributes = layoutManager->_typingAttributes;
curParagraphStyle = [typingAttributes
objectForKey: NSParagraphStyleAttributeName];
curFont = [typingAttributes objectForKey: NSFontAttributeName];
}
else
{
curParagraphStyle = [NSParagraphStyle defaultParagraphStyle];
curFont = [NSFont userFontOfSize: 0];
}
NSDictionary *typingAttributes = [curLayoutManager typingAttributes];
curParagraphStyle = [typingAttributes
objectForKey: NSParagraphStyleAttributeName];
curFont = [typingAttributes objectForKey: NSFontAttributeName];
}
line_height = [curFont defaultLineHeightForFont];

View file

@ -34,6 +34,7 @@
#import "AppKit/NSAttributedString.h"
#import "AppKit/NSTextStorage.h"
#import "AppKit/NSTextContainer.h"
#import "AppKit/NSTextView.h"
/* just for NSAttachmentCharacter */
#import "AppKit/NSTextAttachment.h"
@ -3280,7 +3281,13 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
else if (attributeTag == NSGlyphAttributeBidiLevel)
g->bidilevel = anInt;
}
}
}
- (NSDictionary *) typingAttributes
{
return [NSTextView defaultTypingAttributes];
}
/*
* NSCoding protocol

View file

@ -3017,6 +3017,11 @@ no_soft_invalidation:
}
}
- (NSDictionary *) typingAttributes
{
return _typingAttributes;
}
@end