This minor patch is 1b; the next minor patches will be 1c, 1d... and so on, until enough patches have accumulated to warrant grouping them into a major patch, which will then be available on athena-dist.mit.edu and be "patch1". If you are using Larry Wall's "patch" program, this patch should be applied by cd'ing into the directory above the "src" directory from the distribution, and typing patch -p < patch1b The changes included are: * libMu: Included the sources to libMu (local motif utilities) in the distribution * Imakefile: Added libMu directory * config/site.def: Added HaveSysLibMu flag, and arranged libraries. * server/writed/write.c: (new) network write client. * server/writed/Imakefile: Added write client diff -r -c src.p1/Imakefile src/Imakefile *** src.p1/Imakefile Wed May 15 15:54:09 1991 --- src/Imakefile Wed May 15 12:51:51 1991 *************** *** 16,22 **** WCLDIR=wcl #endif ! SUBDIRS= common logger clients server browser man lib $(WCLDIR) RM=rm -f MV=mv -f --- 16,28 ---- WCLDIR=wcl #endif ! #if HaveSysLibMu ! LIBMUDIR= ! #else ! LIBMUDIR=libMu ! #endif ! ! SUBDIRS= common logger clients server browser man lib $(WCLDIR) $(LIBMUDIR) RM=rm -f MV=mv -f diff -r -c src.p1/config/site.def src/config/site.def *** src.p1/config/site.def Wed May 15 15:52:57 1991 --- src/config/site.def Wed May 15 13:39:59 1991 *************** *** 34,39 **** --- 34,42 ---- #ifndef HaveSysWCL #define HaveSysWCL 1 #endif + #ifndef HaveSysLibMu + #define HaveSysLibMu 1 + #endif #ifndef DoLogging #define DoLogging 1 /* Log requests to daemons */ #endif *************** *** 146,155 **** /* Define these to use $(LIBSUFFIX) or not, absolute pathnames or not, depending on what you have installed. */ ! CursesLib = -lcurses$(LIBSUFFIX) -ltermcap$(LIBSUFFIX) ! ComErrLib = -L/usr/athena/lib -lcom_err$(LIBSUFFIX) MotifWCLLib = -L/mit/motif/$(MACHINE)lib -lWcm MotifUtilLib = -L/mit/motif/$(MACHINE)lib -lMu MotifResLib = -L/mit/motif/$(MACHINE)lib -lMrm MotifLib = -L/mit/motif/$(MACHINE)lib -lXm MotifToolLib = -L/mit/motif/$(MACHINE)lib -lXtm --- 149,168 ---- /* Define these to use $(LIBSUFFIX) or not, absolute pathnames or not, depending on what you have installed. */ ! #if HaveSysWCL MotifWCLLib = -L/mit/motif/$(MACHINE)lib -lWcm + #else + MotifWCLLib = $(TOP)/wcl/libWcm$(LIBSUFFIX).a + #endif + + #if HaveSysLibMu MotifUtilLib = -L/mit/motif/$(MACHINE)lib -lMu + #else + MotifUtilLib = $(TOP)/libMu/libMu$(LIBSUFFIX).a + #endif + + CursesLib = -lcurses$(LIBSUFFIX) -ltermcap$(LIBSUFFIX) + ComErrLib = -L/usr/athena/lib -lcom_err$(LIBSUFFIX) MotifResLib = -L/mit/motif/$(MACHINE)lib -lMrm MotifLib = -L/mit/motif/$(MACHINE)lib -lXm MotifToolLib = -L/mit/motif/$(MACHINE)lib -lXtm diff -r -c src.p1/libMu/DOC src/libMu/DOC *** src.p1/libMu/DOC Wed May 15 15:54:11 1991 --- src/libMu/DOC Fri May 10 08:37:42 1991 *************** *** 0 **** --- 1,555 ---- + 89/10/13 + + Here's a brief description of the functions available in + MotifUtilities. (MotifUtilities is a library of useful motif-related + functions which may be called either from uil or C or both.) + + To link against MotifUtilities library, please add "-lMu" to your list + of libraries in your makefile and please include the file Mu.h in your + C files + + Note: If you try to load libMu.a or any object file compiled by gcc + with -g into saber, it won't work. To fix this use "load -G" + in saber. This tells saber to ignore debugging information, + which is what messes it up with gcc-compiled stuff. + + + ************************************************************************** + ************************************************************************** + + void MuInitialize(toplevel) + + Everyone using MotifUtilities must call MuInitialize(toplevel) + after you XtInitialize your toplevel and before you call "MrmOpenHierarchy." + + You pass your toplevel widget as an argument. + + e.g. + Widget toplevel; + + toplevel = XtInitialize( + "test", + "testclass", + NULL, 0, + &argc, argv); + + MuInitialize(toplevel); + + ************************************************************************ + + void MuRegisterNames() + + If you are using any of the MotifUtilities functions which can be + called from uil, you must call this function. It will automatically + register all MotifUtilities Callback functions in uil so that you + won't have to add them on to your MRMRegisterArg. + + Note: MuRegisterNames() should go before the "MrmFetchWidget" and + after "MrmOpenHierarchy". + + e.g. + if (MrmOpenHierarchy (1, + vec, + NULL, + &s_MrmHierarchy) != MrmSUCCESS) { + printf ("cant' open hierarchy. . . \n"); + } + + MuRegisterNames(); + + The functions which can be called directly from uil are: + + void + MuSetEmacsBindings(), + MuSetSingleLineEmacsBindings(), + MuSetStandardCursor(), + MuSetCursor(integer), + MuSetWaitCursor(), + MuHelp(), + MuRegisterWidget(), + and + MuSetSensitive() . + ************************************************************************* + + void MuSetEmacsBindings(text_widget) and + void MuSetSingleLineEmacsBindings(text_widget) + + These functions add emacs bindings to your text widgets' translation + table so that you can back space, d, d, etc. + From your C file you pass the text_widget you want the emacs bindings + for. MuSetEmacsBindings takes multi-line text widgets, and + MuSetSingleLineEmacsBindings take single-line text widgets. You will + get an error message if the widget you pass is NULL or not a text + widget. + + ---------------------------------------------------------------------- + void MuSetEmacsBindings() and + void MuSetSingleLineEmacsBindings() + + These functions are to be used in the uil file with the create + callbacks of your text widgets. + + e.g. + + object textbox : XmScrolledText { + arguments { + XmNeditable = true; + XmNedit_mode = XmMULTI_LINE_EDIT; + XmNword_wrap = true; + }; + callbacks { + XmNcreateCallback = procedure MuSetEmacsBindings(); + }; + }; + + ************************************************************************* + + void MuSetStandardCursor(widget), + void MuSetWaitCursor(widget), + + void MuSetCursor(widget, cursorshape) + Widget widget; + unsigned int cursorshape; + + These functions set the cursor shape in your interface window. + (Standard cursor is an arrow, and the Wait cursor is a watch.) You + can pass any widget to these functions, and they will set the cursor + shape in the shell ancestor (parent, grandparent, + great-grandparent...) of the widget passed. MuSetCursor sets any + cursor shape (from cursor font) passed. + + (If you do "xfd cursor", you'll get a window with all the cursor + shapes available in font cursor. Click on a cursor shape with your + middle button, and you'll get the number description of the cursor + shape.) + ---------------------------------------------------------------------- + void MuSetStandardCursor(), + void MuSetWaitCursor(), + void MuSetCursor(tag) + + Note: Djf recommends calling these functions from uil because he + feels that the cursor is really part of the interface and as such + belongs in the uil file rather than the C file. + + ** These functions are to be used in the uil file with the activate + callbacks. MuSetCursor takes an integer tag which is the + number description of the cursor shape from the cursor font. + + e.g. + + object button : XmPushButton { + arguments { + XmNlabelString = compound_string('Button'); + }; + callbacks { + XmNactivateCallback = procedures { MuSetWaitCursor(); + Do_some_procedure(); + MuSetStandardCursor(); + }; + }; + }; + *************************************************************************** + + void MuError(string) + char *string; + + void MuWarning(string) + char *string; + + /* MuHelp(string) can also be called from uil. */ + + void MuHelp(string) + char *string; + + + These functions put up an error dialog box and a warning dialog box + when passed a string (can include " \n " in the string to get a new + line). (The dialog boxes will have a standard cursor.) + + Note: MuError and MuWarning pop up modal dialog boxes while MuHelp + pops up a modeless dialog box (see below for more info). + + ---------------------------------------------------------------------- + + You can call MuHelp("help string") from uil as well as from C files. + + void MuHelp(string) + char *string; + + MuHelp puts up a help message box with your choice of help string. + These are "modeless" dialog boxes, and you can have as many as 25 + different help dialog boxes managed at once. (If you try to manage + more than 25 at once, you will get an error message.) + + Don't forget to call MuRegisterNames() before MrmFetchWidget(...) if + you call MotifUtilities functions from uil. + + ************************************************************************* + + void MuErrorSync(string) + char *string + + void MuWarningSync(string) + char *string + + void MuHelpSync(string) + char *string + + MuWarningSync and MuErrorSync are synchronous versions of the + MuWarning and MuError functions. + + MuHelpSync is similar to MuWarningSync and MuErrorSync, but not + similar to MuHelp at all. MuHelpSync does not provide multiple + help dialogs the way MuHelp does, it provides only one, synchronous + dialog box the way that MuErrorSync and MuWarningSync do. + + They popup up and wait for the user to click on "OK" before continuing + with the next line of code (which may well be "exit()"). This is + accomplished by invoking a recursive copy of XtMainLoop inside of the + utility routine and using longjmp() from the Ok callback to abort from + the recursive copy. + + They are great for dealing with fatal errors and the like -- in the + event of a fatal error where the user cannot continue the program, you + can warn the person before taking down the program using MuErrorSync + or MuWarningSync (the function will wait for the OK button, then exit + or do whatever you want it to do). + + ************************************************************************* + + void MuSetTextTraversal(widgets, number, subtree) + WidgetList widgets; + int number; + Widget subtree; + + widgets: array of text widgets + + number: number of text widgets in the array + + subtree: subtree of the hierarchy for which the keyboard focus is to + be set. (e.g. It'll probably be "toplevel".) + + This function enables traversal among a group of text widgets using + the up arrow, down arrow, and the return key. This is useful for text + widgets used for field input. + + The function checks to see if the text widgets passed are + single-line or multi-line text widgets. The Return key binding is not + changed for multi-line text widgets (this is for those of you who + have a scrolled, multi-line text widget, and you want the up and down + arrow keys to be "traversal keys", while the Return key still behaves + like a normal return key). + + The function also checks for sensitivity. Therefore, if a text + field is not "sensitive", it will be skipped during traversal. + + ** You can have more than one set of text widgets for traversal. + i.e. If you call MuSetTextTraversal(widgets1, 3, toplevel) and + MuSetTextTraversal(widgets2, 4, toplevel), traversal among + the text widgets in widgets1 will be set independent of the + text widgets in widgets2. + *************************************************************************** + + About MuGetBoolean, MuGetFileName, and MuGetString ... + + * This is a general description of MuGetBoolean, MuGetFileName, and + * MuGetString. These popup a modal dialog box for communication with + * the user. They provide a synchronous interface to the programmer. + * That is, like gets() or scanf() they return the desired value + * directly to the programmer, without any intervening callbacks. + * This is accomplished by invoking a recursive copy of XtMainLoop + * inside of the each utility routine, and using longjmp() from within + * the ok and cancel callbacks to abort from that recursive copy. + * This is witchcraft, but provides powerful interface tools to the + * programmer. + * For additional convenience, these functions never take compound + * strings as arguments. All strings are passed as char *. + + ------------------------------------------------------------------------ + + Boolean MuGetBoolean(prompt, yeslabel, nolabel, helptext, + defaultbutton, poup_control) + char *prompt, *yeslabel, *nolabel; + char *helptext; + Boolean defaultbutton; + int poup_control; + + * Uses an XmMessageDialog widget to prompt the user for an answer to + * a yes-or-no type question. + * Inputs: + * prompt The question to present the user. + * yeslabel The text to appear on the "True" button. + * nolabel The text to appear on the "False" button. + * helptext The text to appear when the "Help" button is clicked. + * If NULL is specified, the help button will not appear. + * defaultbutton A Boolean indicating which button should be the default + * -- the "Ok" or the "Cancel" button + * poup_control An integer which specifies the position to + * popup the dialog box (see "popup control + * argument for MuGetBoolean, MuGetString, and + * MuGetFileName" below) + * + * Returns: + * a Boolean indicating which button was pressed. + * + + ----------------------------------------------------------------------- + + Boolean MuGetString(prompt, buffer, bufsize, helptext, popup_control) + char *prompt; + char *buffer; + int bufsize; + char *helptext; + int popup_control; + + * MuGetString + * Uses a PromptDialog convenience widget to prompt the user to input + * a string. The string is returned in a passed buffer, and the + * function returns a Boolean indicating whether the "Ok" or the + * "Cancel" button was pressed. + * Inputs: + * prompt The string to prompt the user with. + * buffer A pointer to a buffer to return the string in. + * The contents of the buffer will be displayed as + * the default string. + * bufsize The size in bytes of the buffer. + * This will determine the maximum length of the + * text string, which will be bufsize - 1. + * helptext The text to display if the help button is + * clicked. If NULL, no Help button will be + * displayed. + * popup_control An integer which specifies the position to + * popup the dialog box (see "popup control + * argument for MuGetBoolean, MuGetString, and + * MuGetFileName" below) + * + * Outputs: + * buffer Contains the NULL-terminated string the user + * selected. + * Returns: + * a Boolean indicating whether the user clicked the "Ok" + * button (True) or the "Cancel" button (False). If False is + * returned, then the contents of buffer should be ignored. + */ + + ------------------------------------------------------------------------ + + Boolean MuGetFileName(buffer, bufsize, dirmask, + dirmasksize, helptext, popup_control) + char *buffer; + int bufsize, dirmasksize; + char *dirmask; + char *helptext; + int popup_control; + + * Uses a FileSelectionDialog widget to prompt the user to select a file. + * The string is returned in a passed buffer, and the + * function returns a Boolean indicating whether the "Ok" or the + * "Cancel" button was pressed. + * Inputs: + * buffer A pointer to a buffer to return the file name in. + * (e.g. in your c file, + * declare buffer to be something like .. + * char buffer[50]; ) + * + * bufsize The size in bytes of the buffer. + * This will determine the maximum length of the + * text string -- the maximum will be bufsize - 1. + * + * dirmask A pointer to a buffer to return the value of the + * directory mask. The contents of dirmask will + * be used as the default. + * + * dirmasksize The size in bytes of the dirmask. + * This will determine the maximum length of the + * text string for the dirmask. + * helptext The text to display if the help button is + * clicked. If NULL, no Help button will be + * displayed. + * popup_control An integer which specifies the position to + * popup the dialog box (see "popup control + * argument for MuGetBoolean, MuGetString, and + * MuGetFileName" below) + * Outputs: + * buffer Contains the NULL-terminated file name the user + * selected. + * dirmask Contains the NULL-terminated directory mask used. + * Returns: + * a Boolean indicating whether the user clicked the "Ok" + * button (True) or the "Cancel" button (False). If False is + * returned, then the contents of buffer should be ignored. + */ + + Note: The default value of dirmask in the FileSelectionDialog + resources is " * ". FileSelectionDialog believes that this indicates + the current directory you are in. (i.e. If you're in /mit/motifdev, + it will display all the files in /mit/motifdev .) Changing the + dirmask to be "*.c" or something like that will NOT do what you expect + it to do, which is to display all the c files in the current directory. + However, changing the dirmask to be "/mit/motifdev/projects" will make it + display all the files in /mit/motifdev/projects . + + ------------------------------------------------------------------------ + ** popup control argument for MuGetBoolean, MuGetString, and + ** MuGetFileName + + The options for the popup control are: + + Mu_Popup_Left -- popup to the left of parent, + Mu_Popup_Right -- popup to the right of parent, + Mu_Popup_Bottom -- popup at the bottom of the parent, + Mu_Popup_Top -- popup at the top of the parent, + Mu_Popup_Center -- popup at the center of the parent + (same as passing NULL), + Mu_Popup_Pointer -- popup directly underneath the pointer, + Mu_Popup_Previous -- popup at the same coordinates as the + last "management" of the dialog box + (therefore, if a user moves the dialog box + to a location on the screen different + from where it had popped up, that would be + the coordinates of the last "management" + of the dialog box), + + NULL -- if you want the default behavior, which is popping up in + the center of the parent (same as Mu_Popup_Center). + + Note: If there is not enough room on the screen for a dialog box to + popup on top, bottom, left or right of the parent, then the dialog box + will overlap the parent interface. Also, if you specify + Mu_Popup_Previous and the dialog box had never been managed before + (i.e first time it's being called), it will popup in the upper left + corner of the screen. + + Bug: If you are using mwm, you may notice that the popup dialog box + sometimes will not popup in the correct position. You may see + this problem if you resize your application window after the + dialog box had already been managed once. This behavior may go + away after a couple of popups. Since this problem doesn't occur + in uwm, it's probably an mwm quirk. This bug will be corrected + once we figure out what's going on. + + ***************************************************************************** + + void MuRegisterWidget(string) /* called from uil + and + Widget MuGetWidget(string) /* called from C + + char *string; + + These two functions were written so that you can get a widget id + without using XtNameToWidget() and without having to write a procedure + in your C file to take care of the create callbacks from uil. + + You call MuRegisterWidget from uil, passing it a string (any name you + want to call it) which identifies the widget you want to know the + widget id of in C. + + e.g. + object textbox1 : XmText { + arguments { + XmNtopAttachment = XmATTACH_FORM; + XmNrightAttachment = XmATTACH_FORM; + XmNleftAttachment = XmATTACH_FORM; + }; + callbacks { + XmNcreateCallback = procedure MuRegisterWidget("box1"); + }; + }; + + Then, in C you can get the widget id of the widget by calling + MuGetWidget, passing it the same string. + + e.g. + + Widget w; + + w = MuGetWidget("box1"); + + **************************************************************************** + + void MuSetSensitive(string) /* to be used from UIL only */ + char *string; + + MuSetSensitive is to be used from UIL only. It sets a widget to be + sensitive (the widget should receive keyboard and pointer events) if + it's not currently sensitive, or it sets it to be insensitive + if it's currently sensitive. This is useful if you want to make + some button insensitive or sensitive when a certain process is + called. You pass it a string description of the widget that you had + registered with MuRegisterWidget. + + e.g. + + object button : XmPushButton { + arguments { + XmNlabelString = compound_string('Does something'); + }; + callbacks { + XmNcreateCallback = procedure MuRegisterWidget("p_button"); + XmNactivateCallback = procedures { + MuSetSensitive("p_button"); + Do_something(); + }; + }; + }; + + In this example after the push button is activated, the button will + become insensitive, and the application will "Do_something()". + + ***************************************************************************** + + void MuSetAppPath(path) + char *path; + /* + * Takes a path and sets the application defaults directory variable + * XAPPLRESDIR to that path. Assumes that the path passed in is + * terminated by a /. + */ + + This should be called before XtInitialize(). + + e.g.: + MuSetAppPath("/some/path/name/"); + toplevel = XtInitialize("toplevel", "Appname", NULL, 0, &argc, argv); + + ***************************************************************************** + + void MuSetUidPath(path) + char *path; + /* + * Takes a path and adds path/%N.uid to UIDPATH if it already exists, + * or creates a new UIDPATH with that in it if it doesn't. Assumes + * that the path passed in is terminated by a /. + */ + + This should be called before MrmOpenHierarchy(). The name-list passed + to MrmOpenHierarchy should NOT contain the ".uid" extension. + + e.g.: + MuSetPath("/some/path/name/"); + MrmOpenHierarchy((MrmCount) 1, "myapplication", NULL, &Hierarchy); + + ***************************************************************************** + + int MuSetIconPixmap(w, path, file) + Widget w; + char *path; + char *file; + /* + * Takes a widget (the top-level widget of the application), a path + * and a bitmap filename and installs the file as the icon pixmap for + * the program. Assumes that the path passed in is terminated by a /. + * Returns MrmSUCCESS if it succeeds, MrmFAILURE otherwise. + */ + + ***************************************************************************** + + void MuHelpFile(filename) + char *filename; + /* + * This function takes a filename as its argument, stats the file to find + * it's length, malloc's enough space to hold the text, reads it in, + * then calls MuHelp with that string. + */ + + ************************ END ** END ** END ** END *********************** diff -r -c src.p1/libMu/Imakefile src/libMu/Imakefile *** src.p1/libMu/Imakefile Wed May 15 15:54:11 1991 --- src/libMu/Imakefile Wed May 15 15:28:38 1991 *************** *** 0 **** --- 1,67 ---- + # Imakefile for `libMu'. + # + # $Id: $ + # $Source: $ + # + # For copying and distribution information, + # please see the file . + # + # + + /* #define Profiling */ + + /* Change to whatever's appropriate for your site */ + UIL = /mit/motif/$(MACHINE)bin/uil + + LIB_SRCS = MuGetBoolean.c MuGetFileName.c MuGetString.c MuHelp.c \ + MuHelpFile.c MuInitialize.c MuModalDialogs.c MuRegisterNames.c \ + MuRegisterWidget.c MuSetCursor.c MuSetEmacsBindings.c \ + MuSetTextTraversal.c MuSyncDialogs.c _MuCallbacks.c + + LIB_OBJS = MuGetBoolean.o MuGetFileName.o MuGetString.o MuHelp.o \ + MuHelpFile.o MuInitialize.o MuModalDialogs.o MuRegisterNames.o \ + MuRegisterWidget.o MuSetCursor.o MuSetEmacsBindings.o \ + MuSetTextTraversal.o MuSyncDialogs.o _MuCallbacks.o + + TEST_SRCS = TestMu.c + TEST_OBJS = TestMu.o + TEST_DEPS = TestMu.uid + + DOCSRC = man/man3/libMu.3X man/man1/mockup.1 man/man3/MuError.3X \ + man/man3/MuErrorSync.3X man/man3/MuGetBoolean.3X \ + man/man3/MuGetFilename.3X man/man3/MuGetString.3X \ + man/man3/MuHelpFile.3X man/man3/MuInitialize.3X \ + man/man3/MuRegisterNames.3X man/man3/MuRegisterWidget.3X \ + man/man3/MuSetEmacsBindings.3X man/man3/MuSetTextTraversal.3X \ + man/man3/MuSetWaitCursor.3X + + INCLUDES = -I/mit/motif/include + + SYS_LIBS = $(MotifUtilLib) $(MotifResLib) $(MotifLib) $(MotifToolLib) $(XLib) + + + + LibraryTarget(Mu,$(LIB_OBJS)) + SaberLibraryTarget(Mu,$(LIB_SRCS),$(LIB_OBJS)) + #ifdef Profiling + ProfiledLibraryObjectRule() + ProfiledLibraryTarget(Mu,$(OBJS)) + #endif + + + + NormalProgramTarget(TestMu,$(TEST_OBJS),$(TEST_DEPS),,$(SYS_LIBS)) + SaberProgramTarget(TestMu,$(TEST_SRCS),$(TEST_OBJS),,$(SYS_LIBS)) + TestMu.uid: TestMu.uil + $(UIL) $(INCLUDES)/uil -o TestMu.uid TestMu.uil + + + document: MotifUtilities.PS + MotifUtilities.PS: $(DOCSRC) + psroff -man -t $(DOCSRC) > MotifUtilities.PS + + lint:: + + DependSrcs() + + AllTarget(libMu.a TestMu document) diff -r -c src.p1/libMu/Mu.h src/libMu/Mu.h *** src.p1/libMu/Mu.h Wed May 15 15:54:17 1991 --- src/libMu/Mu.h Mon Oct 15 17:10:43 1990 *************** *** 0 **** --- 1,81 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * $Source: /afs/athena.mit.edu/user/v/vanharen/motifdev/projects/util/src/RCS/Mu.h,v $ + * $Author: vanharen $ + * $Log: Mu.h,v $ + * Revision 1.2 89/12/19 14:55:20 vanharen + * added macros for MuInfo modal dialog and MuInfoSync nonmodal + * dialog box. + * + * Revision 1.1 89/12/09 15:15:00 djf + * Initial revision + * + */ + + #ifndef Mu_h + #define Mu_h + + #include + + #ifdef __STDC__ + + void MuInitialize(Widget); + void MuSetEmacsBindings(Widget); + void MuSetStandardCursor(Widget); + void MuSetWaitCursor(Widget); + void MuHelp(char *); + Boolean MuShellGetBoolean(Widget, char *, char *, char *, char *, int); + Boolean MuGetBoolean(char *, char *, char *, char *, int); + Boolean MuGetString(char *, char *, int, char *); + Boolean MuGetFileName(char *, int, char *, int, char *); + void MuRegisterNames(); + void MuRegisterWidget(Widget, char *); + Widget MuLookupWidget(char *); + void MuHelpFile(char *); + void MuModalDialog(char *, int); + void MuSyncDialog(char *, int); + + #else + + void MuInitialize(); + void MuSetEmacsBindings(); + void MuSetStandardCursor(); + void MuSetWaitCursor(); + void MuHelp(); + Boolean MuShellGetBoolean(); + Boolean MuGetBoolean(); + Boolean MuGetString(); + Boolean MuGetFileName(); + void MuRegisterNames(); + void MuRegisterWidget(); + Widget MuLookupWidget(); + void MuHelpFile(); + void MuModalDialog(); + void MuSyncDialog(); + + #endif + + #define MuError(msg) MuModalDialog(msg,XmDIALOG_ERROR) + #define MuWarning(msg) MuModalDialog(msg,XmDIALOG_WARNING) + #define MuInfo(msg) MuModalDialog(msg,XmDIALOG_INFORMATION) + #define MuErrorSync(msg) MuSyncDialog(msg,XmDIALOG_ERROR) + #define MuWarningSync(msg) MuSyncDialog(msg,XmDIALOG_WARNING) + #define MuInfoSync(msg) MuSyncDialog(msg,XmDIALOG_INFORMATION) + + /* Don't use these macros. For backwards compatibility only. */ + #define MuSetSingleLineEmacsBindings(w) MuSetEmacsBindings(w) + #define MuGetWidget(w) MuLookupWidget(w) + + #endif diff -r -c src.p1/libMu/MuGetBoolean.c src/libMu/MuGetBoolean.c *** src.p1/libMu/MuGetBoolean.c Wed May 15 15:54:18 1991 --- src/libMu/MuGetBoolean.c Mon Oct 15 17:10:44 1990 *************** *** 0 **** --- 1,151 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuGetBoolean.c,v $ + * $Author: djf $ + * $Log: MuGetBoolean.c,v $ + * Revision 1.1 89/12/09 15:13:16 djf + * Initial revision + * + * + * SyncDialogs.c + * This file contains the functions MuGetBoolean, MuGetString, and + * MuGetFileName. These popup a modal dialog box for communication with + * the user. They provide a synchronous interface to the programmer. + * That is, like gets() or scanf() they return the desired value + * directly to the programmer, without any intervening callbacks. + * This is accomplished by invoking a recursive copy of XtMainLoop + * inside of the each utility routine, and using longjmp() from within + * the ok and cancel callbacks to abort from that recursive copy. + * This is witchcraft, but provides powerful interface tools to the + * programmer. + * For additional convenience, these functions never take compound + * strings as arguments. All strings are passed as char *. + * + */ + + #include "MuP.h" + #include + #include + + /* + * MuGetBoolean + * + * Uses an XmMessageDialog widget to prompt the user for an answer to + * a yes-or-no type question. + * Inputs: + * prompt The question to present the user. + * yeslabel The text to appear on the "True" button. + * nolabel The text to appear on the "False" button. + * helptext The text to appear when the "Help" button is clicked. + * If NULL is specified, the help button will not appear. + * defaultbutton A Boolean indicating which button should be the default + * Returns: + * a Boolean indicating which button was pressed. + */ + + Boolean MuGetBoolean(p, y, n, h, d) + char *p, *y, *n, *h; + int d; + { + return(MuShellGetBoolean(_MuToplevel, p, y, n, h, d)); + } + + + Boolean MuShellGetBoolean(shell, prompt, yeslabel, nolabel, + helptext, defaultbutton) + Widget shell; + char *prompt, *yeslabel, *nolabel; + char *helptext; + int defaultbutton; + { + Arg args[5]; + int n; + jmp_buf mark; + int status; + Widget W; + Widget HelpButton; + + static Widget BooleanDialog = NULL; + + if (shell != _MuToplevel || BooleanDialog == NULL) + /* if widget doesn't exist yet */ + { + n = 0; + /* XtSetArg(args[n], XmNdialogType, XmDIALOG_QUESTION); n++; */ + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++; + XtSetArg(args[n], XmNborderWidth, 2); n++; + XtSetArg(args[n], XmNautoUnmanage,False); n++; + W = XmCreateQuestionDialog(shell, "_MuBooleanDialog",args,n); + XtRealizeWidget(W); + MuSetStandardCursor(W); + } + + if (shell == _MuToplevel) + { + if (BooleanDialog == NULL) + BooleanDialog = W; + else + W = BooleanDialog; + } + + HelpButton = XmMessageBoxGetChild(W, XmDIALOG_HELP_BUTTON); + + n = 0; + XtSetArg(args[n],XmNmessageString, + XmStringLtoRCreate(prompt, XmSTRING_DEFAULT_CHARSET) ); n++; + XtSetArg(args[n],XmNokLabelString, + XmStringLtoRCreate(yeslabel, XmSTRING_DEFAULT_CHARSET)); n++; + XtSetArg(args[n],XmNcancelLabelString, + XmStringLtoRCreate(nolabel, XmSTRING_DEFAULT_CHARSET)); n++; + if (defaultbutton == True) + XtSetArg(args[n],XmNdefaultButtonType, XmDIALOG_OK_BUTTON); + else + XtSetArg(args[n],XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); + n++; + XtSetValues(W, args, n); + + XtAddCallback(W, XmNokCallback, _MuOkCallback, mark); + XtAddCallback(W, XmNcancelCallback, _MuCancelCallback, mark); + + if (helptext != NULL) + { + if (!XtIsManaged(HelpButton)) XtManageChild(HelpButton); + XtAddCallback(W, XmNhelpCallback, _MuHelpCallback, helptext); + } + else + { + if (XtIsManaged(HelpButton)) XtUnmanageChild(HelpButton); + } + + if (!XtIsManaged(W)) + XtManageChild(W); + + switch (status = setjmp(mark)) + { + case 0: + XtMainLoop(); + case 1: + case 2: + XtUnmanageChild(W); + XtRemoveCallback(W, XmNokCallback, _MuOkCallback, mark); + XtRemoveCallback(W, XmNcancelCallback, _MuCancelCallback, mark); + if (helptext != NULL) XtRemoveCallback(W, XmNhelpCallback, + _MuHelpCallback, helptext); + } + return((status==1)?True:False); + } + + diff -r -c src.p1/libMu/MuGetFileName.c src/libMu/MuGetFileName.c *** src.p1/libMu/MuGetFileName.c Wed May 15 15:54:18 1991 --- src/libMu/MuGetFileName.c Sat Dec 9 15:14:26 1989 *************** *** 0 **** --- 1,161 ---- + /* + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuGetFileName.c,v $ + * $Author: djf $ + * $Log: MuGetFileName.c,v $ + * Revision 1.1 89/12/09 15:14:18 djf + * Initial revision + * + * + * SyncDialogs.c + * This file contains the functions MuGetBoolean, MuGetString, and + * MuGetFileName. These popup a modal dialog box for communication with + * the user. They provide a synchronous interface to the programmer. + * That is, like gets() or scanf() they return the desired value + * directly to the programmer, without any intervening callbacks. + * This is accomplished by invoking a recursive copy of XtMainLoop + * inside of the each utility routine, and using longjmp() from within + * the ok and cancel callbacks to abort from that recursive copy. + * This is witchcraft, but provides powerful interface tools to the + * programmer. + * For additional convenience, these functions never take compound + * strings as arguments. All strings are passed as char *. + * + */ + + #include "MuP.h" + #include + #include + + /* + * MuGetFileName + * Uses a FileSelectionDialog widget to prompt the user to select a file. + * The string is returned in a passed buffer, and the + * function returns a Boolean indicating whether the "Ok" or the + * "Cancel" button was pressed. + * Inputs: + * buffer A pointer to a buffer to return the file name in. + * The contents of the buffer will be displayed as + * the default ?. + * bufsize The size in bytes of the buffer. + * dirmask A pointer to a buffer to return the value of the + * directory mask. + * dirmasksize The size in bytes of the dirmask. + * helptext The text to display if the help button is + * clicked. If NULL, no Help button will be + * displayed. + * Outputs: + * buffer Contains the NULL-terminated file name the user + * selected. + * dirmask Contains the NULL-terminated directory mask used. + * Returns: + * a Boolean indicating whether the user clicked the "Ok" + * button (True) or the "Cancel" button (False). If False is + * returned, then the contents of buffer should be ignored. + */ + + Boolean MuGetFileName(buffer, bufsize, dirmask, dirmasksize,helptext) + char *buffer; + int bufsize, dirmasksize; + char *dirmask; + char *helptext; + { + Arg args[10]; + int n; + jmp_buf mark; + XmString file_string, dirmask_string; + char *str; + int status; + + static Widget FileDialog = NULL; + static Widget HelpButton = NULL; + static Widget TextBox = NULL; + static Widget FilterText = NULL; + + if (FileDialog == NULL) { /* if widget doesn't exist yet */ + n = 0; + /* XtSetArg(args[n], XmNdialogType, XmDIALOG_FILE_SELECTION); n++; */ + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++; + XtSetArg(args[n],XmNdefaultButtonType, XmDIALOG_OK_BUTTON); n++; + XtSetArg(args[n], XmNborderWidth, 2); n++; + XtSetArg(args[n], XmNautoUnmanage,False); n++; + FileDialog = XmCreateFileSelectionDialog(_MuToplevel, + "_MuFileDialog",args,n); + HelpButton = XmFileSelectionBoxGetChild(FileDialog, + XmDIALOG_HELP_BUTTON); + TextBox = XmFileSelectionBoxGetChild(FileDialog,XmDIALOG_TEXT); + FilterText = XmFileSelectionBoxGetChild(FileDialog, + XmDIALOG_FILTER_TEXT); + + XtRealizeWidget(FileDialog); + MuSetStandardCursor(FileDialog); + MuSetSingleLineEmacsBindings(FilterText); + MuSetSingleLineEmacsBindings(TextBox); + } + + n=0; + XtSetArg(args[n], XmNdirMask, + XmStringLtoRCreate(dirmask,XmSTRING_DEFAULT_CHARSET)); n++; + XtSetArg(args[n], XmNtextColumns, bufsize-1); n++; + XtSetValues(FileDialog, args, n); + + n = 0; + XtSetArg(args[n],XmNmaxLength,bufsize-1); n++; + XtSetValues(TextBox,args, n); + + n = 0; + XtSetArg(args[n],XmNmaxLength,dirmasksize-1); n++; + XtSetValues(FilterText,args, n); + + XtAddCallback(FileDialog, XmNokCallback, _MuOkCallback, mark); + XtAddCallback(FileDialog, XmNcancelCallback, _MuCancelCallback, mark); + + if (helptext != NULL) { + if (!XtIsManaged(HelpButton)) XtManageChild(HelpButton); + XtAddCallback(FileDialog, XmNhelpCallback, _MuHelpCallback, helptext); + } + else { + if (XtIsManaged(HelpButton)) XtUnmanageChild(HelpButton); + } + + if (!XtIsManaged(FileDialog)) + XtManageChild(FileDialog); + + switch (status = setjmp(mark)) { + case 0: + XtMainLoop(); + case 1: + case 2: + if (status == 1) { + n = 0; + XtSetArg(args[n], XmNdirSpec, &file_string); n++; + XtSetArg(args[n], XmNdirMask, &dirmask_string); n++; + XtGetValues(FileDialog, args, n); + XmStringGetLtoR(file_string, XmSTRING_DEFAULT_CHARSET, &str); + strncpy(buffer,str,bufsize); + XmStringGetLtoR(dirmask_string, XmSTRING_DEFAULT_CHARSET, &str); + strncpy(dirmask,str,dirmasksize); + } + XtUnmanageChild(FileDialog); + XtRemoveCallback(FileDialog, XmNokCallback, _MuOkCallback, mark); + XtRemoveCallback(FileDialog,XmNcancelCallback,_MuCancelCallback, mark); + if (helptext != NULL) XtRemoveCallback(FileDialog,XmNhelpCallback, + _MuHelpCallback,helptext); + + } + return((status==1)?True:False); + } diff -r -c src.p1/libMu/MuGetString.c src/libMu/MuGetString.c *** src.p1/libMu/MuGetString.c Wed May 15 15:54:18 1991 --- src/libMu/MuGetString.c Sat Dec 9 15:14:28 1989 *************** *** 0 **** --- 1,141 ---- + /* + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuGetString.c,v $ + * $Author: djf $ + * + * SyncDialogs.c + * This file contains the functions MuGetBoolean, MuGetString, and + * MuGetFileName. These popup a modal dialog box for communication with + * the user. They provide a synchronous interface to the programmer. + * That is, like gets() or scanf() they return the desired value + * directly to the programmer, without any intervening callbacks. + * This is accomplished by invoking a recursive copy of XtMainLoop + * inside of the each utility routine, and using longjmp() from within + * the ok and cancel callbacks to abort from that recursive copy. + * This is witchcraft, but provides powerful interface tools to the + * programmer. + * For additional convenience, these functions never take compound + * strings as arguments. All strings are passed as char *. + * + */ + + #include "MuP.h" + #include + #include + #include + + /* + * MuGetString + * Uses a PromptDialog convenience widget to prompt the user to input + * a string. The string is returned in a passed buffer, and the + * function returns a Boolean indicating whether the "Ok" or the + * "Cancel" button was pressed. + * Inputs: + * prompt The string to prompt the user with. + * buffer A pointer to a buffer to return the string in. + * The contents of the buffer will be displayed as + * the default string. + * bufsize The size in bytes of the buffer. + * helptext The text to display if the help button is + * clicked. If NULL, no Help button will be + * displayed. + * Outputs: + * buffer Contains the NULL-terminated string the user + * selected. + * Returns: + * a Boolean indicating whether the user clicked the "Ok" + * button (True) or the "Cancel" button (False). If False is + * returned, then the contents of buffer should be ignored. + */ + + Boolean MuGetString(prompt, buffer, bufsize, helptext) + char *prompt; + char *buffer; + int bufsize; + char *helptext; + { + Arg args[5]; + int n; + jmp_buf mark; + char *str; + int status; + + static Widget StringDialog; + static Widget HelpButton; + static Widget TextBox; + + if (StringDialog == NULL) { /* if the widget doesn't exist yet */ + n = 0; + XtSetArg(args[n], XmNdefaultButtonType, XmDIALOG_OK_BUTTON); n++; + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++; + /* XtSetArg(args[n], XmNdialogType, XmDIALOG_PROMPT); n++; */ + XtSetArg(args[n], XmNborderWidth, 2); n++; + XtSetArg(args[n], XmNautoUnmanage,False); n++; + StringDialog=XmCreatePromptDialog(_MuToplevel,"_MuStringDialog", + args,n); + HelpButton=XmSelectionBoxGetChild(StringDialog, XmDIALOG_HELP_BUTTON); + TextBox = XmSelectionBoxGetChild(StringDialog, XmDIALOG_TEXT); + XtRealizeWidget(StringDialog); + MuSetStandardCursor(StringDialog); + MuSetSingleLineEmacsBindings(TextBox); + } + + n = 0; + XtSetArg(args[n], XmNtextColumns, bufsize-1); n++; + XtSetArg(args[n], XmNselectionLabelString, + XmStringLtoRCreate(prompt, XmSTRING_DEFAULT_CHARSET)); n++; + XtSetValues(StringDialog, args, n); + + n = 0; + XtSetArg(args[n],XmNvalue, buffer); n++; + XtSetArg(args[n],XmNmaxLength,bufsize-1); n++; + XtSetValues(TextBox,args, n); + + XtAddCallback(StringDialog, XmNokCallback, _MuOkCallback, mark); + XtAddCallback(StringDialog, XmNcancelCallback,_MuCancelCallback,mark); + + if (helptext != NULL) { + if (!XtIsManaged(HelpButton)) XtManageChild(HelpButton); + XtAddCallback(StringDialog, XmNhelpCallback,_MuHelpCallback, helptext); + } + else { + if (XtIsManaged(HelpButton)) XtUnmanageChild(HelpButton); + } + + if (!XtIsManaged(StringDialog)) + XtManageChild(StringDialog); + + switch (status = setjmp(mark)) { + case 0: + XtMainLoop(); + case 1: + case 2: + if (status == 1) { + str = XmTextGetString(TextBox); + strncpy(buffer,str,bufsize); + XtFree(str); + } + XtUnmanageChild(StringDialog); + XtRemoveCallback(StringDialog, XmNokCallback, _MuOkCallback, mark); + XtRemoveCallback(StringDialog, XmNcancelCallback, + _MuCancelCallback,mark); + if (helptext != NULL) XtRemoveCallback(StringDialog,XmNhelpCallback, + _MuHelpCallback,helptext); + + } + return((status==1)?True:False); + } diff -r -c src.p1/libMu/MuHelp.c src/libMu/MuHelp.c *** src.p1/libMu/MuHelp.c Wed May 15 15:54:18 1991 --- src/libMu/MuHelp.c Tue Dec 19 14:56:35 1989 *************** *** 0 **** --- 1,103 ---- + /* + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/user/v/vanharen/motifdev/projects/util/src/RCS/MuHelp.c,v $ + * $Author: vanharen $ + * $Log: MuHelp.c,v $ + * Revision 1.2 89/12/19 14:56:18 vanharen + * fixed an error in logic when hitting the 25 mark... + * + * Revision 1.1 89/12/09 15:14:29 djf + * Initial revision + * + * + * help.c + * This file contains the function MuHelp + * + * These two functions share an array of InformationDialog widgets. + * As many as 25 dialog widgets may be managed at once, but only 5 + * are not destroyed after it's unmanaged. When called, the function + * checks to see if helpbox[0] has been created. If yes, it checks to + * see if it's managed. If not, it will simply set the resource to display + * the proper message string and manage it. If it's managed, then it will + * check to see if helpbox[1] has been created. If not, it will create and + * manage it. If yes, it will continue to check if it's managed and so on. + * + */ + + #include "MuP.h" + #include + #include + + static Widget helpbox[25]; + + static void Destroy(w, tag, callback_data) + Widget w; + caddr_t tag; + caddr_t callback_data; + /*ARGSUSED*/ + { + XtDestroyWidget(w); + helpbox[(int)tag] = (Widget)NULL; + } + + void MuHelp(string) + char *string; + { + Arg args[10]; + int n, i; + Widget dummy; + + /* look through the array for the first un-created or un-managed widget */ + /* on exit from this loop, helpbox[i] is an unmanaged dialog widget */ + for (i=0; i < 25 ; i++) { + if (helpbox[i] == NULL) { /* if not created, create it */ + n = 0; + XtSetArg(args[n], XmNdefaultButtonType, XmDIALOG_OK_BUTTON); n++; + /* XtSetArg(args[n], XmNdialogType, XmDIALOG_INFORMATION); n++; */ + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++; + XtSetArg(args[n], XmNborderWidth, 2); n++; + helpbox[i]=XmCreateInformationDialog(_MuToplevel,"helpbox",args,n); + XtRealizeWidget(helpbox[i]); + MuSetStandardCursor(helpbox[i]); + + dummy = XmMessageBoxGetChild(helpbox[i], XmDIALOG_CANCEL_BUTTON); + XtDestroyWidget(dummy); + dummy = XmMessageBoxGetChild(helpbox[i], XmDIALOG_HELP_BUTTON); + XtDestroyWidget(dummy); + + /* Once created, keep the first three dialog boxes */ + /* for all others, destroy them when done. */ + if (i > 2) + XtAddCallback(helpbox[i], XmNokCallback, Destroy, i); + break; + } + + else if (!XtIsManaged(helpbox[i])) + break; + } + + if (i == 25) { + MuError(" You can not have more than 25 help boxes at once. \n Please click on 'OK' in one of the help boxes."); + return; + } + + XtSetArg(args[0], XmNmessageString, + XmStringLtoRCreate(string,XmSTRING_DEFAULT_CHARSET)); + XtSetValues(helpbox[i], args, 1); + XtManageChild(helpbox[i]); + } + diff -r -c src.p1/libMu/MuHelpFile.c src/libMu/MuHelpFile.c *** src.p1/libMu/MuHelpFile.c Wed May 15 15:54:18 1991 --- src/libMu/MuHelpFile.c Sat Dec 9 15:14:33 1989 *************** *** 0 **** --- 1,80 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuHelpFile.c,v $ + * $Author: djf $ + * $Log: MuHelpFile.c,v $ + * Revision 1.1 89/12/09 15:14:31 djf + * Initial revision + * + */ + + #include "Mu.h" + #include + #include + #include + + char *malloc(); + + /* + * This function takes a filename as its argument, stats the file to find + * it's length, malloc's enough space to hold the text, reads it in, + * then calls MuHelp with that string. + */ + + + void + MuHelpFile(filename) + char *filename; + { + struct stat statbuf; + char *helpbuf; + int fd; + + if (stat(filename, &statbuf)) + { + MuError("MuHelpFile: Unable to stat help file."); + return; + } + + if ((helpbuf = malloc((1 + (int)statbuf.st_size) * sizeof(char))) + == (char *) NULL) + { + MuError("MuHelpFile: Out of memory.\nUnable to malloc enough space for help file."); + return; + } + + if ((fd = open(filename, O_RDONLY, 0)) < 0) + { + MuError("MuHelpFile: Unable to open help file for reading.\nPerhaps the permissions on the file are wrong."); + close(fd); + free(helpbuf); + return; + } + + if ((read(fd, helpbuf, (int)statbuf.st_size)) != statbuf.st_size) + { + MuError("MuHelpFile: An error occurred while reading the file.\nThe number of bytes read does not match the length of the file."); + close(fd); + free(helpbuf); + return; + } + + helpbuf[statbuf.st_size] = '\0'; + MuHelp(helpbuf); + close(fd); + free(helpbuf); + return; + } diff -r -c src.p1/libMu/MuInitialize.c src/libMu/MuInitialize.c *** src.p1/libMu/MuInitialize.c Wed May 15 15:54:18 1991 --- src/libMu/MuInitialize.c Sat Dec 9 15:14:35 1989 *************** *** 0 **** --- 1,38 ---- + /* + * MotifUtils: Utilities for use with Motif and UIL + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuInitialize.c,v $ + * $Author: djf $ + * $Log: MuInitialize.c,v $ + * Revision 1.1 89/12/09 15:14:34 djf + * Initial revision + * + */ + + #include "MuP.h" + + Widget _MuToplevel = NULL; + + void MuInitialize(toplevel) + Widget toplevel; + { + _MuToplevel = toplevel; + } + + + + + diff -r -c src.p1/libMu/MuModalDialogs.c src/libMu/MuModalDialogs.c *** src.p1/libMu/MuModalDialogs.c Wed May 15 15:54:19 1991 --- src/libMu/MuModalDialogs.c Fri Feb 16 18:53:06 1990 *************** *** 0 **** --- 1,85 ---- + + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/src/RCS/MuModalDialogs.c,v $ + * $Author: djf $ + * $Log: MuModalDialogs.c,v $ + * Revision 1.3 89/12/20 12:52:14 djf + * changed XmCreateMessageDialog to XmCreateDialogShell and + * XmCreateMessageBox. Didn't work the old way. + * + * Revision 1.2 89/12/19 14:57:04 vanharen + * Change XtUnmanage to XtDestroy for unused button widgets. + * Saves (a little) memory... + * + * Revision 1.1 89/12/09 15:14:36 djf + * Initial revision + * + * + */ + + + #include "MuP.h" + #include + #include + + Widget _MuModalDialogWidget = (Widget)NULL; + + + static void CreateWidget() + { + Arg args[10]; + int n; + Widget parent, dummy; + + XtSetArg(args[0],XmNallowShellResize,True); + parent = XmCreateDialogShell(_MuToplevel,"_MuModalDialogShell",args,1); + + n = 0; + XtSetArg(args[n], XmNdefaultButtonType, XmDIALOG_OK_BUTTON); n++; + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++; + XtSetArg(args[n], XmNborderWidth, 2); n++; + XtSetArg(args[n], XmNdialogType, XmDIALOG_ERROR); n++; + _MuModalDialogWidget = XmCreateMessageBox(parent,"_MuModalDialogChild", + args,n); + + dummy = XmMessageBoxGetChild(_MuModalDialogWidget,XmDIALOG_CANCEL_BUTTON); + XtUnmanageChild(dummy); + XtDestroyWidget(dummy); + dummy = XmMessageBoxGetChild(_MuModalDialogWidget,XmDIALOG_HELP_BUTTON); + XtUnmanageChild(dummy); + XtDestroyWidget(dummy); + XtRealizeWidget(_MuModalDialogWidget); + MuSetStandardCursor(_MuModalDialogWidget); + } + + + void MuModalDialog(string,type) + char *string; + int type; + { + Arg args[2]; + + if (_MuModalDialogWidget == NULL) CreateWidget(); + + XtSetArg(args[0], XmNmessageString, + XmStringLtoRCreate(string,XmSTRING_DEFAULT_CHARSET)); + XtSetArg(args[1], XmNdialogType, type); + XtSetValues(_MuModalDialogWidget, args, 2); + + if (!XtIsManaged(_MuModalDialogWidget)) + XtManageChild(_MuModalDialogWidget); + } diff -r -c src.p1/libMu/MuP.h src/libMu/MuP.h *** src.p1/libMu/MuP.h Wed May 15 15:54:19 1991 --- src/libMu/MuP.h Sat Dec 9 15:15:05 1989 *************** *** 0 **** --- 1,35 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuP.h,v $ + * $Author: djf $ + * $Log: MuP.h,v $ + * Revision 1.1 89/12/09 15:15:03 djf + * Initial revision + * + */ + + #ifndef MuP_h + #define MuP_H + + #include "Mu.h" + + extern void _MuOkCallback(); + extern void _MuCancelCallback(); + extern void _MuHelpCallback(); + + extern Widget _MuModalDialogWidget; + extern Widget _MuToplevel; + + #endif diff -r -c src.p1/libMu/MuRegisterNames.c src/libMu/MuRegisterNames.c *** src.p1/libMu/MuRegisterNames.c Wed May 15 15:54:19 1991 --- src/libMu/MuRegisterNames.c Sat Dec 9 15:14:43 1989 *************** *** 0 **** --- 1,132 ---- + /* + * MotifUtils: Utilities for use with Motif and UIL + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuRegisterNames.c,v $ + * $Author: djf $ + * $Log: MuRegisterNames.c,v $ + * Revision 1.1 89/12/09 15:14:37 djf + * Initial revision + * + * + * This file contains the function MuRegisterNames, which calls + * MrmRegisterNames to register all the "Callback" MotifUtilities + * functions. Listed below are all the MotifUtilities functions which + * can be called from uil. They are called without the "Callback" tag + * in their names. + */ + + #include "Mu.h" + #include + + static void MuHelpCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuHelp((char *)tag); + } + + static void MuErrorCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuError((char *)tag); + } + + static void MuWarningCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuWarning((char *)tag); + } + + static void MuHelpFileCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuHelpFile((char *)tag); + } + + static void MuSetEmacsBindingsCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuSetEmacsBindings(w); + } + + static void MuSetWaitCursorCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuSetWaitCursor(w); + } + + static void MuSetStandardCursorCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuSetStandardCursor(w); + } + + static void MuRegisterWidgetCallback(w,tag,call_data) + Widget w; + caddr_t tag; + caddr_t call_data; + /* ARGSUSED */ + { + MuRegisterWidget(w,(char *)tag); + } + + static MRMRegisterArg regvec[] = { + {"MuHelp", (caddr_t)MuHelpCallback}, + {"MuError", (caddr_t)MuErrorCallback}, + {"MuWarning", (caddr_t)MuWarningCallback}, + {"MuHelpFile", (caddr_t)MuHelpFileCallback}, + {"MuSetEmacsBindings", (caddr_t)MuSetEmacsBindingsCallback}, + {"MuSetSingleLineEmacsBindings", (caddr_t)MuSetEmacsBindingsCallback}, + {"MuSetStandardCursor", (caddr_t)MuSetStandardCursorCallback}, + {"MuSetWaitCursor", (caddr_t)MuSetWaitCursorCallback}, + {"MuRegisterWidget", (caddr_t)MuRegisterWidgetCallback}, + + {"MUHELP", (caddr_t)MuHelpCallback}, + {"MUERROR", (caddr_t)MuErrorCallback}, + {"MUWARNING", (caddr_t)MuWarningCallback}, + {"MUHELPFILE", (caddr_t)MuHelpFileCallback}, + {"MUSETEMACSBINDINGS", (caddr_t)MuSetEmacsBindingsCallback}, + {"MUSETSINGLELINEEMACSBINDINGS", (caddr_t)MuSetEmacsBindingsCallback}, + {"MUSETSTANDARDCURSOR", (caddr_t)MuSetStandardCursorCallback}, + {"MUSETWAITCURSOR", (caddr_t)MuSetWaitCursorCallback}, + {"MUREGISTERWIDGET", (caddr_t)MuRegisterWidgetCallback}, + }; + + void MuRegisterNames() + { + MrmRegisterNames (regvec, XtNumber(regvec)); + } + diff -r -c src.p1/libMu/MuRegisterWidget.c src/libMu/MuRegisterWidget.c *** src.p1/libMu/MuRegisterWidget.c Wed May 15 15:54:19 1991 --- src/libMu/MuRegisterWidget.c Fri Sep 7 18:03:32 1990 *************** *** 0 **** --- 1,284 ---- + + /* + * + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /mit/motifdev/projects/util/src/RCS/MuRegisterWidget.c,v $ + * $Author: vanharen $ + * $Log: MuRegisterWidget.c,v $ + * Revision 1.4 90/09/07 18:03:29 vanharen + * Changed MuGetWidget to MuLookupWidget since the include file "Mu.h" + * defines MuGetWidget(w) as MuLookupWidget(w). I think the intent was to + * rename the function, but provide the macro for backwards compatibility. + * + * Also, modified MuLookupWidget to return NULL if the hash table hasn't + * been initialized yet. + * + * Revision 1.3 90/02/13 14:26:54 djf + * fixed bad buffer declaration in MuRegisterWidget() + * + * Revision 1.2 90/02/13 14:21:08 djf + * + * Revision 1.1 89/12/09 15:14:44 djf + * Initial revision + * + * + * This file contains the functions MuRegisterWidgetCallback (which is + * called from uil as MuRegisterWidget -- see register.c) and MuGetWidget. + * + * MuRegisterWidget is called from uil as a create callback procedure. + * It is passed a char *string which it converts to a quark using + * XrmStringToQuark. It stores the widget ID of the created widget + * in a hash table using the quark as an integer key (see hash.c). + * + * MuGetWidget is called from C, and it returns the widget ID associated + * with the char *string passed. It calls the routine hash_lookup in + * hash.c , passing it the hash table created in MuRegisterWidget and + * the quark of the string passed. + */ + + #include "Mu.h" + #include + + + /* + * + * Generic hash table routines. Uses integer keys to store Widget values. + * + * (c) Copyright 1988 by the Massachusetts Institute of Technology. + * For copying and distribution information, please see the file + * . + * + * This file contains the hash table functions create_hash, hash_lookup, + * hash_store, hash_update, hash_search, hash_step, and hash_destroy. + * + * Since only the functions create_hash, hash_lookup, and hash_store are + * used, the others have been commented out. They should be uncommented + * if needed. + * + * The general code for these hash table routines were copied from + * another project (smsdev). The routines have been modified for + * MotifUtilities use. In hash_store and hash_lookup the argument key + * is a quark of a char *string, and the argument value in hash_store is + * a widget (see widgets.c). These functions are only called from + * MuRegisterWidget and MuGetWidget. + */ + + /* #include */ + + + + /* Hash table declarations */ + + struct bucket { + struct bucket *next; + int key; + Widget data; + }; + struct hash { + int size; + struct bucket **data; + }; + + #define hash_func(h,key) (key>=0 ? (key % h->size) : (-key % h->size)) + + + /* Create a hash table. The size is just a hint, not a maximum. */ + + struct hash *create_hash(size) + int size; + { + struct hash *h; + extern char * malloc(); + + h = (struct hash *) malloc(sizeof(struct hash)); + h->size = size; + h->data = (struct bucket **) malloc(size * sizeof(struct bucket *)); + bzero(h->data, size * sizeof(struct bucket *)); + return(h); + } + + /* Lookup an object in the hash table. Returns the value associated with + * the key, or NULL (thus NULL is not a very good value to store...) + */ + + Widget hash_lookup(h, key) + struct hash *h; + register int key; + { + register struct bucket *b; + + b = h->data[hash_func(h,key)]; + while (b && b->key != key) + b = b->next; + if (b && b->key == key) + return(b->data); + else + return(NULL); + } + + + /* Store an item in the hash table. Returns 0 if the key was not previously + * there, or 1 if it was. + */ + + int hash_store(h, key, value) + struct hash *h; + register int key; + Widget value; + { + register struct bucket *b, **p; + + p = &(h->data[hash_func(h,key)]); + if (*p == NULL) { + b = *p = (struct bucket *) malloc(sizeof(struct bucket)); + b->next = NULL; + b->key = key; + b->data = value; + return(0); + } + + for (b = *p; b && b->key != key; b = *p) + p = (struct bucket **) *p; + if (b && b->key == key) { + b->data = value; + return(1); + } + b = *p = (struct bucket *) malloc(sizeof(struct bucket)); + b->next = NULL; + b->key = key; + b->data = value; + return(0); + } + + /****************************************************************************/ + /* Update an existing object in the hash table. Returns 1 if the object + * existed, or 0 if not. + */ + + /* int hash_update(h, key, value) + struct hash *h; + register int key; + Widget value; + { + register struct bucket *b; + + b = h->data[hash_func(h,key)]; + while (b && b->key != key) + b = b->next; + if (b && b->key == key) { + b->data = value; + return(1); + } else + return(0); + } */ + + /* Search through the hash table for a given value. For each piece of + * data with that value, call the callback proc with the corresponding key. + */ + + /* hash_search(h, value, callback) + struct hash *h; + register Widget value; + void (*callback)(); + { + register struct bucket *b, **p; + + for (p = &(h->data[h->size - 1]); p >= h->data; p--) { + for (b = *p; b; b = b->next) { + if (b->data == value) + (*callback)(b->key); + } + } + } */ + + + /* Step through the hash table, calling the callback proc with each key. + */ + + /* hash_step(h, callback, hint) + struct hash *h; + void (*callback)(); + Widget hint; + { + register struct bucket *b, **p; + + for (p = &(h->data[h->size - 1]); p >= h->data; p--) { + for (b = *p; b; b = b->next) { + (*callback)(b->key, b->data, hint); + } + } + } */ + + + /* Deallocate all of the memory associated with a table */ + + /* hash_destroy(h) + struct hash *h; + { + register struct bucket *b, **p, *b1; + + for (p = &(h->data[h->size - 1]); p >= h->data; p--) { + for (b = *p; b; b = b1) { + b1 = b->next; + free(b); + } + } + } */ + + + + static struct hash *h = NULL; + #define HASHSIZE 67 + + void MuRegisterWidget(w, name) + Widget w; + char *name; + { + XrmQuark quark; + int i; + char err_buf[BUFSIZ]; + + quark = XrmStringToQuark(name); + + if ( h == NULL ) + h = (struct hash *)(create_hash(HASHSIZE)); + + i = hash_store(h, quark, w); + + if (i == 1) {/* if a widget was already stored by that name, warn */ + sprintf(err_buf, + "MuRegisterName: reuse of name %s. Previously registered value overwritten", + name); + XtWarning(err_buf); + } + } + + + Widget MuLookupWidget(string) + char *string; + { + XrmQuark quark; + Widget w; + + quark = XrmStringToQuark(string); + + if (h == NULL) /* if hash table hasn't been initialized */ + return(NULL); /* yet, return null. */ + + w = (Widget)(hash_lookup(h, quark)); + return(w); + } + diff -r -c src.p1/libMu/MuSetCursor.c src/libMu/MuSetCursor.c *** src.p1/libMu/MuSetCursor.c Wed May 15 15:54:19 1991 --- src/libMu/MuSetCursor.c Sat Dec 9 15:14:48 1989 *************** *** 0 **** --- 1,70 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuSetCursor.c,v $ + * $Author: djf $ + * $Log: MuSetCursor.c,v $ + * Revision 1.1 89/12/09 15:14:46 djf + * Initial revision + * + */ + + #include "Mu.h" + #include + #include + + static void SetCursor(w,c) + Widget w; + Cursor c; + { + while (XtIsSubclass(w, shellWidgetClass) != True) { + w = XtParent(w); + } + XDefineCursor(XtDisplay(w), XtWindow(w), c); + XFlush(XtDisplay(w)); + } + + static Cursor ArrowCursor = (Cursor)NULL; + + void MuSetStandardCursor(widget) + Widget widget; + { + if (ArrowCursor == (Cursor)NULL) + ArrowCursor = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow); + SetCursor(widget,ArrowCursor); + } + + + static Cursor WatchCursor = (Cursor)NULL; + + void MuSetWaitCursor(widget) + Widget widget; + { + if (WatchCursor == (Cursor)NULL) + WatchCursor = XCreateFontCursor(XtDisplay(widget), XC_watch); + SetCursor(widget,WatchCursor); + } + + void MuSetCursor(widget, cursorshape) + Widget widget; + unsigned int cursorshape; + { + SetCursor(widget,XCreateFontCursor(XtDisplay(widget), cursorshape)); + } + + + + + diff -r -c src.p1/libMu/MuSetEmacsBindings.c src/libMu/MuSetEmacsBindings.c *** src.p1/libMu/MuSetEmacsBindings.c Wed May 15 15:54:19 1991 --- src/libMu/MuSetEmacsBindings.c Thu Aug 30 12:40:33 1990 *************** *** 0 **** --- 1,120 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /mit/motifdev/projects/util/src/RCS/MuSetEmacsBindings.c,v $ + * $Author: vanharen $ + * $Log: MuSetEmacsBindings.c,v $ + * Revision 1.5 90/08/30 12:40:31 vanharen + * Two strings were not terminated correctly -- the end-quotes were on the + * next line down. GCC didn't complain, but other compilers did... + * + * Revision 1.4 90/08/28 14:33:58 vanharen + * added return binding for single-line bindings. + * + * Revision 1.3 90/08/23 13:27:24 vanharen + * fixed translation table. + * + * Revision 1.2 89/12/09 16:36:03 djf + * + * changed arg in call to XtGetValues to &arg + * + * Revision 1.1 89/12/09 15:14:49 djf + * Initial revision + * + * + * These functions add emacs key bindings to multiple line or single + * line text widgets when they are passed as arguments. + * + */ + + #include "Mu.h" + #include + + + static XtTranslations EmacsBindings = NULL; + static char EmacsBindingsText[] = + "Delete: delete-previous-character() \n\ + MetaDelete: kill-previous-word() \n\ + CtrlD: delete-next-character() \n\ + MetaD: kill-next-word() \n\ + CtrlK: kill-to-end-of-line() \n\ + CtrlW: kill-selection() \n\ + CtrlY: unkill() \n\ + CtrlF: forward-character() \n\ + CtrlB: backward-character() \n\ + MetaF: forward-word() \n\ + MetaB: backward-word() \n\ + Meta]: forward-paragraph() \n\ + Meta[: backward-paragraph() \n\ + CtrlA: beginning-of-line() \n\ + CtrlE: end-of-line() \n\ + CtrlN: next-line() \n\ + CtrlP: previous-line() \n\ + CtrlV: next-page() \n\ + MetaV: previous-page() \n\ + ~Shift Meta<: beginning-of-file() \n\ + Shift Meta<: end-of-file() \n\ + Meta>: end-of-file() \n\ + CtrlL: redraw-display() \n\ + CtrlM: newline() \n\ + CtrlJ: newline() \n\ + Return: newline() "; + + static XtTranslations SingleLineEmacsBindings = NULL; + static char SingleLineEmacsBindingsText[] = + "Delete: delete-previous-character() \n\ + MetaDelete: kill-previous-word() \n\ + CtrlD: delete-next-character() \n\ + MetaD: kill-next-word() \n\ + CtrlK: kill-to-end-of-line() \n\ + CtrlW: kill-selection() \n\ + CtrlY: unkill() \n\ + CtrlF: forward-character() \n\ + CtrlB: backward-character() \n\ + CtrlA: beginning-of-line() \n\ + CtrlE: end-of-line() \n\ + MetaF: forward-word() \n\ + MetaB: backward-word() \n\ + ~Shift Meta<: beginning-of-line() \n\ + Shift Meta<: end-of-line() \n\ + Meta>: end-of-line() \n\ + Return: activate() "; + + void MuSetEmacsBindings(w) + Widget w; + { + Arg arg; + int editmode; + + if (!XtIsSubclass(w,xmTextWidgetClass)) { + XtWarning("MuSetEmacsBindings() called on non-text widget"); + } + + XtSetArg(arg, XmNeditMode, &editmode); + XtGetValues(w,&arg,1); + + if (editmode == XmMULTI_LINE_EDIT) { + if (EmacsBindings == NULL) + EmacsBindings = XtParseTranslationTable(EmacsBindingsText); + XtOverrideTranslations(w,EmacsBindings); + } + else { + if (SingleLineEmacsBindings == NULL) + SingleLineEmacsBindings = + XtParseTranslationTable(SingleLineEmacsBindingsText); + XtOverrideTranslations(w,SingleLineEmacsBindings); + } + } + diff -r -c src.p1/libMu/MuSetTextTraversal.c src/libMu/MuSetTextTraversal.c *** src.p1/libMu/MuSetTextTraversal.c Wed May 15 15:54:19 1991 --- src/libMu/MuSetTextTraversal.c Sat Dec 9 15:14:54 1989 *************** *** 0 **** --- 1,156 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuSetTextTraversal.c,v $ + * $Author: djf $ + * $Log: MuSetTextTraversal.c,v $ + * Revision 1.1 89/12/09 15:14:52 djf + * Initial revision + * + * + * MuSetTextTraversal.c + * This file contains the function MuSetTextTraversal. When passed an + * array of text widgets, the number of widgets in the array, and the subtree + * of the hierarchy for which the keyboard focus is to be set (most often + * the toplevel widget or the dialog shell widget), this function enables + * traversal among the text widgets passed using the up arrow, down arrow, + * and the return key. If a multi-line text widget is passed, the + * return key will not be bound for that text widget. If a passed text widget + * is not sensitive at any time, it will be skipped during traversal. + * + * MuSetTextTraversal is dependent on the functions get_new_entry, find_entry, + * get_prev_entry, get_next_entry and the upfocus and downfocus callback + * functions contained in this file. + */ + + #include "Mu.h" + + typedef struct link { + Widget w; + Widget subtree; + struct link *next_in_all; + struct link *next_in_list; + struct link *previous_in_list; + } MuTraversalList; + + static MuTraversalList *TraversalList = NULL; + + void MuSetTextTraversal(twidgets, tnum, tsubtree) + Widget twidgets[]; + int tnum; + Widget tsubtree; + { + int i; + MuTraversalList *list; + static XtTranslations translations = NULL; + extern char *malloc(); + + static void upfocus(), downfocus(); + char *strans = + "Up: activate() _Muupfocus()\n\ + Return: activate() _Mudownfocus()\n\ + Down: activate() _Mudownfocus()\n"; + + static XtActionsRec actionTable[] = { + {"_Muupfocus", (XtActionProc) upfocus}, + {"_Mudownfocus", (XtActionProc) downfocus}, + }; + + if (translations == NULL) { + XtAddActions(actionTable, XtNumber(actionTable)); + translations = XtParseTranslationTable(strans); + } + + list = (MuTraversalList *)malloc(sizeof(MuTraversalList) * tnum); + for(i=0; iw != widget)) + entry = entry->next_in_all; + return(entry); + } + + static MuTraversalList *get_prev_entry(entry) + MuTraversalList *entry; + { + MuTraversalList *prev_entry; + + /* get previous entry */ + prev_entry = entry->previous_in_list; + + /* if insensitive, keep looking, but don't go into an infinite loop */ + while (!XtIsSensitive(prev_entry->w) && (prev_entry != entry)) + prev_entry = prev_entry->previous_in_list; + return prev_entry; + } + + static MuTraversalList *get_next_entry(entry) + MuTraversalList *entry; + { + MuTraversalList *next_entry; + + /* get next entry */ + next_entry = entry->next_in_list; + + /* if insensitive, keep looking, but don't go into an infinite loop */ + while (!XtIsSensitive(next_entry->w) && (next_entry != entry)) + next_entry = next_entry->next_in_list; + return next_entry; + } + + static void upfocus(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; + /*ARGSUSED*/ + { + MuTraversalList *entry; + + entry = find_entry(w); + entry = get_prev_entry(entry); + XtSetKeyboardFocus(entry->subtree, entry->w); + } + + static void downfocus(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; + /*ARGSUSED*/ + { + MuTraversalList *entry; + + entry = find_entry(w); + entry = get_next_entry(entry); + XtSetKeyboardFocus(entry->subtree, entry->w); + } + diff -r -c src.p1/libMu/MuSyncDialogs.c src/libMu/MuSyncDialogs.c *** src.p1/libMu/MuSyncDialogs.c Wed May 15 15:54:20 1991 --- src/libMu/MuSyncDialogs.c Sat Dec 9 15:14:56 1989 *************** *** 0 **** --- 1,46 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/MuSyncDialogs.c,v $ + * $Author: djf $ + * $Log: MuSyncDialogs.c,v $ + * Revision 1.1 89/12/09 15:14:55 djf + * Initial revision + * + * + */ + + #include "MuP.h" + #include + + void MuSyncDialog(string,type) + char *string; + int type; + { + jmp_buf mark; + + MuModalDialog(string,type); + XtAddCallback(_MuModalDialogWidget, XmNokCallback, _MuOkCallback, mark); + + switch (setjmp(mark)) { + case 0: + XtMainLoop(); + case 1: + XtUnmanageChild(_MuModalDialogWidget); + XtRemoveCallback(_MuModalDialogWidget,XmNokCallback, + _MuOkCallback, mark); + return; + } + } diff -r -c src.p1/libMu/TestMu.c src/libMu/TestMu.c *** src.p1/libMu/TestMu.c Wed May 15 15:54:20 1991 --- src/libMu/TestMu.c Wed Dec 20 18:06:28 1989 *************** *** 0 **** --- 1,90 ---- + #include + #include + #include "Mu.h" + + Widget toplevel; + + + static char buf[300]; + static char buf2[300]; + + void test(w,tag,call_data) + Widget w; + int *tag; + caddr_t call_data; + /* ARGSUSED */ + { + Boolean result; + Widget wl[3]; + + switch(*tag) { + case 1: + MuErrorSync("This is a \nsynchronous error dialog box."); + break; + case 2: + MuWarningSync("This is a synchronous warning dialog box."); + break; + case 3: + result = MuGetBoolean("Play again?","Yes","No", + "Please click yes or no.",True); + printf("result = %d\n",result); + break; + case 4: + result = MuGetString("Printer name:",buf,20,NULL); + printf("result = %d; name = %s\n",result,buf); + break; + case 5: + result = MuGetFileName(buf,30,buf2,50,"this is help"); + printf("result = %d; file = %s; mask = %s\n",result,buf,buf2); + break; + case 6: + wl[0] = MuLookupWidget("text1"); + wl[1] = MuLookupWidget("text2"); + wl[2] = MuLookupWidget("text3"); + MuSetTextTraversal(wl,3,toplevel); + break; + case 7: + XtSetSensitive(wl[0],False); + break; + case 8: + XtSetSensitive(wl[1],False); + break; + case 9: + XtSetSensitive(wl[2],False); + break; + } + } + + static MRMRegisterArg names[] = { + {"test",(caddr_t)test}, + }; + + main(argc,argv) + int argc; + char **argv; + { + Widget main; + Arg arglist[10]; + char *filename = "TestMu.uid"; + MrmHierarchy Hierarchy; + MrmCode class ; + + + + toplevel = XtInitialize("test","Test",NULL,0,&argc,argv); + XtSetArg (arglist[0], XtNallowShellResize, TRUE) ; + XtSetValues (toplevel, arglist, 1) ; + + MuInitialize(toplevel); + MrmInitialize(); + MuRegisterNames(); + MrmRegisterNames(names, XtNumber(names)); + + MrmOpenHierarchy (1,&filename,NULL,&Hierarchy); + + MrmFetchWidget (Hierarchy,"main",toplevel,&main,&class); + + XtManageChild(main); + XtRealizeWidget(toplevel); + XtMainLoop(); + } diff -r -c src.p1/libMu/TestMu.uid src/libMu/TestMu.uid *** src.p1/libMu/TestMu.uid Wed May 15 15:54:20 1991 --- src/libMu/TestMu.uid Wed May 15 15:30:12 1991 *************** *** 0 **** --- 1,9 ---- + ro|URM 1.0Motif Uil CompilerV2.0-000Wed May 15 15:30:09 1991 + MuTest7/28/1989 ro|D (È®ˆH 0·Xmain®ˆH èâ÷Iè (`mainàØÐĸ¬¤˜„|ph`XPH@grey3grey2grey1text3text2text1traversegetfilegetstringgetboolstandardwaitsyncwarningsyncerrorhelpfilewarningerrorhelp®ˆH  pHâ÷Ip (help ClassTable>ResourceTablegrey3grey2grey1text3text2text1traversegetfilegetstringgetboolstandardwaitsyncwarningsyncerrorhelpfilewarningerrorhelpmainMuTestro|ЈDÌ ˆ diff -r -c src.p1/libMu/TestMu.uil src/libMu/TestMu.uil *** src.p1/libMu/TestMu.uil Wed May 15 15:54:20 1991 --- src/libMu/TestMu.uil Tue Feb 13 12:16:40 1990 *************** *** 0 **** --- 1,170 ---- + module MuTest + version = '7/28/1989' + names = case_sensitive + objects = { + XmSeparator = gadget ; + XmLabel = gadget ; + XmPushButton = gadget ; + XmToggleButton = gadget ; + } + + include file 'XmAppl.uil'; + + procedure + MuSetEmacsBindings(); + MuSetStandardCursor(); + MuSetWaitCursor(); + MuHelp(string); + MuWarning(string); + MuError(string); + MuHelpFile(string); + MuRegisterWidget(string); + test(integer); + + object main : XmRowColumn { + arguments { + XmNwidth = 532; + XmNborderWidth = 1; + XmNspacing = 1; + XmNpacking = XmPACK_TIGHT; + }; + controls { + XmPushButton help; + XmPushButton error; + XmPushButton warning; + XmPushButton helpfile; + XmPushButton syncerror; + XmPushButton syncwarning; + XmPushButton wait; + XmPushButton standard; + XmPushButton getbool; + XmPushButton getstring; + XmPushButton getfile; + XmPushButton traverse; + XmText text1; + XmText text2; + XmText text3; + XmPushButton grey1; + XmPushButton grey2; + XmPushButton grey3; + }; + }; + + object help : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuHelp("This is a help\ndialog."); + }; + }; + + object error : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuError("This is an error\ndialog."); + }; + }; + + object warning : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuWarning("This is a warning\ndialog."); + }; + }; + + object helpfile : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuHelpFile("/mit/motifdev/projects/util/src/MuP.h"); + }; + }; + + object syncerror : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(1); + }; + }; + + object syncwarning : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(2); + }; + }; + + object wait : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuSetWaitCursor(); + }; + }; + + object standard : XmPushButton { + callbacks { + XmNactivateCallback = procedure MuSetStandardCursor(); + }; + }; + + object getbool : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(3); + }; + }; + + object getstring : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(4); + }; + }; + + object getfile : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(5); + }; + }; + + object traverse : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(6); + }; + }; + + object text1 : XmText { + callbacks { + MrmNcreateCallback = procedures { + MuSetEmacsBindings(); + MuRegisterWidget("text1"); + }; + }; + }; + + object text2 : XmText { + callbacks { + MrmNcreateCallback = procedures { + MuSetEmacsBindings(); + MuRegisterWidget("text2"); + }; + }; + }; + + object text3 : XmText { + callbacks { + MrmNcreateCallback = procedures { + ! MuSetEmacsBindings(); + MuRegisterWidget("text3"); + }; + }; + }; + + object grey1 : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(7); + }; + }; + + object grey2 : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(8); + }; + }; + + object grey3 : XmPushButton { + callbacks { + XmNactivateCallback = procedure test(9); + }; + }; + + end module; diff -r -c src.p1/libMu/XmListUtils.c src/libMu/XmListUtils.c *** src.p1/libMu/XmListUtils.c Wed May 15 15:54:20 1991 --- src/libMu/XmListUtils.c Tue Apr 10 14:56:15 1990 *************** *** 0 **** --- 1,75 ---- + #include + #include /* we need to get inside the list. this is illegal */ + + + void XmListGetSelectedPositions(w,return_table, return_count) + XmListWidget w; + int **return_table; + int *return_count; + { + int i,j; + int *table; + + if (w->list.selectedItemCount == 0) { + *return_table = NULL; + *return_count = 0; + return; + } + + table = (int *) XtMalloc(w->list.selectedItemCount * sizeof(int)); + + for (i=j=0; i < w->list.itemCount; i++) { + if (w->list.InternalList[i]->selected) table[j++] = i; + } + + *return_table = table; + *return_count = w->list.selectedItemCount; + } + + void XmListSetSelectedPositions(w, items, num_items) + XmListWidget w; + int *items; + int num_items; + { + register int i,j; + + /* free up the current selected items list */ + if (w->list.selectedItems && w->list.selectedItemCount) { + for (i = 0; i < w->list.selectedItemCount; i++) + XmStringFree(w->list.selectedItems[i]); + XtFree(w->list.selectedItems); + w->list.selectedItemCount = 0; + w->list.selectedItems = NULL; + } + + /* select the new items */ + for(i=0; i < num_items; i++) + w->list.InternalList[items[i]]->selected = TRUE; + + /* build the new list of selected items */ + /* this broken code straight from List widget */ + for (i = 0; i < w->list.itemCount; i++) + if (w->list.InternalList[i]->selected) + { + j = w->list.selectedItemCount++; + w->list.selectedItems =(XmString *)XtRealloc(w->list.selectedItems, + (sizeof(XmString) * (w->list.selectedItemCount))); + w->list.selectedItems[j] = XmStringCopy(w->list.items[i]); + } + + /* force a Redisplay */ + (XtClass(w)->core_class.expose)(w, (XEvent *)NULL, (Region)NULL); + } + + int XmListGetTopPos(w) + XmListWidget w; + { + /* we add one because a top_position of 0, means item 1 is on the top */ + return w->list.top_position + 1; + } + + int XmListGetBottomPos(w) + XmListWidget w; + { + return w->list.top_position + 1 + w->list.visibleItemCount - 1; + } diff -r -c src.p1/libMu/XmListUtils.h src/libMu/XmListUtils.h *** src.p1/libMu/XmListUtils.h Wed May 15 15:54:20 1991 --- src/libMu/XmListUtils.h Fri Apr 6 17:54:25 1990 *************** *** 0 **** --- 1,5 ---- + + void XmListGetSelectedPositions(); + void XmListSetSelectedPositions(); + int XmListGetTopPos(); + int XmListGetBottomPos(); diff -r -c src.p1/libMu/_MuCallbacks.c src/libMu/_MuCallbacks.c *** src.p1/libMu/_MuCallbacks.c Wed May 15 15:54:21 1991 --- src/libMu/_MuCallbacks.c Sat Dec 9 15:15:00 1989 *************** *** 0 **** --- 1,53 ---- + /* + * Copyright 1989 by the Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * MotifUtils: Utilities for use with Motif and UIL + * $Source: /afs/athena.mit.edu/astaff/project/motifdev/projects/util/RCS/_MuCallbacks.c,v $ + * $Author: djf $ + * $Log: _MuCallbacks.c,v $ + * Revision 1.1 89/12/09 15:14:58 djf + * Initial revision + * + * + */ + + #include "MuP.h" + #include + + void _MuOkCallback(w, tag, callback_data) + Widget w; + caddr_t tag; + caddr_t callback_data; + /*ARGSUSED*/ + { + longjmp(*(jmp_buf *)tag, 1); + } + + void _MuCancelCallback(w, tag, callback_data) + Widget w; + caddr_t tag; + caddr_t callback_data; + /*ARGSUSED*/ + { + longjmp(*(jmp_buf *)tag, 2); + } + + void _MuHelpCallback(w, tag, callback_data) + Widget w; + caddr_t tag; + caddr_t callback_data; + /*ARGSUSED*/ + { + MuHelp((char *)tag); + } diff -r -c src.p1/libMu/man/whatis src/libMu/man/whatis *** src.p1/libMu/man/whatis Wed May 15 15:54:11 1991 --- src/libMu/man/whatis Tue Dec 19 13:17:54 1989 *************** *** 0 **** --- 1,13 ---- + MuError, MuWarning, MuHelp (3X) - popup easy dialog boxes. + MuErrorSync, MuWarningSync (3X) - easy dialog boxes with synchronous behavior. + MuGetBoolean (3X) - Ask the user a question and get a synchronous response. + MuGetFileName (3X) - Prompt for and get a filename synchronously. + MuGetString (3X) - Prompt for and get a string synchronously. + MuHelpFile (3X) - display the contents of a help file. + MuInitialize (3X) - Initialize the Motif Utility routines. + MuRegisterNames (3X) - Make Motif Utility functions available to UIL code + MuRegisterWidget, MuLookupWidget (3X) - Pass widget IDs between UIL and C + MuSetEmacsBindings (3X) - Make the text widget do familiar things. + MuSetTextTraversal (3X) - bind arrow keys to traverse between input fields. + MuSetWaitCursor, MuSetStandardCursor (3X) - change the mouse pointer to a "please wait" indicator and back. + libMu.a (3X) - a library of Motif utilities. diff -r -c src.p1/libMu/man/man3/MuError.3X src/libMu/man/man3/MuError.3X *** src.p1/libMu/man/man3/MuError.3X Wed May 15 15:54:12 1991 --- src/libMu/man/man3/MuError.3X Tue Dec 19 12:08:22 1989 *************** *** 0 **** --- 1,78 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuError 3X "November 27, 1989" + .UC 4 + .SH NAME + MuError, MuWarning, MuHelp \- popup easy dialog boxes. + .SH SYNOPSIS (C) + .B #include + .PP + .B void MuError(str) + .br + .B char *str; + .PP + .B void MuWarning(str) + .br + .B char *str; + .PP + .B void MuHelp(str) + .br + .B char *str; + .SH SYNOPSIS (UIL) + .B procedure + .br + .B MuError(string); + .br + .B MuWarning(string); + .br + .B MuHelp(string); + .SH DESCRIPTION + + These functions make use of some of the convenience dialogs provided in + the Motif widget set to display error, warning, and help messages. + .I MuError + and + .I MuWarning + popup application modal dialog boxes. Your application should not + display any further warning or error messages until the existing warning + or error is clicked away by the user. + .I MuHelp + pops up a modeless dialog box with your help message. The user has the + option to keep the help visible while she proceeds to use the + application. There is an upper limit (currently 25) on the number of help + dialog boxes visible at once. If your program attempts to display more + help dialogs than this, the user will see a message explaining that the + limit has been reached, and she should click some of the help dialogs + away. + + .PP + + The dialog boxes are created as children of the widget passed with the + call to + .I MuInitialize. + They will popup centered over this widget. + There is not currently a mechanism for having the dialog boxes pop up + over other top level windows. The dialog boxes are not created until + the first call to each of these functions, and once created, they are + re-used. + + .PP + + You can get multiple lines of text in the dialog box simply by imbedding + the '\\n' character in the passed string. This works from C and from UIL. + + + .SH EXAMPLE (UIL) + .nf + .nj + callbacks { + XmNactivateCallback = procedure MuWarning('Not implemented yet.'); + XmNhelpCallback = procdure MuHelp('Pressing this button will\\n' & + 'quit the application. This\\n' & + 'feature is not implemented yet.'); + + .fi + + + diff -r -c src.p1/libMu/man/man3/MuErrorSync.3X src/libMu/man/man3/MuErrorSync.3X *** src.p1/libMu/man/man3/MuErrorSync.3X Wed May 15 15:54:13 1991 --- src/libMu/man/man3/MuErrorSync.3X Thu Dec 7 14:14:34 1989 *************** *** 0 **** --- 1,51 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuErrorSync 3X "November 27, 1989" + .UC 4 + .SH NAME + MuErrorSync, MuWarningSync \- easy dialog boxes with synchronous behavior. + .SH SYNOPSIS + .B #include + .PP + .B void MuErrorSync(str) + .br + .B char *str; + .PP + .B void MuWarningSync(str) + .br + .B char *str; + .SH DESCRIPTION + .I MuErrorSync + and + .I MuWarningSync + are synchronous versions of + .I MuError + and + .I MuWarning. + They pop up application modal error or warning dialog boxes and enter a + local event loop waiting for the user to click on the "Ok" button. To + the programmer, it appears as if the function call blocks waiting for + the user to popdown the dialog box. + .PP + These functions are useful only in special cases. In a fatal error + handler, for example, you can call + .I MuErrorSync + and then exit(). In most cases, the non-synchronous forms will be + sufficient (and preferred). + .SH SEE ALSO + MuError(3X), MuWarning(3X) + .SH BUGS + Because of a bug in the BulletinBoard widget, modal dialog boxes have + non-modal behavior under the obsolete + .I uwm + window manager. In this case it is sometimes possible for the user to + repeat the action that invoked MuGetString. This causes a "longjmp botch" + and crashes the program. The bug will hopefully be fixed in a future + release of Motif. In the meantime, if the call to MuGetBoolean was + triggered by a click on a button or a menu entry, you can simply cause + that button to be insensitive for the duration of the dialog, thereby + preventing the user from clicking on it again. + + + diff -r -c src.p1/libMu/man/man3/MuGetBoolean.3X src/libMu/man/man3/MuGetBoolean.3X *** src.p1/libMu/man/man3/MuGetBoolean.3X Wed May 15 15:54:14 1991 --- src/libMu/man/man3/MuGetBoolean.3X Thu Dec 7 16:46:58 1989 *************** *** 0 **** --- 1,86 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuGetBoolean 3X "November 27, 1989" + .UC 4 + .SH NAME + MuGetBoolean \- Ask the user a question and get a synchronous response. + .SH SYNOPSIS + .B #include + .PP + .B Boolean MuGetBoolean(prompt, yes, no, helptext, default) + .br + .B char *prompt, *yes, *no; + .br + .B char *helptext; + .br + .B Boolean default; + .SH DESCRIPTION + .I MuGetBoolean + uses an application modal message dialog convenience widget to + ask a question of the user and get a yes-or-no type answer. It returns + a Boolean indicating how the user responded. + Arguments are as follows: + .IP "prompt" 1i + The string to prompt the user with; the question to ask. + .IP "yes" 1i + The text that should appear in the "Yes" (True) button. + .IP "no" 1i + The text that should appear in the "No" (False) button. + .IP "helptext" 1i + The text to display if the user clicks on the "Help" button of the + dialog box. If NULL, no Help button will be displayed in the dialog + box. + .IP "default" 1i + A Boolean indicating which button should be the default. True means + that the "Yes" button should be the default, and False means that the + "No" button should be the default. Striking the Return key will + activate the default button. + + .PP + + Note that this function behaves "synchronously" -- it appears to the + programmer to block waiting for input, like a call to scanf() would. + The function does not return until the user responds to the question by + clicking on the "Yes" or the "No" button. Because the dialog box is + application modal, all other input to the application is blocked out + until the user has responded. This "synchronous" behavior violates the + standard X/Xt event driven programming model but is extremely convenient + at times. It is implemented by recursively invoking XtMainLoop() to + handle events for the dialog box, and then using longjmp() to jump out + of the recursive XtMainLoop() when one of the buttons is hit. + + .SH RETURN VALUE + Returns True if the user clicked on the "Yes" button, or False if the + user clicked on the "No" button. Note that this return value differs + from the return values for + .I MuGetString + and + .I MuGetFileName. + The return value for those functions indicates whether the "Ok" or the + "Cancel" button was pressed. + + .SH EXAMPLE + .nf + .nj + do + PlayTheGame(); + while (MuGetBoolean("Play again?","Yes, please","No, thanks",NULL,True)); + .fi + + .SH SEE ALSO + MuGetString(3X), MuGetFileName(3X) + + .SH BUGS + Because of a bug in the BulletinBoard widget, modal dialog boxes have + non-modal behavior under the obsolete + .I uwm + window manager. In this case it is sometimes possible for the user to + repeat the action that invoked MuGetString. This causes a "longjmp botch" + and crashes the program. The bug will hopefully be fixed in a future + release of Motif. In the meantime, if the call to MuGetBoolean was + triggered by a click on a button or a menu entry, you can simply cause + that button to be insensitive for the duration of the dialog, thereby + preventing the user from clicking on it again. + + diff -r -c src.p1/libMu/man/man3/MuGetFilename.3X src/libMu/man/man3/MuGetFilename.3X *** src.p1/libMu/man/man3/MuGetFilename.3X Wed May 15 15:54:15 1991 --- src/libMu/man/man3/MuGetFilename.3X Thu Dec 7 16:47:12 1989 *************** *** 0 **** --- 1,105 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuGetFileName 3X "November 27, 1989" + .UC 4 + .SH NAME + MuGetFileName \- Prompt for and get a filename synchronously. + .SH SYNOPSIS + .B #include + .PP + .B Boolean MuGetString(filebuf, filebufsize, maskbuf, maskbufsize, helptext) + .br + .B char *filebuf; + .br + .B int filebufsize; + .br + .B char *maskbuf; + .br + .B int maskbufsize; + .br + .B char *helptext; + .SH DESCRIPTION + .I MuGetFileName + uses an application modal file selection dialog convenience widget to + prompt the user to select a file. The filename is returned in a passed + buffer, and the function returns a Boolean indicating whether the "Ok" + or the "Cancel" button was pressed. + Arguments are as follows: + .IP "filebuf" 1i + A pointer to an array of characters. If the user clicks the "Ok" + button, her string is returned in this buffer. If she clicks "Cancel", + then the contents of this buffer are undefined. + .IP "filebufsize" 1i + The size in bytes of the filebuf buffer. The user will not be allowed + to enter a string longer than filebufsize - 1 characters. + .IP "maskbuf" 1i + On entry to + .I MuGetFileName, + this buffer should contain the directory + whose contents should be displayed in the file selection box. The file + selection box allows the user to edit this directory specification. On + exit from + .I MuGetFileName, + this buffer will reflect any changes the user has made to the directory + mask. The wild card characters '?' and '*' are allowed, as is the '~' + character which indicates the user's home directory. A typical default + setting for maskbuf might be "~/*.dat" Note that if the mask buf is + declared as a static variable which is only initialized once, then any + changes the user makes to it will remain across multiple invocations of + .I MuGetFileName. + .IP "maskbufsize" 1i + The size in bytes of the maskbuf buffer. The user will not be allowed + to enter a string for maskbuf which is longer than maskbufsize - 1 + characters. + .IP "helptext" 1i + The text to display if the user clicks on the "Help" button of the + dialog box. If NULL, no Help button will be displayed on the dialog box. + + .PP + Note that this function behaves "synchronously" -- it appears to the + programmer to block waiting for input, like a call to scanf() would. + The function does not return until the user clicks on the "Ok" or on the + "Cancel" button. Because the dialog box is application modal, all other + input to the application is blocked out until the user has responded. + This "synchronous" behavior violates the standard X/Xt event driven + programming model but is extremely convenient at times. It is + implemented by recursively invoking XtMainLoop() to handle events for the + dialog box, and then using longjmp() to jump out of the recursive + XtMainLoop() when either the "Ok" or "Cancel" buttons is hit. + + .SH RETURN VALUE + Returns True if the user clicked on the "Ok" button, or False if the + user clicked on the "Cancel" button. It is the responsibility of the + programmer to abort the operation in progress if the user clicks on + "Cancel". + + .SH EXAMPLE + .nf + .nj + #define BUFSIZE 50 + char filebuf[BUFSIZE]; + static char dirmask[BUFSIZE] = "~/*.plotdata" + Boolean result; + + result = MuGetString(filebuf,BUFSIZE, dirmask, BUFSIZE, NULL); + + if (result == True) PlotFile(filebuf); + .fi + + .SH SEE ALSO + MuGetBoolean(3X), MuGetString(3X) + + .SH BUGS + Because of a bug in the BulletinBoard widget, modal dialog boxes have + non-modal behavior under the obsolete + .I uwm + window manager. In this case it is sometimes possible for the user to + repeat the action that invoked MuGetString. This causes a "longjmp botch" + and crashes the program. The bug will hopefully be fixed in a future + release of Motif. In the meantime, if the call to MuGetFileName was + triggered by a click on a button or a menu entry, you can simply cause + that button to be insensitive for the duration of the dialog, thereby + preventing the user from clicking on it again. + + diff -r -c src.p1/libMu/man/man3/MuGetString.3X src/libMu/man/man3/MuGetString.3X *** src.p1/libMu/man/man3/MuGetString.3X Wed May 15 15:54:15 1991 --- src/libMu/man/man3/MuGetString.3X Thu Dec 7 16:48:01 1989 *************** *** 0 **** --- 1,91 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuGetString 3X "November 27, 1989" + .UC 4 + .SH NAME + MuGetString \- Prompt for and get a string synchronously. + .SH SYNOPSIS + .B #include + .PP + .B Boolean MuGetString(prompt, buffer, bufsize, helptext) + .br + .B char *prompt; + .br + .B char *buffer; + .br + .B int bufsize; + .br + .B char *helptext; + .SH DESCRIPTION + .I MuGetString + uses an application modal prompt dialog convenience widget to prompt the + user to input a string. The string is returned in a passed buffer, and + the function returns a Boolean indicating whether the "Ok" or the + "Cancel" button was pressed. + Arguments are as follows: + .IP "prompt" 1i + The string to prompt the user with. + .IP "buffer" 1i + A pointer to an array of characters. If the user clicks the "Ok" + button, his string is returned in this buffer. If the buffer contains + text when + .I MuGetString + is invoked, that text will be used as the default string. + .IP "bufsize" 1i + The size in bytes of the buffer. The user will not be allowed to enter + a string longer than bufsize - 1 characters. + .IP "helptext" 1i + The text to display if the user clicks on the "Help" button of the + dialog box. If NULL, no Help button will be displayed on the dialog box. + + .PP + + Note that this function behaves "synchronously" -- it appears to the + programmer to block waiting for input, like a call to scanf() would. + The function does not return until the user clicks on the "Ok" or on the + "Cancel" button. Because the dialog box is application modal, all other + input to the application is blocked out until the user has responded. + This "synchronous" behavior violates the standard X/Xt event driven + programming model but is extremely convenient at times. It is + implemented by recursively invoking XtMainLoop() to handle events for the + dialog box, and then using longjmp() to jump out of the recursive + XtMainLoop() when either the "Ok" or "Cancel" buttons is hit. + + .SH RETURN VALUE + Returns True if the user clicked on the "Ok" button, or False if the + user clicked on the "Cancel" button. It is the responsibility of the + programmer to abort the operation in progress if the user clicks on + "Cancel". + + .SH EXAMPLE + .nf + .nj + char pname[50]; + Boolean result; + + pname[0] = '\\0'; /* so we don't get garbage for a default */ + result = MuGetString("Enter printer name: ",pname, 50, + "You must supply the name of the printer that your\\n\\ + document is to be printed to. If you don't know\\n\\ + the name of the printer in your cluster, it should\\n\\ + be displayed on the printer itself."); + if (result == True) PrintDocument(pname); + .fi + + .SH SEE ALSO + MuGetBoolean(3X), MuGetFileName(3X) + + .SH BUGS + Because of a bug in the BulletinBoard widget, modal dialog boxes have + non-modal behavior under the obsolete + .I uwm + window manager. In this case it is sometimes possible for the user to + repeat the action that invoked MuGetString. This causes a "longjmp botch" + and crashes the program. The bug will hopefully be fixed in a future + release of Motif. In the meantime, if the call to MuGetString was + triggered by a click on a button or a menu entry, you can simply cause + that button to be insensitive for the duration of the dialog, thereby + preventing the user from clicking on it again. + + diff -r -c src.p1/libMu/man/man3/MuHelp.3X src/libMu/man/man3/MuHelp.3X *** src.p1/libMu/man/man3/MuHelp.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuHelp.3X Mon Nov 27 12:02:56 1989 *************** *** 0 **** --- 1 ---- + .so man3/MuError.3X diff -r -c src.p1/libMu/man/man3/MuHelpFile.3X src/libMu/man/man3/MuHelpFile.3X *** src.p1/libMu/man/man3/MuHelpFile.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuHelpFile.3X Tue Dec 19 12:11:05 1989 *************** *** 0 **** --- 1,39 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuHelpFile 3X "November 27, 1989" + .UC 4 + .SH NAME + MuHelpFile \- display the contents of a help file. + .SH SYNOPSIS (C) + .B #include + .PP + .B MuHelpFile(filename) + .br + .B char *filename; + .SH SYNOPSIS (UIL) + .B procedure + .br + .B MuHelpFile(string); + .SH DESCRIPTION + .I MuHelpFile + reads the contents of the named file into a string and calls + .I MuHelp + passing it that string. + .SH ERRORS + If the named file does not exist or is not readable, this function + displays an error dialog box containing an explanatory error message. + .SH STATUS + This function provides a very primitive online help capability. + If and when something more sophisticated is developed (scrolling, + multiple fonts?, hypertext?) this function will invoke it + (rather than the simple MuHelp) in a backwardly compatable way. + .SH SEE ALSO + MuHelp(3X) + .SH BUGS + Currently the helpfile appears in an unscrolled information dialog box. + The dialog box will grow in size to accomodate all the lines in the help + file. If the file is too long, the dialog box will be bigger than the + screen. + + diff -r -c src.p1/libMu/man/man3/MuInitialize.3X src/libMu/man/man3/MuInitialize.3X *** src.p1/libMu/man/man3/MuInitialize.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuInitialize.3X Wed Nov 22 17:00:55 1989 *************** *** 0 **** --- 1,36 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuInitialize 3X "November 22, 1989" + .UC 4 + .SH NAME + MuInitialize \- Initialize the Motif Utility routines. + .SH SYNOPSIS + .B #include + .PP + .B void MuInitialize(toplevel) + .br + .B Widget toplevel; + .SH DESCRIPTION + .I MuInitialize + does all necessary initialization required for the functions in the + Motif Utilities library. It should be called before any other Motif + Utilities functions. It saves a copy of the toplevel + shell widget passed to it. This widget is used as the parent of any + popup dialog widgets created by other Mu routines. + .PP + .I MuInitialize + takes a single argument, which should be a pointer to the application's + toplevel shell widget returned by the call to XtInitialize() + widget. + .SH EXAMPLE + .nf + .nj + Widget toplevel; + .PP + toplevel = XtInitialize("xtest","XTest",NULL,0,&argc,argv); + MuInitialize(toplevel); + .fi + + + diff -r -c src.p1/libMu/man/man3/MuLookupWidget.3X src/libMu/man/man3/MuLookupWidget.3X *** src.p1/libMu/man/man3/MuLookupWidget.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuLookupWidget.3X Thu Dec 7 15:07:12 1989 *************** *** 0 **** --- 1 ---- + .so man3/MuRegisterWidget.3X diff -r -c src.p1/libMu/man/man3/MuRegisterNames.3X src/libMu/man/man3/MuRegisterNames.3X *** src.p1/libMu/man/man3/MuRegisterNames.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuRegisterNames.3X Tue Dec 19 12:07:32 1989 *************** *** 0 **** --- 1,56 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuRegisterNames 3X "November 22, 1989" + .UC 4 + .SH NAME + MuRegisterNames \- Make Motif Utility functions available to UIL code + .SH SYNOPSIS + .B #include + .PP + .B void MuRegisterNames() + .SH DESCRIPTION + .I MuRegisterNames + calls the function + .I MrmRegisterNames + to register many of the Mu routines + with the Mrm library. This makes those routines available for use as + callbacks from UIL code. + .I MuRegisterNames + must be called before any widgets are fetched with + .I MrmFetchWidget. + .PP + .IMuRegisterNames registers names both with the normal capitalization + as described here, and also names in all capital letters, for + use with UIL programs written in case insensitive mode. + + Note that calling + .IMuRegisterNames + causes your program to be linked with almost all of the Motif + Utilities library. Do not call it if you are not using UIL. + .PP + The functions registered are: + .br + MuHelp + .br + MuError + .br + MuWarning + .br + MuHelpFile + .br + MuSetEmacsBindings + .br + MuSetStandardCursor + .br + MuSetWaitCursor + .br + MuRegisterWidget + .br + see the man pages for these functions for information on how to use them + from UIL. + + .SH SEE ALSO + MrmRegisterNames(3), MrmFetchWidget(3) + + diff -r -c src.p1/libMu/man/man3/MuRegisterWidget.3X src/libMu/man/man3/MuRegisterWidget.3X *** src.p1/libMu/man/man3/MuRegisterWidget.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuRegisterWidget.3X Thu Dec 7 16:49:16 1989 *************** *** 0 **** --- 1,77 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuRegisterWidget 3X "November 27, 1989" "foobar" + .UC 4 + .SH NAME + MuRegisterWidget, MuLookupWidget \- Pass widget IDs between UIL and C + .SH SYNOPSIS (C) + .B #include + .PP + .B void MuRegisterWidget(w, name) + .br + .B Widget w; + .br + .B char *name; + .PP + .B Widget MuLookupWidget(name) + .br + .B char *name; + .SH SYNOPSIS (UIL) + .B procedure + .br + .B MuRegisterWidget(string) + .SH DESCRIPTION + These functions are designed to allow easy communication of widgets + between UIL code and C code. Call + .I MuRegisterWidget + as a creation callback from UIL, passing whatever name you choose for + that widget. Then you can call + .I MuLookupWidget + with that name from your C code to get the widget itself. + .PP + Another use for these functions is in specifying callbacks from UIL. + It is not possible in the current implementation of UIL to pass a Widget + directly as the argument to a callback function. If you have registered + a name for a widget, though, you can pass the name of the widget as the + callback argument and look up the widget inside the callback. + .PP + It is possible to call MuRegisterWidget from C. This may be useful + on occasion to pass widget IDs across module boundaries without using + global variables. + .PP + These procedures use a hash table to store the widget/name pairs. This + makes looking up a widget an inexpensive operation. + .PP + An alternative approach to looking up widgets is to use the + .I XtNameToWidget + function, but this requires knowing the full hierarchial name of the + widget. Since some parts of this name may be created automatically by + convenience functions, the C programmer will not always know the name of + the widget. + .SH ERRORS + MuRegisterWidget will issue an Xt warning if you register two widgets + with the same name. + .SH EXAMPLE + .nf + .nj + ! + ! UIL code + ! + object message_line : XmText { + callbacks { + XmNcreateCallback = procedure MuRegisterWidget('message_line'); + }; + }; + + /* + * C code + */ + Widget w; + + w = MuGetWidget("message_line"); + + .fi + + + diff -r -c src.p1/libMu/man/man3/MuSetEmacsBindings.3X src/libMu/man/man3/MuSetEmacsBindings.3X *** src.p1/libMu/man/man3/MuSetEmacsBindings.3X Wed May 15 15:54:16 1991 --- src/libMu/man/man3/MuSetEmacsBindings.3X Tue Dec 19 12:26:23 1989 *************** *** 0 **** --- 1,99 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuSetEmacsBindings 3X "November 27, 1989" + .UC 4 + .SH NAME + MuSetEmacsBindings \- Make the text widget + do familiar things. + .SH SYNOPSIS (C) + .B #include + .PP + .B MuSetEmacsBindings(w) + .br + .B Widget w; + .SH SYNOPSIS (UIL) + .B procedure + .br + .B MuSetEmacsBindings(); + .SH DESCRIPTION + .I MuSetEmacsBindings + overrides the translations table of a text widget to make it respond to + keystrokes like the Emacs text editor does. Wherever possible, the + original Motif bindings are left unmodified. It takes a text + widget as its single argument. From UIL, it is designed to be used + as a creation callback. No argument is required because it operates on + the widget for which the callback is invoked. Due to a bug in the + default translations for the Motif Text widget, the backspace key + doesn't behave correctly on our platforms. Calling this function is one + easy way to correct this situation. + + .PP + .I MuSetEmacsBindings + sets the following translations for multi-line text widgets: + .nf + .nj + Delete: delete-previous-character() + MetaDelete: kill-previous-word() + CtrlD: delete-next-character() + MetaD: kill-next-word() + CtrlK: kill-to-end-of-line() + CtrlW: kill-selection() + CtrlY: unkill() + CtrlF: forward-character() + CtrlB: backward-character() + MetaF: forward-word() + MetaB: backward-word() + Meta]: forward-paragraph() + Meta[: backward-paragraph() + CtrlA: beginning-of-line() + CtrlE: end-of-line() + CtrlN: next-line() + CtrlP: previous-line() + CtrlV: next-page() + MetaV: previous-page() + Meta<: beginning-of-file() + Meta>: end-of-file() + CtrlL: redraw-display() + CtrlM: newline() + CtrlJ: newline() + Return: newline() + .fi + .PP + It sets the following translations for single line text widgets. + .nf + .nj + Delete: delete-previous-character() + MetaDelete: kill-previous-word() + CtrlD: delete-next-character() + MetaD: kill-next-word() + CtrlK: kill-to-end-of-line() + CtrlW: kill-selection() + CtrlY: unkill() + CtrlF: forward-character() + CtrlB: backward-character() + CtrlA: beginning-of-line() + CtrlE: end-of-line() + MetaF: forward-word() + MetaB: backward-word() + .fi + .SH EXAMPLE + .nf + .nj + callbacks { + XmNcreateCallback = procedure MuSetEmacsBindings(); + }; + .fi + + .SH SEE ALSO + XmText(3X) + + .SH BUGS + Using this function may compromise the compatibility of your + application with other standard Motif applications. Using it also + "hard-codes" the translations so that they cannot be overriden by the + user of the application. A better (but less convenient) approach is to + include the translations listed above in the app-defaults file for your + application. + + diff -r -c src.p1/libMu/man/man3/MuSetStandardCursor.3X src/libMu/man/man3/MuSetStandardCursor.3X *** src.p1/libMu/man/man3/MuSetStandardCursor.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/MuSetStandardCursor.3X Wed Nov 22 17:16:33 1989 *************** *** 0 **** --- 1,2 ---- + .so man3/MuSetWaitCursor.3X + diff -r -c src.p1/libMu/man/man3/MuSetTextTraversal.3X src/libMu/man/man3/MuSetTextTraversal.3X *** src.p1/libMu/man/man3/MuSetTextTraversal.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/MuSetTextTraversal.3X Thu Dec 7 17:01:31 1989 *************** *** 0 **** --- 1,78 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuSetTextTraversal 3X "November 27, 1989" + .UC 4 + .SH NAME + MuSetTextTraversal \- bind arrow keys to traverse between input fields. + .SH SYNOPSIS + .B #include + .PP + .B void MuSetTextTraversal(widgets, n, subtree) + .br + .B Widget *widgets; + .br + .B int n; + .br + .B Widget subtree; + + .SH DESCRIPTION + .I MuSetTextTraversal + enables keyboard traversal between a group of single line text widgets + using the up and down arrow keys and the return key. The arguments are + as follows: + .IP "widgets" 1i + An array of single line text widgets. + .IP "n" 1i + The number of widgets in the array. + .IP "subtree" 1i + A widget which specifies a subtree of the widget hierarchy of your + application for which input focus is to be redirected to the single line + text widgets. When focus is set to one of the text widgets, that widget + will get all keyboard input while the mouse is within the subtree. All + the text widgets specified must be members of the subtree. In simple + applications, the subtree will often be the entire application, and the + shell widget will be specified for this argument. + .PP + After calling this function, pressing the down arrow return key in one + of the input fields will set the focus to the "next" input field (the + text widget specified after the current one in the array). Pressing the + up arrow key will set focus to the "previous" (the text widget specified + before the current one in the array) input field. + .PP + Input fields which have been made insensitive will be skipped over in + the traversal. + .PP + The up and down arrow keys all invoke the Activate action + before they invoke the action to change the input focus. The Activate + action calls the procedures registered on the XmNactivateCallback list. + This is done for reasons of symmetry, but it means that the activate + callback procedures may be called before the user has actually entered + anything into the field. In general, it doesn't make sense to register + callbacks on text widgets that are have traversal enabled with + .I MuSetTextTraversal. + .PP + Multiple calls to this function will produce groups of widgets that + traverse independently of one another. + .PP + .I MuSetTextTraversal + is not the same as the keyboard focus traversal done with the function + XmAddTabGroup(). + .SH EXAMPLE + .nf + .nj + Widget toplevel; /* the shell widget; the top of the hierarchy */ + Widget filename_widget, printername_widget, options_widget; + Widget widget_list[3]; + + widget_list[0] = filename_widget; + widget_list[1] = printername_widget; + widget_list[2] = options_widget; + + MuSetTextTraversal(widget_list, XtNumber(widget_list), toplevel); + .fi + .SH SEE ALSO + XtSetKeyboardFocus(3X) + + + diff -r -c src.p1/libMu/man/man3/MuSetWaitCursor.3X src/libMu/man/man3/MuSetWaitCursor.3X *** src.p1/libMu/man/man3/MuSetWaitCursor.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/MuSetWaitCursor.3X Fri Dec 8 15:11:21 1989 *************** *** 0 **** --- 1,57 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH MuSetWaitCursor 3X "November 22, 1989" + .UC 4 + .SH NAME + MuSetWaitCursor, MuSetStandardCursor \- change the mouse pointer to a + "please wait" indicator and back. + .SH SYNOPSIS (C) + #include + .PP + .B void MuSetWaitCursor(w) + .br + .B Widget w; + .PP + .B void MuSetStandardCursor(w) + .br + .B Widget w; + .SH SYNOPSIS (UIL) + .B procedure + .br + .B MuSetWaitCursor(); + .br + .B MuSetStandardCursor(); + .SH DESCRIPTION + In their C form these functions take a widget as their only argument. + As callbacks from UIL, they use the widget on which the callback + occured. In both forms, they trace the widget's ancestors until they + find a shell widget. They then call + .I XDefineCursor + on the window of the shell widget to set the cursor to a wristwatch or + an arrow pointing to the upper left. + + It is a good idea to call + .I MuSetStandardCursor + on all the shell widgets of your application. Otherwise the cursor + might not get correctly set under some window managers. + + These functions are particularly useful when called from UIL, as the + example below demonstrates. + .SH EXAMPLE + .nf + .nj + callbacks { + XmNcreateCallback = procedure MuSetStandardCursor(); + XmNactivateCallback = procdures { + MuSetWaitCursor(); + SomethingTimeConsuming(); + MuSetStandardCursor(); + }; + }; + .fi + .SH SEE ALSO + XCreateFontCursor(3X11), XDefineCursor(3X11) + + + diff -r -c src.p1/libMu/man/man3/MuWarning.3X src/libMu/man/man3/MuWarning.3X *** src.p1/libMu/man/man3/MuWarning.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/MuWarning.3X Mon Nov 27 12:02:38 1989 *************** *** 0 **** --- 1 ---- + .so man3/MuError.3X diff -r -c src.p1/libMu/man/man3/MuWarningSync.3X src/libMu/man/man3/MuWarningSync.3X *** src.p1/libMu/man/man3/MuWarningSync.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/MuWarningSync.3X Thu Dec 7 14:16:04 1989 *************** *** 0 **** --- 1 ---- + .so man3/MuErrorSync.3X diff -r -c src.p1/libMu/man/man3/libMu.3X src/libMu/man/man3/libMu.3X *** src.p1/libMu/man/man3/libMu.3X Wed May 15 15:54:17 1991 --- src/libMu/man/man3/libMu.3X Tue Dec 19 13:14:35 1989 *************** *** 0 **** --- 1,76 ---- + .\" ** + .\" ** (c) Copyright 1989 Massachusetts Institiute of Technology + .\" ** + .TH libMu.a 3X "November 27, 1989" + .UC 4 + .SH NAME + libMu.a \- a library of Motif utilities. + .SH DESCRIPTION + The + .I libMu.a + library is a collection of utility routines that make writing programs + with the Motif widget set easier. Many of them are designed to be used + from C or from UIL programs. Before calling any of them, you must call + .I MuInitialize() + with your toplevel shell widget as its single argument. If + you plan to use any of the Mu routines from a UIL program, your C code + must call + .I MuRegisterNames(). + .PP + The routines in the library are the following: + + .IP "MuError, MuWarning, MuHelp (3X)" 2in + popup easy dialog boxes. + .IP "MuErrorSync, MuWarningSync (3X)" 2in + easy dialog boxes with synchronous behavior. + .IP "MuGetBoolean (3X)" 2in + Ask the user a question and get a synchronous response + .IP "MuGetFileName (3X)" 2in + Prompt for and get a filename synchronously. + .IP "MuGetString (3X)" 2in + Prompt for and get a string synchronously. + .IP "MuHelpFile (3X)" 2in + display the contents of a help file. + .IP "MuInitialize (3X)" 2in + Initialize the Motif Utility routines. + .IP "MuRegisterNames (3X)" 2in + Make Motif Utility functions available to UIL code + .IP "MuRegisterWidget, MuLookupWidget (3X)" 2in + Pass widget IDs between UIL and C + .IP "MuSetEmacsBindings (3X)" 2in + Make the text widget do familiar things. + .IP "MuSetTextTraversal (3X)" 2in + bind arrow keys to traverse between input fields. + .IP "MuSetWaitCursor, MuSetStandardCursor (3X)" 2in + change the mouse pointer to a "please wait" indicator and back. + + .SH STATUS + The Motif Utilities library is still evolving. Suggestions for new + routines are welcome. Send them to: + .I djf@athena.mit.edu + + .SH BUGS + The library was designed for applications with a single toplevel shell + window. Applications that have multiple top level windows will have + problems with any of the dialog box routines, because it is not + possible to specify which shell to pop the dialog box up over. A + redesign of the library could fix this problem and retain backwards + compatabilty, but this change is not planned for the near future. + .PP + Please report any bugs you find to + .I bugs@athena.mit.edu + Carbon copy + .I djf@athena.mit.edu + and + .I vanharen@athena.mit.edu + on the bug report. + + .SH AUTHORS + The Motif Utilities library was designed and written at MIT Project + Athena by David Flanagan, Chris VanHaren and Hyun-Ju Vega. It is + provided on an "as is" basis. + .PP + Copyright (C) 1989 Massachusetts Institute of Technology + + + diff -r -c src.p1/server/writed/Imakefile src/server/writed/Imakefile *** src.p1/server/writed/Imakefile Wed May 15 16:01:57 1991 --- src/server/writed/Imakefile Wed May 15 12:48:50 1991 *************** *** 1,24 **** # ! # $Id: Imakefile,v 1.3 91/05/08 11:06:57 lwvanels Exp $ # $Source: /afs/athena.mit.edu/astaff/project/olcdev/src/server/writed/RCS/Imakefile,v $ # Copyright (C) 1991 by the Massachusetts Institute of Technology. # For copying and distribution information, see the file "mit-copyright.h". # ! SRCS = writed.c ! OBJS = writed.o ! NormalProgramTarget(writed,$(OBJS),,,) ! SaberProgramTarget(writed,$(SRCS),$(OBJS),,) DependSrcs() LintTarget() #ifdef InstallAltLoc ! InstallProgram(writed,$(DESTDIR)/etc/athena) #else InstallProgram(writed,$(DESTDIR)/etc) #endif ! AllTarget(writed) --- 1,31 ---- # ! # $Id: Imakefile,v 1.4 91/05/15 12:35:20 lwvanels Exp $ # $Source: /afs/athena.mit.edu/astaff/project/olcdev/src/server/writed/RCS/Imakefile,v $ # Copyright (C) 1991 by the Massachusetts Institute of Technology. # For copying and distribution information, see the file "mit-copyright.h". # ! D_SRCS = writed.c ! D_OBJS = writed.o ! C_SRCS = write.c ! C_OBJS = write.o ! NormalProgramTarget(writed,$(D_OBJS),,,) ! SaberProgramTarget(writed,$(D_SRCS),$(D_OBJS),,) + NormalProgramTarget(write,$(C_OBJS),,,) + SaberProgramTarget(write,$(C_SRCS),$(C_OBJS),,) + DependSrcs() LintTarget() #ifdef InstallAltLoc ! InstallProgram(writed,$(DESTDIR)/usr/athena/etc) ! InstallProgramWithFlags(write,$(DESTDIR)/usr/athena/bin,-g tty -m 2755) #else InstallProgram(writed,$(DESTDIR)/etc) + InstallProgramWithFlags(write,$(DESTDIR)/bin,-g tty -m 2755) #endif ! AllTarget(writed write) diff -r -c src.p1/server/writed/write.c src/server/writed/write.c *** src.p1/server/writed/write.c Wed May 15 16:21:45 1991 --- src/server/writed/write.c Wed May 15 16:13:45 1991 *************** *** 0 **** --- 1,418 ---- + /* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms are permitted provided + * that: (1) source distributions retain this entire copyright notice and + * comment, and (2) distributions including binaries display the following + * acknowledgement: ``This product includes software developed by the + * University of California, Berkeley and its contributors'' in the + * documentation or other materials provided with the distribution and in + * all advertising materials mentioning features or use of this software. + * Neither the name of the University nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + + /* + * Copyright (c) by the Massachusetts Institute of Technology + */ + + #include + + /* + * $Source: /afs/athena.mit.edu/astaff/project/olcdev/src/server/writed/RCS/write.c,v $ + * $Header: /afs/athena.mit.edu/astaff/project/olcdev/src/server/writed/RCS/write.c,v 1.1 91/05/15 12:36:40 lwvanels Exp $ + */ + + #ifndef lint + static char *rcsid_write_c = "$Header: /afs/athena.mit.edu/astaff/project/olcdev/src/server/writed/RCS/write.c,v 1.1 91/05/15 12:36:40 lwvanels Exp $"; + #endif lint + + #ifndef lint + static char *sccsid = "@(#)write.c 4.13 3/13/86"; + #endif + /* + * write to another user + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #define NMAX sizeof(ubuf.ut_name) + #define LMAX sizeof(ubuf.ut_line) + + char *strcat(); + char *strcpy(); + struct utmp ubuf; + int signum[] = {SIGHUP, SIGINT, SIGQUIT, 0}; + char mebuf[NMAX + 1] = "???"; + char *me; + char *him; + int netme = 0; + int nethim = 0; + char *mytty; + char histty[32]; + char ttybuf[32]; + char *histtya; + char myhost[32]; + char *hishost; + struct hostent *hp; + struct servent *sp; + struct sockaddr_in sin; + int fds; + char buf[128]; + struct passwd *pwdent; + FILE *tf; + int logcnt; + char *ttyname(); + char *rindex(); + int eof(); + int timout(); + char *getenv(); + + #ifdef _AIX + #define setpgrp setpgid + #endif + + main(argc, argv) + int argc; + char *argv[]; + { + struct stat stbuf; + register i; + register FILE *uf; + int c1, c2; + long clock = time(0); + int suser = getuid() == 0; + int nomesg = 0; + struct tm *localtime(); + struct tm *localclock = localtime( &clock ); + + me = mebuf; + if ((argc > 3) && (getuid() == 0) && + (strcmp("-f", argv[1]) == 0) && + (mytty = rindex(argv[2], '@'))) { + me = argv[2]; + *mytty++ = '\0'; + netme = 1; + argc -= 2; + argv += 2; + } + if (argc < 2 || argc > 3) { + fprintf(stderr, "Usage: write user [ttyname]\n"); + exit(1); + } + him = argv[1]; + if ((!netme) && (hishost = rindex(him, '@'))) { + *hishost++ = '\0'; + hp = gethostbyname(hishost); + if (hp == NULL) { + static struct hostent def; + static struct in_addr defaddr; + static char namebuf[128]; + int inet_addr(); + + defaddr.s_addr = inet_addr(hishost); + if (defaddr.s_addr == -1) { + printf("unknown host: %s\n", hishost); + exit(1); + } + strcpy(namebuf, hishost); + def.h_name = namebuf; + def.h_addr = (char *)&defaddr; + def.h_length = sizeof (struct in_addr); + def.h_addrtype = AF_INET; + def.h_aliases = 0; + hp = &def; + } + nethim = 1; + } + + if (argc == 3) + histtya = argv[2]; + if ((uf = fopen("/etc/utmp", "r")) == NULL) { + perror("write: Can't open /etc/utmp"); + if (histtya == 0) + exit(10); + goto cont; + } + if (!netme) { + mytty = ttyname(2); + if (mytty == NULL) { + fprintf(stderr, "write: Can't find your tty\n"); + exit(1); + } + if (stat(mytty, &stbuf) < 0) { + perror("write: Can't stat your tty"); + exit(1); + } + if ((stbuf.st_mode&020) == 0) { + fprintf(stderr, + "write: You have write permission turned off\n"); + if (!suser) + exit(1); + } + mytty = rindex(mytty, '/') + 1; + } + if (histtya) { + strcpy(histty, "/dev/"); + strcat(histty, histtya); + } + while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) { + if (ubuf.ut_name[0] == '\0') + continue; + if ((!netme) && strcmp(ubuf.ut_line, mytty)==0) { + for (i=0; i 1) { + fprintf(stderr, + "write: %s logged in more than once ... writing to %s\n", + him, histty+5); + } + #ifdef _AIX + /* This appears to flush the stderr buffer on the PS/2 so that + both sides of the connection don't receive the message. + Wierd. - Ezra */ + fflush(stderr); + #endif + } + cont: + fclose(uf); + if((!netme) && (mebuf[0] == '?')) { + pwdent = getpwuid(getuid()); + if (pwdent == NULL) { + printf("You don't exist. Go away.\n"); + exit(-1); + } + strcpy(mebuf, pwdent->pw_name); + } + if (nethim) { + sp = getservbyname("write", "tcp"); + if (sp == 0) { + printf("tcp/write: unknown service\n"); + exit(1); + } + sin.sin_family = hp->h_addrtype; + bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); + sin.sin_port = sp->s_port; + fds = socket(hp->h_addrtype, SOCK_STREAM, 0); + if (fds < 0) { + perror("socket"); + exit(1); + } + if (connect(fds, (char *)&sin, sizeof (sin)) < 0) { + perror("connect"); + close(fds); + exit(1); + } + + write(fds, me, strlen(me)); + write(fds, "@", 1); + gethostname(myhost, sizeof (myhost)); + write(fds, myhost, strlen(myhost)); + write(fds, " ", 1); + write(fds, him, strlen(him)); + if (histtya) { + write(fds, " ", 1); + write(fds, histtya, strlen(histtya)); + } + write(fds, "\r\n", 2); + sigs(eof); + tf = fdopen(fds, "r+"); + while (1) { + if (fgets(buf, sizeof(buf), tf) == NULL) exit(1); + if (buf[0] == '\n') break; + write(1, buf, strlen(buf)); + } + } else { + if (access(histty, 0) < 0) { + fprintf(stderr, "write: No such tty\n"); + exit(1); + } + signal(SIGALRM, timout); + alarm(5); + #ifndef ultrix + if (setpgrp(0,0)) + perror("setpgrp 0"); + #endif + if (stat(histty, &stbuf) < 0 || (stbuf.st_mode&020) == 0 + || (tf = fopen(histty, "w")) == NULL) { + fprintf(stderr, "write: Permission denied\n"); + exit(1); + } + if (setpgrp(0,getpid())) + perror("setpgrp !0"); + alarm(0); + sigs(eof); + if (netme) { + printf("\n"); + fflush(stdout); + fprintf(tf, + "\r\nMessage from %s on %s at %d:%02d ...\r\n\007\007\007", + me, mytty, localclock->tm_hour, localclock->tm_min); + } else + { char hostname[32]; + gethostname(hostname, sizeof (hostname)); + fprintf(tf, + "\r\nMessage from %s@%s on %s at %d:%02d ...\r\n\007\007\007", + me, hostname, mytty, localclock->tm_hour, localclock->tm_min); + } + fflush(tf); + fds = fileno(tf); + + } + for (;;) { + char buf[BUFSIZ]; + register char *bp; + i = read(0, buf, sizeof buf); + if (i <= 0) + eof(); + if ((!netme) && buf[0] == '!') { + buf[i] = 0; + ex(buf); + continue; + } + for (bp = buf; --i >= 0; bp++) { + if (*bp == '\n') + putc('\r', tf); + + if (!isascii(*bp)) { + putc('M', tf); + putc('-', tf); + *bp = toascii(*bp); + } + + if (isprint(*bp) || + *bp == ' ' || *bp == '\t' || *bp == '\n' + || *bp == '\r') { + putc(*bp, tf); + } else { + putc('^', tf); + putc(*bp ^ 0100, tf); + } + + if (*bp == '\n') + fflush(tf); + + if (ferror(tf) || feof(tf)) { + printf("\n\007Write failed (%s logged out?)\n", + him); + exit(1); + } + } + } + } + + timout() + { + + fprintf(stderr, "write: Timeout opening their tty\n"); + exit(1); + } + + eof() + { + + if (!nethim) { + fprintf(tf, "EOF\r\n"); + fflush(tf); + } + exit(0); + } + + ex(bp) + char *bp; + { + register int i; + + sigs(SIG_IGN); + i = fork(); + if (i < 0) { + printf("Try again\n"); + goto out; + } + if (i == 0) { + fclose(tf); /* Close his terminal */ + setgid(getgid()); /* Give up effective group privs */ + sigs((int (*)())0); + execl(getenv("SHELL") ? + getenv("SHELL") : "/bin/sh", "sh", "-c", bp+1, 0); + exit(0); + } + while (wait((int *)NULL) != i) + ; + printf("!\n"); + out: + sigs(eof); + } + + sigs(sig) + int (*sig)(); + { + register int i; + + for (i=0; signum[i]; i++) + signal(signum[i], sig); + }