/* help menu */ "*xgapMenu.helpButton.label: Help", "*xgapMenu.helpButton*copyHelp.label: Copyright", "*xgapMenu.helpButton*helpHelp.label: Helpsystem", "*xgapMenu.helpButton*chpsHelp.label: Chapters", "*xgapMenu.helpButton*secsHelp.label: Sections", "*xgapMenu.helpButton*nchpHelp.label: Next Chapter", "*xgapMenu.helpButton*pchpHelp.label: Previous Chapter", "*xgapMenu.helpButton*nextHelp.label: Next Help Section", "*xgapMenu.helpButton*prevHelp.label: Previous Help Section",
/* gap graphic window */ "*xgapWindowViewport.width: 800", "*xgapWindowViewport.height: 600",
/**************************************************************************** ** *F UpdateMenus( <state> ) . . . . . . update menus in case of state change
*/ void UpdateMenus ( Int state)
{
TypeList l; Int i;
/* menu entry active only in break loop */
l = ListErrorOnly; for ( i = 0; i < l->len; i++ )
{ if ( state == GAP_ERROR )
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)True,
(String)NULL ); else
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)False,
(String)NULL );
}
/* menu entry active only during input */
l = ListInputOnly; for ( i = 0; i < l->len; i++ )
{ if ( state == GAP_ERROR || state == GAP_INPUT )
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)True,
(String)NULL ); else
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)False,
(String)NULL );
}
/* menu entry active only during normal input */
l = ListNormalOnly; for ( i = 0; i < l->len; i++ )
{ if ( state == GAP_INPUT )
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)True,
(String)NULL ); else
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)False,
(String)NULL );
}
/* menu entry active only while gap is running */
l = ListRunningOnly; for ( i = 0; i < l->len; i++ )
{ if ( state == GAP_RUNNING )
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)True,
(String)NULL ); else
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)False,
(String)NULL );
}
/* menu entry active only while gap is helping */
l = ListHelpOnly; for ( i = 0; i < l->len; i++ )
{ if ( state == GAP_HELP )
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)True,
(String)NULL ); else
XtVaSetValues( (Widget)l->ptr[i], XtNsensitive, (XtArgVal)False,
(String)NULL );
}
}
/* is this a resize event */ if ( evt->type == ConfigureNotify )
{
/* compute a sensible size */
XtVaGetValues( talk, XtNtextSink, (XtArgVal)&snk, (String)NULL );
XtVaGetValues( snk, XtNfont, (XtArgVal)&font, (String)NULL );
w = evt->xconfigure.width / font->max_bounds.width - 3;
h = evt->xconfigure.height / ( font->max_bounds.ascent
+ font->max_bounds.descent ) - 2; if ( w < 2 ) w = 2; if ( h < 2 ) h = 2; if ( w == w1 && h == h1 ) return;
w1 = w;
h1 = h;
/* construct gap command */
strcpy( buf, "SizeScreen([ " );
ptr = buf + strlen(buf); for ( i = 3; 0 <= i; i--, w = w / 10 )
ptr[i] = w%10 + '0';
ptr += 4;
*ptr++ = ',';
*ptr++ = ' '; for ( i = 3; 0 <= i; i--, h = h / 10 )
ptr[i] = h%10 + '0';
ptr += 4;
strcpy( ptr, " ]);;\n" );
/* if gap is waiting for input, do it */ if ( GapState == GAP_INPUT || GapState == GAP_ERROR )
SimulateInput( buf ); else
strcpy( ScreenSizeBuffer, buf );
}
}
/**************************************************************************** ** *F CreateGapWindow() . . . . . . . . . . . . . . create communication window ** ** RESOURCES ** *xgapMenu*shapeStyle ** style of the menu buttons, default "Oval" ** *xgap.height ** *xgap.width ** start size of the communication text window
*/ staticvoid CreateGapWindow ( void )
{
Widget paned;
Widget box;
Widget button;
Pixmap symbol;
Display * display;
Boolean flag; Int i;
/* create a "paned" for the menu and text window */
paned = XtVaCreateManagedWidget( "paned", panedWidgetClass,
XGap, (String)NULL );
/* create a menu box for the menu buttons */
box = XtVaCreateManagedWidget( "xgapMenu", boxWidgetClass,
paned,
XtNx, (XtArgVal)0,
XtNy, (XtArgVal)0,
XtNresizeToPreferred, (XtArgVal)True,
(String)NULL );
/* create a menu button drop down symbol */
display = XtDisplay(box);
symbol = XCreateBitmapFromData( display,
DefaultRootWindow(display), "\376\3\2\2\2\6\162\6\2\6\162\6\2\6\162\6\2\6\2\6\376\7\370\7",
12, 12 );
/* create file menu button and file menu */
button = XtVaCreateManagedWidget( "gapButton", menuButtonWidgetClass,
box,
XtNleftBitmap, (XtArgVal)symbol,
XtNx, (XtArgVal)0,
(String)NULL );
CreateMenu( button, GapMenu );
/* create run menu button and run menu */
button = XtVaCreateManagedWidget( "runButton", menuButtonWidgetClass,
box,
XtNleftBitmap, (XtArgVal)symbol,
XtNx, (XtArgVal)10,
(String)NULL );
CreateMenu( button, RunMenu );
/* create help menu button and help menu */
button = XtVaCreateManagedWidget( "helpButton", menuButtonWidgetClass,
box,
XtNleftBitmap, (XtArgVal)symbol,
XtNx, (XtArgVal)10,
(String)NULL );
CreateMenu( button, HelpMenu );
/* to quit or not do quit on CTR-D */
XtVaGetValues( GapTalk, XtNquitGapCtrD, (XtArgVal)&flag, (String)NULL ); if ( flag )
{ for ( i = 0; GapMenu[i].label; i++ ) if ( !strcmp( GapMenu[i].label, "quitGapCTRD" ) ) break; if ( GapMenu[i].label && GapMenu[i].click )
GapMenu[i].click(&(GapMenu[i]));
}
/* paste GAP prompt into talk window? */
XtVaGetValues( GapTalk, XtNpasteGapPrompt, &flag, NULL ); if ( flag )
{ for ( i = 0; GapMenu[i].label; i++ ) if ( !strcmp( GapMenu[i].label, "pastePrompt" ) ) break; if ( GapMenu[i].label && GapMenu[i].click )
GapMenu[i].click(&(GapMenu[i]));
}
staticvoid MySignalHandlerHUP (int signo)
{
fputs( "killing gap because of signal HUP\n", stderr );
KillGap();
OldSignalHandlerHUP(signo); exit(1);
} staticvoid MySignalHandlerINT (int signo)
{
fputs( "killing gap because of signal INT\n", stderr );
KillGap();
OldSignalHandlerINT(signo); exit(1);
} staticvoid MySignalHandlerQUIT (int signo)
{
fputs( "killing gap because of signal QUIT\n", stderr );
KillGap();
OldSignalHandlerQUIT(signo); exit(1);
} staticvoid MySignalHandlerILL (int signo)
{
fputs( "killing gap because of signal ILL\n", stderr );
KillGap();
OldSignalHandlerILL(signo); exit(1);
} staticvoid MySignalHandlerIOT (int signo)
{
fputs( "killing gap because of signal IOT\n", stderr );
KillGap();
OldSignalHandlerIOT(signo); exit(1);
} staticvoid MySignalHandlerBUS (int signo)
{
fputs( "killing gap because of signal BUS\n", stderr );
KillGap();
OldSignalHandlerBUS(signo); exit(1);
}
staticvoid MySignalHandlerSEGV (int signo)
{
fputs( "killing gap because of signal SEGV\n", stderr );
KillGap();
OldSignalHandlerSEGV(signo); exit(1);
}
/* print a usage message */
usage:
fputs("usage: xgap [OPTIONS] -- [GAP OPTIONS]\n",stderr);
fputs(" run the X-Windows front-end for GAP,\n",stderr);
fputs(" use '-h' option to get help.\n",stderr);
fputs("\n",stderr); exit(1);
fullusage:
fputs("usage: xgap [OPTIONS] -- [GAP OPTIONS]\n",stderr);
fputs(" run the X-Windows front-end for GAP,\n",stderr);
fputs("\n",stderr);
fputs(" -h print this help message\n",stderr);
fputs(" -D set debug level\n",stderr);
fputs(" -W try to workaround broken wm\n",stderr);
fputs(" -E toggle spy mode\n",stderr);
fputs(" -G filename of the GAP executable\n",stderr); exit(1);
}
/* WM_DELETE_WINDOW atom */
WmDeleteWindowAtom = XInternAtom(GapDisplay, "WM_DELETE_WINDOW", False);
/* install our error handler, we have to kill gap in this case */
OldIOErrorHandler = XSetIOErrorHandler( MyIOErrorHandler );
OldErrorHandler = XSetErrorHandler ( MyErrorHandler );
/***************WIN32 CYGWIN fix***************/ /* SIGIOT not defined in CYGWIN signal.h unless !defined(SIGTRAP)
there may be a way to get ...? */ #ifdef __CYGWIN__ # define SIGIOT 6 /* IOT instruction */ # define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ #endif /***************WIN32 CYGWIN fix***************/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.