Uniform font defaults to use PCPreferenceController, fix Debugger to actually make setFont work thorugh the view-delegate chain.

This commit is contained in:
Riccardo Mottola 2020-03-24 23:54:22 +01:00
parent 5d80d86a0c
commit 8b48d77cbb
9 changed files with 70 additions and 33 deletions

View file

@ -1,3 +1,15 @@
2020-03-24 Riccardo Mottola <rm@gnu.org>
* Framework/PCProjectLauncher.m
* Modules/Debuggers/ProjectCenter/PCDebugger.m
* Modules/Debuggers/ProjectCenter/PCDebuggerView.h
* Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h
* Modules/Debuggers/ProjectCenter/PipeDelegate.h
* Modules/Debuggers/ProjectCenter/PipeDelegate.m
* Modules/Editors/ProjectCenter/PCEditorView.m
Uniform font defaults to use PCPreferenceController, fix Debugger to
actually make setFont work thorugh the view-delegate chain.
2020-03-24 Riccardo Mottola <rm@gnu.org>
* Modules/Preferences/EditorFSC/PCEditorFSCPrefs.m

View file

@ -1,7 +1,7 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
Copyright (C) 2000-2016 Free Software Foundation
Copyright (C) 2000-2020 Free Software Foundation
Authors: Philippe C.D. Robert
Serg Stoyan
@ -35,6 +35,9 @@
#import <ProjectCenter/PCLogController.h>
#import "Modules/Preferences/Misc/PCMiscPrefs.h"
#import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h"
#import "PCPrefController.h"
#ifndef NOTIFICATION_CENTER
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
@ -145,7 +148,16 @@ enum {
if ((self = [super init]))
{
NSFont *font = [NSFont userFixedPitchFontOfSize: 10.0];
PCPrefController *prefs = [PCPrefController sharedPCPreferences];
NSFont *font;
NSString *fontName;
CGFloat fontSize;
fontName = [prefs stringForKey:ConsoleFixedFont];
fontSize = [prefs floatForKey:ConsoleFixedFontSize];
font = [NSFont fontWithName:fontName size:fontSize];
if (font == nil)
font = [NSFont userFixedPitchFontOfSize:0];
project = aProject;

View file

@ -1,7 +1,7 @@
/*
** PCDebugger.m
**
** Copyright (c) 2008-2016
** Copyright (c) 2008-2020
**
** Author: Gregory Casamento <greg.casamento@gmail.com>
** Riccardo Mottola <rm@gnu.org>>
@ -36,7 +36,7 @@
#import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h"
#import "PCDebuggerViewDelegateProtocol.h"
#import "PipeDelegate.h"
#import "PCPrefController.h"
#ifndef NOTIFICATION_CENTER
@ -120,22 +120,17 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
+ (NSFont *)defaultConsoleFont
{
NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
PCPrefController *prefs = [PCPrefController sharedPCPreferences];
NSString *fontName;
float fontSize;
CGFloat fontSize;
NSFont *font = nil;
fontName = [df objectForKey:ConsoleFixedFont];
fontSize = [df floatForKey:ConsoleFixedFontSize];
fontName = [prefs stringForKey:ConsoleFixedFont];
fontSize = [prefs floatForKey:ConsoleFixedFontSize];
if (fontName != nil && fontSize > 0)
{
font = [NSFont fontWithName:fontName size:fontSize];
}
font = [NSFont fontWithName:fontName size:fontSize];
if (font == nil)
{
font = [NSFont userFixedPitchFontOfSize:0];
}
font = [NSFont userFixedPitchFontOfSize:0];
return font;
}
@ -144,6 +139,7 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
{
if((self = [super init]) != nil)
{
NSLog(@"PCDebugger Init");
id <PCDebuggerViewDelegateProtocol> viewDelegate;
// initialization here...
if([NSBundle loadNibNamed: @"PCDebugger" owner: self] == NO)
@ -157,6 +153,7 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
[viewDelegate setTextView:debuggerView];
[viewDelegate setDebugger:self];
[viewDelegate release];
[debuggerView setFont: [PCDebugger defaultConsoleFont]];
subProcessId = 0;
gdbVersion = 0.0;
@ -236,7 +233,6 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
[debuggerWindow setToolbar: toolbar];
RELEASE(toolbar);
[debuggerView setFont: [PCDebugger defaultConsoleFont]];
[debuggerWindow setFrameAutosaveName: @"PCDebuggerWindow"];
[self setStatus: @"Idle."];
}

View file

@ -1,7 +1,7 @@
/*
** PCDebuggerView
**
** Copyright (c) 2008-2016
** Copyright (c) 2008-2020
**
** Author: Gregory Casamento <greg.casamento@gmail.com>
** Riccardo Mottola <rm@gnu.org>
@ -41,6 +41,9 @@
- (void) setCurrentFile: (NSString *)fileName;
- (NSString *) currentFile;
- (void)setFont:(NSFont *)font;
- (void) runProgram: (NSString *)path
inCurrentDirectory: (NSString *)directory

View file

@ -57,6 +57,11 @@
}
- (void)setFont:(NSFont *)aFont
{
[viewDelegate setFont:aFont];
}
/**
* Log string to the view.
*/

View file

@ -1,7 +1,7 @@
/*
** PCDebuggerViewDelegateProtocol.h
**
** Copyright (c) 2016
** Copyright (c) 2016-2020
**
** Author: Riccardo Mottola <rm@gnu.org>
**
@ -30,6 +30,8 @@
@protocol PCDebuggerViewDelegateProtocol <NSObject>
- (void)setFont:(NSFont *)font;
- (NSColor *)userInputColor;
- (NSColor *)debuggerColor;
- (NSColor *)messageColor;

View file

@ -56,6 +56,7 @@ typedef enum PCDebuggerOutputType_enum {
NSColor *messageColor;
NSColor *errorColor;
NSColor *promptColor;
NSFont *font;
BOOL debuggerStarted;
}

View file

@ -1,7 +1,7 @@
/*
** PipeDelegate.m
**
** Copyright (c) 2008-2016 Free Software Foundation
** Copyright (c) 2008-2020 Free Software Foundation
**
** Author: Gregory Casamento <greg.casamento@gmail.com>
** Riccardo Mottola <rm@gnu.org>
@ -90,6 +90,17 @@
}
}
- (void)setFont:(NSFont *)aFont
{
if (font != aFont)
{
[font release];
font = aFont;
[font retain];
}
}
- (NSColor *)userInputColor
{
return userInputColor;
@ -127,7 +138,7 @@
}
textAttributes = [NSMutableDictionary dictionary];
[textAttributes setObject:[NSFont userFixedPitchFontOfSize:0] forKey:NSFontAttributeName];
[textAttributes setObject:font forKey:NSFontAttributeName];
if (color)
{

View file

@ -4,7 +4,7 @@
Implementation of the PCEditorView class for the
ProjectManager application.
Copyright (C) 2005-2016 Free Software Foundation
Copyright (C) 2005-2020 Free Software Foundation
Saso Kiselkov
Serg Stoyan
Riccardo Mottola
@ -44,7 +44,7 @@
#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,22 +360,17 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
+ (NSFont *)defaultEditorFont
{
NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
PCPrefController *prefs = [PCPrefController sharedPCPreferences];
NSString *fontName;
float fontSize;
CGFloat fontSize;
NSFont *font = nil;
fontName = [df objectForKey:EditorTextFont];
fontSize = [df floatForKey:EditorTextFontSize];
fontName = [prefs stringForKey:EditorTextFont];
fontSize = [prefs floatForKey:EditorTextFontSize];
if (fontName != nil && fontSize > 0)
{
font = [NSFont fontWithName:fontName size:fontSize];
}
font = [NSFont fontWithName:fontName size:fontSize];
if (font == nil)
{
font = [NSFont userFixedPitchFontOfSize:fontSize];
}
font = [NSFont userFixedPitchFontOfSize:0];
return font;
}