home *** CD-ROM | disk | FTP | other *** search
- /* Systems Sciences Laboratory, Webster Research Center */
-
- static char *PROGRAM_information[] =
- {
- "Copyright (c) 1988 Xerox Corporation. All rights reserved.",
- "$Header$",
- "$Locker$"
- }
- ;
-
- /*
- * Copyright protection claimed includes all forms and matters of copyrightable
- * material and information now allowed by statutory or judicial lay or
- * herinafter granted, including without limitation, material generated from
- * the software programs which are displayed on the screen such as icons,
- * screen display looks, etc.
- */
-
-
- #include "xfilebrowser.h"
- #include <ctype.h>
-
- extern char *get_userdir();
-
- /* ARGSUSED */
- disp_message(fmt, arg1, arg2, arg3, arg4)
- char *fmt;
- {
- char buf[1024];
- int maxlength = 1024;
- XtTextBlock text;
- XtTextPosition pos, start;
-
- sprintf(buf, fmt, arg1, arg2, arg3, arg4);
- text.length = strlen(buf);
- text.ptr = buf;
- text.firstPos = 0;
- allowedit = 1;
-
- pos = (*messsource->Scan)(messsource, 0, XtstAll, XtsdRight,1,0);
-
- if ( (pos + text.length) > maxlength) start = 0;
- else start = pos;
- XtTextReplace( messwidget, start, pos, &text);
- XtTextSetInsertionPoint(messwidget, start + text.length);
-
- allowedit = 0;
- /* Feep(); */
- }
-
-
- /* ARGSUSED */
- Widget makeCommandButton(box, name, function)
- Window box;
- char *name;
- XtCallbackProc function;
- {
- static XtCallbackRec callbackList[] = { {NULL, NULL}, {NULL, NULL} };
- static Arg arg[] = { {XtNcallback,(XtArgVal)callbackList} };
-
- callbackList[0].callback = function;
- return (XtCreateManagedWidget(name, commandWidgetClass, box, arg, 1));
- }
-
- /* ARGSUSED */
- Widget makeStringBox(parentBox, string, length)
- Widget parentBox;
- char *string;
- {
- Arg args[5];
- Widget StringW;
- int numargs;
- numargs = 0;
- MakeArg(XtNeditType, (XtArgVal)XttextEdit );
- MakeArg(XtNtextOptions, (XtArgVal)( resizeWidth));
- MakeArg(XtNstring,(XtArgVal)string);
- MakeArg(XtNwidth, (XtArgVal)length);
- MakeArg(XtNlength, (XtArgVal)1000);
- StringW = XtCreateManagedWidget("stringthing", asciiStringWidgetClass,
- parentBox, args, numargs);
- return(StringW);
- }
-
- /* ARGSUSED */
- clear_widget(w, wsrc)
- Widget w;
- XtTextSource wsrc;
- {
- XtTextBlock text;
- XtTextPosition end;
-
- allowedit = 1;
- text.length = 0;
- text.ptr = "";
- text.firstPos = 0;
-
- end = (*wsrc->Scan)(wsrc, 0, XtstAll, XtsdRight, 1, 0);
-
- XtTextReplace(w, 0, end, &text);
- XtTextUnsetSelection(w);
- XtTextSetInsertionPoint(w, 0);
- allowedit = 0;
- }
-
-
- int setup_dirlabel(dir, pattern)
- char *dir, *pattern;
- {
- Arg dirargs[1];
- XtTextSource src;
- XtTextBlock text, block;
- XtTextPosition end;
-
- /* setup the new pattern in the fpatwindow widget */
- allowedit = 1;
- text.length = strlen(pattern);
- text.ptr = pattern;
- text.firstPos = 0;
-
- src = XtTextGetSource(fpatwindow);
- (void)(*src->Read)(src, 0, &block, 254);
-
- end = block.length;
- XtTextReplace(fpatwindow, 0, end, &text);
- allowedit = 0;
-
- /* setup the new directory label in dirwidget */
- XtSetArg(dirargs[0], XtNlabel, dir);
- XtSetValues(dirwidget, dirargs, XtNumber(dirargs));
- }
-
-
- setup_iconname()
- {
- Arg topargs[1];
- char *p;
- char pattern[32];
-
- if ( ((p = rindex(curdirectory, '/')) == NULL) || (strlen(p) == 1))
- XtSetArg(topargs[0], XtNiconName, (XtArgVal)"xbrowser");
- else {
- sprintf(pattern, "../%s", p+1);
- XtSetArg(topargs[0], XtNiconName, (XtArgVal)pattern);
- }
- XtSetValues(toplevel, topargs, XtNumber(topargs));
- }
-
- /* ARGSUSED */
- int getsize(w, width, height)
- Widget w;
- Dimension *width, *height;
- {
- static Dimension twidth, theight;
-
- static Arg args[] = {
- {XtNwidth, (XtArgVal)&twidth},
- {XtNheight, (XtArgVal)&theight},
- };
-
- XtGetValues(w, args, (Cardinal)2);
- *width = twidth;
- *height = theight;
- }
-
- /* ARGSUSED */
- int getpos(w, posx, posy)
- Widget w;
- Position *posx, *posy;
- {
- static Position tposx, tposy;
-
- static Arg args[] = {
- {XtNy, (XtArgVal)&tposy},
- {XtNx, (XtArgVal)&tposx},
- };
-
- XtGetValues(w, args, (Cardinal)2);
- *posx = tposx;
- *posy = tposy;
- }
-
- /* ARGSUSED */
- char *expand_tilde(s)
- char *s;
- {
- char *home, *getenv();
- char *p, *fullname;
- int i;
- char user[12];
-
- if (s[0] == '~' && (s[1] == '\0' || s[1] == '/') ) {
- home = getenv("HOME");
- p = s + 1;
- }
- else if (s[0] == '~' && isalnum(s[1])) {
- p = s + 1;
- i = 0;
- while (*p != '/' && *p != '\0') user[i++] = *p++;
- user[i] = '\0';
-
- if ( (home = get_userdir(user)) == NULL) return((char *)NULL);
- }
-
- fullname = XtMalloc(strlen(home) + strlen(p));
- sprintf(fullname, "%s%s", home, p);
- return fullname;
- }
-
-