eddyg@cogs.sussex.ac.uk (EdwardJ. Groenendaal) (05/19/91)
Submitted-by: Edward "J." Groenendaal <eddyg@cogs.sussex.ac.uk> Posting-number: Volume 13, Issue 11 Archive-name: xdtm/part06 Submitted-by: eddyg@cste Archive-name: xdtm/part06 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is part 06 of xdtm # ============= xdtm/display.c ============== if test ! -d 'xdtm'; then echo 'x - creating directory xdtm' mkdir 'xdtm' fi if test -f 'xdtm/display.c' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/display.c (File already exists)' else echo 'x - extracting xdtm/display.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/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#ifndef TRUE_SYSV X#include <sys/file.h> /* For access(2) */ X#endif X 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 X/***************************************************************************** X * init_query * X *****************************************************************************/ Xpublic void init_query(Widget top) X{ X /* Initialise the query dialog widgets. */ 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 X/***************************************************************************** X * init_display * X *****************************************************************************/ Xpublic void init_display(Widget top) X{ X /* Initialise the widgets used for viewing a file */ X X private void destroy_display_dialog(Boolean); X 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 the X * value in the application defaults (default 85), X * set the height of the widget to (ascent + descent) * value in the X * application defaults (default 25). 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 via 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/***************************************************************************** X * query_dialog * X *****************************************************************************/ Xpublic void query_dialog(String fullname, Boolean Query) X{ X /* Pop the query dialog up onto screen. If Query is true then X * the default string is displayed, "View selected File?" and X * the callback is linked with the display popup, otherwise X * the user supplied string 'fullname' is used, the callback just X * unpopup's the popup. X * This dialog can be used as a multi-purpose query dialog by using X * this feature. X * X * - Takes an optional string to display, and a boolean saying whether X * to use the default function or not. X */ 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 X/***************************************************************************** X * destroy_query_dialog * X *****************************************************************************/ Xprivate void destroy_query_dialog(void) X{ X /* Popdown the query dialog, remove the callback lists */ X X XtPopdown(querypopup); X X XtRemoveAllCallbacks(queryyes, XtNcallback); X XtRemoveAllCallbacks(queryno, XtNcallback); X X} X X/* display */ X X/***************************************************************************** X * displayfile * X *****************************************************************************/ Xpublic void displayfile(String fullname) X{ X /* This procedure popup's a window with the file 'fullname' contained X * within a text widget. When quit is selected the window is popped down. X * On my A/UX machine the text widget breaks with a segmentation fault X * if the specified file is not a text file (most of the time), X * therefore rather than check the type of the file X * everytime before viewing a file I check for the SIGSEGV signal, X * if this occurs it is assumed that the file is not a text X * file and an error message is displayed, the program continues. X * X * - Takes the name of the file to be viewed X */ 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 X/***************************************************************************** X * seggie * X *****************************************************************************/ Xprivate void seggie(int value) X{ X /* This procedure is called if a segmentation fault occurs when trying X * to view a file. It jumps back to the point immediately before X * the text widget tried to load the file and display's an error message. X */ X X longjmp(env, value); X} X X/***************************************************************************** X * destroy_display_dialog * X *****************************************************************************/ Xprivate void destroy_display_dialog(Boolean destroy) X{ X /* Popdown the display popup */ X X XtPopdown(displaypopup); X} X X/***************************************************************************** X * queryQueryResult * X *****************************************************************************/ Xprivate void queryQueryResult(Widget w, queryReturn result, caddr_t dummy) X{ X /* Pop the query dialog down, if the user asked to view a file then X * call display file to view it (if readable). X * X * - Takes a result of the button presses, if this is ViewReturn display X * the file, otherwise it is CancelReturn. X */ 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 xdtm/display.c || echo 'restore of xdtm/display.c failed' Wc_c="`wc -c < 'xdtm/display.c'`" test 11820 -eq "$Wc_c" || echo 'xdtm/display.c: original size 11820, current size' "$Wc_c" fi # ============= xdtm/docs/README ============== if test ! -d 'xdtm/docs'; then echo 'x - creating directory xdtm/docs' mkdir 'xdtm/docs' fi if test -f 'xdtm/docs/README' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/docs/README (File already exists)' else echo 'x - extracting xdtm/docs/README (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/docs/README' && XThe printable documentation for the X Desktop Manager is available Xonly in Macintosh Word 4 format. X XOnly the User's Guide is currently available, to obtain this file Xyou should mail a request to an automatic mail server running on my Xaccount. The service is triggered by the string "-SUIS-" in the XSubject line of your message. X XTo obtain the index of xdtm files available: X X% mail eddyg@cogs.sussex.ac.uk XTo: eddyg@cogs.sussex.ac.uk XSubject: -SUIS- X XRequest: xdtm XTopic: index XRequest: end X X^D X XTo obtain the xdtm User's Guide: X XRequest: xdtm XTopic: xdtm.hqx.01 XTopic: xdtm.hqx.02 XTopic: xdtm.hqx.03 XTopic: xdtm.hqx.04 XRequest: end X X SHAR_EOF chmod 0644 xdtm/docs/README || echo 'restore of xdtm/docs/README failed' Wc_c="`wc -c < 'xdtm/docs/README'`" test 637 -eq "$Wc_c" || echo 'xdtm/docs/README: original size 637, current size' "$Wc_c" fi # ============= xdtm/fileman.c ============== if test -f 'xdtm/fileman.c' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/fileman.c (File already exists)' else echo 'x - extracting xdtm/fileman.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/fileman.c' && X/***************************************************************************** X ** File : fileman.c ** X ** Purpose : Receive and distribute directory changes ** X ** Author : Edward Groenendaal ** X ** Date : 18th Feb 1991 ** 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 X/***************************************************************************** X * createFileManagerWidgets * X *****************************************************************************/ Xpublic void createFileManagerWidgets(Widget w) X{ X /* Create file manager widgets, this includes directory manager, X * directory selector and may in the future include the tree manager X * which displays a tree structure representing the file system X */ X X private void GotoDir(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 X/***************************************************************************** X * initFileManager * X *****************************************************************************/ Xpublic void initFileManager(Widget w) X{ X /* initialise file management bits */ 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 X/***************************************************************************** X * * X *****************************************************************************/ Xprivate void GotoDir(Widget w, XButtonEvent *event) X{ X /* Goto directory, this is an action called in reponse to the key return X * within the directory selector. X */ X X private goto_dir(Widget, caddr_t, caddr_t); X X goto_dir(w, 0, 0); X} X X/***************************************************************************** X * goto_dir * 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, this should be expanded to include ~username */ X if (*value == '~') { X tmp = (String) XtMalloc ((strlen(home) + strlen(value) + 2) * 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 X/***************************************************************************** X * setCursor * 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 xdtm/fileman.c || echo 'restore of xdtm/fileman.c failed' Wc_c="`wc -c < 'xdtm/fileman.c'`" test 9280 -eq "$Wc_c" || echo 'xdtm/fileman.c: original size 9280, current size' "$Wc_c" fi # ============= xdtm/help ============== if test -f 'xdtm/help' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/help (File already exists)' else echo 'x - extracting xdtm/help (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/help' && X This is the X Desktop Manager Help file. X Version 1.0 X for Version 1.4 of xdtm. X X Edward Groenendaal, April 1991. X X X +--------------------------------------------------------------+ X | File Options View Goto: directory selector | X |--------------------------------------------------------------| X | selection menu | | X |----------------| | X | | | X | | | X | application | | X | manager | directory manager | X | | | X | | | X | | | X | | | X | | | X | | | X | | | X |-------------- | | X |Trash move copy | | X +--------------------------------------------------------------+ X Figure 1: X Desktop Manager X X X1. Selecting files X================== X XWhen a file is selected the icon and/or filename representing it in Xthe filemanager is highlighted by inverting it. When a file is Xselected it is available as an argument to another program or to be Xmoved, copied or deleted. X XFiles may be selected either via the mouse, regular expression, or all Xthe files via a key-press. X X1.1 Selecting files via the mouse X--------------------------------- X XTo select a file using the mouse, press the first mouse button down Xwhile the pointer is over the file you wish to select. To select more Xthan one file at a time the modifier key SHIFT may be applied at the Xsame time as the mouse button in which case any files already selected Xwill remain so, and the file selected will also be selected. X X1.2 Selecting files via a regular expression X-------------------------------------------- X XUsing the 'Select files by template' option in the 'Options' menu the Xuser may enter a standard UNIX regular expression describing the set Xof filenames to be selected. (See section 12 on regular expressions at Xthe end of this help file) X XExample. X X The regular expression "\.c$" will select all C source files X The regular expression "^#.*#$" will select all emacs auto-save X files, (#filename#). X X1.3 Selecting files via the keyboard X------------------------------------ X XIf you want to select all the files in the current directory, except X'.' and '..' you may use may press the key 'a' when in the directory Xmanager window. X X1.4 Executing, and Viewing files X-------------------------------- X XIf you double click on a file then depending on the type of file Xone of three things will happen, if the file is a directory you will Xchange to that directory, if the file is executable it will be executed, Xotherwise you will be prompted whether you want to view the file. X X1.4.1 Viewing files X------------------- X XTo view a file double-click on a plain file then answer View to the Xquery box. A large text-window with a scroll bar will appear in the Xcenter of the application. Use the scroll bar to move through the Xfile. Text maybe highlighted using the mouse, then pasted into other X Xapplications. The text widget also understands some emacs commands: X XControl V - Next Page XMeta V - Previous Page XControl S - Forward Search XControl R - Reverse Search X XLook at the documentation for the Athena Text Widget for a full list Xof the translations. X X2. Deleting files X================= X XTo delete files, select the files (or directories) to delete, then Xeither select the TRASH button under the application manager, or Xselect the 'Delete files' option in the 'File' menu. X XBefore the files are deleted the user will be prompted, only if delete Xis then chosen will the files actually be deleted. X XAfter the files have been deleted, the directory listing will be Xupdated. It is possible using the application resource (or command Xline option -delay) to set a delay period between the delete and the Xupdate of the directory, this is for machines working over an NFS Xnetwork where the update of directories can be slow. X X3. Moving files X=============== X XTo move files from one directory to another, select the files (or Xdirectories) to move, then either select the MOVE button under the Xapplication manager or select the 'Move files" option in the 'File' Xmenu. The cursor will change to a move cursor (a smaller version of Xthe picture on the MOVE button), change directory to the file in which Xyou wish to place the files. X XBefore the files are copied the user will be prompted, only if move Xis chosen will the files actually be moved. X XAfter the files have been moved the directory listing will be updated. XIt is possible using the application resource (or command line option X-delay) to set a delay period between the delete and the update of the Xdirectory, this is for machines working over an NFS network where the Xupdate of directories can be slow. X X4. Copying files X================ X XThe copying of files is exactly the same as the moving of files Xdescribed above. X X5. Changing Directories X======================= X XTo change directories you may either type a new directory in the Xdirectory selector, double click on the directory you wish to enter, Xor press the key 'u' on the keyboard to ascend to the above directory X(previous directory in the path). X X5.1 Directory Selector X---------------------- X XTo edit the directory in the directory selector move the pointer over Xthe directory selector text until the pointer changes into a text Xinsert cursor. X XAt this point you can do the following: X XPress a mouse button - The caret will move to the position of the pointer XPress Control A - The caret goes to the start of the text XPress Control E - The caret goes to the end of the text XPress Return - The directory manager will change directory to X the one in the directory selector. It will ring X the Bell on failure. XPress Escape - Clear the text in the directory selector XPress Right Arrow - Move caret right XPress Left Arrow - Move caret left XPress Delete - Delete character to left of caret XPress Backspace - Delete character to left of caret XPress any other key - Insert that letter X XDirectories must start with either '/' or your home directory '~/' you Xcannot specify someone else's home directory, '~alix/'. X X6. The Directory View X===================== X XThe directory list may show either: X X o Icons - icons and filenames X o No Icons - filenames X o Long Listing - filenames plus zero or more of permissions, X number of links, owner, group, size, modification time, and access time. X XThe different modes may be selected via the 'View' menu. To set Xthe long listing options select 'Options' in the 'View' menu. X XNote: If you are using xdtm on a network using NIS (yellow pages) then Xthe lookup time for user name and group may be unbearably slow. If you Xwish to fix this yourself look at the Enhancements file in the xdtm Xsource directory. X X7. Mapping a program over selected files X======================================== X XThis option found in the 'Options' menu will prompt you for a command Xto execute with the selected files as parameters. The format of this Xcommand should be the same as that used to specify commands for the Xselection list (See section 9.2.1). X XThe program will be run in the background, therefore use of xdtm may Xcontinue. A bell will sound when the program terminates and if the XdirOnExit application resource is True the directory manager will Xrefresh the directory listing. X X8. Application Manager Selection Lists X====================================== X XThe application manager controls a number of selection lists, each Xselection list contains a number of icons which when pressed will Xexecute a specific command. X Xexample, X XThe programming selection list would contain all the programs normally Xused by yourself when developing a piece of software. In my case that Xlist contains, emacs - To edit files, Make All - To recompile files, XMake etags - To re-make the emacs TAGS database, Make clean - to remove Xall unnecessary files from the current directory, and gdb - to debug Xprograms. X XThe Application manager can only display one selection list at a time Xand so to switch between selection lists the selection menu is used. XThe selection menu lists all the available selection lists. X XWhen a command is executed from the application manager it is run Xin the background, therefore xdtm may be used in parallel. When Xa program terminates a bell is rung. X XSome programs that may be in the selection list expect filenames as Xarguments. To execute these commands the user must select one or more Xfiles in the current directory BEFORE double-clicking on the selection Xin the selection list. Conversely some commands do not expect Xarguments, for these no files should be selected. X X9. Configuration file X===================== X XWhen xdtm is executed it expects to read a configuration file. There Xare four places it will try: X X o Use the application resource 'Xdtm.configFile' to obtain a file name X o Use the command line argument '-cf <filename>' X o Look in the users home directory for the file '.xdtmrc' X o Look for the system xdtmrc, in a public lib directory. X XIf all these methods fail the program will terminate. X XThe configuration file contains two important sections, the icon rules Xfor specifying which icons are mapped to which filenames and types, Xand the selection lists. X XThe configuration language is a mix between C and csh, but is very Xeasy to learn even for someone without any previous computer Xexperience. X XBefore you can define either the icon rules or the selection lists Xxdtm must know where to find the icon bitmaps. At the top of the file Xshould be a command setting the 'path' through which xdtm will search Xfor an icon with the specified name. The path should be a colon Xdelimited list of directories. E.g. X X set path = "/usr/local/lib/xdtm/icons:~/lib/eddy:~/lib/alix"; X Xwould tell xdtm to search the directories, /usr/local/lib/xdtm/icons, X~/lib/eddy and ~/lib/alix (where ~ refers to my home directory). The Xpath my be reset at any point in the configuration file, but because Xthe icons are all loaded while parsing the config file on startup no Xruntime speed increase will be noticed. X XComments may be included anywhere in the file. They are started by a Xhash '#' preceeded by either one or more spaces or tabs. The comments Xare terminated by the next newline. X X9.1 Icon Rules X-------------- X XThe mapping between files and their representative icons is performed Xby a sequence of possibly nested if-then statements. Each 'if' statement Xtries to limit the set of possible icons for that filename until there Xare no more rules left to apply, in which case that icon will be used. X XAn if statement may test for the following characteristics of a file: X X 1) Is it a directory? X 2) Is it a plain file? X 3) Is it block special? X 4) Is it character special? X 5) Is it a symbolic link? X 6) Is it a fifo? X 7) Is it a socket? X 8) Is it executable? X 9) Is it readable? X10) Is it writable? X11) Does it's filename match this regular expression? X XExamples : X Xif (type==dir) { if (type==file) { if (type==block) { X ... ... ... X} } } X Xif (type==character) { if (type==slink) { if (type==fifo) { X ... ... ... X} } } X Xif (type==socket) { if (type==exe) { if (type==read) { X ... ... ... X} } } X Xif (type==write) { if (name=="\.tar$") { X ... ... X} } X XThese rules may be nested to any depth. Note. that when checking a Xfilename the rules in a block are NOT executed top-down they are Xexecuted in the same order as the numbered list above. X X9.1.1 Symbolic Links X-------------------- X XAfter a successful match on a symbolic link any rules within that Xblock refer to the file that the link points to. Note: You *cannot* Xnest checks for symbolic links. X XExample: X X if (type==slink) { X set deficon="slink.icon"; X if (type==dir) { X set icon="folder.icon"; X } X } X X If the symbolic link points to a directory then show the X icon for a directory, otherwise use the symbolic link icon. X X9.1.2 Checking the path or just filename X---------------------------------------- X XWhen checking the name of a file against a regular expression the Xmatch can be applied over the full path of the file or just the file. XThis may be set at any point in the file by setting the variable X'checkpath' to either 'True' to check the whole path or 'False' to Xcheck only the filename. X XExample: X X set checkpath = False; X if (name == "\.man$") { X set icon = "manpage.icon"; X } X set checkpath = True; X if (name == "/man[1-8l]/") { X set icon = "manpage.icon"; X } X X The first rule will match any filename ending in .man. The second X will set the icon to manpage.icon of any file within a manual page X directory. X X9.1.3 Setting the default icon X------------------------------ X XWithin any block you may set the default icon which will be used if Xno other icon has been set within that block. It is often used at Xthe top of the file in case no rules are matched. X XExample: X X if (type == dir) { X set deficon = "folder.icon"; X if (name == "^\.\.$") { X set icon = "dotdot.icon"; X } X } X X All directories will have the icon folder.icon unless they have the X name ".." in which case they will have the icon dotdot.icon. X X9.1.4 Ignoring files X-------------------- XTo ignore files you may use the ignore variable, if set within a block Xit takes the place of an icon. When viewing directories in Icon mode Xany files that would be matched by that rule are not displayed. This Xis useful for ignoring temporary and configuration files. X XExample: X X if (name=="^#\.*#$") { X set ignore; X } X X Ignore all files which have a filename starting and ending in a X hash. (Emacs auto-save files) X X9.2 Selection Lists X------------------- X XYou may define as many selection lists as you like, each list may contain Xan unlimited amount of commands. The selection lists are defined Xusing the following syntax: X Xdefine "selection name" = { X { X name = "Name in Selection List"; X icon = "filename of icon"; X prog = "program to execute"; X options = NSEL; X } X { X ... X } X . X . X . X} X XThe name entry of a command is the title given to the icon in the Xselection list. XThe icon is the filename of the icon displayed. XThe prog is the program and arguments to be executed when the icon Xis double-clicked. XThe options specify whether the program can accept filenames as Xarguments, if it can then just one file or multiple files. X X9.2.1 Program specification X--------------------------- X XThe program line must start with an executable program, though it Xdoesn't have to be a binary (unless the exec on your machine Xdoesn't understand the #! notation at the top of scripts). The Xrest of the program line may contain arguments to this program Xarguments may be grouped together by inclosing them in single Xquotes. The filenames if allowed will by default be appended to Xthis program line. If you wish to have the filenames inserted Xat some other point then insert the characters "!@" where you Xwish the filenames to be inserted. X XXdtm does NOT understand escaped characters. X XWhen the program is executed it's standard input and output are Xredirected to /dev/NULL. This prevents interactive programs from Xgrabbing the terminal from which you executed xdtm, they will receive Xa EOF character as soon as they try to read. You also don't want to Xsee any output messages from these programs unless they are error Xmessages in which case they will be displayed. The program is run Xin the background, this means that you can carry on using xdtm. When Xthis program terminates a bell will be sounded and if the application Xresource dirOnExit is set to True the directory list will be updated. X XIf you wish to use an interactive program which does NOT have an X Xfront end you should execute an xterm then execute your program Xwithin that xterm. X XExample, X Xprog = "xterm -T 'Test of Xdtm' -e sh -c 'make | tee Make.out | less'" X XThis command line will execute an xterm with the title Test of Xdtm Xwithin that xterm a bourne shell will be executed which will in turn Xexecute make piping the output to tee which will save a copy in the Xfile Make.out and pipe the rest to less (which stops the xterm dyeing Xas soon as make terminates). X X X10. Command Line arguments X========================== X XXdtm understands all the normal X Toolkit command line arguments, plus X X-delay <number> The delay between files being modified and the directory X being updated. Number should be between 0 and 5 seconds X-cf <filename> Use filename as the configuration file. X-dmfont <font> Use font for in the directory list. X X11. Application Resources X========================= X XResource Name Default Description X------------- ------- ----------- X XviewWidth 85 Width in characters of the view window XviewHeight 25 Height in characters of the view window Xmode icons Initial mode for directory list X one of "icons", "short", "long" Xdelay 0 Delay between files being modified X and the directory being updated. X In seconds, range 0 to 5. XdirOnExit False Refresh dir when a program terminates XconfigFile NULL Config filename XviewFont 6x10 Font when viewing a file XdmFont *-courier-bold-r-*-120-* Font in directory Manager X X X12. Regular Expressions X======================= X Xdot '.' X matches any single character X Xasterisk '*' X matches any number (including zero) of any single character X (including a regular expression meta character) preceding X it. X Xsquare brackets '[ ]' X match any one of the characters inclosed within the brackets. X A range of characters may be specified by separating the first X and last character of the range with a hyphen. A circumflex (^) X as the first character in the list negates the match; i.e. match X any character NOT in the list. X Xescaped braces '\{n, m\}' X matches a range of occurrences of a single character (including X any regular expression meta character) preceding it. n and m X are cardinals between 0 and 256 that specify the minimum and X maximum number of occurrences to match. e.g. [0-9]\{4,6\} will X match any number of 4 to 6 digits in length. X Xcaret '^' X A caret requires that the rest of the expression be matched at X the beginning of the string. X Xdollar sign '$' X A dollar sign requires that the preceding expression be matched X at the end of the string. X Xbackslash '\' X A backslash escapes the meaning of any regular expression meta X character so that it has the meaning of a normal character. X X13. Thanks X========== X XThanks to the following people who sent me bug reports, suggestions, Xpatches etc.. (not in any particular order) X XDidier Fort, David Byers, Andreas (the Imake man), Christos Zoulas, XBrett McCoy, Bill McLean, Johan Vromans, Johan Widen, Gustaf Neumann, XJames Beal, Harald Vogt, Hugues Leroy, and Henry Thomas. X XAnd a special thanks to Alix Courtney for designing all the pretty Xicons in the directory alix. X XAnd Song-Tu Yang who did a port of version 1.0 to the MIPS but I haven't Xbeen able to contact him through the supplied addresses to get the patches! X XAnd Jean-Christophe Collet (jcc) for porting xdtm to straight SYSV machines. X X14. Files X========= X X$LIBDIR/xdtm/help - This help file X$LIBDIR/xdtm/xdtmrc - The system configuration file X$LIBDIR/xdtm/icons - The system icon bitmaps X~/.xdtmrc - User configuration file X$BINDIR/xdtm - executable. X Xwhere $LIBDIR and $BINDIR are defined in the imake config files to Xbe the local library and binary directories. SHAR_EOF chmod 0644 xdtm/help || echo 'restore of xdtm/help failed' Wc_c="`wc -c < 'xdtm/help'`" test 20446 -eq "$Wc_c" || echo 'xdtm/help: original size 20446, current size' "$Wc_c" fi # ============= xdtm/icons/alix/airballoon.icon ============== if test ! -d 'xdtm/icons'; then echo 'x - creating directory xdtm/icons' mkdir 'xdtm/icons' fi if test ! -d 'xdtm/icons/alix'; then echo 'x - creating directory xdtm/icons/alix' mkdir 'xdtm/icons/alix' fi if test -f 'xdtm/icons/alix/airballoon.icon' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/icons/alix/airballoon.icon (File already exists)' else echo 'x - extracting xdtm/icons/alix/airballoon.icon (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/icons/alix/airballoon.icon' && X/* This X bitmap is designed for use with the X Desktop Manager. X * it was designed by Alix Courtney, April 1991. X */ X#define drawing3_width 32 X#define drawing3_height 32 Xstatic char drawing3_bits[] = { X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x05, X 0x00, 0x18, 0x8c, 0x0a, 0x00, 0x04, 0x10, 0x00, 0x00, 0x02, 0x20, 0x00, X 0x00, 0x02, 0x20, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x07, 0x70, 0x14, X 0x00, 0xf9, 0x4f, 0x2a, 0x00, 0x81, 0x40, 0x00, 0x00, 0x81, 0x40, 0x00, X 0x00, 0x82, 0x20, 0x00, 0x00, 0x82, 0x20, 0x00, 0x00, 0x84, 0x10, 0x00, X 0x00, 0x9c, 0x1c, 0x00, 0x00, 0xe4, 0x13, 0x00, 0x00, 0x88, 0x08, 0x00, X 0x00, 0x88, 0x28, 0x00, 0x00, 0x90, 0x34, 0x00, 0x00, 0x90, 0x0c, 0x00, X 0x00, 0x90, 0x3e, 0x00, 0x14, 0xf0, 0x47, 0x00, 0x2a, 0x90, 0x04, 0x00, X 0x00, 0x90, 0x04, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x10, 0x04, 0x01, X 0x00, 0xf0, 0x87, 0x02, 0x00, 0x00, 0x40, 0x04, 0x40, 0x00, 0x20, 0x08, X 0xa0, 0x00, 0x70, 0x1f, 0xf0, 0x01, 0xf8, 0x3f}; SHAR_EOF chmod 0644 xdtm/icons/alix/airballoon.icon || echo 'restore of xdtm/icons/alix/airballoon.icon failed' Wc_c="`wc -c < 'xdtm/icons/alix/airballoon.icon'`" test 1005 -eq "$Wc_c" || echo 'xdtm/icons/alix/airballoon.icon: original size 1005, current size' "$Wc_c" fi # ============= xdtm/icons/alix/alien.icon ============== if test -f 'xdtm/icons/alix/alien.icon' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/icons/alix/alien.icon (File already exists)' else echo 'x - extracting xdtm/icons/alix/alien.icon (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/icons/alix/alien.icon' && X/* This X bitmap is designed for use with the X Desktop Manager. X * it was designed by Alix Courtney, April 1991. X */ X#define pic_width 32 X#define pic_height 32 Xstatic char pic_bits[] = { X 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x10, 0x1c, 0x60, 0x00, 0x1c, X 0x0e, 0xd0, 0x0c, 0x38, 0x1c, 0x90, 0x1a, 0x1c, 0x04, 0x70, 0x12, 0x10, X 0x00, 0x60, 0x0c, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x68, 0x1c, 0x00, X 0x40, 0x44, 0x28, 0x00, 0x70, 0x04, 0x40, 0x30, 0xe0, 0x04, 0x44, 0x4b, X 0x70, 0x44, 0x42, 0x45, 0x40, 0x8c, 0x21, 0x41, 0x00, 0x30, 0x3c, 0x42, X 0x00, 0xc8, 0x23, 0x22, 0x00, 0x04, 0x60, 0x11, 0x00, 0x04, 0xc0, 0x11, X 0x00, 0x02, 0x00, 0x08, 0x00, 0x09, 0x00, 0x08, 0x00, 0x05, 0x60, 0x04, X 0x80, 0x04, 0x80, 0x03, 0x80, 0x04, 0x80, 0x00, 0x80, 0x04, 0x80, 0x00, X 0x60, 0x04, 0x80, 0x00, 0x10, 0x08, 0x40, 0x00, 0xd0, 0x09, 0xc0, 0x01, X 0x20, 0x06, 0x20, 0x06, 0x10, 0x00, 0x10, 0x08, 0x10, 0x00, 0x10, 0x08, X 0x10, 0x30, 0x10, 0x08, 0xe0, 0xef, 0xef, 0x07}; SHAR_EOF chmod 0644 xdtm/icons/alix/alien.icon || echo 'restore of xdtm/icons/alix/alien.icon failed' Wc_c="`wc -c < 'xdtm/icons/alix/alien.icon'`" test 990 -eq "$Wc_c" || echo 'xdtm/icons/alix/alien.icon: original size 990, current size' "$Wc_c" fi # ============= xdtm/icons/alix/bat.icon ============== if test -f 'xdtm/icons/alix/bat.icon' -a X"$1" != X"-c"; then echo 'x - skipping xdtm/icons/alix/bat.icon (File already exists)' else echo 'x - extracting xdtm/icons/alix/bat.icon (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xdtm/icons/alix/bat.icon' && X/* This X bitmap is designed for use with the X Desktop Manager. X * it was designed by Alix Courtney, April 1991. X */ X#define bat_width 32 X#define bat_height 32 Xstatic char bat_bits[] = { X 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, 0x0a, 0x39, 0x00, X 0x00, 0x94, 0x4a, 0x00, 0x00, 0x64, 0x92, 0x00, 0x00, 0x54, 0x22, 0x01, X 0x60, 0x54, 0x22, 0x02, 0x50, 0x04, 0x41, 0x04, 0x48, 0x68, 0x41, 0x08, X 0x48, 0x08, 0x21, 0x10, 0x44, 0x08, 0x11, 0x20, 0x82, 0x04, 0x0e, 0x20, X 0x02, 0x07, 0x04, 0x40, 0x01, 0x04, 0x0c, 0x40, 0x01, 0x02, 0x10, 0x40, X 0x01, 0x02, 0x10, 0x80, 0x01, 0x02, 0x00, 0x80, 0x01, 0x02, 0x00, 0xb0, X 0x01, 0x02, 0x00, 0x48, 0x01, 0x02, 0x00, 0x44, 0x01, 0x04, 0xc0, 0x45, X 0x01, 0x08, 0x20, 0x06, 0x01, 0x10, 0x20, 0x04, 0x01, 0x20, 0x20, 0x00, X 0x01, 0x40, 0x2e, 0x00, 0x01, 0x78, 0xb1, 0x03, 0xc2, 0x84, 0xc1, 0x00, X 0x26, 0x03, 0x41, 0x03, 0x2c, 0xc2, 0x47, 0x00, 0x28, 0x40, 0xc1, 0x00, X 0x30, 0x00, 0x03, 0x00, 0x60, 0x00, 0x00, 0x00}; SHAR_EOF chmod 0644 xdtm/icons/alix/bat.icon || echo 'restore of xdtm/icons/alix/bat.icon failed' Wc_c="`wc -c < 'xdtm/icons/alix/bat.icon'`" test 990 -eq "$Wc_c" || echo 'xdtm/icons/alix/bat.icon: original size 990, current size' "$Wc_c" fi true || echo 'restore of xdtm/icons/alix/bear.icon failed' echo End of part 6, continue with part 7 exit 0 -- Dan Heller O'Reilly && Associates Z-Code Software Comp-sources-x: Senior Writer President comp-sources-x@uunet.uu.net argv@ora.com argv@zipcode.com