diff options
author | Johan Paulsson <gonz@users.sourceforge.net> | 2013-02-26 17:07:05 +0000 |
---|---|---|
committer | Johan Paulsson <gonz@users.sourceforge.net> | 2013-02-26 17:07:05 +0000 |
commit | 44fc6c6fc022b7262175a71a981ddc3969132ed5 (patch) | |
tree | 677ded4cf5d5c61ff0375b7025e77300b4382950 /tikzit/src | |
parent | 814372e88b23ce7956b2322d6f382742e2277ea5 (diff) |
osx gui parsing errors
Diffstat (limited to 'tikzit/src')
-rw-r--r-- | tikzit/src/osx/ParseErrorView.h | 13 | ||||
-rw-r--r-- | tikzit/src/osx/ParseErrorView.m | 40 | ||||
-rw-r--r-- | tikzit/src/osx/TikzSourceController.h | 10 | ||||
-rw-r--r-- | tikzit/src/osx/TikzSourceController.m | 15 |
4 files changed, 76 insertions, 2 deletions
diff --git a/tikzit/src/osx/ParseErrorView.h b/tikzit/src/osx/ParseErrorView.h new file mode 100644 index 0000000..bb6141f --- /dev/null +++ b/tikzit/src/osx/ParseErrorView.h @@ -0,0 +1,13 @@ +// +// ParseErrorView.h +// TikZiT +// +// Created by Karl Johan Paulsson on 27/01/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// + +#import <Cocoa/Cocoa.h> + +@interface ParseErrorView : NSView + +@end diff --git a/tikzit/src/osx/ParseErrorView.m b/tikzit/src/osx/ParseErrorView.m new file mode 100644 index 0000000..97b1b94 --- /dev/null +++ b/tikzit/src/osx/ParseErrorView.m @@ -0,0 +1,40 @@ +// +// ParseErrorView.m +// TikZiT +// +// Created by Karl Johan Paulsson on 27/01/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// + +#import "ParseErrorView.h" + +@implementation ParseErrorView + +- (id)initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code here. + } + + return self; +} + +- (void)drawRect:(NSRect)dirtyRect +{ + // Drawing code here. +} + +- (void)awakeFromNib{ + self.layer = [CALayer layer]; + self.wantsLayer = YES; + CALayer *newLayer = [CALayer layer]; + self.layer.backgroundColor = [[NSColor controlColor] CGColor]; + //CGColorCreate(CGColorSpaceCreateDeviceRGB(), (CGFloat[]){ 1, .9, .64, 1 }); +// newLayer.backgroundColor = [NSColor redColor].CGColor; + newLayer.frame = NSMakeRect(100,100,100,100);//NSMakeRect(0,0,image.size.width,image.size.height); + newLayer.position = CGPointMake(20,20); + //[self.layer addSublayer:newLayer]; +} + +@end diff --git a/tikzit/src/osx/TikzSourceController.h b/tikzit/src/osx/TikzSourceController.h index 01c2cf3..c829336 100644 --- a/tikzit/src/osx/TikzSourceController.h +++ b/tikzit/src/osx/TikzSourceController.h @@ -25,6 +25,7 @@ #import "GraphicsView.h" #import "TikzGraphAssembler.h" +#import "ParseErrorView.h" @interface TikzSourceController : NSObject { GraphicsView *graphicsView; @@ -34,8 +35,9 @@ NSDictionary *textAttrs; NSColor *successColor; NSColor *failedColor; - - + NSTextField *errorMessage; + ParseErrorView *errorNotification; + NSUndoManager *documentUndoManager; BOOL tikzChanged; @@ -51,10 +53,14 @@ @property NSUndoManager *documentUndoManager; @property (copy) NSAttributedString *source; @property (copy) NSString *tikz; +@property IBOutlet ParseErrorView *errorNotification; +@property IBOutlet NSTextField *errorMessage; - (void)updateTikzFromGraph; - (void)graphChanged:(NSNotification*)n; +- (IBAction)closeParseError:(id)pId; + // called by code, these do not register an undo - (BOOL)tryParseTikz; - (void)doRevertTikz; diff --git a/tikzit/src/osx/TikzSourceController.m b/tikzit/src/osx/TikzSourceController.m index 6d1580c..428c6ba 100644 --- a/tikzit/src/osx/TikzSourceController.m +++ b/tikzit/src/osx/TikzSourceController.m @@ -28,6 +28,7 @@ @synthesize graphicsView, sourceView, source, status; @synthesize documentUndoManager, tikzChanged; +@synthesize errorMessage, errorNotification; - (void)endEditing { NSResponder *res = [[sourceView window] firstResponder]; @@ -125,6 +126,10 @@ if ([graphicsView enabled]) [self updateTikzFromGraph]; } +- (IBAction)closeParseError:(id)pId{ + [errorNotification setHidden:TRUE]; +} + - (void)textDidBeginEditing:(NSNotification *)notification { if ([graphicsView enabled]) { [graphicsView setEnabled:NO]; @@ -169,9 +174,19 @@ [status setStringValue:@"success"]; [status setTextColor:successColor]; + + [errorNotification setHidden:TRUE]; } else { [status setStringValue:@"parse error"]; [status setTextColor:failedColor]; + + + NSLog(@"Parse error: %@",[assembler lastError]); + + NSError *e = [assembler lastError]; + + [errorMessage setStringValue:[[[assembler lastError] userInfo] valueForKey:NSLocalizedDescriptionKey]]; + [errorNotification setHidden:FALSE]; } } } |