Annotation of OpenXM_contrib2/asir2000/parse/xdeb.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM: OpenXM/src/asir99/parse/xdeb.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */
! 2: #if defined(VISUAL)
! 3: #if defined(VISUAL_LIB)
! 4: #include <stdio.h>
! 5: #include <stdlib.h>
! 6: #include <windows.h>
! 7: #include <signal.h>
! 8: #include <process.h>
! 9:
! 10: #define FROMASIR_EXIT 0
! 11: #define FROMASIR_TEXT 1
! 12: #define FROMASIR_HEAPSIZE 2
! 13: #define FROMASIR_SHOW 3
! 14: #define FROMASIR_HIDE 4
! 15:
! 16: void show_debug_window(int);
! 17: int create_debug_gui();
! 18: void set_debug_handles(int);
! 19: void get_rootdir(char *,int);
! 20:
! 21: void show_debug_window(int on)
! 22: {
! 23: static int debug_gui_invoked = 0;
! 24:
! 25: /* debug_gui_invoked < 0 : failed to invoke debug GUI */
! 26: if ( debug_gui_invoked < 0 )
! 27: return;
! 28: if ( !debug_gui_invoked ) {
! 29: if ( !on )
! 30: return;
! 31: else if ( create_debug_gui() < 0 ) {
! 32: debug_gui_invoked = -1;
! 33: return;
! 34: }
! 35: debug_gui_invoked = 1;
! 36: }
! 37: set_debug_handles(on);
! 38: }
! 39:
! 40: #else /* VISUAL_LIB */
! 41: void show_debug_window(int on)
! 42: {}
! 43: #endif
! 44: #else /* VISUAL */
! 45: /*
! 46: * xdeb.c --- Asir Debug interface.
! 47: *
! 48: * akashi@sy.ssl.fujitsu.co.jp
! 49: */
! 50: #include <X11/Intrinsic.h>
! 51: #include <X11/StringDefs.h>
! 52: #include <X11/Shell.h>
! 53: #include <X11/Xaw/Dialog.h>
! 54: #include <stdio.h>
! 55:
! 56: static XrmOptionDescRec options[] = {
! 57: {"-reverse","*reverse",XrmoptionNoArg,"on"},
! 58: {"-fg","*foreground",XrmoptionSepArg,NULL},
! 59: {"-bg","*background",XrmoptionSepArg,NULL},
! 60: };
! 61:
! 62: static String fallback[] = {
! 63: "*Dialog*baseTranslations:#override <Key>Return: done()",
! 64: NULL
! 65: };
! 66:
! 67: static void Done();
! 68: static void SetSelected();
! 69:
! 70: static XtActionsRec actions_table[] = {
! 71: {"done",Done},
! 72: };
! 73:
! 74: char debug_cmd[BUFSIZ];
! 75:
! 76: static Widget toplevel, mainwin, cmdwin;
! 77: static XtAppContext app_con;
! 78: static int done;
! 79: static Display *display;
! 80:
! 81: void get_cmd();
! 82:
! 83: static void Done(w,e,p,n)
! 84: Widget w;
! 85: XEvent *e;
! 86: String *p;
! 87: Cardinal *n;
! 88: {
! 89: SetSelected(w,0,0);
! 90: }
! 91:
! 92: static void SetSelected(w,cld,cad)
! 93: Widget w;
! 94: XtPointer cld,cad;
! 95: {
! 96: Arg arg[5];
! 97: char *cmd;
! 98:
! 99: done = 1;
! 100: cmd = XawDialogGetValueString(cmdwin);
! 101: strcpy(debug_cmd,cmd);
! 102: XtSetArg(arg[0], XtNvalue, "");
! 103: XtSetValues(cmdwin, arg, 1);
! 104: }
! 105:
! 106: init_cmdwin()
! 107: {
! 108: Arg arg[5];
! 109: int argc=0;
! 110: char *argv[1];
! 111: int n;
! 112: char *d;
! 113: extern char displayname[];
! 114: extern int do_server_in_X11;
! 115:
! 116: if ( !displayname[0] ) {
! 117: d = (char *)getenv("DISPLAY");
! 118: if ( d )
! 119: strcpy(displayname,d);
! 120: else
! 121: do_server_in_X11 = 0;
! 122: }
! 123: if ( displayname[0] ) {
! 124: argv[0] = 0;
! 125: XtToolkitInitialize();
! 126: app_con = XtCreateApplicationContext();
! 127: XtAppAddActions(app_con,actions_table, XtNumber(actions_table));
! 128: XtAppSetFallbackResources(app_con,fallback);
! 129: display = XtOpenDisplay(app_con,displayname,"ox_asir_debug_window","ox_asir_debug_window",
! 130: options,XtNumber(options),&argc,argv);
! 131: toplevel = XtAppCreateShell(0,"ox_asir_debug_window",applicationShellWidgetClass,
! 132: display,0,0);
! 133: XtSetArg(arg[0],XtNiconName,"ox_asir_debug_window");
! 134: mainwin = XtCreatePopupShell("shell",topLevelShellWidgetClass,
! 135: toplevel,arg,1);
! 136: /*
! 137: * Command line
! 138: */
! 139: cmdwin = XtCreateManagedWidget("cmdwin", dialogWidgetClass,
! 140: mainwin, NULL, 0);
! 141: XawDialogAddButton(cmdwin,"OK",SetSelected,"OK");
! 142: n = 0;
! 143: XtSetArg(arg[n], XtNlabel, "Command : "); n++;
! 144: XtSetArg(arg[n], XtNvalue, ""); n++;
! 145: XtSetValues(cmdwin, arg, n);
! 146: XtRealizeWidget(mainwin);
! 147: }
! 148: }
! 149:
! 150: show_debug_window(on)
! 151: int on;
! 152: {
! 153: XEvent ev;
! 154:
! 155: if ( mainwin ) {
! 156: if ( on )
! 157: XtPopup(mainwin,XtGrabNone);
! 158: else
! 159: XtPopdown(mainwin);
! 160: XFlush(display);
! 161: while ( XtAppPending(app_con) ) {
! 162: XtAppNextEvent(app_con,&ev);
! 163: XtDispatchEvent(&ev);
! 164: }
! 165: }
! 166: }
! 167:
! 168: get_line(buf)
! 169: char *buf;
! 170: {
! 171: XEvent ev;
! 172:
! 173: done = 0;
! 174: while ( !done ) {
! 175: XtAppNextEvent(app_con,&ev);
! 176: XtDispatchEvent(&ev);
! 177: }
! 178: strcpy(buf,debug_cmd);
! 179: }
! 180: #endif /* VISUAL */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>