X Desktop Manager(2)
Edward J. Groenendaal
eddyg at syma.sussex.ac.uk
Thu Apr 18 06:48:25 AEST 1991
---- Cut Here and unpack ----
#!/bin/sh
# this is part 2 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file code/dirman.c continued
#
CurArch=2
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
if test "$Scheck" != $CurArch
then echo "Please unpack part $Scheck next!"
exit 1;
else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file code/dirman.c"
sed 's/^X//' << 'SHAR_EOF' >> code/dirman.c
X{
X extern Boolean buttonSensitive;
X extern Widget trashButton, moveButton, copyButton;
X public void changestate(Boolean);
X extern void setCursor(Cursor);
X extern Mode mode;
X extern Cursor busy;
X
X Arg arglist[1];
X Cardinal i;
X
X if (mode == NormalMode) {
X setCursor(busy);
X XedwListHighlight(w, XedwAll);
X
X /* unhighlight . and .. */
X for (i=0; i < icon_list_size &&
X (strcmp(getfilename(icon_list[i]->string), ".") != 0); i++);
X XedwListUnhighlight(w, i);
X for (i=i; i < icon_list_size &&
X (strcmp(getfilename(icon_list[i]->string), "..") != 0); i++);
X XedwListUnhighlight(w, i);
X setCursor(NULL);
X } else
X XBell(XtDisplay(w), 100);
X
X /* do buttons */
X if (icon_list_size > 2) {
X changestate(True);
X }
X}
X
Xprivate void Refresh(Widget w, XButtonEvent *event)
X{
X directoryManagerNewDirectory(cwd);
X}
X
Xpublic void changestate(Boolean new)
X{
X extern Boolean buttonSensitive;
X extern Widget trashButton, copyButton, moveButton;
X extern Mode mode;
X
X if (buttonSensitive == True) {
X if (mode == MoveMode) {
X /* Turn off Trash and Copy */
X XtSetSensitive(copyButton, False);
X XtSetSensitive(trashButton, False);
X XtSetSensitive(copymenu, False);
X XtSetSensitive(trashmenu, False);
X XtSetSensitive(mapmenu, False);
X XtSetSensitive(getinfomenu, False);
X XtSetSensitive(duplicatemenu, False);
X buttonSensitive = False;
X } else if (mode == CopyMode) {
X /* Turn off Trash and Move */
X XtSetSensitive(moveButton, False);
X XtSetSensitive(trashButton, False);
X XtSetSensitive(movemenu, False);
X XtSetSensitive(trashmenu, False);
X XtSetSensitive(mapmenu, False);
X XtSetSensitive(getinfomenu, False);
X XtSetSensitive(duplicatemenu, False);
X buttonSensitive = False;
X } else if (new == False) {
X /* Turn off All */
X XtSetSensitive(moveButton, False);
X XtSetSensitive(copyButton, False);
X XtSetSensitive(trashButton, False);
X XtSetSensitive(copymenu, False);
X XtSetSensitive(movemenu, False);
X XtSetSensitive(trashmenu, False);
X XtSetSensitive(mapmenu, False);
X XtSetSensitive(getinfomenu, False);
X XtSetSensitive(duplicatemenu, False);
X buttonSensitive = False;
X }
X } else {
X /* buttonSensitive == False */
X
X /* If in MoveMode or CopyMode, then everything is set anyway */
X if (mode == NormalMode && new == True) {
X /* Set all to True */
X XtSetSensitive(trashButton, True);
X XtSetSensitive(moveButton, True);
X XtSetSensitive(copyButton, True);
X XtSetSensitive(trashmenu, True);
X XtSetSensitive(movemenu, True);
X XtSetSensitive(copymenu, True);
X XtSetSensitive(getinfomenu, True);
X XtSetSensitive(duplicatemenu, True);
X XtSetSensitive(mapmenu, True);
X buttonSensitive = True;
X }
X }
X}
X
Xpublic String getfilename(String s)
X{
X extern Icon_mode current_mode;
X
X if (current_mode.mode == Long && (strlen(s) > current_mode.length))
X return (s+current_mode.length);
X else
X return (s);
X}
SHAR_EOF
echo "File code/dirman.c is complete"
chmod 0644 code/dirman.c || echo "restore of code/dirman.c fails"
echo "x - extracting code/display.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/display.c &&
X/*****************************************************************************
X ** File : display.c **
X ** Purpose : Initialise and Realise display and query dialogs **
X ** Author : Edward Groenendaal **
X ** Date : April 1991 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : **
X *****************************************************************************/
X
X#include "xdtm.h"
X
X#include <sys/file.h> /* For access(2) */
X#include <sys/signal.h> /* For longjmp */
X#include <setjmp.h> /* For longjmp */
X
X#include <X11/Shell.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/AsciiText.h>
X#include "Xedw/XedwForm.h"
X
Xextern void realize_dialog(Widget);
X
X
Xtypedef enum {ViewReturn, CancelReturn} queryReturn;
X
Xpublic String viewfile;
Xprivate jmp_buf env;
X
X/* Widgets */
Xprivate Widget querypopup; /* For asking whether to display a file */
Xprivate Widget displaypopup; /* For displaying a file */
Xprivate Widget queryform;
Xprivate Widget displayform;
Xprivate Widget querylabel;
Xprivate Widget displaylabel;
Xprivate Widget queryyes;
Xprivate Widget queryno;
Xprivate Widget displayquit;
Xprivate Widget displaytext;
X
Xpublic void init_query(Widget top)
X{
X Arg arglist[5];
X Cardinal i;
X
X querypopup = XtCreatePopupShell("querypopup",
X transientShellWidgetClass,
X top,
X NULL, 0);
X
X queryform = XtCreateManagedWidget("queryform",
X xedwFormWidgetClass,
X querypopup,
X NULL, 0);
X
X i = 0;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X querylabel = XtCreateManagedWidget("querylabel",
X labelWidgetClass,
X queryform,
X arglist, i);
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, querylabel); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X queryno = XtCreateManagedWidget("queryno",
X commandWidgetClass,
X queryform,
X arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, querylabel); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X XtSetArg(arglist[i], XtNfromHoriz, queryno); i++;
X XtSetArg(arglist[i], XtNwidthLinked, queryno); i++;
X queryyes = XtCreateManagedWidget("queryyes",
X commandWidgetClass,
X queryform,
X arglist, i);
X
X}
X
Xpublic void init_display(Widget top)
X{
X private void destroy_display_dialog(Boolean);
X
X extern AppData app_data;
X XFontStruct *font;
X Arg arglist[8];
X Cardinal i, width, height;
X
X private String DisplayQuit = "Quit";
X
X /* Create popup */
X displaypopup = XtCreatePopupShell("displaypopup",
X transientShellWidgetClass,
X top,
X NULL, 0);
X
X displayform = XtCreateManagedWidget("displayform",
X xedwFormWidgetClass,
X displaypopup,
X NULL, 0);
X i = 0;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X displaylabel = XtCreateManagedWidget("displaylabel",
X labelWidgetClass,
X displayform,
X arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNfont, app_data.view_font); i++;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X XtSetArg(arglist[i], XtNfromVert, displaylabel); i++;
X XtSetArg(arglist[i], XtNscrollVertical, XawtextScrollAlways); i++;
X XtSetArg(arglist[i], XtNtype, XawAsciiFile); i++;
X XtSetArg(arglist[i], XtNstring, "/dev/null"); i++;
X XtSetArg(arglist[i], XtNdataCompression, False); i++;
X displaytext = XtCreateManagedWidget("displaytext",
X asciiTextWidgetClass,
X displayform,
X arglist, i);
X
X /* Get font from text widget, set the width of the widget to the
X * maximum width of any character in that font multiplied by 85,
X * set the height of the widget to (ascent + descent) * 24.
X *
X * This gives a default viewing area of 85x25 characters if using a fixed
X * width font, wider if using a variable width font.
X *
X * Note: The user may override these sizes view the application resources.
X */
X
X XtSetArg(arglist[0], XtNfont, &font);
X XtGetValues(displaytext, arglist, 1);
X
X width = (font->max_bounds.width * app_data.view_width);
X height = ((font->max_bounds.ascent +
X font->max_bounds.descent) * app_data.view_height);
X
X i = 0;
X XtSetArg(arglist[i], XtNwidth, width); i++;
X XtSetArg(arglist[i], XtNheight, height); i++;
X XtSetValues(displaytext, arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNlabel, DisplayQuit); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X XtSetArg(arglist[i], XtNfromVert, displaytext); i++;
X displayquit = XtCreateManagedWidget("displayquit",
X commandWidgetClass,
X displayform,
X arglist, i);
X
X XtAddCallback(displayquit, XtNcallback, destroy_display_dialog, True);
X
X}
X
X
Xpublic void query_dialog(String fullname, Boolean Query)
X{
X private void queryQueryResult(Widget, queryReturn, caddr_t);
X
X Arg arglist[2];
X Cardinal i;
X
X if (Query == True) {
X /* display query dialog */
X
X private String QueryLabel = "View selected file?";
X private String QueryNo = " Cancel ";
X private String QueryYes = "View";
X
X i = 0;
X XtSetArg(arglist[i], XtNlabel, QueryLabel); i++;
X XtSetValues(querylabel, arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNsensitive, True); i++;
X XtSetArg(arglist[i], XtNlabel, QueryNo); i++;
X XtSetValues(queryno, arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNlabel, QueryYes); i++;
X XtSetValues(queryyes, arglist, i);
X
X XtAddCallback(queryyes, XtNcallback, queryQueryResult, ViewReturn);
X XtAddCallback(queryno, XtNcallback, queryQueryResult, CancelReturn);
X
X viewfile = XtNewString(fullname);
X
X } else {
X /* display view error dialog */
X
X private String QueryNo = " Cancel ";
X private String QueryYes = "OK";
X
X i = 0;
X XtSetArg(arglist[i], XtNlabel, fullname); i++;
X XtSetValues(querylabel, arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNsensitive, False); i++;
X XtSetArg(arglist[i], XtNlabel, QueryNo); i++;
X XtSetValues(queryno, arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNlabel, QueryYes); i++;
X XtSetValues(queryyes, arglist, i);
X
X XtAddCallback(queryyes, XtNcallback, queryQueryResult, CancelReturn);
X XtAddCallback(queryno, XtNcallback, queryQueryResult, CancelReturn);
X
X XBell(XtDisplay(displaypopup), 100);
X }
X
X realize_dialog(querypopup);
X
X}
X
Xprivate void destroy_query_dialog(void)
X{
X XtPopdown(querypopup);
X
X XtRemoveAllCallbacks(queryyes, XtNcallback);
X XtRemoveAllCallbacks(queryno, XtNcallback);
X
X}
X
X/* display */
X
Xpublic void displayfile(String fullname)
X{
X extern void setCursor(Cursor);
X extern Cursor busy;
X private void seggie(int);
X Arg arglist[5];
X Cardinal i;
X
X setCursor(busy);
X signal(SIGSEGV, seggie);
X if (setjmp(env) == 0) {
X i = 0;
X XtSetArg(arglist[i], XtNstring, fullname); i++;
X XtSetValues(displaytext, arglist, i);
X i = 0;
X XtSetArg(arglist[i], XtNlabel, fullname); i++;
X XtSetValues(displaylabel, arglist, i);
X
X setCursor(NULL);
X realize_dialog(displaypopup);
X } else {
X setCursor(NULL);
X query_dialog("Not a text file!", False);
X }
X signal(SIGSEGV, SIG_DFL);
X}
X
Xprivate void seggie(int value)
X{
X longjmp(env, value);
X}
X
X
Xprivate void destroy_display_dialog(Boolean destroy)
X{
X XtPopdown(displaypopup);
X}
X
X
Xprivate void queryQueryResult(Widget w, queryReturn result, caddr_t dummy)
X{
X destroy_query_dialog();
X
X if (result == ViewReturn) {
X /* Call display */
X if (access(viewfile, R_OK) == 0)
X displayfile(viewfile);
X else
X query_dialog("File not readable!", False);
X }
X}
X
SHAR_EOF
chmod 0644 code/display.c || echo "restore of code/display.c fails"
echo "x - extracting code/fileman.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/fileman.c &&
X/* v0.1 */
X/*****************************************************************************
X ** File : fileman.c **
X ** Purpose : Receive and distribute directory changes **
X ** Author : Edward Groenendaal **
X ** Date : 18th Feb 1990 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : treeman.c, dirman.c, pathman.c, main.c **
X *****************************************************************************/
X
X#include "xdtm.h"
X
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Paned.h>
X#include <X11/Xaw/Viewport.h>
X#include <X11/cursorfont.h>
X
X#include "Xedw/XedwForm.h"
X
Xpublic Widget vert_bar;
Xpublic Widget dirSelector;
Xpublic Cursor busy, left_ptr;
Xpublic Widget directoryManagerView;
X
Xpublic void setCursor(Cursor);
X
Xpublic void createFileManagerWidgets(Widget w)
X{
X private void GotoDir(Widget, XButtonEvent*);
X private void ClearSel(Widget, XButtonEvent*);
X private void goto_dir(Widget, caddr_t, caddr_t);
X
X Widget fileManagerPane, treeManagerView;
X Widget dirSelectorForm, dirButton, dirLabel;
X extern Widget menuBar;
X Arg arglist[6], *newlist;
X Cardinal i;
X XtTranslations dirSelTranslations;
X
X static XtActionsRec actions[] = {
X {"GotoDir", GotoDir},
X {NULL, NULL}
X };
X
X
X static char defaultTranslations[] =
X "Ctrl<Key>A: beginning-of-line() \n\
X Ctrl<Key>E: end-of-line() \n\
X <Key>Return: GotoDir() \n\
X <Key>Escape: beginning-of-line() kill-to-end-of-line() \n\
X <Key>Right: forward-character() \n\
X <Key>Left: backward-character() \n\
X <Key>Delete: delete-previous-character() \n\
X <Key>BackSpace: delete-previous-character() \n\
X <Key>: insert-char() \n\
X <FocusIn>: focus-in() \n\
X <FocusOut>: focus-out() \n\
X <BtnDown>: select-start()";
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, menuBar); i++;
X XtSetArg(arglist[i], XtNfullHeight, True); i++;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X XtSetArg(arglist[i], XtNfromHoriz, XtNameToWidget(w, "appManagerButton"));i++;
X newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
X fileManagerPane = XtCreateManagedWidget("fileManagerPane",
X panedWidgetClass,
X w,
X newlist, i + chain_size);
X
X XtFree(newlist);
X
X/* Here is the hook onto which the tree manager will fit.
X *
X * i = 0;
X * XtSetArg(arglist[i], XtNforceBars, True); i++;
X * XtSetArg(arglist[i], XtNallowVert, True); i++;
X * XtSetArg(arglist[i], XtNallowHoriz, True); i++;
X * treeManagerView = XtCreateManagedWidget("treeManagerView",
X * viewportWidgetClass,
X * fileManagerPane,
X * arglist, i);
X */
X
X i = 0;
X XtSetArg(arglist[i], XtNforceBars, True); i++;
X XtSetArg(arglist[i], XtNallowVert, True); i++;
X directoryManagerView = XtCreateManagedWidget("directoryManagerView",
X viewportWidgetClass,
X fileManagerPane,
X arglist, i);
X
X createDirectoryManagerWidgets(directoryManagerView);
X /* createTreeManagerWidgets(treeManagerView); */
X
X /* Create text widget */
X
X i = 0;
X XtSetArg(arglist[i], XtNrubberHeight, False); i++;
X XtSetArg(arglist[i], XtNrubberWidth, False); i++;
X XtSetArg(arglist[i], XtNfromHoriz, menuBar); i++;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNlabel, "Goto:"); i++;
X newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
X dirButton = XtCreateManagedWidget("dirButton",
X commandWidgetClass,
X w,
X newlist, i + chain_size);
X
X XtFree(newlist);
X
X i = 0;
X XtSetArg(arglist[i], XtNrubberHeight, False); i++;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X XtSetArg(arglist[i], XtNfromHoriz, dirButton); i++;
X XtSetArg(arglist[i], XtNeditType, XawtextEdit); i++;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNvertDistance, 6); i++;
X newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
X dirSelector = XtCreateManagedWidget("dirSelector",
X asciiTextWidgetClass,
X w,
X newlist, i + chain_size);
X XtFree(newlist);
X XtAddCallback(dirButton, XtNcallback, goto_dir, 0);
X XtAddActions(actions, XtNumber(actions));
X XtUninstallTranslations(dirSelector);
X dirSelTranslations = XtParseTranslationTable(defaultTranslations);
X XtOverrideTranslations(dirSelector, dirSelTranslations);
X
X }
X
Xpublic void initFileManager(Widget w)
X{
X extern void initDirectoryManager(void); /* dirman.c */
X /* extern void initTreeManager(void); */
X busy = XCreateFontCursor(XtDisplay(w), XC_watch);
X left_ptr = XCreateFontCursor(XtDisplay(w), XC_left_ptr);
X
X /* Check what should be mapped, unmapping those that shouldn't */
X
X initDirectoryManager();
X /* initTreeManager(); */
X}
X
Xprivate void GotoDir(Widget w, XButtonEvent *event)
X{
X private goto_dir(Widget, caddr_t, caddr_t);
X
X goto_dir(w, 0, 0);
X}
X
Xprivate void goto_dir(Widget w, caddr_t client_data, caddr_t call_data)
X{
X /* Called when the goto directory button is pressed, Or when return is
X * pressed in the directory selector.
X */
X extern Boolean directoryManagerNewDirectory(String);
X
X extern String home;
X extern String cwd;
X Arg args[1];
X String value, tmp;
X
X /* Get the contents of the dirselector */
X XtSetArg(args[0], XtNstring, &value);
X XtGetValues(dirSelector, args, 1);
X
X /* expand ~ to HOME */
X if (*value == '~') {
X tmp = (String) XtMalloc ((strlen(home) + strlen(value)) * sizeof(char));
X strcpy(tmp, home);
X if (*(value+1) != '\0')
X strcat(tmp, value+1);
X value = tmp;
X }
X
X /* change to the directory specified */
X if (directoryManagerNewDirectory(value) == False) {
X XBell(XtDisplay(w), 100);
X } else {
X XtFree(cwd);
X cwd = XtNewString(value);
X }
X
X}
X
Xprivate void ClearSel(Widget w, XButtonEvent *event)
X{
X Arg args[1];
X
X XtSetArg(args[0], XtNstring, "");
X XtSetValues(dirSelector, args, 1);
X}
X
Xpublic void setCursor(Cursor newcursor)
X{
X
X /* This should be called with a cursor to change to, or NULL to
X * go back to saved values.
X * If the cursor is NULL then reset cursors to their defaults in
X * widgets.
X * Otherwise..
X * Set the cursor to newcursor in the following widgets:
X * directoryManager
X * dirSelector
X *
X */
X
X extern Widget directoryManager, appManager;
X
X static Cursor dirManCursor, appManCursor;
X Arg arglist[1];
X Cardinal i;
X
X if (newcursor == NULL) {
X /* Go back to saved values */
X XtSetArg(arglist[0], XtNcursor, dirManCursor);
X XtSetValues(directoryManager, arglist, 1);
X /* XtSetArg(arglist[0], XtNcursor, treeManCursor);
X * XtSetValues(treeManager, arglist, 1); */
X XtSetArg(arglist[0], XtNcursor, appManCursor);
X XtSetValues(appManager, arglist, 1);
X } else {
X /* Get old values */
X XtSetArg(arglist[0], XtNcursor, &dirManCursor);
X XtGetValues(directoryManager, arglist, 1);
X /* XtSetArg(arglist[0], XtNcursor, &treeManCursor);
X * XtGetValues(treeManager, arglist, 1); */
X XtSetArg(arglist[0], XtNcursor, &appManCursor);
X XtGetValues(appManager, arglist, 1);
X
X XtSetArg(arglist[0], XtNcursor, newcursor);
X XtSetValues(directoryManager, arglist, 1);
X /* XtSetValues(treeManager, arglist, 1); */
X XtSetValues(appManager, arglist, 1);
X }
X
X XFlush(XtDisplay(directoryManager)); /* Change cursors immediately */
X}
X
SHAR_EOF
chmod 0644 code/fileman.c || echo "restore of code/fileman.c fails"
echo "x - extracting code/info.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/info.c &&
X/***********************************************************************************
X ** File : info.c **
X ** Purpose : Initialise and Realise info dialog **
X ** Author : Edward Groenendaal **
X ** Date : April 1991 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : **
X ***********************************************************************************/
X
X#include "xdtm.h"
X
X
Xpublic void init_info(Widget top)
X{
X
X}
SHAR_EOF
chmod 0644 code/info.c || echo "restore of code/info.c fails"
echo "x - extracting code/lexical.l (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/lexical.l &&
X%{ /*-*- Mode: C -*-*/
X/**************************************************************************
X * Filename : lexical.l
X * Author : Edward Groenendaal
X **************************************************************************/
X
X#ifdef YYLMAX
X# if (YYLMAX<1024) /* Allow 1024 characters of look-ahead */
X# undef YYLMAX /* therefore allowing 1024 characters in a */
X# define YYLMAX 1024 /* comment. (default on my machine is 200 */
X# endif
X#endif
X
X#include "xdtm.h"
X
X/* I shall use the macro RETURN whenever returning a token. If DEBUG_LEX has
X * been defined then the token will be printed out, otherwise it will
X * be returned.
X */
X
X#ifdef DEBUG_LEX
X
X/* define the RETURN macro to print the token to be returned */
X# define RETURN(token) fprintf(stdout,"Token: " #token "\tReturned.\n")
X
X /* define the tokens to be returned. ONLY in DEBUG mode, when in normal
X * operation the tokens are defined by yacc.
X */
X enum tokens { IF_T,
X SET_T,
X ICON_T,
X NAME_T,
X PATH_T,
X ASSIGN_T,
X EQUAL_T,
X NEQUAL_T,
X STRING_T,
X SEMIC_T,
X O_PAR_T,
X C_PAR_T,
X O_BRACE_T,
X C_BRACE_T,
X DEFICON_T,
X CHECKPATH_T,
X TRUE_T,
X FALSE_T,
X TYPE_T,
X DIR_T,
X FILE_T,
X READ_T,
X WRITE_T,
X EXE_T,
X PROG_T,
X OPTIONS_T,
X COMMA_T,
X MSEL_T,
X OSEL_T,
X NSEL_T,
X DEFINE_T,
X IGNORE_T,
X ERRORTOKEN
X };
X
X#else /* No DEBUG */
X
X#include "parser.h" /* get the tokens from yacc */
X
X/* define the RETURN token to set the return value to the token to be
X * returned, then return that token.
X */
X# define RETURN(token) yylval.number=token;return(token)
X#endif
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <stdarg.h>
X
X#define MAXERR 20 /* Maximum number of errors before the parser */
X /* quits. */
X
Xvoid yyerror(char*, ...);
X
Xtypedef struct { /* structure for keyword table */
X String name;
X int token;
X} keyword;
X
Xstatic keyword keywordtable[] = { /* table of keywords */
X {"False", FALSE_T},
X {"MSEL", MSEL_T},
X {"NSEL", NSEL_T},
X {"OSEL", OSEL_T},
X {"True", TRUE_T},
X {"checkpath", CHECKPATH_T},
X {"deficon", DEFICON_T},
X {"define", DEFINE_T},
X {"dir", DIR_T},
X {"exe", EXE_T},
X {"false", FALSE_T},
X {"file", FILE_T},
X {"icon", ICON_T},
X {"if", IF_T},
X {"ignore", IGNORE_T},
X {"name", NAME_T},
X {"options", OPTIONS_T},
X {"path", PATH_T},
X {"prog", PROG_T},
X {"read", READ_T},
X {"set", SET_T},
X {"true", TRUE_T},
X {"type", TYPE_T},
X {"write", WRITE_T}
X};
X/* number of entries in the keyword table */
Xstatic int numkeywords = (sizeof(keywordtable)/sizeof(keywordtable[0]));
X
Xint parseerror=0; /* Number of parse errors */
X
X%}
X%%
X[\t ]*"#".* { /* Remove Comments from beginning of line */ }
X"=" { RETURN(ASSIGN_T); }
X"==" { RETURN(EQUAL_T); }
X"{" { RETURN(O_BRACE_T); }
X"}" { RETURN(C_BRACE_T); }
X"(" { RETURN(O_PAR_T); }
X")" { RETURN(C_PAR_T); }
X";" { RETURN(SEMIC_T); }
X"," { RETURN(COMMA_T); }
X[A-Za-z]+ { int token = parse_keyword(yytext);
X#ifndef DEBUG_LEX
X yylval.number = token;
X return(token);
X#endif
X }
X[\n\t ] { /* Ignore White space */ }
X\"[^\"]*\" {
X#ifdef DEBUG_LEX
X fprintf(stdout, "Token STRING_T %s returned", yytext);
X#else
X yylval.string = yytext;
X return(STRING_T);
X#endif
X }
X. { yyerror("illegal character \'%c\'.", yytext[0]);
X }
X%%
X
X
X/*****************************************************************************
X * yywrap *
X *****************************************************************************/
Xint yywrap(void)
X{
X /* function called when EOF encounterd.
X *
X * - Takes nothing
X * + returns EOF token, not actually used other than to indicate an error
X * to the parser. Useful in DEBUG mode to see that EOF has been detected.
X */
X
X RETURN(EOFTOKEN);
X}
X
X
X/*****************************************************************************
X * parse_keyword *
X *****************************************************************************/
Xint parse_keyword(String str)
X{
X /* Function to determine whether a string is a reserved keyword or an
X * identifier. A table of keywords is searched via a binary search to check
X * to see if the string is a keyword,if it is found the associated
X * token is returned, otherwise the IDENT_T token is returned and
X * the value of the string is assigned to a global structure for
X * use in yacc. The effect of debugging is to prevent the assignment
X * to the yacc structure, and to print out the keyword if found.
X *
X * - Takes a string to check
X * + Returns a token (int)
X */
X
X register int lower = 0, upper = numkeywords-1;
X
X while (lower <= upper) {
X int middle = (lower + upper) /2;
X keyword *p = &keywordtable[middle];
X int res = strcmp(p->name, str);
X
X if (res < 0) {
X lower = middle +1;
X } else if (res == 0) {
X#ifdef DEBUG_LEX
X fprintf(stdout, "Token: %s\tReturned.\n", p->name);
X#endif
X return(p->token);
X } else {
X upper = middle -1;
X }
X }
X yyerror("unknown keyword \'%s\'.", yytext);
X RETURN(ERRORTOKEN);
X}
X
X/*********************************************************************************
X * yyerror *
X *********************************************************************************/
Xvoid yyerror(char *fmt, ...)
X{
X /* Error printing procedure. This procedure takes a variable argument list
X * in the same format as printf(3s), and outputs it on the stderr stream
X * prepended by the line-number currently being processed.
X * parserrror is incremented to indicate that an error has occurred, if
X * more than MAXERR errors occur the parser exits.
X *
X * - Takes a formatted string + parameters to print.
X * + Returns noting.
X */
X
X va_list args;
X extern int yylineno;
X
X if (!parseerror) {
X }
X if (parseerror < MAXERR) {
X va_start(args, fmt);
X fprintf(stderr, "(E) line :%2d: ", yylineno);
X vfprintf(stderr, fmt, args);
X fprintf(stderr, "\n");
X va_end(args);
X parseerror++;
X } else {
X fprintf(stderr, "Fatal error: over %d errors, exiting\n", MAXERR);
X exit(2);
X }
X}
SHAR_EOF
chmod 0644 code/lexical.l || echo "restore of code/lexical.l fails"
echo "x - extracting code/listoption.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/listoption.c &&
X/****************************************************************************
X ** File : listoption.c **
X ** Purpose : Initialise and Realise long listing dialog options **
X ** Author : Edward Groenendaal **
X ** Date : April 1991 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : **
X ****************************************************************************/
X
X#include "xdtm.h"
X#include "menus.h"
X#include <X11/Shell.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/Command.h>
X#include "Xedw/XedwForm.h"
X
X/* Note ListOption *same* order as listoptions */
X
Xtypedef enum {perms, nlinks, owner, group, size, modtm, acctm} ListOption;
X
Xstatic String listoptions[] = {
X "rwxrwxrwx ",
X "1 ",
X "owner ",
X "group ",
X "size ",
X "modtm ",
X "acctm "
X};
X
X/* Widgets */
X
Xprivate Widget listoptionpopup;
Xprivate Widget listoptionform1;
Xprivate Widget listoptionform2;
Xprivate Widget listoptionform3;
Xprivate Widget listoptionlabel;
Xprivate Widget listoptionsettings;
Xprivate Widget listoptionpermsButton;
Xprivate Widget listoptionpermsLabel;
Xprivate Widget listoptionlinksButton;
Xprivate Widget listoptionlinksLabel;
Xprivate Widget listoptionownerButton;
Xprivate Widget listoptionownerLabel;
Xprivate Widget listoptiongroupButton;
Xprivate Widget listoptiongroupLabel;
Xprivate Widget listoptionsizeButton;
Xprivate Widget listoptionsizeLabel;
Xprivate Widget listoptionacctmButton;
Xprivate Widget listoptionacctmLabel;
Xprivate Widget listoptionmodtmButton;
Xprivate Widget listoptionmodtmLabel;
Xprivate Widget listoptionquitButton;
X
X#define ToggleButton(b, w) \
X{ \
X Arg arglist[1]; \
X XtSetArg(arglist[0], XtNbitmap, \
X (current_mode.options & b) ? tick : emptytick); \
X XtSetValues(w, arglist, 1); \
X}
X
X
Xpublic void init_listoption(Widget top)
X{
X private void destroy_listoption_dialog(Widget, caddr_t, caddr_t);
X private void optionbutton_toggled(Widget, ListOption, caddr_t);
X Arg arglist[7];
X Cardinal i;
X XFontStruct *font;
X String settings;
X int width;
X
X static String Label = "Long Listing Options";
X
X /* constuct settings label */
X settings = (String) XtMalloc (sizeof(char) * 55);
X
X sprintf(settings, "%s%s%s%s%s%s%sfilename",
X listoptions[perms],
X listoptions[nlinks],
X listoptions[owner],
X listoptions[group],
X listoptions[size],
X listoptions[modtm],
X listoptions[acctm]);
X
X listoptionpopup = XtCreatePopupShell("listoptionpopup",
X transientShellWidgetClass,
X top,
X NULL, 0);
X
X listoptionform1 = XtCreateManagedWidget("listoptionform1",
X xedwFormWidgetClass,
X listoptionpopup,
X NULL, 0);
X
X i = 0;
X XtSetArg(arglist[i], XtNfullWidth, True); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
X XtSetArg(arglist[i], XtNlabel, Label); i++;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X listoptionlabel = XtCreateManagedWidget("listoptionlabel",
X labelWidgetClass,
X listoptionform1,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNfromVert, listoptionlabel); i++;
X XtSetArg(arglist[i], XtNjustify, XtJustifyLeft); i++;
X listoptionsettings = XtCreateManagedWidget("listoptionsettings",
X labelWidgetClass,
X listoptionform1,
X arglist, i);
X
X /* Get font from widget, then use XTextWidth to find width of string,
X * then set the width of the label to this width + 10.
X */
X
X XtSetArg(arglist[0], XtNfont, &font);
X XtGetValues(listoptionsettings, arglist, 1);
X
X width = XTextWidth(font, settings, strlen(settings));
X
X XtSetArg(arglist[0], XtNwidth, width + 20);
X XtSetValues(listoptionlabel, arglist, 1);
X
X XtFree(settings);
X
X i = 0;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromVert, listoptionsettings); i++;
X listoptionform2 = XtCreateManagedWidget("listoptionform2",
X xedwFormWidgetClass,
X listoptionform1,
X arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromVert, listoptionsettings); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionform2); i++;
X listoptionform3 = XtCreateManagedWidget("listoptionform3",
X xedwFormWidgetClass,
X listoptionform1,
X arglist, i);
X
X /* First bank of buttons */
X
X /* Permissions */
X i = 0;
X listoptionpermsButton = XtCreateManagedWidget("listoptionpermsButton",
X commandWidgetClass,
X listoptionform2,
X arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionpermsButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Permissions"); i++;
X listoptionpermsLabel = XtCreateManagedWidget("listoptionpermsLabel",
X labelWidgetClass,
X listoptionform2,
X arglist, i);
X
X XtAddCallback(listoptionpermsButton, XtNcallback, optionbutton_toggled, perms);
X
X /* Nlinks */
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptionpermsButton); i++;
X listoptionlinksButton = XtCreateManagedWidget("listoptionlinksButton",
X commandWidgetClass,
X listoptionform2,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionlinksButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Number of links"); i++;
X listoptionlinksLabel = XtCreateManagedWidget("listoptionlinksLabel",
X labelWidgetClass,
X listoptionform2,
X arglist, i);
X
X XtAddCallback(listoptionlinksButton, XtNcallback, optionbutton_toggled, nlinks);
X
X /* Owner */
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptionlinksButton); i++;
X listoptionownerButton = XtCreateManagedWidget("listoptionownerButton",
X commandWidgetClass,
X listoptionform2,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionownerButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Owner of file"); i++;
X listoptionownerLabel = XtCreateManagedWidget("listoptionownerLabel",
X labelWidgetClass,
X listoptionform2,
X arglist, i);
X
X XtAddCallback(listoptionownerButton, XtNcallback, optionbutton_toggled, owner);
X
X /* Second bank of buttons */
X
X /* Group */
X
X i = 0;
X listoptiongroupButton = XtCreateManagedWidget("listoptiongroupButton",
X commandWidgetClass,
X listoptionform3,
X arglist, i);
X
X i = 0;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptiongroupButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Group of file"); i++;
X listoptiongroupLabel = XtCreateManagedWidget("listoptiongroupLabel",
X labelWidgetClass,
X listoptionform3,
X arglist, i);
X
X XtAddCallback(listoptiongroupButton, XtNcallback, optionbutton_toggled, group);
X
X /* Size */
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptiongroupButton); i++;
X listoptionsizeButton = XtCreateManagedWidget("listoptionsizeButton",
X commandWidgetClass,
X listoptionform3,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionsizeButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Size of file"); i++;
X listoptionsizeLabel = XtCreateManagedWidget("listoptionsizeLabel",
X labelWidgetClass,
X listoptionform3,
X arglist, i);
X
X XtAddCallback(listoptionsizeButton, XtNcallback, optionbutton_toggled, size);
X
X /* Modification Time */
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptionsizeButton); i++;
X listoptionmodtmButton = XtCreateManagedWidget("listoptionmodtmButton",
X commandWidgetClass,
X listoptionform3,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionmodtmButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Modification time"); i++;
X listoptionmodtmLabel = XtCreateManagedWidget("listoptionmodtmLabel",
X labelWidgetClass,
X listoptionform3,
X arglist, i);
X
X XtAddCallback(listoptionmodtmButton, XtNcallback, optionbutton_toggled, modtm);
X
X /* Access Time */
X
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptionmodtmButton); i++;
X listoptionacctmButton = XtCreateManagedWidget("listoptionacctmButton",
X commandWidgetClass,
X listoptionform3,
X arglist, i);
X
X i = 1;
X XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X XtSetArg(arglist[i], XtNfromHoriz, listoptionacctmButton); i++;
X XtSetArg(arglist[i], XtNlabel, "Access time"); i++;
X listoptionacctmLabel = XtCreateManagedWidget("listoptionacctmLabel",
X labelWidgetClass,
X listoptionform3,
X arglist, i);
X
X XtAddCallback(listoptionacctmButton, XtNcallback, optionbutton_toggled, acctm);
X
X i = 0;
X XtSetArg(arglist[i], XtNfromVert, listoptionform2); i++;
X XtSetArg(arglist[i], XtNlabel, "OK"); i++;
X listoptionquitButton = XtCreateManagedWidget("listoptionquitButton",
X commandWidgetClass,
X listoptionform1,
X arglist, i);
X
X XtAddCallback(listoptionquitButton, XtNcallback, destroy_listoption_dialog, 0);
X}
X
Xpublic void listoption_dialog(void)
X{
X private String makeoptionstring(void);
X String settings;
X Arg arglist[1];
X
X /* set up initial button settings */
X ToggleButton(PERMS, listoptionpermsButton);
X ToggleButton(NLINKS, listoptionlinksButton);
X ToggleButton(OWNER, listoptionownerButton);
X ToggleButton(GROUP, listoptiongroupButton);
X ToggleButton(SIZE, listoptionsizeButton);
X ToggleButton(MODTM, listoptionmodtmButton);
X ToggleButton(ACCTM, listoptionacctmButton);
X
X settings = makeoptionstring();
X
X XtSetArg(arglist[0], XtNlabel, settings);
X XtSetValues(listoptionsettings, arglist, 1);
X
X XtFree(settings);
X
X realize_dialog(listoptionpopup);
X}
X
Xprivate void destroy_listoption_dialog(Widget w, caddr_t client_data,
X caddr_t call_data)
X{
X extern directoryManagerNewDirectory(String);
X extern String cwd;
X
X XtPopdown(listoptionpopup);
X if (current_mode.mode == Long)
X directoryManagerNewDirectory(cwd);
X}
X
Xprivate void optionbutton_toggled(Widget w, ListOption button, caddr_t call_data)
X{
X private String makeoptionstring(void);
X Arg arglist[1];
X String settings;
X
X switch (button) {
X case perms:
X if (current_mode.options & PERMS) {
X current_mode.options &= ~PERMS;
X } else {
X current_mode.options |= PERMS;
X }
X ToggleButton(PERMS, listoptionpermsButton);
X break;
X case nlinks:
X if (current_mode.options & NLINKS) {
X current_mode.options &= ~NLINKS;
X } else {
X current_mode.options |= NLINKS;
X }
X ToggleButton(NLINKS, listoptionlinksButton);
X break;
X case owner:
X if (current_mode.options & OWNER) {
X current_mode.options &= ~OWNER;
X } else {
X current_mode.options |= OWNER;
X }
X ToggleButton(OWNER, listoptionownerButton);
X break;
X case group:
X if (current_mode.options & GROUP) {
X current_mode.options &= ~GROUP;
X } else {
X current_mode.options |= GROUP;
X }
X ToggleButton(GROUP, listoptiongroupButton);
X break;
X case size:
X if (current_mode.options & SIZE) {
X current_mode.options &= ~SIZE;
X } else {
X current_mode.options |= SIZE;
X }
X ToggleButton(SIZE, listoptionsizeButton);
X break;
X case modtm:
X if (current_mode.options & MODTM) {
X current_mode.options &= ~MODTM;
X } else {
X current_mode.options |= MODTM;
X }
X ToggleButton(MODTM, listoptionmodtmButton);
X break;
X case acctm:
X if (current_mode.options & ACCTM) {
X current_mode.options &= ~ACCTM;
X } else {
X current_mode.options |= ACCTM;
X }
X ToggleButton(ACCTM, listoptionacctmButton);
X break;
X default:
X fprintf(stderr, "Error: Listoptions programmer error, option out"
X " of range\n");
X break;
X }
X
X /* Put current options in settings string */
X
X settings = makeoptionstring();
X
X /* Put new settings string in the settings label */
X
X XtSetArg(arglist[0], XtNlabel, settings);
X XtSetValues(listoptionsettings, arglist, 1);
X
X XtFree(settings);
X}
X
Xprivate String makeoptionstring(void)
X{
X /* construct a string representing the current options,
X * the user is responsible for free'ing it.
X */
X String permstring, nlinkstring, ownerstring, groupstring, sizestring;
X String modtmstring, acctmstring, settings;
X
X static String empty = "";
X
X settings = (String) XtMalloc (sizeof(char) * 55);
X
X if (current_mode.options & PERMS)
X permstring = listoptions[perms];
X else
X permstring = empty;
X if (current_mode.options & NLINKS)
X nlinkstring = listoptions[nlinks];
X else
X nlinkstring = empty;
X if (current_mode.options & OWNER)
X ownerstring = listoptions[owner];
X else
X ownerstring = empty;
X if (current_mode.options & GROUP)
X groupstring = listoptions[group];
X else
X groupstring = empty;
X if (current_mode.options & SIZE)
X sizestring = listoptions[size];
X else
X sizestring = empty;
X if (current_mode.options & MODTM)
X modtmstring = listoptions[modtm];
X else
X modtmstring = empty;
X if (current_mode.options & ACCTM)
X acctmstring = listoptions[acctm];
X else
X acctmstring = empty;
X
X sprintf(settings, "%s%s%s%s%s%s%sfilename",
X permstring,
X nlinkstring,
X ownerstring,
X groupstring,
X sizestring,
X modtmstring,
X acctmstring);
X
X return(settings);
X}
SHAR_EOF
chmod 0644 code/listoption.c || echo "restore of code/listoption.c fails"
echo "x - extracting code/main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/main.c &&
X/* v0.1 */
X/***********************************************************************************
X ** File : main.c **
X ** Purpose : Initialise and Realise xdtm **
X ** Author : Edward Groenendaal **
X ** Date : 18th Feb 1990 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : All other xdtm files **
X ***********************************************************************************/
X
X#include "xdtm.h"
X#include "menus.h"
X
X/* local headers */
X
X#include <X11/Shell.h>
X#include "Xedw/XedwForm.h"
X
X/* topLevel is global because it is needed by the quit popup to determine the centre
X * of the application.
X */
Xpublic Widget topLevel;
Xpublic String home;
Xpublic AppData app_data;
X
Xstatic XtResource resources[] = {
X {
X XtNviewWidth,
X XtCViewWidth,
X XtRInt,
X sizeof(int),
X XtOffset(AppDataPtr, view_width),
X XtRImmediate,
X (caddr_t) 85,
X },
X {
X XtNviewHeight,
X XtCViewHeight,
X XtRInt,
X sizeof(int),
X XtOffset(AppDataPtr, view_height),
X XtRImmediate,
X (caddr_t) 25,
X },
X {
X XtNmode,
X XtCMode,
X XtRString,
X sizeof(String),
X XtOffset(AppDataPtr, mode),
X XtRImmediate,
X (caddr_t) "icons",
X },
X {
X XtNviewFont,
X XtCFont,
X XtRFontStruct,
X sizeof(XFontStruct*),
X XtOffset(AppDataPtr, view_font),
X XtRString,
X (caddr_t) "6x10",
X },
X {
X XtNdmFont,
X XtCFont,
X XtRFontStruct,
X sizeof(XFontStruct*),
X XtOffset(AppDataPtr, dm_font),
X XtRString,
X (caddr_t) "*-courier-bold-r-*-120-*",
X },
X};
X
X
Xpublic void main(int argc, char *argv[])
X{
X private void initialiseXdtm(void);
X extern void createMenuWidgets(Widget); /* menus.c */
X extern void createAppManagerWidgets(Widget); /* appman.c */
X extern void createFileManagerWidgets(Widget); /* fileman.c */
X extern void createDialogWidgets(Widget); /* dialogs.c */
X
X extern Icon_mode current_mode;
X Widget topForm;
X Arg arglist[6];
X Cardinal i;
X static String Title = "X DeskTop Manager";
X
X /* Command Line Arguments */
X
X static XrmOptionDescRec options[] = {
X {"-dmfont", "*directoryManager.font", XrmoptionSepArg, NULL}
X };
X
X /* Initialise Program */
X if ((home = (String) getenv("HOME")) == NULL) {
X fprintf(stderr, "can\'t get environment variable HOME\n");
X home = XtNewString("/");
X } else
X home = XtNewString(home);
X
X /* Initialise the user interface */
X
X topLevel = XtInitialize(argv[0],
X "Xdtm",
X options,
X XtNumber(options),
X &argc, argv);
X
X /* Check left over command line arguments */
X if (argc > 1) {
X /* incorrect command line arguments */
X int i;
X static int errs = False;
X
X for (i = 1; i < argc; i++) {
X if (!errs++)
X fprintf(stderr, "%s: command line option unknown:\n", argv[0]);
X fprintf(stderr, "option: %s\n\n", argv[i]);
X }
X fprintf(stderr, "%s understands all standard Xt "
X "command-line options.\n", argv[0]);
X fprintf(stderr, "Additional options are as follows:\n");
X fprintf(stderr, "Option Valid Range\n");
X fprintf(stderr, "-dmfont Any font, should be fixed width\n");
X exit(2);
X }
X
X /* get application resources */
X XtGetApplicationResources(topLevel,
X &app_data,
X resources,
X XtNumber(resources),
X NULL, 0);
X
X /* check values of application resources */
X if (app_data.view_width < 1 || app_data.view_height < 1) {
X fprintf(stderr, "%s: error in resource settings:\n"
X "view window must be greater than 1x1 characters\n",
X argv[0]);
X exit(2);
X }
X
X if (strcmp(app_data.mode, "icons") == 0)
X current_mode.mode = Icons;
X else if (strcmp(app_data.mode, "short") == 0)
X current_mode.mode = Short;
X else if (strcmp(app_data.mode, "long") == 0)
X current_mode.mode = Long;
X else {
X fprintf(stderr, "%s: error in resource settings:\n"
X "mode must be one of either:\n"
X "'icons' Show icons\n"
X "'short' Just display file names\n"
X "'long' Display file names with additional data.\n",
X argv[0]);
X exit(2);
X }
X
X i = 0;
X XtSetArg(arglist[i], XtNbottom, XtChainBottom); i++;
X XtSetArg(arglist[i], XtNtop, XtChainTop); i++;
X XtSetArg(arglist[i], XtNleft, XtChainLeft); i++;
X XtSetArg(arglist[i], XtNright, XtChainRight); i++;
X XtSetArg(arglist[i], XtNhorizDistance, 5); i++;
X XtSetArg(arglist[i], XtNvertDistance, 5); i++;
X topForm = XtCreateManagedWidget("topForm",
X xedwFormWidgetClass,
X topLevel,
X arglist, i);
X
X /* These must be called in this order, top left -> bottom right */
X createMenuWidgets (topForm);
X createAppManagerWidgets (topForm);
X createFileManagerWidgets (topForm);
X createDialogWidgets (topForm);
X
X i = 0;
X XtSetArg(arglist[i], XtNtitle, Title); i++;
X XtSetArg(arglist[i], XtNminWidth, 400); i++;
X XtSetArg(arglist[i], XtNminHeight, 200); i++;
X XtSetValues(topLevel, arglist, i);
X
X tzset();
X
X /* Realize the widgets, (display program) then loop waiting for events */
X
X XtRealizeWidget(topLevel);
X
X initialiseXdtm();
X
X XtMainLoop();
X
X}
X
Xpublic void quitQueryResult(Widget w, Boolean quit, caddr_t call_data)
X{
X extern void destroy_quit_dialog(void);
X /* Quit selected */
X if (quit == True)
X exit(0);
X
X /* Cancel selected */
X destroy_quit_dialog();
X}
X
Xprivate void initialiseXdtm(void)
X{
X
X extern void initAppManager(Widget); /* appman.c */
X extern void initFileManager(Widget); /* fileman.c */
X extern void parsePreferences(Widget); /* parse.c */
X
X parsePreferences(topLevel);
X initAppManager(topLevel);
X initFileManager(topLevel);
X}
SHAR_EOF
chmod 0644 code/main.c || echo "restore of code/main.c fails"
echo "x - extracting code/map.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > code/map.c &&
X/*****************************************************************************
X ** File : map.c **
X ** Purpose : Initialise and Realise map dialog **
X ** Author : Edward Groenendaal **
X ** Date : April 1991 **
X ** Documentation : Xdtm Design Folder **
X ** Related Files : **
X *****************************************************************************/
X
X#include "xdtm.h"
X#include "parse.h" /* For SelOptions, ESIZE */
SHAR_EOF
echo "End of part 2"
echo "File code/map.c is continued in part 3"
echo "3" > s2_seq_.tmp
exit 0
More information about the Alt.sources
mailing list