Revision: 29653
http://sourceforge.net/p/bibdesk/svn/29653
Author: hofman
Date: 2025-10-03 09:31:15 +0000 (Fri, 03 Oct 2025)
Log Message:
-----------
Editor does not need to know exact formatter class. Combine methods into one
Modified Paths:
--------------
trunk/bibdesk/BDSKComplexStringEditor.h
trunk/bibdesk/BDSKComplexStringEditor.m
Modified: trunk/bibdesk/BDSKComplexStringEditor.h
===================================================================
--- trunk/bibdesk/BDSKComplexStringEditor.h 2025-10-02 21:34:00 UTC (rev
29652)
+++ trunk/bibdesk/BDSKComplexStringEditor.h 2025-10-03 09:31:15 UTC (rev
29653)
@@ -41,17 +41,15 @@
NS_ASSUME_NONNULL_BEGIN
-@class BDSKComplexStringFormatter;
-
@interface BDSKComplexStringEditor : NSWindowController {
NSTextField *expandedValueTextField;
NSImageView *focusRingView;
NSBox *box;
- __weak BDSKComplexStringFormatter *formatter;
+ __weak NSFormatter *formatter;
NSText *editor;
}
-- (instancetype)initWithFormatter:(BDSKComplexStringFormatter *)aFormatter
NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithFormatter:(NSFormatter *)aFormatter
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithWindow:(nullable NSWindow *)window NS_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
Modified: trunk/bibdesk/BDSKComplexStringEditor.m
===================================================================
--- trunk/bibdesk/BDSKComplexStringEditor.m 2025-10-02 21:34:00 UTC (rev
29652)
+++ trunk/bibdesk/BDSKComplexStringEditor.m 2025-10-03 09:31:15 UTC (rev
29653)
@@ -46,9 +46,8 @@
#define WINDOW_MARGIN 4.0
#define MIN_WINDOW_WIDTH 16.0
-@interface BDSKComplexStringEditor (Private)
+@interface BDSKComplexStringEditor ()
-- (void)displayValue:(NSString *)value isError:(BOOL)isError;
- (BOOL)getEnclosingView:(NSView **)view scrollingView:(NSView **)contentView;
- (void)editorFrameDidChange:(NSNotification *)notification;
@@ -59,12 +58,13 @@
@end
+
@implementation BDSKComplexStringEditor
@synthesize expandedValueTextField, focusRingView, box;
@dynamic attached;
-- (instancetype)initWithFormatter:(BDSKComplexStringFormatter *)aFormatter {
+- (instancetype)initWithFormatter:(NSFormatter *)aFormatter {
self = [super initWithWindow:nil];
if (self) {
// don't retain as it owns us
@@ -77,6 +77,16 @@
return @"ComplexStringEditor";
}
+- (void)windowDidLoad {
+ [super windowDidLoad];
+
+ [[self window] setOpaque:NO];
+ [[self window] setBackgroundColor:[NSColor clearColor]];
+ [[self window] setAlphaValue:0.9];
+}
+
+#pragma mark API
+
- (void)attachToEditor:(NSText *)textObj {
if ([self isAttached]) {
if (editor == textObj) {
@@ -173,30 +183,9 @@
[[self window] orderOut:nil];
}
-@end
+#pragma mark -
+#pragma mark Private
-@implementation BDSKComplexStringEditor (Private)
-
-- (void)windowDidLoad {
- [super windowDidLoad];
-
- [[self window] setOpaque:NO];
- [[self window] setBackgroundColor:[NSColor clearColor]];
- [[self window] setAlphaValue:0.9];
-}
-
-- (void)displayValue:(NSString *)string isError:(BOOL)isError {
- [expandedValueTextField setObjectValue:string];
- if (isError) {
- [expandedValueTextField setTextColor:[NSColor systemRedColor]];
- [expandedValueTextField setToolTip:[NSString
stringWithFormat:NSLocalizedString(@"Invalid BibTeX string: %@. This change
will not be recorded.", @"Tool tip message"), string]];
- } else {
- [expandedValueTextField setTextColor:[NSColor controlTextColor]];
- [expandedValueTextField setToolTip:NSLocalizedString(@"This field
contains macros and is being edited as it would appear in a BibTeX file. This
is the expanded value.", @"Tool tip message")];
- }
- [expandedValueTextField setNeedsDisplay:YES];
-}
-
- (void)updateFocusRing {
NSImage *image = nil;
if ([editor isEditable] && [[editor window] isKeyWindow]) {
@@ -299,10 +288,16 @@
- (void)editorTextDidChange:(NSNotification *)notification {
NSString *string = [editor string];
NSString *error = nil;
- if ([formatter getObjectValue:&string forString:string
errorDescription:&error])
- [self displayValue:string isError:NO];
- else
- [self displayValue:error isError:YES];
+ if ([formatter getObjectValue:&string forString:string
errorDescription:&error]) {
+ [expandedValueTextField setObjectValue:string];
+ [expandedValueTextField setTextColor:[NSColor controlTextColor]];
+ [expandedValueTextField setToolTip:NSLocalizedString(@"This field
contains macros and is being edited as it would appear in a BibTeX file. This
is the expanded value.", @"Tool tip message")];
+ } else {
+ [expandedValueTextField setObjectValue:error];
+ [expandedValueTextField setTextColor:[NSColor systemRedColor]];
+ [expandedValueTextField setToolTip:[NSString
stringWithFormat:NSLocalizedString(@"Invalid BibTeX string: %@. This change
will not be recorded.", @"Tool tip message"), string]];
+ }
+ [expandedValueTextField setNeedsDisplay:YES];
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit