summaryrefslogtreecommitdiff
path: root/tikzit/src/osx
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@cs.ox.ac.uk>2013-08-07 16:56:23 +0100
committerAlex Merry <alex.merry@cs.ox.ac.uk>2013-08-07 17:04:48 +0100
commitac7b53be102860d76f318ab0575cfb546635d04e (patch)
tree5e869a1390c224b9b601d55a4e267160af7ab585 /tikzit/src/osx
parent5a94458d9ee3ee8afd978477c755200df432a9b0 (diff)
Allow preambles to omit the tikzit-specific preview stuff
The editable preambles include a bunch of things that *have* to be there for previews to work, which makes figuring out what you can edit hard. We now add a \documentclass automagically if it is missing, and if \begin{document} is missing, we assume the preview-specific stuff should be added. OSX changes are untested.
Diffstat (limited to 'tikzit/src/osx')
-rw-r--r--tikzit/src/osx/PreambleController.h1
-rw-r--r--tikzit/src/osx/PreambleController.m5
-rw-r--r--tikzit/src/osx/PreviewController.m5
3 files changed, 7 insertions, 4 deletions
diff --git a/tikzit/src/osx/PreambleController.h b/tikzit/src/osx/PreambleController.h
index 2d5a8ab..fca52ae 100644
--- a/tikzit/src/osx/PreambleController.h
+++ b/tikzit/src/osx/PreambleController.h
@@ -48,6 +48,7 @@
- (void)savePreambles:(NSString*)plist;
- (NSString*)currentPreamble;
- (NSString*)currentPostamble;
+- (NSString*)buildDocumentForTikz:(NSString*)tikz;
- (IBAction)setPreamble:(id)sender;
- (IBAction)insertDefaultStyles:(id)sender;
diff --git a/tikzit/src/osx/PreambleController.m b/tikzit/src/osx/PreambleController.m
index e424e7b..af9a778 100644
--- a/tikzit/src/osx/PreambleController.m
+++ b/tikzit/src/osx/PreambleController.m
@@ -108,6 +108,11 @@
return [preambles currentPostamble];
}
+- (NSString*)buildDocumentForTikz:(NSString*)tikz {
+ [self flushText];
+ return [preambles buildDocumentForTikz:tikz];
+}
+
- (void)setSelectionIndexes:(NSIndexSet *)idx {
[self willChangeValueForKey:@"selectionIndexes"];
selectionIndexes = idx;
diff --git a/tikzit/src/osx/PreviewController.m b/tikzit/src/osx/PreviewController.m
index 7c41562..94a80a4 100644
--- a/tikzit/src/osx/PreviewController.m
+++ b/tikzit/src/osx/PreviewController.m
@@ -52,10 +52,7 @@ static PreviewController *preview = nil;
int fnum = typesetCount++;
- NSString *tex = [NSString stringWithFormat:@"%@%@%@",
- [preambleController currentPreamble],
- tikz,
- [preambleController currentPostamble]];
+ NSString *tex = [preambleController buildDocumentForTikz:tikz];
NSString *texFile = [NSString stringWithFormat:@"%@/tikzit_%d.tex", tempDir, fnum];
NSString *pdfFile = [NSString stringWithFormat:@"%@/tikzit_%d.pdf", tempDir, fnum];