2
* xless - X Window System file browser.
4
* Copyright 1989 Massachusetts Institute of Technology
6
* Permission to use, copy, modify, and distribute this software and its
7
* documentation for any purpose and without fee is hereby granted, provided
8
* that the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of M.I.T. not be used in advertising
11
* or publicity pertaining to distribution of the software without specific,
12
* written prior permission. M.I.T. makes no representations about the
13
* suitability of this software for any purpose. It is provided "as is"
14
* without express or implied warranty.
16
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
18
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
* carlo@athena.mit.edu
27
* Date: October 11, 1989
29
* $Header: /usr/sww/share/src/X11R5/local/clients/xless-1.4/RCS/main.c,v 1.23 1993/04/30 21:40:35 dglo Exp dglo $
33
#include "XLessTop.icon"
39
XLessResources resources;
41
#define Offset(field) (XtOffset(XLessResources *, field))
43
static XtResource priv_resources[] = {
44
{"helpFile", XtCFile, XtRString, sizeof(char *),
45
Offset(help_file), XtRString, "xless.help"},
46
{"standardCur", XtCCursor, XtRCursor, sizeof(Cursor),
47
Offset(cursors.top), XtRString, STANDARDCUR},
48
{"dialogCur", XtCCursor, XtRCursor, sizeof(Cursor),
49
Offset(cursors.dialog), XtRString, STANDARDCUR},
50
{"standardFont", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
51
Offset(fonts.standard), XtRString, STANDARDFONT},
52
{"textFont", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
53
Offset(fonts.text), XtRString, TEXTFONT},
54
{"labelFont", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
55
Offset(fonts.label), XtRString, LABELFONT},
56
{"buttonFont", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
57
Offset(fonts.button), XtRString, BUTTONFONT},
58
{"editorDoesWindows", "EditorDoesWindows", XtRBoolean, sizeof(Boolean),
59
Offset(editorDoesWindows), XtRString, "False"},
60
{"printCommand", "PrintCommand", XtRString, sizeof(char *),
61
Offset(printCmd), XtRString, PRINTCMD},
62
{"printCmd", "PrintCommand", XtRString, sizeof(char *),
63
Offset(printCmd), XtRString, PRINTCMD},
64
{"maxWindows", "MaxWindows", XtRInt, sizeof(int),
65
Offset(maxWindows), XtRString, "0"},
66
{"quitButton", "QuitButton", XtRBoolean, sizeof(Boolean),
67
Offset(quitButton), XtRString, "False"},
68
{"textGeometry", "Geometry", XtRString, sizeof(char *),
69
Offset(textGeometry), XtRString, "150x25"},
70
{"sizeToFit", "SizeToFit", XtRBoolean, sizeof(Boolean),
71
Offset(sizeToFit), XtRString, "True"},
72
{"namePrefix", "NamePrefix", XtRString, sizeof(char *),
73
Offset(namePrefix), XtRString, "xless:"},
74
{"removePath", "RemovePath", XtRBoolean, sizeof(Boolean),
75
Offset(removePath), XtRString, "True"},
76
{"helpMessage", "HelpMessage", XtRBoolean, sizeof(Boolean),
77
Offset(helpMessage), XtRString, "False"},
80
static XrmOptionDescRec options[] = {
81
{"-help", "*helpMessage", XrmoptionNoArg, "True"},
87
XtDestroyWidget(toplevel);
88
XtDestroyApplicationContext(context);
99
#ifdef _DEBUG_MALLOC_INC
101
union dbmalloptarg moa;
104
dbmallopt(MALLOC_CKCHAIN, &moa);
107
toplevel = XtAppInitialize(&context, XLESS_CLASS, NULL, (Cardinal )0,
108
&argc, argv, NULL, NULL, 0);
110
XtGetApplicationResources(toplevel, (XtPointer )&resources, priv_resources,
111
XtNumber(priv_resources), NULL, (Cardinal) 0);
113
XtAppAddActions(context, actions, numactions);
115
disp = XtDisplay(toplevel);
118
XtSetArg(arg[n], XtNiconPixmap,
119
XCreateBitmapFromData(disp, XRootWindow(disp, 0),
120
XLessTop_bits, XLessTop_width,
121
XLessTop_height)); n++;
122
XtSetValues(toplevel, arg, n);
126
for (i = 1; resources.helpMessage || i < argc; i++) {
128
/* whine if there's still an argument */
129
if (resources.helpMessage || *argv[i] == '-') {
130
fprintf(stdout, "usage:\txless filename\n");
131
fprintf(stdout, "\t(xless also takes input from stdin)\n");
136
CreateWindow(toplevel, argv[i]);
139
/* if we haven't opened a window yet... */
140
if (windowcount == 0) {
142
* Not really necessary to call this an error,
143
* but if the control terminal (for commands)
144
* and the input file (for data) are the same,
145
* we get weird results at best.
147
if (isatty(fileno(stdin))) {
148
fprintf(stderr, "xless: can't take input from terminal\n");
153
/* bring up controlling window using stdin as input */
154
CreateWindow(toplevel, NULL);
157
XtAppMainLoop(context);