#include <X11/Xaw/Cardinals.h>
#include "selfile.h"
+#include "xstat.h"
+
+/* added missing prototypes */
+extern void SFdrawList(int,int);
+extern void SFinitFont();
+extern void SFcreateGC();
+extern int SFchdir(char *);
+extern void SFupdatePath();
+extern void SFsetText(char *);
+extern char SFstatChar(struct stat*);
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
int (*SFfunc)();
+Boolean SFpathFlag; // [HGM]
+
static char *oneLineTextEditTranslations = "\
<Key>Return: redraw-display()\n\
Ctrl<Key>M: redraw-display()\n\
return;
}
- SFdrawList(n, SF_DO_NOT_SCROLL);
+ SFdrawList((int)(intptr_t)n, SF_DO_NOT_SCROLL);
}
/* ARGSUSED */
scrollbarWidgetClass, selFileLists[n], arglist, i);
XtAddCallback(selFileVScrolls[n], XtNjumpProc,
- SFvFloatSliderMovedCallback, (XtPointer) n);
+ SFvFloatSliderMovedCallback, (XtPointer)(intptr_t) n);
XtAddCallback(selFileVScrolls[n], XtNscrollProc,
- SFvAreaSelectedCallback, (XtPointer) n);
+ SFvAreaSelectedCallback, (XtPointer)(intptr_t) n);
i = 0;
scrollbarWidgetClass, selFileLists[n], arglist, i);
XtAddCallback(selFileHScrolls[n], XtNjumpProc,
- SFhSliderMovedCallback, (XtPointer) n);
+ SFhSliderMovedCallback, (XtPointer)(intptr_t) n);
XtAddCallback(selFileHScrolls[n], XtNscrollProc,
- SFhAreaSelectedCallback, (XtPointer) n);
+ SFhAreaSelectedCallback, (XtPointer)(intptr_t) n);
}
i = 0;
for (n = 0; n < NR; n++) {
XtAddEventHandler(selFileLists[n], ExposureMask, True,
- SFexposeList, (XtPointer) n);
+ SFexposeList, (XtPointer)(intptr_t) n);
XtAddEventHandler(selFileLists[n], EnterWindowMask, False,
- SFenterList, (XtPointer) n);
+ SFenterList, (XtPointer)(intptr_t) n);
XtAddEventHandler(selFileLists[n], LeaveWindowMask, False,
- SFleaveList, (XtPointer) n);
+ SFleaveList, (XtPointer)(intptr_t) n);
XtAddEventHandler(selFileLists[n], PointerMotionMask, False,
- SFmotionList, (XtPointer) n);
+ SFmotionList, (XtPointer)(intptr_t) n);
XtAddEventHandler(selFileLists[n], ButtonPressMask, False,
- SFbuttonPressList, (XtPointer) n);
+ SFbuttonPressList, (XtPointer)(intptr_t) n);
XtAddEventHandler(selFileLists[n], ButtonReleaseMask, False,
- SFbuttonReleaseList, (XtPointer) n);
+ SFbuttonReleaseList, (XtPointer)(intptr_t) n);
}
XtAddEventHandler(selFileField, KeyPressMask, False,
{
if ((SFtextBuffer[0] == '/') || (SFtextBuffer[0] == '~')) {
- (void) strcpy(SFcurrentPath, SFtextBuffer);
+ (void) strncpy(SFcurrentPath, SFtextBuffer, MAXPATHLEN);
SFtextPos = XawTextGetInsertionPoint(selFileField);
} else {
- (void) strcat(strcpy(SFcurrentPath, SFstartDir), SFtextBuffer);
+ (void) strcat(strncpy(SFcurrentPath, SFstartDir, MAXPATHLEN), SFtextBuffer);
SFtextPos = XawTextGetInsertionPoint(selFileField) +
strlen(SFstartDir);
cancel = "Cancel";
}
+ if(SFpathFlag != (mode && mode[0] == 'p')) { // [HGM] ignore everything that is not a directory
+ if(SFdirs) XtFree(SFdirs);
+ SFdirs = NULL; // kludge to throw away all cached info
+ SFpathFlag = !SFpathFlag;
+ }
+
if (firstTime) {
firstTime = 0;
SFdisplay = XtDisplay(toplevel);
XtAppError(SFapp, "XsraSelFile: can't get current directory");
}
(void) strcat(SFstartDir, "/");
- (void) strcpy(SFcurrentDir, SFstartDir);
+ (void) strncpy(SFcurrentDir, SFstartDir, MAXPATHLEN);
if (init_path) {
if (init_path[0] == '/') {
- (void) strcpy(SFcurrentPath, init_path);
+ (void) strncpy(SFcurrentPath, init_path, MAXPATHLEN);
if (strncmp(
SFcurrentPath,
SFstartDir,
SFsetText(&(SFcurrentPath[strlen(SFstartDir)]));
}
} else {
- (void) strcat(strcpy(SFcurrentPath, SFstartDir),
+ (void) strcat(strncpy(SFcurrentPath, SFstartDir, MAXPATHLEN),
init_path);
SFsetText(&(SFcurrentPath[strlen(SFstartDir)]));
}
} else {
- (void) strcpy(SFcurrentPath, SFstartDir);
+ (void) strncpy(SFcurrentPath, SFstartDir, MAXPATHLEN);
}
SFfunc = show_entry;
break;
case SEL_FILE_OK:
*name_return = SFgetText();
+ if(mode && (mode[0] == 'p' || mode[0] == 'f')) { // [HGM] for use in file-option browse button
+ SFprepareToReturn();
+ return stderr;
+ }
if (fp = SFopenFile(*name_return, mode,
prompt, failed)) {
SFprepareToReturn();