Respect background selection preferences and infer text as inverse.

This commit is contained in:
Riccardo Mottola 2021-02-06 12:31:10 +01:00
parent 17182aea86
commit ad65327732
2 changed files with 28 additions and 4 deletions
ChangeLog
Modules/Editors/ProjectCenter

View file

@ -1,3 +1,9 @@
2021-02-06 Riccardo Mottola <rm@gnu.org>
* Modules/Editors/ProjectCenter/PCEditor.m
Respect background selection preferences and infer text
as inverse.
2021-02-04 Riccardo Mottola <rm@gnu.org>
* Framework/PCProjectManager.m

View file

@ -1,7 +1,7 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
Copyright (C) 2002-2015 Free Software Foundation
Copyright (C) 2002-2021 Free Software Foundation
Authors: Philippe C.D. Robert
Serg Stoyan
@ -112,9 +112,13 @@
- (PCEditorView *)_createEditorViewWithFrame:(NSRect)fr
{
PCEditorView *ev = nil;
NSTextContainer *tc = nil;
NSLayoutManager *lm = nil;
PCEditorView *ev = nil;
NSTextContainer *tc = nil;
NSLayoutManager *lm = nil;
NSColor *bSelCol = nil;
NSColor *tSelCol = nil;
id <PCPreferences> prefs;
NSDictionary *selAttributes;
/*
* setting up the objects needed to manage the view but using the
@ -152,6 +156,19 @@
[ev setEditable:_isEditable];
prefs = [[_editorManager projectManager] prefController];
bSelCol = [prefs colorForKey:EditorSelectionColor];
tSelCol = [NSColor colorWithCalibratedRed: 1.0 - [bSelCol redComponent]
green: 1.0 - [bSelCol greenComponent]
blue: 1.0 - [bSelCol blueComponent]
alpha: [bSelCol alphaComponent]];
selAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
bSelCol, NSBackgroundColorAttributeName,
tSelCol, NSForegroundColorAttributeName,
nil];
[ev setSelectedTextAttributes:selAttributes];
[ev setSelectedTextAttributes:selAttributes];
// Activate undo
[ev setAllowsUndo: YES];
@ -296,6 +313,7 @@
text = [NSString stringWithContentsOfFile:_path];
attributedString = [attributedString initWithString:text attributes:attributes];
[attributes release];
_storage = [[NSTextStorage alloc] init];
[_storage setAttributedString:attributedString];