Term-Gnuplot
view release on metacpan or search on metacpan
gnuterm/term/next.trm view on Meta::CPAN
NEXToff = NEXTBufAt - NEXTBuffer;
NEXTsize *= 2;
NEXTBuffer = realloc(NEXTBuffer, NEXTsize);
NEXTBufEnd = NEXTBuffer + NEXTsize;
NEXTBufAt = NEXTBuffer + NEXToff;
}
*NEXTBufAt = *pb;
}
return;
}
/* This next section implements the GnuTermDriver object which manages
the D.O. connection and interface to OBjC
*/
@protocol GnuTermServerMethods
/*- (oneway) executePScode:(in char *)PStext termTitle:(in char *)title;*/
- executePScode:(in char *)
PStext termTitle:(in char *) title;
@end
@implementation GnuTermDriver
- init
{
NXConnection *myConnection;
char serverpath[100], *envstring;
int GnuTermPathSet = 0;
/* Ask OS for connection to server */
server =[NXConnection connectToName:"gnuplotServer"];
/* Server is running ready to go */
if (server) /*printf("Connected to server\n") */
;
/* Server isn't running, we must fire it up */
else {
/*printf("Launching GnuTerm\n"); */
*serverpath = 0;
/* Check for path set in environment */
if ((envstring = getenv("GNUTERMPATH")) != (char *) NULL) {
sprintf(serverpath, "%s/GnuTerm.app/GnuTerm", envstring);
GnuTermPathSet = 1;
}
/* Not in environment */
else
strcpy(serverpath, "GnuTerm");
/* Try to launch application */
if ([[Application workspace] launchApplication:serverpath] == NO) {
printf("Failed to launch %s.\n", serverpath);
/* Offer a little advice */
if (GnuTermPathSet) {
printf("You must have setenv GNUTERMPATH to something wrong\n");
printf("I recommend you exit gnuplot and fix this.\n");
} else {
printf("It must be located in ~/Apps or /LocalApps\n");
printf("I recommend that you either\n");
printf("- move GnuTerm.app to one of these locations\n");
printf("- set GNUTERMPATH with host%% setenv GNUTERMPATH /directory/containing_GnuTerm.app\n");
printf("- start GnuTerm ahead of the first plot command\n");
#ifdef NEXT_OLDTERMINAL
printf("- use the old driver version (set term next old)\n");
#endif
}
}
/* I wish the gnuplot terminal interface would
let me return an error here.
*/
/* Application is launching */
else {
/* Wait for it to register Server methods with OS */
do {
server =[NXConnection connectToName:"gnuplotServer"];
} while (!server); /* This could result in a hang,
but I've never seen it fail */
}
}
/* By limiting ourselves to known protocol
* we speed up the messaging
*/
[server setProtocolForProxy:@protocol(GnuTermServerMethods)];
myConnection =[server connectionForProxy];
/* If the server dies we want to know about it */
[myConnection registerForInvalidationNotification:self];
/* In fact, we'll worry about it */
[NXPort worryAboutPortInvalidation];
return self;
}
-plot:(char *) PSstr;
{
/* If server has become invalid, re-initialize */
if (!server)
[self init];
/* This is where we send the huge postscript string to the server
Note:
The D.O. system doesn't actually give this pointer to the server.
The pointer is dereferenced on the client side and the
resulting data is sent to the server. On the server side,
space for the data is automatically allocated, and a pointer to
the local data is received.
For details check out:
/NextLibrary/Documentation/NextDev/GeneralRef/06_DistributedObjects/IntroDistObjects.rtf
*/
/*printf("Calling server..."); */
[server executePScode: PSstr termTitle:NEXT_title];
/*printf("returned\n"); */
*NEXT_title = 0;
return self;
( run in 0.948 second using v1.01-cache-2.11-cpan-2398b32b56e )