*** DialogF.c 1997/09/26 18:28:17 1.1 --- DialogF.c 1997/10/10 00:14:09 1.2 *************** *** 24,26 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)DialogF.c 1.10 10/3/96"; #include --- 24,26 ---- *******************************************************************************/ ! #include #include *************** *** 36,38 **** #include "DialogF.h" ! #define NUM_DIALOGS_SUPPORTED 6 #define NUM_BUTTONS_SUPPORTED 3 /* except prompt dialog */ --- 36,38 ---- #include "DialogF.h" ! #define NUM_DIALOGS_SUPPORTED 7 #define NUM_BUTTONS_SUPPORTED 3 /* except prompt dialog */ *************** *** 91,93 **** * (refer to DialogF.h for dialog type values) * ! * Widget parent - parent widget ID * * unsigned n - # of buttons to display * --- 91,93 ---- * (refer to DialogF.h for dialog type values) * ! * Widget parent - parent widget ID * * unsigned n - # of buttons to display * *************** *** 98,100 **** * specifications for vsprintf) * ! * char * input_string - if dialog type = DF_PROMPT, then: * * a character string array in which to put * --- 98,103 ---- * specifications for vsprintf) * ! * char * initial_value - if dialog type = DF_PROMPT2, then: * ! * A string that contains the initial value for * ! * the text field. ! * char * input_string - if dialog type = DF_PROMPT, then: * * a character string array in which to put * *************** *** 103,105 **** * dialog types. * ! * char * but_lbl - button label(s) for buttons requested * * (if n > 0, one but_lbl argument per button) * --- 106,108 ---- * dialog types. * ! * char * but_lbl - button label(s) for buttons requested * * (if n > 0, one but_lbl argument per button) * *************** *** 117,118 **** --- 120,123 ---- * new_sub_category, categories[i]); * + * but_pressed = DialogF (DF_PROMPT2, toplevel, 0, categories[i], "New %s", * + * new_sub_category, categories[i]); * */ *************** *** 130,134 **** char *but_lbl, *input_string, *input_string_ptr; int argcount, num_but_lbls = 0, i, but_index, cancel_index = -1; Arg args[256]; ! struct dfcallbackstruct df; --- 135,141 ---- char *but_lbl, *input_string, *input_string_ptr; + char *initial_value = 0; int argcount, num_but_lbls = 0, i, but_index, cancel_index = -1; Arg args[256]; ! XmString textstr_xms = 0; ! struct dfcallbackstruct df; *************** *** 163,165 **** dialog_num = dialog_type - 1; ! prompt = (dialog_type == DF_PROMPT); if (!prompt && (n > NUM_BUTTONS_SUPPORTED) || --- 170,172 ---- dialog_num = dialog_type - 1; ! prompt = (dialog_type == DF_PROMPT || dialog_type == DF_PROMPT2); if (!prompt && (n > NUM_BUTTONS_SUPPORTED) || *************** *** 173,176 **** if (prompt) { /* Get where to put dialog input string */ ! input_string = va_arg(var, char*); } --- 180,186 ---- + if (dialog_type == DF_PROMPT2) { + initial_value = va_arg(var, char*); + } if (prompt) { /* Get where to put dialog input string */ ! input_string = va_arg(var, char*); } *************** *** 201,273 **** if (prompt) { /* Prompt dialog */ ! XtSetArg (args[argcount], XmNselectionLabelString, msgstr_xms); ! argcount++; ! XtSetArg (args[argcount], XmNdialogTitle, titstr_xms); ! argcount++; #ifdef MOTIF10 ! XtSetArg (args[argcount], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ! argcount ++; #else ! XtSetArg (args[argcount], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); ! argcount ++; #endif ! dialog = XmCreatePromptDialog (parent, dialog_name[dialog_num], args, ! argcount); ! XtAddCallback (dialog, XmNokCallback, (XtCallbackProc)ok_callback, ! (char *)&df); ! XtAddCallback (dialog, XmNcancelCallback, ! (XtCallbackProc)cancel_callback, (char *)&df); ! XtAddCallback (dialog, XmNhelpCallback, (XtCallbackProc)help_callback, ! (char *)&df); ! XtAddCallback (dialog, XmNapplyCallback, (XtCallbackProc)apply_callback, ! (char *)&df); ! RemapDeleteKey(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT)); ! ! /* Text area in prompt dialog should get focus, not ok button ! since user enters text first. To fix this, we need to turn ! off the default button for the dialog, until after keyboard ! focus has been established */ ! XtVaSetValues(dialog, XmNdefaultButton, NULL, 0); ! XtAddCallback(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmNfocusCallback, (XtCallbackProc)focusCB, (char *)dialog); ! ! /* Limit the length of the text that can be entered in text field */ ! XtVaSetValues(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmNmaxLength, DF_MAX_PROMPT_LENGTH-1, 0); ! ! /* Turn on the requested number of buttons in the dialog by ! managing/unmanaging the button widgets */ ! switch (n) { /* number of buttons requested */ ! case 0: case 3: ! break; /* or default of 3 buttons */ ! case 1: ! XtUnmanageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_CANCEL_BUTTON) ); ! case 2: ! XtUnmanageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_HELP_BUTTON) ); ! break; ! case 4: ! XtManageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_APPLY_BUTTON) ); ! df.apply_up = 1; /* apply button managed */ ! default: ! break; ! } /* end switch */ - /* If the button labeled cancel or dismiss is not the cancel button, or - if there is no button labeled cancel or dismiss, redirect escape key - events (this is necessary because the XmNcancelButton resource in - the bulletin board widget class is blocked from being reset) */ - if (cancel_index == -1) - addEscapeHandler(dialog, NULL, 0); - else if (cancel_index != CANCEL_BTN) - addEscapeHandler(dialog, &df, cancel_index); - - /* Add a callback to the window manager close callback for the dialog */ - AddMotifCloseCallback(XtParent(dialog), - (XtCallbackProc)(cancel_index == APPLY_BTN ? apply_callback : - (cancel_index == CANCEL_BTN ? cancel_callback : - (cancel_index == HELP_BTN ? help_callback : ok_callback))), &df); - /* A previous call to SetDialogFPromptHistory can request that an --- 211,292 ---- if (prompt) { /* Prompt dialog */ ! if(initial_value) { ! textstr_xms = XmStringCreateLtoR (initial_value, XmSTRING_DEFAULT_CHARSET); ! XtSetArg (args[argcount], XmNtextString, textstr_xms); ! argcount++; ! } ! XtSetArg (args[argcount], XmNselectionLabelString, msgstr_xms); ! argcount++; ! XtSetArg (args[argcount], XmNdialogTitle, titstr_xms); ! argcount++; #ifdef MOTIF10 ! XtSetArg (args[argcount], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ! argcount ++; #else ! XtSetArg (args[argcount], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); ! argcount ++; #endif ! dialog = XmCreatePromptDialog (parent, dialog_name[dialog_num], args, ! argcount); ! XtAddCallback (dialog, XmNokCallback, (XtCallbackProc)ok_callback, ! (char *)&df); ! XtAddCallback (dialog, XmNcancelCallback, ! (XtCallbackProc)cancel_callback, (char *)&df); ! XtAddCallback (dialog, XmNhelpCallback, (XtCallbackProc)help_callback, ! (char *)&df); ! XtAddCallback (dialog, XmNapplyCallback, (XtCallbackProc)apply_callback, ! (char *)&df); ! RemapDeleteKey(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT)); ! if(textstr_xms) ! XmStringFree(textstr_xms); ! ! /* Text area in prompt dialog should get focus, not ok button ! since user enters text first. To fix this, we need to turn ! off the default button for the dialog, until after keyboard ! focus has been established */ ! XtVaSetValues(dialog, XmNdefaultButton, NULL, 0); ! XtAddCallback(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmNfocusCallback, (XtCallbackProc)focusCB, (char *)dialog); ! ! /* Limit the length of the text that can be entered in text field */ ! XtVaSetValues(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmNmaxLength, DF_MAX_PROMPT_LENGTH-1, 0); ! ! /* Turn on the requested number of buttons in the dialog by ! managing/unmanaging the button widgets */ ! switch (n) { /* number of buttons requested */ ! case 0: case 3: ! break; /* or default of 3 buttons */ ! case 1: ! XtUnmanageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_CANCEL_BUTTON) ); ! case 2: ! XtUnmanageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_HELP_BUTTON) ); ! break; ! case 4: ! XtManageChild (XmSelectionBoxGetChild (dialog, ! XmDIALOG_APPLY_BUTTON) ); ! df.apply_up = 1; /* apply button managed */ ! default: ! break; ! } /* end switch */ ! ! va_end(var); ! ! /* If the button labeled cancel or dismiss is not the cancel button, or ! if there is no button labeled cancel or dismiss, redirect escape key ! events (this is necessary because the XmNcancelButton resource in ! the bulletin board widget class is blocked from being reset) */ ! if (cancel_index == -1) ! addEscapeHandler(dialog, NULL, 0); ! else if (cancel_index != CANCEL_BTN) ! addEscapeHandler(dialog, &df, cancel_index); ! ! /* Add a callback to the window manager close callback for the dialog */ ! AddMotifCloseCallback(XtParent(dialog), ! (XtCallbackProc)(cancel_index == APPLY_BTN ? apply_callback : ! (cancel_index == CANCEL_BTN ? cancel_callback : ! (cancel_index == HELP_BTN ? help_callback : ok_callback))), &df); /* A previous call to SetDialogFPromptHistory can request that an *************** *** 278,301 **** ! /* Pop up the dialog */ ! ManageDialogCenteredOnPointer(dialog); ! ! /* Get the focus to the input string. There is some timing problem ! within Motif that requires this to be called several times */ ! for (i=0; i<20; i++) ! XmProcessTraversal(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmTRAVERSE_CURRENT); ! ! /* Wait for a response to the dialog */ ! while (!df.done_with_dialog) ! XtAppProcessEvent (XtWidgetToApplicationContext(dialog), XtIMAll); ! ! argcount = 0; /* Pass back string user entered */ ! XtSetArg (args[argcount], XmNtextString, &input_string_xms); argcount++; ! XtGetValues (dialog, args, argcount); ! XmStringGetLtoR (input_string_xms, XmSTRING_DEFAULT_CHARSET, ! &input_string_ptr); ! strcpy (input_string, input_string_ptr); /* This step is necessary */ ! XmStringFree(input_string_xms ); ! XtFree(input_string_ptr); ! XtDestroyWidget(dialog); PromptHistory = NULL; --- 297,320 ---- ! /* Pop up the dialog */ ! ManageDialogCenteredOnPointer(dialog); ! ! /* Get the focus to the input string. There is some timing problem ! within Motif that requires this to be called several times */ ! for (i=0; i<20; i++) ! XmProcessTraversal(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ! XmTRAVERSE_CURRENT); ! ! /* Wait for a response to the dialog */ ! while (!df.done_with_dialog) ! XtAppProcessEvent (XtWidgetToApplicationContext(dialog), XtIMAll); ! ! argcount = 0; /* Pass back string user entered */ ! XtSetArg (args[argcount], XmNtextString, &input_string_xms); argcount++; ! XtGetValues (dialog, args, argcount); ! XmStringGetLtoR (input_string_xms, XmSTRING_DEFAULT_CHARSET, ! &input_string_ptr); ! strcpy (input_string, input_string_ptr); /* This step is necessary */ ! XmStringFree(input_string_xms ); ! XtFree(input_string_ptr); ! XtDestroyWidget(dialog); PromptHistory = NULL; *************** *** 328,329 **** --- 347,350 ---- + va_end(var); + /* Make extraneous buttons disappear */ *************** *** 343,358 **** ! /* If the button labeled cancel or dismiss is not the cancel button, or ! if there is no button labeled cancel or dismiss, redirect escape key ! events (this is necessary because the XmNcancelButton resource in ! the bulletin board widget class is blocked from being reset) */ ! if (cancel_index == -1) ! addEscapeHandler(dialog, NULL, 0); ! else if (cancel_index != CANCEL_BTN) ! addEscapeHandler(dialog, &df, cancel_index); ! ! /* Add a callback to the window manager close callback for the dialog */ ! AddMotifCloseCallback(XtParent(dialog), ! (XtCallbackProc)(cancel_index == APPLY_BTN ? apply_callback : ! (cancel_index == CANCEL_BTN ? cancel_callback : ! (cancel_index == HELP_BTN ? help_callback : ok_callback))),&df); --- 364,379 ---- ! /* If the button labeled cancel or dismiss is not the cancel button, or ! if there is no button labeled cancel or dismiss, redirect escape key ! events (this is necessary because the XmNcancelButton resource in ! the bulletin board widget class is blocked from being reset) */ ! if (cancel_index == -1) ! addEscapeHandler(dialog, NULL, 0); ! else if (cancel_index != CANCEL_BTN) ! addEscapeHandler(dialog, &df, cancel_index); ! ! /* Add a callback to the window manager close callback for the dialog */ ! AddMotifCloseCallback(XtParent(dialog), ! (XtCallbackProc)(cancel_index == APPLY_BTN ? apply_callback : ! (cancel_index == CANCEL_BTN ? cancel_callback : ! (cancel_index == HELP_BTN ? help_callback : ok_callback))),&df); *************** *** 360,364 **** ManageDialogCenteredOnPointer(dialog); while (!df.done_with_dialog) XtAppProcessEvent (XtWidgetToApplicationContext(dialog), XtIMAll); ! XtDestroyWidget(dialog_shell); --- 381,387 ---- ManageDialogCenteredOnPointer(dialog); + + /* Wait for a response to the dialog */ while (!df.done_with_dialog) XtAppProcessEvent (XtWidgetToApplicationContext(dialog), XtIMAll); ! XtDestroyWidget(dialog_shell); *** DialogF.h 1997/09/26 18:28:17 1.1 --- DialogF.h 1997/10/10 00:14:09 1.2 *************** *** 25,26 **** --- 25,27 ---- #define DF_PROMPT 6 /* Prompt Dialog */ + #define DF_PROMPT2 7 /* Prompt Dialog with initial value */ *** Makefile.in 1997/10/10 00:13:14 1.1 --- Makefile.in 1997/10/24 01:10:20 1.5 *************** *** 0 **** --- 1,274 ---- + # Makefile.in generated automatically by automake 0.28 from Makefile.am + + # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation + # gives unlimited permission to copy, distribute and modify it. + + + SHELL = /bin/sh + + srcdir = @srcdir@ + top_srcdir = @top_srcdir@ + VPATH = @srcdir@ + prefix = @prefix@ + exec_prefix = @exec_prefix@ + + bindir = @bindir@ + sbindir = @sbindir@ + libexecdir = @libexecdir@ + datadir = @datadir@ + sysconfdir = @sysconfdir@ + sharedstatedir = @sharedstatedir@ + localstatedir = @localstatedir@ + libdir = @libdir@ + infodir = @infodir@ + mandir = @mandir@ + includedir = @includedir@ + oldincludedir = /usr/include + + pkgdatadir = $(datadir)/@PACKAGE@ + pkglibdir = $(libdir)/@PACKAGE@ + pkgincludedir = $(includedir)/@PACKAGE@ + + AR = @AR@ + RANLIB = @RANLIB@ + PURIFY = @PURIFY@ + + INSTALL = @INSTALL@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_DATA = @INSTALL_DATA@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + transform = @program_transform_name@ + + AUTOMAKE_OPTIONS = + + bin_PROGRAMS = nedit nc + + DIST_OTHER = + DISTCLEANFILES = + + INCLUDES = -I.. -I$(top_srcdir)/util -I$(srcdir) + CONFIG_HEADER = ../config.h + + LDADD = ../util/libNUtil.a + PROGRAMS = $(bin_PROGRAMS) + + CC = @CC@ + LEX = @LEX@ + YACC = @YACC@ + + DEFS = @DEFS@ + CPPFLAGS = @CPPFLAGS@ + CFLAGS = @CFLAGS@ + BIGGER_STRINGS = @BIGGER_STRINGS@ + LDFLAGS = @LDFLAGS@ + MOTIF_CFLAGS = @MOTIF_CFLAGS@ + MOTIF_LDFLAGS = @MOTIF_LDFLAGS@ + MOTIF_PRE_LIBS = @MOTIF_PRE_LIBS@ + MOTIF_LIBS = @MOTIF_LIBS@ + MOTIF_EXTRA_LIBS = @MOTIF_EXTRA_LIBS@ + LIBS = @LIBS@ + + ALL_X_LIBS = $(MOTIF_PRE_LIBS) $(MOTIF_LIBS) $(MOTIF_EXTRA_LIBS) + COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(MOTIF_CFLAGS) + LINK = $(PURIFY) $(CC) $(LDFLAGS) $(MOTIF_LDFLAGS) -o $@ + + o = .@U@o + + DIST_COMMON = + + PACKAGE = @PACKAGE@ + VERSION = @VERSION@ + + DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \ + $(TEXINFOS) $(INFOS) $(MANS) $(DIST_OTHER) $(DATA) + + DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \ + $(TEXINFOS) $(INFO_DEPS) $(MANS) $(DIST_OTHER) $(DATA) + + HEADERS = \ + DialogF.h fontsel.h misc.h printUtils.h vmsUtils.h \ + fileUtils.h getfiles.h prefFile.h vmsParam.h \ + managedList.h + + SOURCES = \ + DialogF.c fontsel.c misc.c printUtils.c \ + fileUtils.c getfiles.c prefFile.c vmsUtils.c \ + managedList.c + + OBJECTS = \ + DialogF$o fontsel$o misc$o printUtils$o \ + fileUtils$o getfiles$o prefFile$o vmsUtils$o \ + managedList$o + + default: all + + + #$(srcdir)/Makefile.in: Makefile.am + # cd $(top_srcdir) && automake $(subdir)/Makefile + + Makefile: ../config.status Makefile.in + cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status + + mostlyclean-binPROGRAMS: + + clean-binPROGRAMS: + rm -f $(bin_PROGRAMS) + + distclean-binPROGRAMS: + + maintainer-clean-binPROGRAMS: + + install-binPROGRAMS: all + $(top_srcdir)/mkinstalldirs $(bindir) + for p in $(bin_PROGRAMS); do \ + if test -f $$p; then \ + $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi \ + done + + uninstall-binPROGRAMS: + for p in $(bin_PROGRAMS); do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + + .c.o: + $(COMPILE) $< + + mostlyclean-compile: + rm -f *.o core + + clean-compile: + rm -f *.a + + distclean-compile: + rm -f *.tab.c + + maintainer-clean-compile: + + ID: $(HEADERS) $(SOURCES) + here=`pwd` && cd $(srcdir) && mkid -f $$here/ID $(SOURCES) $(HEADERS) + + tags: TAGS + + TAGS: + here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS + + mostlyclean-tags: + + clean-tags: + + distclean-tags: + rm -f TAGS ID + + maintainer-clean-tags: + + subdir = util + distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) + dist: $(DEP_DISTFILES) + @for file in $(DISTFILES); do \ + test -f $(distdir)/$$file \ + || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir)/$$file; \ + done + + all: libNUtil.a + + libNUtil.a: $(OBJECTS) + $(AR) libNUtil.a $(OBJECTS) + $(RANLIB) libNUtil.a + + printUtils.o: printUtils.c + $(COMPILE) $(PRINTFLAGS) $< + + info: + + dvi: + + check: + + install-exec: install-binPROGRAMS + + install: install-exec + @: + + uninstall: uninstall-binPROGRAMS + + installdirs: + $(top_srcdir)/mkinstalldirs $(bindir) + + + mostlyclean-generic: + test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + + clean-generic: + test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + + distclean-generic: + rm -f Makefile $(DISTCLEANFILES) + rm -f config.cache config.log $(CONFIG_HEADER) stamp-h + + maintainer-clean-generic: + test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + + clean: clean-binPROGRAMS clean-compile clean-tags \ + clean-generic mostlyclean + + distclean: distclean-binPROGRAMS distclean-compile \ + distclean-tags distclean-generic clean + rm -f config.status + + maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-tags maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + + .PHONY: default mostlyclean-binPROGRAMS distclean-binPROGRAMS \ + clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \ + mostlyclean-compile distclean-compile clean-compile \ + maintainer-clean-compile \ + tags mostlyclean-tags distclean-tags clean-tags \ + maintainer-clean-tags dist all info dvi check installcheck install-exec \ + install uninstall installdirs mostlyclean-generic distclean-generic \ + clean-generic maintainer-clean-generic clean mostlyclean distclean \ + maintainer-clean + + + $(PROGRAMS): $(LDADD) + + version.c: stamp-v + stamp-v: Makefile + rm -f t-version.c + echo '#include ' > t-version.c + echo '#include "version.h"' >> t-version.c + echo 'const char *version_string = "'GNU @PACKAGE@ @VERSION@'";' \ + >> t-version.c + if cmp -s version.c t-version.c; then \ + rm t-version.c; \ + else \ + mv t-version.c version.c; \ + fi + echo timestamp > $@ + + .SUFFIXES: + .SUFFIXES: .c .o + + # Tell versions [3.59,3.63) of GNU make to not export all variables. + # Otherwise a system limit (for SysV at least) may be exceeded. + .NOEXPORT: + + $(OBJECTS): ../config.h + + DialogF.o: misc.h DialogF.h + fileUtils.o: fileUtils.h + fontsel.o: DialogF.h misc.h fontsel.h + getfiles.o: fileUtils.h misc.h getfiles.h + managedList.o: misc.h managedList.h + misc.o: DialogF.h misc.h + prefFile.o: prefFile.h + printUtils.o: DialogF.h misc.h prefFile.h printUtils.h + vmsUtils.c: vmsUtils.h *** fileUtils.c 1997/09/26 18:28:17 1.1 --- fileUtils.c 1997/10/10 00:14:27 1.2 *************** *** 26,28 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)fileUtils.c 1.5 1/10/96"; #include --- 26,28 ---- *******************************************************************************/ ! #include #include *************** *** 33,37 **** #include "vmsparam.h" #else #include ! #include #include --- 33,41 ---- #include "vmsparam.h" + #include #else #include ! #ifdef HAVE_UNISTD_H ! # include ! #endif ! #include #include *************** *** 43,44 **** --- 47,52 ---- + #ifndef S_ISLNK + #define S_ISLNK(mode) (((mode)&0xF000) == S_IFLNK) + #endif + static int normalizePathname(char *pathname); *************** *** 117,119 **** { ! char oldPathname[MAXPATHLEN], wd[MAXPATHLEN]; --- 125,127 ---- { ! char oldPathname[MAXPATHLEN+1], wd[MAXPATHLEN+1]; *************** *** 125,128 **** getcwd(wd, MAXPATHLEN); ! /* prepend it to the path */ ! strcpy(pathname, wd); strcat(pathname, "/"); --- 133,140 ---- getcwd(wd, MAXPATHLEN); ! /* remove /tmp_mnt from the getcwd() result */ ! if(strncmp(wd, "/tmp_mnt/", 9) == 0) ! strcpy(pathname, wd + 8); ! else ! /* prepend it to the path */ ! strcpy(pathname, wd); strcat(pathname, "/"); *************** *** 137,163 **** { ! char *inPtr, *outPtr; ! ! /* compress out . and .. */ ! inPtr = &pathname[1]; /* start after initial / */ ! outPtr = &pathname[1]; ! while (TRUE) { ! /* if the next component is "../", remove previous component */ ! if (compareThruSlash(inPtr, "../")) { ! /* error if already at beginning of string */ ! if (outPtr == &pathname[1]) ! return FALSE; ! /* back up outPtr to remove last path name component */ ! outPtr = prevSlash(outPtr); ! inPtr = nextSlash(inPtr); ! } else if (compareThruSlash(inPtr, "./")) { ! /* don't copy the component if it's the redundant "./" */ ! inPtr = nextSlash(inPtr); ! } else { ! /* copy the component to outPtr */ ! copyThruSlash(&outPtr, &inPtr); } ! if (inPtr == NULL) { ! return TRUE; ! } ! } } --- 149,187 ---- { ! char buf[MAXPATHLEN+1]; ! char *inPtr, *outPtr; ! struct stat statbuf; ! ! /* compress out . and .. */ ! inPtr = pathname; ! outPtr = buf; ! /* copy initial / */ ! copyThruSlash(&outPtr, &inPtr); ! while (inPtr != NULL) { ! /* if the next component is "../", remove previous component */ ! if (compareThruSlash(inPtr, "../")) { ! *outPtr = 0; ! /* Just copy the ../ if at the beginning the filesystem will take ! care of it. And Just copy the ../ if the previous component ! is a symbolic link. It is not valid to compress ! ../ when the previous component is a symbolic link because ! ../ is not relative to the previous component anymore. It instead ! relative to where the link points. */ ! if(outPtr-1 == buf || (lstat(buf, &statbuf) == 0 && S_ISLNK(statbuf.st_mode))) { ! copyThruSlash(&outPtr, &inPtr); ! } else { ! /* back up outPtr to remove last path name component */ ! outPtr = prevSlash(outPtr); ! inPtr = nextSlash(inPtr); ! } ! } else if (compareThruSlash(inPtr, "./")) { ! /* don't copy the component if it's the redundant "./" */ ! inPtr = nextSlash(inPtr); ! } else { ! /* copy the component to outPtr */ ! copyThruSlash(&outPtr, &inPtr); ! } } ! /* updated pathname with the new value */ ! strcpy(pathname, buf); ! return TRUE; } *** fontsel.c 1997/09/26 18:28:17 1.1 --- fontsel.c 1997/10/10 00:14:27 1.2 *************** *** 24,27 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)fontsel.c 1.12 10/3/96"; ! #include --- 24,26 ---- *******************************************************************************/ ! #include #include *************** *** 146,147 **** --- 145,148 ---- * * + * char * title - Title of the dialog * + * * * Returns: * *************** *** 159,161 **** ! char *FontSel(Widget parent, int showPropFonts, char *currFont) { --- 160,162 ---- ! char *FontSel(Widget parent, int showPropFonts, char *currFont, char *title) { *************** *** 179,181 **** ! dialog = XmCreateDialogShell (parent, "Font Selector", args, 0); --- 180,186 ---- ! title = title ? title : "Font Selector"; ! ! n = 0; ! XtSetArg(args[n], XmNtitle, title); n++; ! dialog = XmCreateDialogShell (parent, "fontSelectorDialog", args, n); *************** *** 1154,1156 **** ! if (i != 1) { --- 1159,1161 ---- ! if (fontName == 0 || i != 1) { *************** *** 1158,1160 **** "Invalid Font Specification", "Dismiss"); ! XFreeFontNames(fontName); } --- 1163,1166 ---- "Invalid Font Specification", "Dismiss"); ! if(fontName) ! XFreeFontNames(fontName); } *************** *** 1173,1177 **** XtFree(ctrlBlk->sel3); ! XFreeFontNames(fontName); - XFreeFontNames(ctrlBlk->fontData); --- 1179,1184 ---- XtFree(ctrlBlk->sel3); ! if (ctrlBlk->fontData) ! XFreeFontNames(ctrlBlk->fontData); ! XFreeFontNames(fontName); *************** *** 1194,1198 **** ! if (i == 0) { /* invalid font passed in at startup */ ! XFreeFontNames(fontName); return; --- 1201,1206 ---- ! if (fontName == 0 || i == 0) { /* invalid font passed in at startup */ ! if(fontName) ! XFreeFontNames(fontName); return; *** fontsel.h 1997/09/26 18:28:17 1.1 --- fontsel.h 1997/10/10 00:14:27 1.2 *************** *** 54,55 **** --- 54,57 ---- * * + * char * title - Title of the dialog * + * * * Returns: * *************** *** 76,77 **** ! char *FontSel(Widget parent, int showPropFont, char *currFont); --- 78,79 ---- ! char *FontSel(Widget parent, int showPropFont, char *currFont, char *title); *** getfiles.c 1997/09/26 18:28:17 1.1 --- getfiles.c 1997/10/10 00:14:27 1.2 *************** *** 44,46 **** ******************************************************************************/ ! static char SCCSID[] = "@(#)getfiles.c 1.42 2/26/97"; #include --- 44,46 ---- ******************************************************************************/ ! #include #include *************** *** 54,58 **** #else ! #include ! #include ! #include #include --- 54,61 ---- #else ! #ifdef HAVE_UNISTD_H ! # include ! #endif ! #ifdef HAVE_FCNTL_H ! # include ! #endif #include *************** *** 64,65 **** --- 67,69 ---- #include + #include #include *************** *** 285,287 **** /* */ ! int GetExistingFilename (Widget parent, char *promptString, char *filename) { --- 289,291 ---- /* */ ! int GetExistingFilename (Widget parent, char *promptString, char *filename, char *title) { *************** *** 295,297 **** labelString = XmStringCreateSimple(promptString); ! titleString = XmStringCreateSimple(" "); XtSetArg(args[n], XmNlistLabelString, labelString); n++; --- 299,301 ---- labelString = XmStringCreateSimple(promptString); ! titleString = XmStringCreateSimple((title == 0 || *title == 0) ? " " : title); XtSetArg(args[n], XmNlistLabelString, labelString); n++; *************** *** 396,397 **** --- 400,403 ---- XtVaSetValues(existFileSB, XmNdefaultButton, NULL, 0); + { + int i; for (i=1; i<30; i++) *************** *** 399,400 **** --- 405,407 ---- XmDIALOG_LIST), XmTRAVERSE_CURRENT); + } #endif *************** *** 408,409 **** --- 415,418 ---- &cDir, XmNpattern, &cPattern, 0); + if (DefaultDirectory != NULL) XmStringFree(DefaultDirectory); + if (DefaultPattern != NULL) XmStringFree(DefaultPattern); /* Undocumented: file selection box widget allocates copies of these *************** *** 412,415 **** realization, therefore OSF can't easily go back and change it */ - if (DefaultDirectory != NULL) XmStringFree(DefaultDirectory); - if (DefaultPattern != NULL) XmStringFree(DefaultPattern); DefaultDirectory = cDir; --- 421,422 ---- *************** *** 419,421 **** XmStringFree(cFileString); ! XtFree(fileString); } --- 426,428 ---- XmStringFree(cFileString); ! XtFree(fileString); } *************** *** 521,523 **** char *fileString; /* C string for file selected */ - int i; --- 528,529 ---- *************** *** 532,536 **** #endif ! if (DefaultDirectory != NULL || DefaultPattern != NULL) XtVaSetValues(newFileSB, XmNdirectory, DefaultDirectory, XmNpattern, DefaultPattern, 0); help = createPanelHelp(newFileSB, HelpNew, "Saving a File"); --- 538,547 ---- #endif ! if (DefaultDirectory != NULL || DefaultPattern != NULL) { XtVaSetValues(newFileSB, XmNdirectory, DefaultDirectory, XmNpattern, DefaultPattern, 0); + cFileString = XmStringCreateLtoR (filename, + XmSTRING_DEFAULT_CHARSET); + XtVaSetValues(newFileSB, XmNdirSpec, cFileString, 0); + XmStringFree(cFileString); + } help = createPanelHelp(newFileSB, HelpNew, "Saving a File"); *************** *** 561,565 **** XtVaSetValues(newFileSB, XmNdefaultButton, NULL, 0); ! for (i=1; i<30; i++) XmProcessTraversal(XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_TEXT), XmTRAVERSE_CURRENT); #endif --- 572,579 ---- XtVaSetValues(newFileSB, XmNdefaultButton, NULL, 0); ! { ! int i; ! for (i=1; i<30; i++) XmProcessTraversal(XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_TEXT), XmTRAVERSE_CURRENT); + } #endif *************** *** 787,789 **** doErrorDialog("Please supply a name for the file", NULL); ! XtFree(filename); return; --- 801,803 ---- doErrorDialog("Please supply a name for the file", NULL); ! XtFree(filename); return; *************** *** 800,802 **** doErrorDialog("Error: %s is a directory", filename); ! XtFree(filename); return; --- 814,816 ---- doErrorDialog("Error: %s is a directory", filename); ! XtFree(filename); return; *************** *** 815,816 **** --- 829,831 ---- #endif /*VMS*/ + XtFree(filename); return; *************** *** 820,822 **** doErrorDialog("Error: can't create %s ", filename); ! XtFree(filename); return; --- 835,837 ---- doErrorDialog("Error: can't create %s ", filename); ! XtFree(filename); return; *************** *** 827,829 **** } ! XtFree(filename); *client_data = True; /* done with dialog */ --- 842,844 ---- } ! XtFree(filename); *client_data = True; /* done with dialog */ *************** *** 1001,1003 **** if (nKeystrokes >= MAX_LIST_KEYSTROKES) ! XBell(XtDisplay(w), 100); else --- 1016,1018 ---- if (nKeystrokes >= MAX_LIST_KEYSTROKES) ! XBell(XtDisplay(w), 0); else *************** *** 1018,1020 **** ParseFilename(itemString, name, path); ! XtFree(itemString); cmp = strncmp(name, keystrokes, nKeystrokes); --- 1033,1035 ---- ParseFilename(itemString, name, path); ! XtFree(itemString); cmp = strncmp(name, keystrokes, nKeystrokes); *** getfiles.h 1997/09/26 18:28:17 1.1 --- getfiles.h 1997/10/10 00:14:27 1.2 *************** *** 22,24 **** int GetNewFilename (Widget parent, char *promptString, char *filename); ! int GetExistingFilename (Widget parent, char *promptString, char *filename); int HandleCustomExistFileSB(Widget existFileSB, char *filename); --- 22,24 ---- int GetNewFilename (Widget parent, char *promptString, char *filename); ! int GetExistingFilename (Widget parent, char *promptString, char *filename, char *title); int HandleCustomExistFileSB(Widget existFileSB, char *filename); *** managedList.c 1997/09/26 18:28:17 1.1 --- managedList.c 1997/10/23 19:07:29 1.2 *************** *** 24,25 **** --- 24,26 ---- *******************************************************************************/ + #include #include *************** *** 29,31 **** #include ! #include "../util/misc.h" #include "managedList.h" --- 30,32 ---- #include ! #include "misc.h" #include "managedList.h" *** misc.c 1997/09/26 18:28:17 1.1 --- misc.c 1997/10/14 04:46:15 1.3 *************** *** 24,26 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)misc.c 1.39 2/1/96"; #include --- 24,26 ---- *******************************************************************************/ ! #include #include *************** *** 29,30 **** --- 29,31 ---- #include + #include #include *************** *** 714,716 **** } ! newList = (char **)XtMalloc(sizeof(char *) * *nItems + 1); for (i=0; i < *nItems; i++) --- 715,717 ---- } ! newList = (char **)XtMalloc(sizeof(char *) * (*nItems + 1)); for (i=0; i < *nItems; i++) *************** *** 782,783 **** --- 783,800 ---- XUndefineCursor(XtDisplay(topCursorWidget), XtWindow(topCursorWidget)); + } + + /* + ** StrCaseCmp compares its arguments IGNORING case differences. + ** Returns 0 if the two strings are equal. Otherwise returns -1 + ** if str1 is less and str2 and 1 if str1 is greater than str2. + */ + int StrCaseCmp(char *str1, char *str2) + { + for (; ; str1++, str2++) { + if (toupper(*str1) != toupper(*str2)) + return toupper(*str2) - toupper(*str1); + if (*str1 == 0 || *str2 == 0) + break; + } + return 0; } *** misc.h 1997/09/26 18:28:17 1.1 --- misc.h 1997/10/10 00:14:27 1.2 *************** *** 64 **** --- 64,65 ---- void AddToHistoryList(char *newItem, char ***historyList, int *nItems); + int StrCaseCmp(char *str1, char *str2); *** prefFile.c 1997/09/26 18:28:17 1.1 --- prefFile.c 1997/10/10 00:14:27 1.2 *************** *** 24,25 **** --- 24,26 ---- *******************************************************************************/ + #include #include *************** *** 206,208 **** FILE *fp; ! int type; int i; --- 207,209 ---- FILE *fp; ! PrefDataType type; int i; *** prefFile.h 1997/09/26 18:28:17 1.1 --- prefFile.h 1997/10/10 00:14:27 1.2 *************** *** 26,29 **** ! enum PrefDataTypes {PREF_INT, PREF_BOOLEAN, PREF_ENUM, PREF_STRING, ! PREF_ALLOC_STRING}; --- 26,30 ---- ! typedef enum _PrefDataType { ! PREF_INT, PREF_BOOLEAN, PREF_ENUM, PREF_STRING, PREF_ALLOC_STRING ! } PrefDataType; *************** *** 32,34 **** char *class; ! int dataType; char *defaultString; --- 33,35 ---- char *class; ! PrefDataType dataType; char *defaultString; *** printUtils.c 1997/09/26 18:28:17 1.1 --- printUtils.c 1997/10/10 00:14:27 1.2 *************** *** 28,31 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)printUtils.c 1.20 1/10/96"; ! #include --- 28,30 ---- *******************************************************************************/ ! #include #include *************** *** 45,51 **** #else ! #ifdef USE_DIRENT ! #include #else ! #include ! #endif /* USE_DIRENT */ #include --- 44,61 ---- #else ! #ifdef HAVE_DIRENT_H ! # include ! # define NAMLEN(dirent) strlen((dirent)->d_name) #else ! # define dirent direct ! # define NAMLEN(dirent) (dirent)->d_namlen ! # ifdef HAVE_SYS_NDIR_H ! # include ! # endif ! # ifdef HAVE_SYS_DIR_H ! # include ! # endif ! # ifdef HAVE_NDIR_H ! # include ! # endif ! #endif #include *************** *** 766,772 **** DIR *dfile; - #ifdef USE_DIRENT struct dirent *DirEntryPtr; - #else - struct direct *DirEntryPtr; - #endif struct stat statbuf; --- 776,778 ---- *** vmsUtils.c 1997/09/26 18:28:17 1.1 --- vmsUtils.c 1997/10/24 01:11:05 1.3 *************** *** 60,62 **** *******************************************************************************/ ! static char SCCSID[] = "@(#)vmsUtils.c 1.8 7/7/94"; --- 60,63 ---- *******************************************************************************/ ! ! #include