Article View: vmsnet.sources
Article #15Ghostview for VMS 02/14
From: Terry Poot
Date: Thu, 29 Oct 1992 18:49
Date: Thu, 29 Oct 1992 18:49
1551 lines
49033 bytes
49033 bytes
Submitted-by: Terry Poot <tp@mccall.com>
Posting-number: Volume 3, Issue 220
Archive-name: ghostview/part02
-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
Xsections when you distribute them as separate works. But when you
Xdistribute the same sections as part of a whole which is a work based
Xon the Program, the distribution of the whole must be on the terms of
Xthis License, whose permissions for other licensees extend to the
Xentire whole, and thus to each and every part regardless of who wrote it.
X
XThus, it is not the intent of this section to claim rights or contest
Xyour rights to work written entirely by you; rather, the intent is to
Xexercise the right to control the distribution of derivative or
Xcollective works based on the Program.
X
XIn addition, mere aggregation of another work not based on the Program
Xwith the Program (or with a work based on the Program) on a volume of
Xa storage or distribution medium does not bring the other work under
Xthe scope of this License.
X
X 3. You may copy and distribute the Program (or a work based on it,
Xunder Section 2) in object code or executable form under the terms of
XSections 1 and 2 above provided that you also do one of the following:
X
X a) Accompany it with the complete corresponding machine-readable
X source code, which must be distributed under the terms of Sections
X 1 and 2 above on a medium customarily used for software interchange; or,
X
X b) Accompany it with a written offer, valid for at least three
X years, to give any third party, for a charge no more than your
X cost of physically performing source distribution, a complete
X machine-readable copy of the corresponding source code, to be
X distributed under the terms of Sections 1 and 2 above on a medium
X customarily used for software interchange; or,
X
X c) Accompany it with the information you received as to the offer
X to distribute corresponding source code. (This alternative is
X allowed only for noncommercial distribution and only if you
X received the program in object code or executable form with such
X an offer, in accord with Subsection b above.)
X
XThe source code for a work means the preferred form of the work for
Xmaking modifications to it. For an executable work, complete source
Xcode means all the source code for all modules it contains, plus any
Xassociated interface definition files, plus the scripts used to
Xcontrol compilation and installation of the executable. However, as a
Xspecial exception, the source code distributed need not include
Xanything that is normally distributed (in either source or binary
Xform) with the major components (compiler, kernel, and so on) of the
Xoperating system on which the executable runs, unless that component
Xitself accompanies the executable.
X
XIf distribution of executable or object code is made by offering
Xaccess to copy from a designated place, then offering equivalent
Xaccess to copy the source code from the same place counts as
Xdistribution of the source code, even though third parties are not
Xcompelled to copy the source along with the object code.
X
X
X
X
X
X
X
X
X
X
X
X 4. You may not copy, modify, sublicense, or distribute the Program
Xexcept as expressly provided under this License. Any attempt
Xotherwise to copy, modify, sublicense or distribute the Program is
Xvoid, and will automatically terminate your rights under this License.
XHowever, parties who have received copies, or rights, from you under
Xthis License will not have their licenses terminated so long as such
Xparties remain in full compliance.
X
X 5. You are not required to accept this License, since you have not
Xsigned it. However, nothing else grants you permission to modify or
Xdistribute the Program or its derivative works. These actions are
Xprohibited by law if you do not accept this License. Therefore, by
Xmodifying or distributing the Program (or any work based on the
XProgram), you indicate your acceptance of this License to do so, and
Xall its terms and conditions for copying, distributing or modifying
Xthe Program or works based on it.
X
X 6. Each time you redistribute the Program (or any work based on the
XProgram), the recipient automatically receives a license from the
Xoriginal licensor to copy, distribute or modify the Program subject to
Xthese terms and conditions. You may not impose any further
Xrestrictions on the recipients' exercise of the rights granted herein.
XYou are not responsible for enforcing compliance by third parties to
Xthis License.
X
X 7. If, as a consequence of a court judgment or allegation of patent
Xinfringement or for any other reason (not limited to patent issues),
Xconditions are imposed on you (whether by court order, agreement or
Xotherwise) that contradict the conditions of this License, they do not
Xexcuse you from the conditions of this License. If you cannot
Xdistribute so as to satisfy simultaneously your obligations under this
XLicense and any other pertinent obligations, then as a consequence you
Xmay not distribute the Program at all. For example, if a patent
Xlicense would not permit royalty-free redistribution of the Program by
Xall those who receive copies directly or indirectly through you, then
Xthe only way you could satisfy both it and this License would be to
Xrefrain entirely from distribution of the Program.
X
XIf any portion of this section is held invalid or unenforceable under
Xany particular circumstance, the balance of the section is intended to
Xapply and the section as a whole is intended to apply in other
Xcircumstances.
X
XIt is not the purpose of this section to induce you to infringe any
Xpatents or other property right claims or to contest validity of any
Xsuch claims; this section has the sole purpose of protecting the
Xintegrity of the free software distribution system, which is
Ximplemented by public license practices. Many people have made
Xgenerous contributions to the wide range of software distributed
Xthrough that system in reliance on consistent application of that
Xsystem; it is up to the author/donor to decide if he or she is willing
Xto distribute software through any other system and a licensee cannot
Ximpose that choice.
X
XThis section is intended to make thoroughly clear what is believed to
Xbe a consequence of the rest of this License.
X
X
X
X
X
X
X
X
X
X
X
X
X 8. If the distribution and/or use of the Program is restricted in
Xcertain countries either by patents or by copyrighted interfaces, the
Xoriginal copyright holder who places the Program under this License
Xmay add an explicit geographical distribution limitation excluding
Xthose countries, so that distribution is permitted only in or among
Xcountries not thus excluded. In such case, this License incorporates
Xthe limitation as if written in the body of this License.
X
X 9. The Free Software Foundation may publish revised and/or new versions
Xof the General Public License from time to time. Such new versions will
Xbe similar in spirit to the present version, but may differ in detail to
Xaddress new problems or concerns.
X
XEach version is given a distinguishing version number. If the Program
Xspecifies a version number of this License which applies to it and "any
Xlater version", you have the option of following the terms and conditions
Xeither of that version or of any later version published by the Free
XSoftware Foundation. If the Program does not specify a version number of
Xthis License, you may choose any version ever published by the Free Software
XFoundation.
X
X 10. If you wish to incorporate parts of the Program into other free
Xprograms whose distribution conditions are different, write to the author
Xto ask for permission. For software which is copyrighted by the Free
XSoftware Foundation, write to the Free Software Foundation; we sometimes
Xmake exceptions for this. Our decision will be guided by the two goals
Xof preserving the free status of all derivatives of our free software and
Xof promoting the sharing and reuse of software generally.
X
X`09`09`09 NO WARRANTY
X
X 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
XREPAIR OR CORRECTION.
X
X 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
XPOSSIBILITY OF SUCH DAMAGES.
X
X`09`09 END OF TERMS AND CONDITIONS
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X`09Appendix: How to Apply These Terms to Your New Programs
X
X If you develop a new program, and you want it to be of the greatest
Xpossible use to the public, the best way to achieve this is to make it
Xfree software which everyone can redistribute and change under these terms.
X
X To do so, attach the following notices to the program. It is safest
Xto attach them to the start of each source file to most effectively
Xconvey the exclusion of warranty; and each file should have at least
Xthe "copyright" line and a pointer to where the full notice is found.
X
X <one line to give the program's name and a brief idea of what it does.>
X Copyright (C) 19yy <name of author>
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of the GNU General Public License as published by
X the Free Software Foundation; either version 2 of the License, or
X (at your option) any later version.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X GNU General Public License for more details.
X
X You should have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XAlso add information on how to contact you by electronic and paper mail.
X
XIf the program is interactive, make it output a short notice like this
Xwhen it starts in an interactive mode:
X
X Gnomovision version 69, Copyright (C) 19yy name of author
X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `60show
V w'.
X This is free software, and you are welcome to redistribute it
X under certain conditions; type `60show c' for details.
X
XThe hypothetical commands `60show w' and `60show c' should show the appropri
Vate
Xparts of the General Public License. Of course, the commands you use may
Xbe called something other than `60show w' and `60show c'; they could even be
Xmouse-clicks or menu items--whatever suits your program.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the program, if
Xnecessary. Here is a sample; alter the names:
X
X Yoyodyne, Inc., hereby disclaims all copyright interest in the program
X `60Gnomovision' (which makes passes at compilers) written by James Hacker.
X
X <signature of Ty Coon>, 1 April 1989
X Ty Coon, President of Vice
X
XThis General Public License does not permit incorporating your program into
Xproprietary programs. If your program is a subroutine library, you may
Xconsider it more useful to permit linking proprietary applications with the
Xlibrary. If this is what you want to do, use the GNU Library General
XPublic License instead of this License.
$ CALL UNPACK COPYING.;1 2085588731
$ create 'f'
X.first
X`09@lsrc:`5Bx11`5Dlogicals.com !<<< change for your system!
X`09copy/log x11_xmu:xmushr.psects,x11_xaw:xawshr.psects,x11_xaw:user.opt -
X`09`09gv.opt
XGV.EXE : GV.OLB XMUSHR XAWSHR
X`09$(link) $(linkflags) /exe=gv.exe `09`09gv.olb/include=main/library,gv.opt
V/opt
XGV.OLB : GV.OLB(MAIN=MAIN.OBJ) GV.OLB(MISC=MISC.OBJ) GV.OLB(CALLBACKS=CALLBA
VCKS.OBJ) -
X`09 GV.OLB(ACTIONS=ACTIONS.OBJ) GV.OLB(DIALOGS=DIALOGS.OBJ) GV.OLB(GHOSTVIEW
V=GHOSTVIEW.OBJ) -
X`09 GV.OLB(PS=PS.OBJ) GV.OLB(STRCASECMP=STRCASECMP.OBJ)
X`09@ continue
XGV.OLB(MAIN=MAIN.OBJ) : MAIN.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ MAIN.OBJ
XMAIN.OBJ : MAIN.C GHOSTVIEW.H GV.H -
X`09 PS.H APP-DEFAULTS.H
X`09$(CC) $(CFLAGS) MAIN.C
XAPP-DEFAULTS.H : GHOSTVIEW.AD
X`09get_run = 0
X`09get_ad2c = 0
X`09if f$search("run-ad2c.").eqs."" then get_run = 1
X`09if f$search("ad2c.").eqs."" then get_ad2c = 1
X`09- if get_run then cms fetch run-ad2c.
X`09- if get_ad2c then cms fetch ad2c.
X`09- posix/run posix$bin:sh. run-ad2c
X`09if get_run then delete run-ad2c.;*
X`09if get_ad2c then delete ad2c.;*
XGV.OLB(MISC=MISC.OBJ) : MISC.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ MISC.OBJ
XMISC.OBJ : MISC.C GHOSTVIEW.H GV.H -
X`09 PS.H
X`09$(CC) $(CFLAGS) MISC.C
XGV.OLB(CALLBACKS=CALLBACKS.OBJ) : CALLBACKS.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ CALLBACKS.OBJ
XCALLBACKS.OBJ : CALLBACKS.C GHOSTVIEW.H GV.H -
X`09 PS.H
X`09$(CC) $(CFLAGS) CALLBACKS.C
XGV.OLB(ACTIONS=ACTIONS.OBJ) : ACTIONS.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ ACTIONS.OBJ
XACTIONS.OBJ : ACTIONS.C GV.H GHOSTVIEW.H -
X`09 PS.H
X`09$(CC) $(CFLAGS) ACTIONS.C
XGV.OLB(DIALOGS=DIALOGS.OBJ) : DIALOGS.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ DIALOGS.OBJ
XDIALOGS.OBJ : DIALOGS.C GV.H GHOSTVIEW.H
X`09$(CC) $(CFLAGS) DIALOGS.C
XGV.OLB(GHOSTVIEW=GHOSTVIEW.OBJ) : GHOSTVIEW.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ GHOSTVIEW.OBJ
XGHOSTVIEW.OBJ : GHOSTVIEW.C GHOSTVIEWP.H GHOSTVIEW.H -
X`09 VMS_TYPES.H
X`09$(CC) $(CFLAGS) GHOSTVIEW.C
XGV.OLB(PS=PS.OBJ) : PS.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ PS.OBJ
XPS.OBJ : PS.C PS.H
X`09$(CC) $(CFLAGS) PS.C
XGV.OLB(STRCASECMP=STRCASECMP.OBJ) : STRCASECMP.OBJ
X`09If "''F$Search("$@")'" .EQS. "" Then $(LIBR)/Create $@
X`09$(LIBR)$(LIBRFLAGS) $@ STRCASECMP.OBJ
XSTRCASECMP.OBJ : STRCASECMP.C STDC.H
X`09$(CC) $(CFLAGS) STRCASECMP.C
$ CALL UNPACK DESCRIP.MMS;1 274270372
$ create 'f'
X/*
X * dialogs.c -- Dialog box for ghostview.
X * Copyright (C) 1992 Timothy O. Theisen
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X * Author: Tim Theisen Systems Programmer
X * Internet: tim@cs.wisc.edu Department of Computer Sciences
X * UUCP: uwvax!tim University of Wisconsin-Madison
X * Phone: (608)262-0438 1210 West Dayton Street
X * FAX: (608)262-9777 Madison, WI 53706
X */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xos.h>
X#include <X11/Xaw/Cardinals.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Command.h>
X#include "gv.h"
X
Xstatic String okay_accelerators =
X "#override\n\
X <Key>Return: set() notify() unset()\n";
X
X/* Create a dialog widget */
X/* It is just a form widget with
X * a label prompt
X * a text response
X * an oky button
X * a cancel button */
XWidget
XCreateDialog(parent, name, okay_callback, cancel_callback)
X Widget parent;
X String name;
X XtCallbackProc okay_callback;
X XtCallbackProc cancel_callback;
X`7B
X Widget form, prompt, response, okay, cancel;
X Arg args`5B20`5D;
X Cardinal num_args;
X
X`09`09`09`09`09`09`09num_args = 0;
X if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X `7D
X form = XtCreateManagedWidget(name, formWidgetClass, parent, args, num_ar
Vgs);
X
X`09`09`09`09`09`09`09num_args = 0;
X if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNforeground, black);`09num_args++;
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X `7D
X XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNright, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNresizable, True);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNborderWidth, 0);`09num_args++;
X prompt = XtCreateManagedWidget("prompt", labelWidgetClass,
X`09`09`09`09 form, args, num_args);
X
X`09`09`09`09`09`09`09num_args = 0;
X if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNforeground, black);`09num_args++;
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X `7D
X XtSetArg(args`5Bnum_args`5D, XtNfromVert, prompt);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNright, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNresizable, True);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNeditType, XawtextEdit);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNresize, XawtextResizeWidth);`09num_args+
V+;
X XtSetArg(args`5Bnum_args`5D, XtNstring, "");`09`09num_args++;
X response = XtCreateManagedWidget("response", asciiTextWidgetClass,
X`09`09`09`09 form, args, num_args);
X
X`09`09`09`09`09`09`09num_args = 0;
X if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNforeground, black);`09num_args++;
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X `7D
X XtSetArg(args`5Bnum_args`5D, XtNfromVert, response);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNright, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNresizable, True);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNaccelerators,
X`09 XtParseAcceleratorTable(okay_accelerators));`09num_args++;
X okay = XtCreateManagedWidget("okay", commandWidgetClass,
X`09`09`09`09 form, args, num_args);
X XtAddCallback(okay, XtNcallback, okay_callback, form);
X
X`09`09`09`09`09`09`09num_args = 0;
X if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNforeground, black);`09num_args++;
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X `7D
X XtSetArg(args`5Bnum_args`5D, XtNfromVert, response);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNfromHoriz, okay);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainTop);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNright, XtChainLeft);`09num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNresizable, True);`09num_args++;
X cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
X`09`09`09`09 form, args, num_args);
X XtAddCallback(cancel, XtNcallback, cancel_callback, parent);
X
X XtInstallAccelerators(response, okay);
X XtSetKeyboardFocus(form, response);
X
X return form;
X`7D
X
X/* get the prompt from the dialog box. Used a startup time to
X * save away the initial prompt */
XString
XGetDialogPrompt(w)
X Widget w;
X`7B
X Arg args`5B1`5D;
X Widget label;
X String s;
X
X label = XtNameToWidget(w, "prompt");
X XtSetArg(args`5B0`5D, XtNlabel, &s);
X XtGetValues(label, args, ONE);
X return XtNewString(s);
X`7D
X
X/* set the prompt. This is used to put error information in the prompt */
Xvoid
XSetDialogPrompt(w, newprompt)
X Widget w;
X String newprompt;
X`7B
X Arg args`5B1`5D;
X Widget label;
X
X label = XtNameToWidget(w, "prompt");
X XtSetArg(args`5B0`5D, XtNlabel, newprompt);
X XtSetValues(label, args, ONE);
X`7D
X
X/* get what the user typed */
XString
XGetDialogResponse(w)
X Widget w;
X`7B
X Arg args`5B1`5D;
X Widget response;
X String s;
X
X response = XtNameToWidget(w, "response");
X XtSetArg(args`5B0`5D, XtNstring, &s);
X XtGetValues(response, args, ONE);
X return XtNewString(s);
X`7D
X
X/* set the default reponse */
Xvoid
XSetDialogResponse(w, s)
X Widget w;
X String s;
X`7B
X Arg args`5B3`5D;
X Widget response;
X XFontStruct *font;
X Dimension width, leftMargin, rightMargin;
X
X response = XtNameToWidget(w, "response");
X XtSetArg(args`5B0`5D, XtNfont, &font);
X XtSetArg(args`5B1`5D, XtNleftMargin, &leftMargin);
X XtSetArg(args`5B2`5D, XtNrightMargin, &rightMargin);
X XtGetValues(response, args, THREE);
X width = font->max_bounds.width * strlen(s) + leftMargin + rightMargin;
X
X XtSetArg(args`5B0`5D, XtNstring, s);
X XtSetArg(args`5B1`5D, XtNwidth, width);
X XtSetValues(response, args, TWO);
X XawTextSetInsertionPoint(response, strlen(s));
X
X`7D
X
X/* clear the response */
Xvoid
XClearDialogResponse(w)
X Widget w;
X`7B
X Arg args`5B2`5D;
X Widget response;
X
X response = XtNameToWidget(w, "response");
X XtSetArg(args`5B0`5D, XtNstring, "");
X XtSetArg(args`5B1`5D, XtNwidth, 100);
X XtSetValues(response, args, TWO);
X`7D
$ CALL UNPACK DIALOGS.C;1 236238783
$ create 'f'
X/*
X * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted, provided
X * that the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of Software Research Associates not be u
Vsed
X * in advertising or publicity pertaining to distribution of the software
X * without specific, written prior permission. Software Research Associates
X * makes no representations about the suitability of this software for any
X * purpose. It is provided "as is" without express or implied warranty.
X *
X * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
V,
X * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FRO
VM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENC
VE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author: Erik M. van der Poel
X * Software Research Associates, Inc., Tokyo, Japan
X * erik@sra.co.jp
X */
X
X#include <stdio.h>
X
X#ifdef SEL_FILE_IGNORE_CASE
X#include <ctype.h>
X#endif /* def SEL_FILE_IGNORE_CASE */
X
X#include "SFinternal.h"
X
X#if defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG)
X#include <dirent.h>
X#else /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X#include <sys/dir.h>
X#define dirent direct
X#endif /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X
X#include <sys/stat.h>
X
X#if defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG)
Xextern void qsort();
X#endif /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X
X#ifdef SEL_FILE_IGNORE_CASE
Xint
XSFcompareEntries(p, q)
X`09SFEntry`09*p;
X`09SFEntry`09*q;
X`7B
X`09register char`09*r, *s;
X`09register char`09c1, c2;
X
X`09r = p->real;
X`09s = q->real;
X
X`09c1 = *r++;
X`09if (islower(c1)) `7B
X`09`09c1 = toupper(c1);
X`09`7D
X`09c2 = *s++;
X`09if (islower(c2)) `7B
X`09`09c2 = toupper(c2);
X`09`7D
X
X`09while (c1 == c2) `7B
X`09`09if (!c1) `7B
X`09`09`09return strcmp(p->real, q->real);
X`09`09`7D
X`09`09c1 = *r++;
X`09`09if (islower(c1)) `7B
X`09`09`09c1 = toupper(c1);
X`09`09`7D
X`09`09c2 = *s++;
X`09`09if (islower(c2)) `7B
X`09`09`09c2 = toupper(c2);
X`09`09`7D
X`09`7D
X
X`09return c1 - c2;
X`7D
X#else /* def SEL_FILE_IGNORE_CASE */
Xint
XSFcompareEntries(p, q)
X`09SFEntry`09*p;
X`09SFEntry`09*q;
X`7B
X`09return strcmp(p->real, q->real);
X`7D
X#endif /* def SEL_FILE_IGNORE_CASE */
X
Xint
XSFgetDir(dir)
X`09SFDir`09*dir;
X`7B
X`09SFEntry`09`09*result = NULL;
X`09int`09`09alloc = 0;
X`09int`09`09i;
X`09DIR`09`09*dirp;
X`09struct dirent`09*dp;
X`09char`09`09*str;
X`09int`09`09len;
X`09int`09`09maxChars;
X`09struct stat`09statBuf;
X
X`09maxChars = strlen(dir->dir) - 1;
X
X`09dir->entries = NULL;
X`09dir->nEntries = 0;
X`09dir->nChars = 0;
X
X`09result = NULL;
X`09i = 0;
X
X`09dirp = opendir(".");
X`09if (!dirp) `7B
X`09`09return 1;
X`09`7D
X
X`09(void) stat(".", &statBuf);
X`09dir->mtime = statBuf.st_mtime;
X
X`09(void) readdir(dirp);`09/* throw away "." */
X
X#ifndef S_IFLNK
X`09(void) readdir(dirp);`09/* throw away ".." */
X#endif /* ndef S_IFLNK */
X
X`09while (dp = readdir(dirp)) `7B
X`09`09if (i >= alloc) `7B
X`09`09`09alloc = 2 * (alloc + 1);
X`09`09`09result = (SFEntry *) XtRealloc((char *) result,
X`09`09`09`09(unsigned) (alloc * sizeof(SFEntry)));
X`09`09`7D
X`09`09result`5Bi`5D.statDone = 0;
X`09`09str = dp->d_name;
X`09`09len = strlen(str);
X`09`09result`5Bi`5D.real = XtMalloc((unsigned) (len + 2));
X`09`09(void) strcat(strcpy(result`5Bi`5D.real, str), " ");
X`09`09if (len > maxChars) `7B
X`09`09`09maxChars = len;
X`09`09`7D
X`09`09result`5Bi`5D.shown = result`5Bi`5D.real;
X`09`09i++;
X`09`7D
X
X#if defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG)
X`09qsort((char *) result, (unsigned) i, sizeof(SFEntry), SFcompareEntries);
X#else /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X`09qsort((char *) result, i, sizeof(SFEntry), SFcompareEntries);
X#endif /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X
X`09dir->entries = result;
X`09dir->nEntries = i;
X`09dir->nChars = maxChars + 1;
X
X`09closedir(dirp);
X
X`09return 0;
X`7D
$ CALL UNPACK DIR.C;1 1916621846
$ create 'f'
X/*
X * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted, provided
X * that the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of Software Research Associates not be u
Vsed
X * in advertising or publicity pertaining to distribution of the software
X * without specific, written prior permission. Software Research Associates
X * makes no representations about the suitability of this software for any
X * purpose. It is provided "as is" without express or implied warranty.
X *
X * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
V,
X * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FRO
VM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENC
VE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author: Erik M. van der Poel
X * Software Research Associates, Inc., Tokyo, Japan
X * erik@sra.co.jp
X */
X
X#include <stdio.h>
X#include "SFinternal.h"
X#include "xstat.h"
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Scrollbar.h>
X
X#define SF_DEFAULT_FONT "9x15"
X
X#define ABS(x) (((x) < 0) ? (-(x)) : (x))
X
Xtypedef struct `7B
X`09char *fontname;
X`7D TextData, *textPtr;
X
Xint SFcharWidth, SFcharAscent, SFcharHeight;
X
Xint SFcurrentInvert`5B3`5D = `7B -1, -1, -1 `7D;
X
Xstatic GC SFlineGC, SFscrollGC, SFinvertGC, SFtextGC;
X
Xstatic XtResource textResources`5B`5D = `7B
X`09`7BXtNfont, XtCFont, XtRString, sizeof (char *),
X`09`09XtOffset(textPtr, fontname), XtRString, SF_DEFAULT_FONT`7D,
X`7D;
X
Xstatic XFontStruct *SFfont;
X
Xstatic int SFcurrentListY;
X
Xstatic XtIntervalId SFscrollTimerId;
X
XSFinitFont()
X`7B
X`09TextData`09*data;
X
X`09data = XtNew(TextData);
X
X`09XtGetApplicationResources(selFileForm, (XtPointer) data, textResources,
X`09`09XtNumber(textResources), (Arg *) NULL, 0);
X
X`09SFfont = XLoadQueryFont(SFdisplay, data->fontname);
X`09if (!SFfont) `7B
X`09`09SFfont = XLoadQueryFont(SFdisplay, SF_DEFAULT_FONT);
X`09`09if (!SFfont) `7B
X`09`09`09char`09sbuf`5B256`5D;
X
X`09`09`09(void) sprintf(sbuf, "XsraSelFile: can't get font %s",
X`09`09`09`09SF_DEFAULT_FONT);
X
X`09`09`09XtAppError(SFapp, sbuf);
X`09`09`7D
X`09`7D
X
X`09SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
X`09SFcharAscent = SFfont->max_bounds.ascent;
X`09SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
X`7D
X
XSFcreateGC()
X`7B
X`09XGCValues`09gcValues;
X`09XRectangle`09rectangles`5B1`5D;
X
X`09gcValues.foreground = SFfore;
X
X`09SFlineGC = XtGetGC(
X`09`09selFileLists`5B0`5D,
X`09`09(XtGCMask)
X`09`09`09GCForeground`09`09`7C
X`09`09`090,
X`09`09&gcValues
X`09);
X
X`09SFscrollGC = XtGetGC(
X`09`09selFileLists`5B0`5D,
X`09`09(XtGCMask)
X`09`09`090,
X`09`09&gcValues
X`09);
X
X`09gcValues.function = GXinvert;
X`09gcValues.plane_mask = (SFfore `5E SFback);
X
X`09SFinvertGC = XtGetGC(
X`09`09selFileLists`5B0`5D,
X`09`09(XtGCMask)
X`09`09`09GCFunction`09`09`7C
X`09`09`09GCPlaneMask`09`09`7C
X`09`09`090,
X`09`09&gcValues
X`09);
X
X`09gcValues.foreground = SFfore;
X`09gcValues.background = SFback;
X`09gcValues.font = SFfont->fid;
X
X`09SFtextGC = XCreateGC(
X`09`09SFdisplay,
X`09`09XtWindow(selFileLists`5B0`5D),
X`09`09(unsigned long)
X`09`09`09GCForeground`09`09`7C
X`09`09`09GCBackground`09`09`7C
X`09`09`09GCFont`09`09`09`7C
X`09`09`090,
X`09`09&gcValues
X`09);
X
X`09rectangles`5B0`5D.x = SFlineToTextH + SFbesideText;
X`09rectangles`5B0`5D.y = 0;
X`09rectangles`5B0`5D.width = SFcharsPerEntry * SFcharWidth;
X`09rectangles`5B0`5D.height = SFupperY + 1;
X
X`09XSetClipRectangles(
X`09`09SFdisplay,
X`09`09SFtextGC,
X`09`090,
X`09`090,
X`09`09rectangles,
X`09`091,
X`09`09Unsorted
X`09);
X`7D
X
XSFclearList(n, doScroll)
X`09int`09n;
X`09int`09doScroll;
X`7B
X`09SFDir`09*dir;
X
X`09SFcurrentInvert`5Bn`5D = -1;
X
X`09XClearWindow(SFdisplay, XtWindow(selFileLists`5Bn`5D));
X
X`09XDrawSegments(SFdisplay, XtWindow(selFileLists`5Bn`5D), SFlineGC, SFsegs,
X`09`092);
X
X`09if (doScroll) `7B
X`09`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X
X`09`09if ((SFdirPtr + n < SFdirEnd) && dir->nEntries && dir->nChars) `7B
X`09`09`09XawScrollbarSetThumb(
X`09`09`09`09selFileVScrolls`5Bn`5D,
X`09`09`09`09(float) (((double) dir->vOrigin) /
X`09`09`09`09`09dir->nEntries),
X`09`09`09`09(float) (((double) ((dir->nEntries < SFlistSize)
X`09`09`09`09`09? dir->nEntries : SFlistSize)) /
X`09`09`09`09`09dir->nEntries)
X`09`09`09);
X
X`09`09`09XawScrollbarSetThumb(
X`09`09`09`09selFileHScrolls`5Bn`5D,
X`09`09`09`09(float) (((double) dir->hOrigin) / dir->nChars),
X`09`09`09`09(float) (((double) ((dir->nChars <
X`09`09`09`09`09SFcharsPerEntry) ? dir->nChars :
X`09`09`09`09`09SFcharsPerEntry)) / dir->nChars)
X`09`09`09);
X`09`09`7D else `7B
X`09`09`09XawScrollbarSetThumb(selFileVScrolls`5Bn`5D, (float) 0.0,
X`09`09`09`09(float) 1.0);
X`09`09`09XawScrollbarSetThumb(selFileHScrolls`5Bn`5D, (float) 0.0,
X`09`09`09`09(float) 1.0);
X`09`09`7D
X`09`7D
X`7D
X
Xstatic
XSFdeleteEntry(dir, entry)
X`09SFDir`09*dir;
X`09SFEntry`09*entry;
X`7B
X`09register SFEntry`09*e;
X`09register SFEntry`09*end;
X`09int`09`09`09n;
X`09int`09`09`09idx;
X
X`09idx = entry - dir->entries;
X
X`09if (idx < dir->beginSelection) `7B
X`09`09dir->beginSelection--;
X`09`7D
X`09if (idx <= dir->endSelection) `7B
X`09`09dir->endSelection--;
X`09`7D
X`09if (dir->beginSelection > dir->endSelection) `7B
X`09`09dir->beginSelection = dir->endSelection = -1;
X`09`7D
X
X`09if (idx < dir->vOrigin) `7B
X`09`09dir->vOrigin--;
X`09`7D
X
X`09XtFree(entry->real);
X
X`09end = &(dir->entries`5Bdir->nEntries - 1`5D);
X
X`09for (e = entry; e < end; e++) `7B
X`09`09*e = *(e + 1);
X`09`7D
X
X`09if (!(--dir->nEntries)) `7B
X`09`09return;
X`09`7D
X
X`09n = dir - &(SFdirs`5BSFdirPtr`5D);
X`09if ((n < 0) `7C`7C (n > 2)) `7B
X`09`09return;
X`09`7D
X
X`09XawScrollbarSetThumb(
X`09`09selFileVScrolls`5Bn`5D,
X`09`09(float) (((double) dir->vOrigin) / dir->nEntries),
X`09`09(float) (((double) ((dir->nEntries < SFlistSize) ?
X`09`09`09dir->nEntries : SFlistSize)) / dir->nEntries)
X`09);
X`7D
X
Xstatic
XSFwriteStatChar(name, last, statBuf)
X`09char`09`09*name;
X`09int`09`09last;
X`09struct stat`09*statBuf;
X`7B
X`09name`5Blast`5D = SFstatChar(statBuf);
X`7D
X
Xstatic int
XSFstatAndCheck(dir, entry)
X`09SFDir`09*dir;
X`09SFEntry`09*entry;
X`7B
X`09struct stat`09statBuf;
X`09char`09`09save;
X`09int`09`09last;
X
X`09/*
X`09 * must be restored before returning
X`09 */
X`09save = *(dir->path);
X`09*(dir->path) = 0;
X
X`09if (!SFchdir(SFcurrentPath)) `7B
X`09`09last = strlen(entry->real) - 1;
X`09`09entry->real`5Blast`5D = 0;
X`09`09entry->statDone = 1;
X`09`09if (
X`09`09`09(!stat(entry->real, &statBuf))
X
X#ifdef S_IFLNK
X
X`09`09 `7C`7C (!lstat(entry->real, &statBuf))
X
X#endif /* ndef S_IFLNK */
X
X`09`09) `7B
X`09`09`09if (SFfunc) `7B
X`09`09`09`09char *shown;
X
X`09`09`09`09shown = NULL;
X`09`09`09`09if (SFfunc(entry->real, &shown, &statBuf)) `7B
X`09`09`09`09`09if (shown) `7B
X`09`09`09`09`09`09int len;
X
X`09`09`09`09`09`09len = strlen(shown);
X`09`09`09`09`09`09entry->shown = XtMalloc(
X`09`09`09`09`09`09`09(unsigned) (len + 2)
X`09`09`09`09`09`09);
X`09`09`09`09`09`09(void) strcpy(entry->shown,
X`09`09`09`09`09`09`09shown);
X`09`09`09`09`09`09SFwriteStatChar(
X`09`09`09`09`09`09`09entry->shown,
X`09`09`09`09`09`09`09len,
X`09`09`09`09`09`09`09&statBuf
X`09`09`09`09`09`09);
X`09`09`09`09`09`09entry->shown`5Blen + 1`5D = 0;
X`09`09`09`09`09`7D
X`09`09`09`09`7D else `7B
X`09`09`09`09`09SFdeleteEntry(dir, entry);
X
X`09`09`09`09`09*(dir->path) = save;
X`09`09`09`09`09return 1;
X`09`09`09`09`7D
X`09`09`09`7D
X`09`09`09SFwriteStatChar(entry->real, last, &statBuf);
X`09`09`7D else `7B
X`09`09`09entry->real`5Blast`5D = ' ';
X`09`09`7D
X`09`7D
X
X`09*(dir->path) = save;
X`09return 0;
X`7D
X
Xstatic
XSFdrawStrings(w, dir, from, to)
X`09register Window`09w;
X`09register SFDir`09*dir;
X`09register int`09from;
X`09register int`09to;
X`7B
X`09register int`09`09i;
X`09register SFEntry`09*entry;
X`09int`09`09`09x;
X
X`09x = SFtextX - dir->hOrigin * SFcharWidth;
X
X`09if (dir->vOrigin + to >= dir->nEntries) `7B
X`09`09to = dir->nEntries - dir->vOrigin - 1;
X`09`7D
X`09for (i = from; i <= to; i++) `7B
X`09`09entry = &(dir->entries`5Bdir->vOrigin + i`5D);
X`09`09if (!(entry->statDone)) `7B
X`09`09`09if (SFstatAndCheck(dir, entry)) `7B
X`09`09`09`09if (dir->vOrigin + to >= dir->nEntries) `7B
X`09`09`09`09`09to = dir->nEntries - dir->vOrigin - 1;
X`09`09`09`09`7D
X`09`09`09`09i--;
X`09`09`09`09continue;
X`09`09`09`7D
X`09`09`7D
X`09`09XDrawImageString(
X`09`09`09SFdisplay,
X`09`09`09w,
X`09`09`09SFtextGC,
X`09`09`09x,
X`09`09`09SFtextYoffset + i * SFentryHeight,
X`09`09`09entry->shown,
X`09`09`09strlen(entry->shown)
X`09`09);
X`09`09if (dir->vOrigin + i == dir->beginSelection) `7B
X`09`09`09XDrawLine(
X`09`09`09`09SFdisplay,
X`09`09`09`09w,
X`09`09`09`09SFlineGC,
X`09`09`09`09SFlineToTextH + 1,
X`09`09`09`09SFlowerY + i * SFentryHeight,
X`09`09`09`09SFlineToTextH + SFentryWidth - 2,
X`09`09`09`09SFlowerY + i * SFentryHeight
X`09`09`09);
X`09`09`7D
X`09`09if (
X`09`09`09(dir->vOrigin + i >= dir->beginSelection) &&
X`09`09`09(dir->vOrigin + i <= dir->endSelection)
X`09`09) `7B
X`09`09`09SFcompletionSegs`5B0`5D.y1 = SFcompletionSegs`5B1`5D.y1 =
X`09`09`09`09SFlowerY + i * SFentryHeight;
X`09`09`09SFcompletionSegs`5B0`5D.y2 = SFcompletionSegs`5B1`5D.y2 =
X`09`09`09`09SFlowerY + (i + 1) * SFentryHeight - 1;
X`09`09`09XDrawSegments(
X`09`09`09`09SFdisplay,
X`09`09`09`09w,
X`09`09`09`09SFlineGC,
X`09`09`09`09SFcompletionSegs,
X`09`09`09`092
X`09`09`09);
X`09`09`7D
X`09`09if (dir->vOrigin + i == dir->endSelection) `7B
X`09`09`09XDrawLine(
X`09`09`09`09SFdisplay,
X`09`09`09`09w,
X`09`09`09`09SFlineGC,
X`09`09`09`09SFlineToTextH + 1,
X`09`09`09`09SFlowerY + (i + 1) * SFentryHeight - 1,
X`09`09`09`09SFlineToTextH + SFentryWidth - 2,
X`09`09`09`09SFlowerY + (i + 1) * SFentryHeight - 1
X`09`09`09);
X`09`09`7D
X`09`7D
X`7D
X
XSFdrawList(n, doScroll)
X`09int`09n;
X`09int`09doScroll;
X`7B
X`09SFDir`09*dir;
X`09Window`09w;
X
X`09SFclearList(n, doScroll);
X
X`09if (SFdirPtr + n < SFdirEnd) `7B
X`09`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X`09`09w = XtWindow(selFileLists`5Bn`5D);
X`09`09XDrawImageString(
X`09`09`09SFdisplay,
X`09`09`09w,
X`09`09`09SFtextGC,
X`09`09`09SFtextX - dir->hOrigin * SFcharWidth,
X`09`09`09SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
X`09`09`09dir->dir,
X`09`09`09strlen(dir->dir)
X`09`09);
X`09`09SFdrawStrings(w, dir, 0, SFlistSize - 1);
X`09`7D
X`7D
X
XSFdrawLists(doScroll)
X`09int`09doScroll;
X`7B
X`09int`09i;
X
X`09for (i = 0; i < 3; i++) `7B
X`09`09SFdrawList(i, doScroll);
X`09`7D
X`7D
X
Xstatic
XSFinvertEntry(n)
X`09register int`09n;
X`7B
X`09XFillRectangle(
X`09`09SFdisplay,
X`09`09XtWindow(selFileLists`5Bn`5D),
X`09`09SFinvertGC,
X`09`09SFlineToTextH,
X`09`09SFcurrentInvert`5Bn`5D * SFentryHeight + SFlowerY,
X`09`09SFentryWidth,
X`09`09SFentryHeight
X`09);
X`7D
X
Xstatic unsigned long
XSFscrollTimerInterval()
X`7B
X`09static int`09maxVal = 200;
X`09static int`09varyDist = 50;
X`09static int`09minDist = 50;
X`09int`09`09t;
X`09int`09`09dist;
X
X`09if (SFcurrentListY < SFlowerY) `7B
X`09`09dist = SFlowerY - SFcurrentListY;
X`09`7D else if (SFcurrentListY > SFupperY) `7B
X`09`09dist = SFcurrentListY - SFupperY;
X`09`7D else `7B
X`09`09return (unsigned long) 1;
X`09`7D
X
X`09t = maxVal - ((maxVal / varyDist) * (dist - minDist));
X
X`09if (t < 1) `7B
X`09`09t = 1;
X`09`7D
X
X`09if (t > maxVal) `7B
X`09`09t = maxVal;
X`09`7D
X
X`09return (unsigned long) t;
X`7D
X
Xstatic void
XSFscrollTimer(n)
X`09int`09n;
X`7B
X`09SFDir`09*dir;
X`09int`09save;
X
X`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X`09save = dir->vOrigin;
X
X`09if (SFcurrentListY < SFlowerY) `7B
X`09`09if (dir->vOrigin > 0) `7B
X`09`09`09SFvSliderMovedCallback(selFileVScrolls`5Bn`5D, n,
X`09`09`09`09dir->vOrigin - 1);
X`09`09`7D
X`09`7D else if (SFcurrentListY > SFupperY) `7B
X`09`09if (dir->vOrigin < dir->nEntries - SFlistSize) `7B
X`09`09`09SFvSliderMovedCallback(selFileVScrolls`5Bn`5D, n,
X`09`09`09`09dir->vOrigin + 1);
X`09`09`7D
X`09`7D
X
X`09if (dir->vOrigin != save) `7B
X`09`09if (dir->nEntries) `7B
X`09`09 XawScrollbarSetThumb(
X`09`09`09selFileVScrolls`5Bn`5D,
X`09`09`09(float) (((double) dir->vOrigin) / dir->nEntries),
X`09`09`09(float) (((double) ((dir->nEntries < SFlistSize) ?
X`09`09`09`09dir->nEntries : SFlistSize)) / dir->nEntries)
X`09`09 );
X`09`09`7D
X`09`7D
X
X`09if (SFbuttonPressed) `7B
X`09`09SFscrollTimerId = XtAppAddTimeOut(SFapp,
X`09`09`09SFscrollTimerInterval(), SFscrollTimer, (XtPointer) n);
X`09`7D
X`7D
X
Xstatic int
XSFnewInvertEntry(n, event)
X`09register int`09`09n;
X`09register XMotionEvent`09*event;
X`7B
X`09register int`09x, y;
X`09register int`09new;
X`09static int`09SFscrollTimerAdded = 0;
X
X`09x = event->x;
X`09y = event->y;
X
X`09if (SFdirPtr + n >= SFdirEnd) `7B
X`09`09return -1;
X`09`7D else if (
X`09`09(x >= 0)`09&& (x <= SFupperX) &&
X`09`09(y >= SFlowerY)`09&& (y <= SFupperY)
X`09) `7B
X`09`09register SFDir *dir = &(SFdirs`5BSFdirPtr + n`5D);
X
X`09`09if (SFscrollTimerAdded) `7B
X`09`09`09SFscrollTimerAdded = 0;
X`09`09`09XtRemoveTimeOut(SFscrollTimerId);
X`09`09`7D
X
X`09`09new = (y - SFlowerY) / SFentryHeight;
X`09`09if (dir->vOrigin + new >= dir->nEntries) `7B
X`09`09`09return -1;
X`09`09`7D
X`09`09return new;
X`09`7D else `7B
X`09`09if (SFbuttonPressed) `7B
X`09`09`09SFcurrentListY = y;
X`09`09`09if (!SFscrollTimerAdded) `7B
X`09`09`09`09SFscrollTimerAdded = 1;
X`09`09`09`09SFscrollTimerId = XtAppAddTimeOut(SFapp,
X`09`09`09`09`09SFscrollTimerInterval(), SFscrollTimer,
X`09`09`09`09`09(XtPointer) n);
X`09`09`09`7D
X`09`09`7D
X
X`09`09return -1;
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFenterList(w, n, event)
X`09Widget`09`09`09`09w;
X`09register int`09`09`09n;
X`09register XEnterWindowEvent`09*event;
X`7B
X`09register int`09new;
X
X`09/* sanity */
X`09if (SFcurrentInvert`5Bn`5D != -1) `7B
X`09`09SFinvertEntry(n);
X`09`09SFcurrentInvert`5Bn`5D = -1;
X`09`7D
X
X`09new = SFnewInvertEntry(n, (XMotionEvent *) event);
X`09if (new != -1) `7B
X`09`09SFcurrentInvert`5Bn`5D = new;
X`09`09SFinvertEntry(n);
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFleaveList(w, n, event)
X`09Widget`09`09w;
X`09register int`09n;
X`09XEvent`09`09*event;
X`7B
X`09if (SFcurrentInvert`5Bn`5D != -1) `7B
X`09`09SFinvertEntry(n);
X`09`09SFcurrentInvert`5Bn`5D = -1;
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFmotionList(w, n, event)
X`09Widget`09`09`09w;
X`09register int`09`09n;
X`09register XMotionEvent`09*event;
X`7B
X`09register int`09new;
X
X`09new = SFnewInvertEntry(n, event);
X
X`09if (new != SFcurrentInvert`5Bn`5D) `7B
X`09`09if (SFcurrentInvert`5Bn`5D != -1) `7B
X`09`09`09SFinvertEntry(n);
X`09`09`7D
X`09`09SFcurrentInvert`5Bn`5D = new;
X`09`09if (new != -1) `7B
X`09`09`09SFinvertEntry(n);
X`09`09`7D
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFvFloatSliderMovedCallback(w, n, fnew)
X`09Widget`09w;
X`09int`09n;
X`09float`09*fnew;
X`7B
X`09int`09new;
X
X`09new = (*fnew) * SFdirs`5BSFdirPtr + n`5D.nEntries;
X
X`09SFvSliderMovedCallback(w, n, new);
X`7D
X
X/* ARGSUSED */
Xvoid
XSFvSliderMovedCallback(w, n, new)
X`09Widget`09w;
X`09int`09n;
X`09int`09new;
X`7B
X`09int`09`09old;
X`09register Window`09win;
X`09SFDir`09`09*dir;
X
X`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X
X`09old = dir->vOrigin;
X`09dir->vOrigin = new;
X
X`09if (old == new) `7B
X`09`09return;
X`09`7D
X
X`09win = XtWindow(selFileLists`5Bn`5D);
X
X`09if (ABS(new - old) < SFlistSize) `7B
X`09`09if (new > old) `7B
X`09`09`09XCopyArea(
X`09`09`09`09SFdisplay,
X`09`09`09`09win,
X`09`09`09`09win,
X`09`09`09`09SFscrollGC,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY + (new - old) * SFentryHeight,
X`09`09`09`09SFentryWidth + SFlineToTextH,
X`09`09`09`09(SFlistSize - (new - old)) * SFentryHeight,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY
X`09`09`09);
X`09`09`09XClearArea(
X`09`09`09`09SFdisplay,
X`09`09`09`09win,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY + (SFlistSize - (new - old)) *
X`09`09`09`09`09SFentryHeight,
X`09`09`09`09SFentryWidth + SFlineToTextH,
X`09`09`09`09(new - old) * SFentryHeight,
X`09`09`09`09False
X`09`09`09);
X`09`09`09SFdrawStrings(win, dir, SFlistSize - (new - old),
X`09`09`09`09SFlistSize - 1);
X`09`09`7D else `7B
X`09`09`09XCopyArea(
X`09`09`09`09SFdisplay,
X`09`09`09`09win,
X`09`09`09`09win,
X`09`09`09`09SFscrollGC,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY,
X`09`09`09`09SFentryWidth + SFlineToTextH,
X`09`09`09`09(SFlistSize - (old - new)) * SFentryHeight,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY + (old - new) * SFentryHeight
X`09`09`09);
X`09`09`09XClearArea(
X`09`09`09`09SFdisplay,
X`09`09`09`09win,
X`09`09`09`09SFlineToTextH,
X`09`09`09`09SFlowerY,
X`09`09`09`09SFentryWidth + SFlineToTextH,
X`09`09`09`09(old - new) * SFentryHeight,
X`09`09`09`09False
X`09`09`09);
X`09`09`09SFdrawStrings(win, dir, 0, old - new);
X`09`09`7D
X`09`7D else `7B
X`09`09XClearArea(
X`09`09`09SFdisplay,
X`09`09`09win,
X`09`09`09SFlineToTextH,
X`09`09`09SFlowerY,
X`09`09`09SFentryWidth + SFlineToTextH,
X`09`09`09SFlistSize * SFentryHeight,
X`09`09`09False
X`09`09);
X`09`09SFdrawStrings(win, dir, 0, SFlistSize - 1);
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFvAreaSelectedCallback(w, n, pnew)
X`09Widget`09w;
X`09int`09n;
X`09int`09pnew;
X`7B
X`09SFDir`09*dir;
X`09int`09new;
X
X`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X
X`09new = dir->vOrigin +
X`09`09(((double) pnew) / SFvScrollHeight) * dir->nEntries;
X
X`09if (new > dir->nEntries - SFlistSize) `7B
X`09`09new = dir->nEntries - SFlistSize;
X`09`7D
X
X`09if (new < 0) `7B
X`09`09new = 0;
X`09`7D
X
X`09if (dir->nEntries) `7B
X`09`09float`09f;
X
X`09`09f = ((double) new) / dir->nEntries;
X
X`09`09XawScrollbarSetThumb(
X`09`09`09w,
X`09`09`09f,
X`09`09`09(float) (((double) ((dir->nEntries < SFlistSize) ?
X`09`09`09`09dir->nEntries : SFlistSize)) / dir->nEntries)
X`09`09);
X`09`7D
X
X`09SFvSliderMovedCallback(w, n, new);
X`7D
X
X/* ARGSUSED */
Xvoid
XSFhSliderMovedCallback(w, n, new)
X`09Widget`09w;
X`09int`09n;
X`09float`09*new;
X`7B
X`09SFDir`09*dir;
X`09int`09save;
X
X`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X`09save = dir->hOrigin;
X`09dir->hOrigin = (*new) * dir->nChars;
X`09if (dir->hOrigin == save) `7B
X`09`09return;
X`09`7D
X
X`09SFdrawList(n, SF_DO_NOT_SCROLL);
X`7D
X
X/* ARGSUSED */
Xvoid
XSFhAreaSelectedCallback(w, n, pnew)
X`09Widget`09w;
X`09int`09n;
X`09int`09pnew;
X`7B
X`09SFDir`09*dir;
X`09int`09new;
X
X`09dir = &(SFdirs`5BSFdirPtr + n`5D);
X
X`09new = dir->hOrigin +
X`09`09(((double) pnew) / SFhScrollWidth) * dir->nChars;
X
X`09if (new > dir->nChars - SFcharsPerEntry) `7B
X`09`09new = dir->nChars - SFcharsPerEntry;
X`09`7D
X
X`09if (new < 0) `7B
X`09`09new = 0;
X`09`7D
X
X`09if (dir->nChars) `7B
X`09`09float`09f;
X
X`09`09f = ((double) new) / dir->nChars;
X
X`09`09XawScrollbarSetThumb(
X`09`09`09w,
X`09`09`09f,
X`09`09`09(float) (((double) ((dir->nChars < SFcharsPerEntry) ?
X`09`09`09`09dir->nChars : SFcharsPerEntry)) / dir->nChars)
X`09`09);
X
X`09`09SFhSliderMovedCallback(w, n, &f);
X`09`7D
X`7D
X
X/* ARGSUSED */
Xvoid
XSFpathSliderMovedCallback(w, client_data, new)
X`09Widget`09`09w;
X`09XtPointer`09client_data;
X`09float`09*new;
X`7B
+-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-
Technical Details
Message-ID:
<8881758@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!ux1.cso.uiuc.edu!sdd.hp.com!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sourcesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!ux1.cso.uiuc.edu!sdd.hp.com!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources Newsgroups: vmsnet.sources From: Terry Poot <tp@mccall.com> Subject: Ghostview for VMS 02/14 Message-ID: <8881758@MVB.SAIC.COM> Date: Thu, 29 Oct 1992 18:49:15 GMT Lines: 1551 Approved: Mark.Berryman@Mvb.Saic.Com