Skip to content

Commit

Permalink
fix tab stop width in SLiMguiLegacy
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Jan 18, 2025
1 parent 2569e25 commit 0caf465
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion EidosScribe/EidosCocoaExtra.mm
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,18 @@ + (NSDictionary *)eidosTextAttributesWithColor:(NSColor *)textColor size:(double
static double menloFontSize = 0.0;
static NSFont *menloFont = nil;
static NSMutableParagraphStyle *paragraphStyle = nil;
bool recachedFont = false;

if (!menloFont || (menloFontSize != fontSize))
{
if (menloFont)
[menloFont release];

menloFont = [[NSFont fontWithName:@"Menlo" size:fontSize] retain];
recachedFont = true;
}

if (!paragraphStyle)
if (!paragraphStyle || recachedFont)
{
if (paragraphStyle)
[paragraphStyle release];
Expand Down
22 changes: 20 additions & 2 deletions EidosScribe/EidosTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1356,10 +1356,28 @@ - (void)setDisplayFontSize:(int)fontSize

// set the typing attributes; this code just makes an assumption about the correct typing attributes
// based on the class, probably I ought to add a new method on EidosTextView to get a typing attr dict...
NSDictionary *textAttributes;

if ([self isKindOfClass:[EidosConsoleTextView class]])
[self setTypingAttributes:[NSDictionary eidosInputAttrsWithSize:[self displayFontSize]]];
textAttributes = [NSDictionary eidosInputAttrsWithSize:[self displayFontSize]];
else
[self setTypingAttributes:[NSDictionary eidosTextAttributesWithColor:nil size:_displayFontSize]];
textAttributes = [NSDictionary eidosTextAttributesWithColor:nil size:_displayFontSize];

[self setTypingAttributes:textAttributes];

// fix the tab stops
NSParagraphStyle *pstyle = [textAttributes objectForKey:NSParagraphStyleAttributeName];

[ts beginEditing];

[ts enumerateAttribute:NSParagraphStyleAttributeName inRange:NSMakeRange(0, ts.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
if (value) {
[ts removeAttribute:NSParagraphStyleAttributeName range:range];
[ts addAttribute:NSParagraphStyleAttributeName value:pstyle range:range];
}
}];

[ts endEditing];
}
}

Expand Down

0 comments on commit 0caf465

Please sign in to comment.