=================================================================== RCS file: /home/cvs/OpenXM/src/cfep/MyDocument.m,v retrieving revision 1.3 retrieving revision 1.11 diff -u -p -r1.3 -r1.11 --- OpenXM/src/cfep/MyDocument.m 2006/03/07 11:15:23 1.3 +++ OpenXM/src/cfep/MyDocument.m 2016/10/03 07:42:29 1.11 @@ -18,6 +18,8 @@ static int myDocumentSaidTheMessageAboutX = 0; @implementation MyDocument +static int NoEngine = 0; // experimental. +static NSMenuItem *menuItemNoEngine = nil; // NoEngine // For OnState or OffState in the execution menu static NSMenuItem *menuItemNotebookMode = nil; static NSMenuItem *menuItemBasicMode = nil; @@ -72,6 +74,11 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret [self addMenuExec]; // adding the execution menu. [textViewIn setAllowsUndo:YES]; if ([textViewIn isContinuousSpellCheckingEnabled]) [textViewIn toggleContinuousSpellChecking: self]; // Turn off the spell checking. + if ([textViewIn isAutomaticQuoteSubstitutionEnabled]) [textViewIn toggleAutomaticQuoteSubstitution: self]; // Turn off the smart quote. + if ([MyEnvironment isX11Installed] != 1) + [self messageDialog: NSLocalizedString(@"XQuartz(X11) is not installed. To install it, visit http://www.xquartz.org.",nil) with: 0]; +// if ([MyEnvironment isGccInstalled] != 1) +// [self messageDialog: NSLocalizedString(@"gcc is not installed. To install it, insert MacOS DVD1 and open Xcode Tools->XcodeTools.mpkg",nil) with: 0]; [self sayTheMessageAboutX]; [self initAux]; } @@ -150,7 +157,7 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret [self openMyModel: myEnvironment ]; [MyOpenGLController initMyOpenGLController]; // For the second execution, it will do nothing. } --(int) getMyDocumentKey { return myDocumentKey; } +-(NSString *) getMyDocumentKey { return myDocumentKey; } -(id) openMyModel: (MyEnvironment *) myEnvironment { [myEnvironment showForDebug]; // for debug. @@ -165,6 +172,8 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret [peerEndEvaluteMark retain]; [self stopIndicator]; + if (NoEngine && (!restartMode)) { task = nil; return self; } + // Initialization to call /bin/bash outboundPipe = [NSPipe pipe]; // since autorelease is called in pipe. inboundPipe = [NSPipe pipe]; @@ -227,6 +236,7 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret -(id) restartMyModel: (enum peer_type) peerType { MyEnvironment *myEnvironment; + restartMode = 1; [self closeMyModel]; myEnvironment = [[MyEnvironment alloc] initFor: peerType]; //BUG. leak memory? [myEnvironment retain]; @@ -240,8 +250,11 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret NSLog(@"myDocumentSaidTheMessageAboutX=%d\n",myDocumentSaidTheMessageAboutX); if (!myDocumentSaidTheMessageAboutX) { if ([MyEnvironment checkX] != 1) - [self messageDialog: - NSLocalizedString(@"A few commands (plot, ...) cannot be used, because X11 is not running.",nil) with: 0]; + // [self messageDialog: + // NSLocalizedString(@"A few commands (plot, ...) cannot be used, because X11 is not running.",nil) with: 0]; + [self changeOutputCounterFieldWithString: + [NSLocalizedString(@"Output mini-view: ",nil) stringByAppendingString: + NSLocalizedString(@"A few commands (plot, ...) cannot be used, because X11 is not running.",nil)]]; myDocumentSaidTheMessageAboutX = 1; } } @@ -251,6 +264,7 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret NSMutableString *cmd; NSRange r; + if (!task) return; if (inEvaluation) { NSLog(@"In evaluatioin. "); [self messageDialog: NSLocalizedString(@"Evaluating...",nil) with: 0]; @@ -283,7 +297,13 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret [textViewIn replaceCharactersInRange: NSMakeRange(pos,0) withString: @"\n"]; } cmd0 = [cmd0 substringWithRange:r ]; - } + } + [self outputBorderLine: [NSColor magentaColor]]; + [self outputString: cmd0]; + if ([cmd0 length] > 0) { + if ([cmd0 characterAtIndex: ([cmd0 length]-1)] != 0xa) [self outputString: @"\n"]; + } + [self outputBorderLine: [NSColor yellowColor]]; }else{ cmd0 = [textViewIn string]; MyOutputWindowController *mc; @@ -313,7 +333,7 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret [alert release]; fprintf(stderr,"Trying to interrupt.\n"); - [task interrupt]; + if (task) [task interrupt]; inputCounter = outputCounter = 0; [self stopIndicator]; [myDecoder reset]; @@ -370,6 +390,7 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret NSLog(@"Evaluating... "); NSLog(@"%@",cmd); // Evaluation is here. + if (!task) return -1; cmdInData = [cmd dataUsingEncoding: NSUTF8StringEncoding]; @try { //todo if (yes) [outboundFileHandle writeData: peerStartEvaluateMark]; @@ -401,6 +422,11 @@ static NSMenuItem *menuItemPrettyPrint = nil; // pret else [mc outputStringToOutputWindow: amt]; } } +-(void)outputBorderLine: (NSColor *)color { + MyOutputWindowController *mc; + mc = [MyOutputWindowController sharedMyOutputWindowController: self]; + [mc outputStringToOutputWindow: @"----------------------------------------\n" withColor: color]; +} - (void) outputErrorString: (NSString *) amt { int oldEnd; int newEnd; @@ -1025,7 +1051,7 @@ int debugInbound = 0; return -1; } gid = [[a objectAtIndex: 0] intValue]; - if ([[a objectAtIndex: 1] hasPrefix: @"meta"]) {[self openGLMeta: [a objectAtIndex: 1] to: gid]; return; } + if ([[a objectAtIndex: 1] hasPrefix: @"meta"]) {[self openGLMeta: [a objectAtIndex: 1] to: gid]; return 0; } [MyOpenGLController addOglComm: [a objectAtIndex: 1] to: gid from: self]; return 0; } @@ -1044,19 +1070,20 @@ int debugInbound = 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 (!oglc) {[self printErrorMessage: + [NSString stringWithFormat: @"Invalid gid %d in openGLMeta command %@\n",gid,cmd]]; return; } if ([cmd hasPrefix: @"meta_showListOfOglComm"]) { [self showListOfOglComm: gid]; return ; + }else if ([cmd hasPrefix: @"meta_removeAllInit"]) { // longer command must come first, because we use prefix. + [oglc removeAllOfOglInitComm]; + }else if ([cmd hasPrefix: @"meta_removeLastInit"]) { + [oglc removeLastOfOglInitComm]; }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]]; + [self printErrorMessage: [NSString stringWithFormat: @"Unknown OpenGL meta command %@\n",cmd]]; } } -(void) showListOfOglComm: (int) gid { @@ -1101,7 +1128,7 @@ int debugInbound = 0; // NSLog(@"%@",a); if ([[a objectAtIndex: 0] hasPrefix: @"notAvailable"]) { [self messageDialog: - NSLocalizedString(@"Typeset the output by TeX is not available. latex, dvips, and pstoimg must be installed.",nil) with: 0]; + NSLocalizedString(@"Typeset the output by TeX is not available. latex and dvipng must be installed.",nil) with: 0]; prettyPrint = 1; [self setPrettyPrint: nil]; return; } else if ([[a objectAtIndex: 0] compare: @"showFile"] == NSOrderedSame) { @@ -1188,6 +1215,15 @@ int debugInbound = 0; if (menuItemPrettyPrint) [menuItemPrettyPrint setState: NSOnState]; } } +-(void) setNoEngine: (id) sender { + if (NoEngine) { + NoEngine = 0; + if (menuItemNoEngine) [menuItemNoEngine setState: NSOffState]; + } else { + NoEngine = 1; + if (menuItemNoEngine) [menuItemNoEngine setState: NSOnState]; + } +} -(void) loadAsirContrib: (id) sender { NSString *com; @@ -1274,13 +1310,6 @@ int debugInbound = 0; [menuItemGotoNextError setTarget: [[NSApp mainWindow] document]]; [menuExec addItem: menuItemGotoNextError]; - // outputDebugMessage - menuItemOutputDebugMessages = [[[NSMenuItem alloc] init] autorelease]; [menuItemOutputDebugMessages retain]; - [menuItemOutputDebugMessages setTitle: NSLocalizedString(@"Output debug messages",nil)]; - [menuItemOutputDebugMessages setAction: @selector(setDebugMyTunnel:)]; - [menuItemOutputDebugMessages setTarget: [[NSApp mainWindow] document]]; - [menuExec addItem: menuItemOutputDebugMessages]; - // pretty print menuItemPrettyPrint = [[[NSMenuItem alloc] init] autorelease]; [menuItemPrettyPrint retain]; // it is the static variable. [menuItemPrettyPrint setTitle: NSLocalizedString(@"Typeset the output by TeX",nil)]; @@ -1335,6 +1364,19 @@ int debugInbound = 0; [menuExec addItem: menuItemSelectEngine]; [self updateSelectEngineMenu]; + // outputDebugMessage + menuItemOutputDebugMessages = [[[NSMenuItem alloc] init] autorelease]; [menuItemOutputDebugMessages retain]; + [menuItemOutputDebugMessages setTitle: NSLocalizedString(@"Output debug messages",nil)]; + [menuItemOutputDebugMessages setAction: @selector(setDebugMyTunnel:)]; + [menuItemOutputDebugMessages setTarget: [[NSApp mainWindow] document]]; + [menuExec addItem: menuItemOutputDebugMessages]; + + // NoEngine + menuItemNoEngine = [[[NSMenuItem alloc] init] autorelease]; [menuItemNoEngine retain]; // it is the static variable. + [menuItemNoEngine setTitle: NSLocalizedString(@"Do not start engine at startup",nil)]; + [menuItemNoEngine setAction: @selector(setNoEngine:)]; + [menuItemNoEngine setTarget: [[NSApp mainWindow] document]]; + [menuExec addItem: menuItemNoEngine]; // test menuItemForTest = [[[NSMenuItem alloc] init] autorelease];