summaryrefslogtreecommitdiff
path: root/tikzit/src/osx
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/osx')
-rw-r--r--tikzit/src/osx/ParseErrorView.h13
-rw-r--r--tikzit/src/osx/ParseErrorView.m40
-rw-r--r--tikzit/src/osx/TikzSourceController.h10
-rw-r--r--tikzit/src/osx/TikzSourceController.m15
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];
}
}
}