19036bfb48c3826f6756b9bc1305aa47f493ba8f
[xboard.git] / filebrowser / selfile.h
1 /*
2  * File-Selector dialog of GhostView 1.5, incorporated in XBoard by H.G.Muller
3  *
4  * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
5  *
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 Software Research Associates not be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission.  Software Research Associates
13  * makes no representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied warranty.
15  *
16  * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
18  * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
19  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: Erik M. van der Poel
25  *         Software Research Associates, Inc., Tokyo, Japan
26  *         erik@sra.co.jp
27  */
28
29 #include <X11/Intrinsic.h>
30 #include <X11/StringDefs.h>
31 #include <X11/Xos.h>
32 #include <X11/Xaw/Text.h>
33 #include <X11/Xaw/AsciiText.h>
34
35 #define SEL_FILE_CANCEL         -1
36 #define SEL_FILE_OK             0
37 #define SEL_FILE_NULL           1
38 #define SEL_FILE_TEXT           2
39
40 #define SF_DO_SCROLL            1
41 #define SF_DO_NOT_SCROLL        0
42
43 #define NR 3 /* [HGM] (so far failed) attempt to suppress some of the director listings */
44
45 typedef struct {
46         int     statDone;
47         char    *real;
48         char    *shown;
49 } SFEntry;
50
51 typedef struct {
52         char    *dir;
53         char    *path;
54         SFEntry *entries;
55         int     nEntries;
56         int     vOrigin;
57         int     nChars;
58         int     hOrigin;
59         int     changed;
60         int     beginSelection;
61         int     endSelection;
62         time_t  mtime;
63 } SFDir;
64
65 extern int SFstatus;
66
67 extern char SFcurrentPath[], SFstartDir[], SFcurrentDir[];
68
69 extern Widget
70                 selFile,
71                 selFileCancel,
72                 selFileField,
73                 filterField,
74                 selFileForm,
75                 selFileHScroll,
76                 selFileHScrolls[],
77                 selFileLists[],
78                 selFileOK,
79                 selFilePrompt,
80                 selFileVScrolls[];
81
82 extern Display *SFdisplay;
83
84 extern int SFcharWidth, SFcharHeight, SFcharAscent;
85
86 extern SFDir *SFdirs;
87
88 extern int SFdirEnd, SFdirPtr;
89
90 extern Pixel SFfore, SFback;
91
92 extern Atom SFwmDeleteWindow;
93
94 extern XSegment SFsegs[], SFcompletionSegs[];
95
96 extern XawTextPosition SFtextPos;
97
98 extern void
99         SFenterList(),
100         SFleaveList(),
101         SFmotionList(),
102         SFbuttonPressList(),
103         SFbuttonReleaseList();
104
105 extern void
106         SFvSliderMovedCallback(),
107         SFvFloatSliderMovedCallback(),
108         SFhSliderMovedCallback(),
109         SFpathSliderMovedCallback(),
110         SFvAreaSelectedCallback(),
111         SFhAreaSelectedCallback(),
112         SFpathAreaSelectedCallback();
113
114 extern int SFupperX, SFlowerY, SFupperY;
115
116 extern int SFtextX, SFtextYoffset;
117
118 extern int SFentryWidth, SFentryHeight;
119
120 extern int SFlineToTextH, SFlineToTextV;
121
122 extern int SFbesideText, SFaboveAndBelowText;
123
124 extern int SFcharsPerEntry;
125
126 extern int SFlistSize;
127
128 extern int SFcurrentInvert[];
129
130 extern int SFworkProcAdded;
131
132 extern Boolean SFworkProc();
133
134 extern XtAppContext SFapp;
135
136 extern int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
137
138 extern char SFfilterBuffer[];
139
140 extern int SFbuttonPressed;
141
142 extern int SFcompareEntries();
143
144 extern void SFdirModTimer();
145
146 extern char SFstatChar();
147
148 extern XtIntervalId SFdirModTimerId;
149
150 extern int (*SFfunc)();
151
152 extern Boolean SFpathFlag; // [HGM]
153
154 /* added missing prototypes */
155 char SFstatChar(struct stat *);
156 int  SFchdir(char *);
157 void SFvSliderMovedCallback(Widget, int, int);
158 void SFdrawList(int,int);
159 void SFdrawLists(int);
160 void SFinitFont();
161 void SFcreateGC();
162 void SFupdatePath();
163 void SFsetText(char *);
164 void SFtextChanged();
165 int  SFgetDir(SFDir *);
166 void SFclearList(int, int);
167 void SFmotionList(Widget, int, XMotionEvent*);
168
169
170