version 1.2, 2006/03/06 08:55:31 |
version 1.3, 2006/03/07 11:15:23 |
Line 18 static int myDocumentSaidTheMessageAboutX = 0; |
|
Line 18 static int myDocumentSaidTheMessageAboutX = 0; |
|
|
|
|
|
@implementation MyDocument |
@implementation MyDocument |
|
// For OnState or OffState in the execution menu |
|
static NSMenuItem *menuItemNotebookMode = nil; |
|
static NSMenuItem *menuItemBasicMode = nil; |
|
static NSMenuItem *menuItemRisaAsir = nil; |
|
static NSMenuItem *menuItemKanSm1 = nil; |
|
static NSMenuItem *menuItemOutputDebugMessages = nil; //cf. debugMyTunnel; |
|
static NSMenuItem *menuItemPrettyPrint = nil; // prettyPrint. |
|
|
|
|
- (void)dealloc { |
- (void)dealloc { |
MyOutputWindowController *mowc; |
MyOutputWindowController *mowc; |
if (myDebug) NSLog(@"dealloc of MyDocument.\n"); |
if (myDebug) NSLog(@"dealloc of MyDocument.\n"); |
Line 140 static int myDocumentSaidTheMessageAboutX = 0; |
|
Line 148 static int myDocumentSaidTheMessageAboutX = 0; |
|
myDecoder = [[MyDecoder alloc] init]; [myDecoder retain]; |
myDecoder = [[MyDecoder alloc] init]; [myDecoder retain]; |
|
|
[self openMyModel: myEnvironment ]; |
[self openMyModel: myEnvironment ]; |
|
[MyOpenGLController initMyOpenGLController]; // For the second execution, it will do nothing. |
} |
} |
-(int) getMyDocumentKey { return myDocumentKey; } |
-(int) getMyDocumentKey { return myDocumentKey; } |
|
|
Line 388 static int myDocumentSaidTheMessageAboutX = 0; |
|
Line 397 static int myDocumentSaidTheMessageAboutX = 0; |
|
else { |
else { |
MyOutputWindowController *mc; |
MyOutputWindowController *mc; |
mc = [MyOutputWindowController sharedMyOutputWindowController: self]; |
mc = [MyOutputWindowController sharedMyOutputWindowController: self]; |
[mc outputStringToOutputWindow: amt]; |
if (prettyPrint) [mc outputStringToOutputWindow: amt withColor: [NSColor blueColor]]; |
|
else [mc outputStringToOutputWindow: amt]; |
} |
} |
} |
} |
- (void) outputErrorString: (NSString *) amt { |
- (void) outputErrorString: (NSString *) amt { |
Line 976 int debugInbound = 0; |
|
Line 986 int debugInbound = 0; |
|
NSRange r; |
NSRange r; |
NSRange r3; |
NSRange r3; |
int currentLine,i; |
int currentLine,i; |
|
[self outputErrorString: NSLocalizedString(@"Move to the line ",nil)]; |
|
[self outputErrorString: [NSString stringWithFormat: @"%d\n",line]]; |
// move the selection to the line line. |
// move the selection to the line line. |
s = [textViewIn string]; |
s = [textViewIn string]; |
if (onlySelectedArea || notebookMode) r = [textViewIn selectedRange]; |
if (onlySelectedArea || notebookMode) r = [textViewIn selectedRange]; |
Line 996 int debugInbound = 0; |
|
Line 1008 int debugInbound = 0; |
|
} |
} |
-(int) gotoNextError: (id) sender{ |
-(int) gotoNextError: (id) sender{ |
int n; |
int n; |
|
if (onlySelectedArea || notebookMode) |
|
[self outputErrorString: NSLocalizedString(@"The next error action will not work properly in this mode.\n",nil)]; |
n = [self nextLine: 0]; |
n = [self nextLine: 0]; |
if (n >= 0) { [self gotoLine: n]; return n;} |
if (n >= 0) { [self gotoLine: n]; return n;} |
else return -1; |
else return -1; |
Line 1011 int debugInbound = 0; |
|
Line 1025 int debugInbound = 0; |
|
return -1; |
return -1; |
} |
} |
gid = [[a objectAtIndex: 0] intValue]; |
gid = [[a objectAtIndex: 0] intValue]; |
|
if ([[a objectAtIndex: 1] hasPrefix: @"meta"]) {[self openGLMeta: [a objectAtIndex: 1] to: gid]; return; } |
[MyOpenGLController addOglComm: [a objectAtIndex: 1] to: gid from: self]; |
[MyOpenGLController addOglComm: [a objectAtIndex: 1] to: gid from: self]; |
return 0; |
return 0; |
} |
} |
Line 1026 int debugInbound = 0; |
|
Line 1041 int debugInbound = 0; |
|
[MyOpenGLController addOglInitComm: [a objectAtIndex: 1] to: gid from: self]; |
[MyOpenGLController addOglInitComm: [a objectAtIndex: 1] to: gid from: self]; |
return 0; |
return 0; |
} |
} |
|
-(void)openGLMeta: (NSString *) cmd to: (int) gid{ |
|
MyOpenGLController *oglc; |
|
oglc = [MyOpenGLController getOglWindow: gid]; |
|
if (!oglc) {[self outputErrorString: [NSString stringWithFormat: @"Invalid gid %d in openGLMeta\n",gid]]; return; } |
|
if ([cmd hasPrefix: @"meta_showListOfOglComm"]) { |
|
[self showListOfOglComm: gid]; return ; |
|
}else if ([cmd hasPrefix: @"meta_removeAll"]) { |
|
[oglc removeAllOfOglComm]; |
|
}else if ([cmd hasPrefix: @"meta_removeLast"]) { |
|
[oglc removeLastOfOglComm]; |
|
}else if ([cmd hasPrefix: @"meta_removeAllInit"]) { |
|
[oglc removeAllOfOglInitComm]; |
|
}else if ([cmd hasPrefix: @"meta_removeLastInit"]) { |
|
[oglc removeLastOfOglInitComm]; |
|
}else{ |
|
[self outputErrorString: [NSString stringWithFormat: @"Unknown OpenGL meta command %@\n",cmd]]; |
|
} |
|
} |
|
-(void) showListOfOglComm: (int) gid { |
|
MyDocument *md; |
|
MyOpenGLController *oglc; |
|
NSMutableArray *comm; |
|
int i,n; |
|
md = self; |
|
oglc = [MyOpenGLController getOglWindow: gid]; |
|
if (!oglc) {[self outputErrorString: @"Invalid gid in showListOfOglComm\n"]; return; } |
|
comm = [oglc getListOfOglInitComm]; |
|
n = [comm count]; |
|
[md outputString: NSLocalizedString(@"OpenGL init commands\n",nil)]; |
|
for (i=0; i<n; i++) { |
|
[md outputString: [NSString stringWithFormat: @"%04d: ",i]]; |
|
[md outputString: [[comm objectAtIndex: i] toString]]; |
|
[md outputString: @"\n"]; |
|
} |
|
comm = [oglc getListOfOglComm]; |
|
n = [comm count]; |
|
[md outputString: NSLocalizedString(@"OpenGL redraw commands\n",nil)]; |
|
for (i=0; i<n; i++) { |
|
[md outputString: [NSString stringWithFormat: @"%04d: ",i]]; |
|
[md outputString: [[comm objectAtIndex: i] toString]]; |
|
[md outputString: @"\n"]; |
|
} |
|
} |
|
|
|
|
-(void) pngActionFor: (NSString *)act { |
-(void) pngActionFor: (NSString *)act { |
NSArray *a; |
NSArray *a; |
id typesetExpression; |
id typesetExpression; |
Line 1093 int debugInbound = 0; |
|
Line 1152 int debugInbound = 0; |
|
[self updateSelectEngineMenu]; |
[self updateSelectEngineMenu]; |
[self oxEvaluateString: @"!sm1;" withMark: TRUE]; |
[self oxEvaluateString: @"!sm1;" withMark: TRUE]; |
} |
} |
|
// BUG: update* must be called when the focus is changed to "setState:" |
-(void) updateSelectEngineMenu { |
-(void) updateSelectEngineMenu { |
if (!menuItemRisaAsir) return; |
if (!menuItemRisaAsir) return; |
if (!menuItemKanSm1) return; |
if (!menuItemKanSm1) return; |
Line 1114 int debugInbound = 0; |
|
Line 1174 int debugInbound = 0; |
|
} |
} |
[MyUtil setDebugMyUtil]; |
[MyUtil setDebugMyUtil]; |
} |
} |
|
|
|
//BUG: [self setPrettyPrint: nil] or update must be called when focus is changed to "setState:" |
-(void) setPrettyPrint: (id) sender { |
-(void) setPrettyPrint: (id) sender { |
if (prettyPrint) { |
if (prettyPrint) { |
prettyPrint = 0; |
prettyPrint = 0; |
Line 1213 int debugInbound = 0; |
|
Line 1275 int debugInbound = 0; |
|
[menuExec addItem: menuItemGotoNextError]; |
[menuExec addItem: menuItemGotoNextError]; |
|
|
// outputDebugMessage |
// outputDebugMessage |
menuItemOutputDebugMessages = [[[NSMenuItem alloc] init] autorelease]; |
menuItemOutputDebugMessages = [[[NSMenuItem alloc] init] autorelease]; [menuItemOutputDebugMessages retain]; |
[menuItemOutputDebugMessages setTitle: NSLocalizedString(@"Output debug messages",nil)]; |
[menuItemOutputDebugMessages setTitle: NSLocalizedString(@"Output debug messages",nil)]; |
[menuItemOutputDebugMessages setAction: @selector(setDebugMyTunnel:)]; |
[menuItemOutputDebugMessages setAction: @selector(setDebugMyTunnel:)]; |
[menuItemOutputDebugMessages setTarget: [[NSApp mainWindow] document]]; |
[menuItemOutputDebugMessages setTarget: [[NSApp mainWindow] document]]; |
[menuExec addItem: menuItemOutputDebugMessages]; |
[menuExec addItem: menuItemOutputDebugMessages]; |
|
|
// pretty print |
// pretty print |
menuItemPrettyPrint = [[[NSMenuItem alloc] init] autorelease]; |
menuItemPrettyPrint = [[[NSMenuItem alloc] init] autorelease]; [menuItemPrettyPrint retain]; // it is the static variable. |
[menuItemPrettyPrint setTitle: NSLocalizedString(@"Typeset the output by TeX",nil)]; |
[menuItemPrettyPrint setTitle: NSLocalizedString(@"Typeset the output by TeX",nil)]; |
[menuItemPrettyPrint setAction: @selector(setPrettyPrint:)]; |
[menuItemPrettyPrint setAction: @selector(setPrettyPrint:)]; |
[menuItemPrettyPrint setTarget: [[NSApp mainWindow] document]]; |
[menuItemPrettyPrint setTarget: [[NSApp mainWindow] document]]; |
Line 1236 int debugInbound = 0; |
|
Line 1298 int debugInbound = 0; |
|
[menuItemBasicLike setTitle: NSLocalizedString(@"BASIC-like",nil)]; |
[menuItemBasicLike setTitle: NSLocalizedString(@"BASIC-like",nil)]; |
[menuItemBasicLike setAction: @selector(setBasicStyle:)]; |
[menuItemBasicLike setAction: @selector(setBasicStyle:)]; |
[menuItemBasicLike setTarget: [[NSApp mainWindow] document]]; |
[menuItemBasicLike setTarget: [[NSApp mainWindow] document]]; |
menuItemBasicMode = menuItemBasicLike; |
menuItemBasicMode = menuItemBasicLike; [menuItemBasicMode retain]; |
[submenuInterfaceItem addItem: menuItemBasicLike]; |
[submenuInterfaceItem addItem: menuItemBasicLike]; |
// notebook-like |
// notebook-like |
NSMenuItem *menuItemNotebookLike = [[[NSMenuItem alloc] init] autorelease]; |
NSMenuItem *menuItemNotebookLike = [[[NSMenuItem alloc] init] autorelease]; |
[menuItemNotebookLike setTitle: NSLocalizedString(@"Notebook-like",nil)]; |
[menuItemNotebookLike setTitle: NSLocalizedString(@"Notebook-like",nil)]; |
[menuItemNotebookLike setAction: @selector(setNotebookStyle:)]; |
[menuItemNotebookLike setAction: @selector(setNotebookStyle:)]; |
[menuItemNotebookLike setTarget: [[NSApp mainWindow] document]]; |
[menuItemNotebookLike setTarget: [[NSApp mainWindow] document]]; |
menuItemNotebookMode = menuItemNotebookLike; |
menuItemNotebookMode = menuItemNotebookLike; [menuItemNotebookMode retain]; |
[submenuInterfaceItem addItem: menuItemNotebookLike]; |
[submenuInterfaceItem addItem: menuItemNotebookLike]; |
|
|
menuItemInterfaceStyle = [[[NSMenuItem alloc] init] autorelease]; |
menuItemInterfaceStyle = [[[NSMenuItem alloc] init] autorelease]; |
Line 1255 int debugInbound = 0; |
|
Line 1317 int debugInbound = 0; |
|
// select engine |
// select engine |
NSMenu *submenuSelectEngineItem = [[[NSMenu alloc] init] autorelease]; |
NSMenu *submenuSelectEngineItem = [[[NSMenu alloc] init] autorelease]; |
// asir |
// asir |
menuItemRisaAsir = [[[NSMenuItem alloc] init] autorelease]; |
menuItemRisaAsir = [[[NSMenuItem alloc] init] autorelease]; [menuItemRisaAsir retain]; |
[menuItemRisaAsir setTitle: NSLocalizedString(@"Risa/Asir",nil)]; |
[menuItemRisaAsir setTitle: NSLocalizedString(@"Risa/Asir",nil)]; |
[menuItemRisaAsir setAction: @selector(setEngineRisaAsir:)]; |
[menuItemRisaAsir setAction: @selector(setEngineRisaAsir:)]; |
[menuItemRisaAsir setTarget: [[NSApp mainWindow] document]]; |
[menuItemRisaAsir setTarget: [[NSApp mainWindow] document]]; |
[submenuSelectEngineItem addItem: menuItemRisaAsir]; |
[submenuSelectEngineItem addItem: menuItemRisaAsir]; |
// notebook-like |
// notebook-like |
menuItemKanSm1 = [[[NSMenuItem alloc] init] autorelease]; |
menuItemKanSm1 = [[[NSMenuItem alloc] init] autorelease]; [menuItemKanSm1 retain]; |
[menuItemKanSm1 setTitle: NSLocalizedString(@"Kan/sm1",nil)]; |
[menuItemKanSm1 setTitle: NSLocalizedString(@"Kan/sm1",nil)]; |
[menuItemKanSm1 setAction: @selector(setEngineKanSm1:)]; |
[menuItemKanSm1 setAction: @selector(setEngineKanSm1:)]; |
[menuItemKanSm1 setTarget: [[NSApp mainWindow] document]]; |
[menuItemKanSm1 setTarget: [[NSApp mainWindow] document]]; |