mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-03-14 06:31:31 +00:00
Separate font accessors in to class and instance methods.
Do not use preferences in class methods, since they are outside the protocol.
This commit is contained in:
parent
3df9137f39
commit
445b31db3f
3 changed files with 63 additions and 11 deletions
|
@ -4,6 +4,12 @@
|
|||
* Modules/Editors/ProjectCenter/SyntaxHighlighter.m
|
||||
Add setters for fonts.
|
||||
|
||||
* Modules/Editors/ProjectCenter/PCEditorView.h
|
||||
* Modules/Editors/ProjectCenter/PCEditorView.m
|
||||
Separate font accessors in to class and instance methods.
|
||||
Do not use preferences in class methods, since they are outside the
|
||||
protocol.
|
||||
|
||||
2020-09-08 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Framework/PCProjectLauncher.m
|
||||
|
|
|
@ -42,6 +42,12 @@
|
|||
+ (NSFont *)defaultEditorItalicFont;
|
||||
+ (NSFont *)defaultEditorBoldItalicFont;
|
||||
|
||||
- (NSFont *)editorFont;
|
||||
- (NSFont *)editorBoldFont;
|
||||
- (NSFont *)editorItalicFont;
|
||||
- (NSFont *)editorBoldItalicFont;
|
||||
|
||||
|
||||
- (void)setEditor:(NSObject <CodeEditor> *)anEditor;
|
||||
|
||||
- (void)createSyntaxHighlighterForFileType:(NSString *)fileType;
|
||||
|
|
|
@ -40,11 +40,12 @@
|
|||
|
||||
#import <ctype.h>
|
||||
|
||||
#import <ProjectCenter/PCProjectManager.h>
|
||||
|
||||
#import "PCEditor.h"
|
||||
#import "SyntaxHighlighter.h"
|
||||
#import "LineJumper.h"
|
||||
#import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h"
|
||||
#import "PCPrefController.h"
|
||||
|
||||
/**
|
||||
* Computes the indenting offset of the last line before the passed
|
||||
|
@ -360,18 +361,9 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
|
|||
|
||||
+ (NSFont *)defaultEditorFont
|
||||
{
|
||||
PCPrefController *prefs = [PCPrefController sharedPCPreferences];
|
||||
NSString *fontName;
|
||||
CGFloat fontSize;
|
||||
NSFont *font = nil;
|
||||
|
||||
fontName = [prefs stringForKey:EditorTextFont];
|
||||
fontSize = [prefs floatForKey:EditorTextFontSize];
|
||||
|
||||
font = [NSFont fontWithName:fontName size:fontSize];
|
||||
if (font == nil)
|
||||
font = [NSFont userFixedPitchFontOfSize:0];
|
||||
|
||||
font = [NSFont userFixedPitchFontOfSize:0];
|
||||
return font;
|
||||
}
|
||||
|
||||
|
@ -400,6 +392,50 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
|
|||
NSItalicFontMask];
|
||||
}
|
||||
|
||||
- (NSFont *)editorFont
|
||||
{
|
||||
id <PCPreferences> prefs;
|
||||
NSString *fontName;
|
||||
CGFloat fontSize;
|
||||
NSFont *font = nil;
|
||||
|
||||
prefs = [[[editor editorManager] projectManager] prefController];
|
||||
|
||||
fontName = [prefs stringForKey:EditorTextFont];
|
||||
fontSize = [prefs floatForKey:EditorTextFontSize];
|
||||
|
||||
font = [NSFont fontWithName:fontName size:fontSize];
|
||||
if (font == nil)
|
||||
font = [NSFont userFixedPitchFontOfSize:0];
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
- (NSFont *)editorBoldFont
|
||||
{
|
||||
NSFont *font = [self editorFont];
|
||||
|
||||
return [[NSFontManager sharedFontManager] convertFont:font
|
||||
toHaveTrait:NSBoldFontMask];
|
||||
}
|
||||
|
||||
- (NSFont *)editorItalicFont
|
||||
{
|
||||
NSFont *font = [self editorFont];
|
||||
|
||||
return [[NSFontManager sharedFontManager] convertFont:font
|
||||
toHaveTrait:NSItalicFontMask];
|
||||
}
|
||||
|
||||
- (NSFont *)editorBoldItalicFont
|
||||
{
|
||||
NSFont *font = [self editorFont];
|
||||
|
||||
return [[NSFontManager sharedFontManager] convertFont:font
|
||||
toHaveTrait:NSBoldFontMask |
|
||||
NSItalicFontMask];
|
||||
}
|
||||
|
||||
// ---
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
|
@ -475,6 +511,10 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
|
|||
[[[SyntaxHighlighter alloc] initWithFileType:fileType
|
||||
textStorage:[self textStorage]]
|
||||
autorelease]);
|
||||
[highlighter setNormalFont: [self editorFont]];
|
||||
[highlighter setBoldFont: [self editorBoldFont]];
|
||||
[highlighter setItalicFont: [self editorItalicFont]];
|
||||
[highlighter setBoldItalicFont: [self editorBoldItalicFont]];
|
||||
}
|
||||
|
||||
- (void)insertText:text
|
||||
|
|
Loading…
Reference in a new issue