#include <stdio.h>
#include "xstat.h"
#include "selfile.h"
+#include "config.h"
#include <X11/StringDefs.h>
#include <X11/Xaw/Scrollbar.h>
#include <X11/Xaw/Cardinals.h>
XtOffset(textPtr, fontname), XtRString, SF_DEFAULT_FONT},
};
+#if ENABLE_NLS
+extern XFontSet fontSet; //XXX should really be in a .h file
+#else
static XFontStruct *SFfont;
+#endif
static int SFcurrentListY;
void
SFinitFont()
{
+#if ENABLE_NLS
+ XFontSetExtents *fse = XExtentsOfFontSet(fontSet);
+ SFcharWidth = fse->max_logical_extent.width;
+ SFcharAscent = -fse->max_logical_extent.y;
+ SFcharHeight = fse->max_logical_extent.height;
+#else
TextData *data;
data = XtNew(TextData);
SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
SFcharAscent = SFfont->max_bounds.ascent;
SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
+#endif
return;
}
gcValues.foreground = SFfore;
gcValues.background = SFback;
+#if !ENABLE_NLS
gcValues.font = SFfont->fid;
+#endif
SFtextGC = XCreateGC(
SFdisplay,
(unsigned long)
GCForeground |
GCBackground |
+#if !ENABLE_NLS
GCFont |
+#endif
0,
&gcValues
);
continue;
}
}
+#if ENABLE_NLS
+ XmbDrawImageString(
+ SFdisplay,
+ w,
+ fontSet,
+ SFtextGC,
+ x,
+ SFtextYoffset + i * SFentryHeight,
+ entry->shown,
+ strlen(entry->shown)
+ );
+#else
XDrawImageString(
SFdisplay,
w,
entry->shown,
strlen(entry->shown)
);
+#endif
if (dir->vOrigin + i == dir->beginSelection) {
XDrawLine(
SFdisplay,
if (SFdirPtr + (3-NR) + n < SFdirEnd) {
dir = &(SFdirs[SFdirPtr + n + (3-NR)]);
w = XtWindow(selFileLists[n]);
+#if ENABLE_NLS
+ XmbDrawImageString(
+ SFdisplay,
+ w,
+ fontSet,
+ SFtextGC,
+ SFtextX - dir->hOrigin * SFcharWidth,
+ SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
+ dir->dir,
+ strlen(dir->dir)
+ );
+#else
XDrawImageString(
SFdisplay,
w,
dir->dir,
strlen(dir->dir)
);
+#endif
SFdrawStrings(w, dir, 0, SFlistSize - 1);
}
return;
int SFstatus = SEL_FILE_NULL;
char
- SFstartDir[MAXPATHLEN],
- SFcurrentPath[MAXPATHLEN],
- SFlastPath[MAXPATHLEN],
- SFcurrentDir[MAXPATHLEN];
+ SFstartDir[MAXPATHLEN+1],
+ SFcurrentPath[MAXPATHLEN+1],
+ SFlastPath[MAXPATHLEN+1],
+ SFcurrentDir[MAXPATHLEN+1];
Widget
selFile,
int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
-char SFtextBuffer[MAXPATHLEN];
+char SFtextBuffer[MAXPATHLEN+1];
-char SFfilterBuffer[MAXPATHLEN];
+char SFfilterBuffer[MAXPATHLEN+1];
XtIntervalId SFdirModTimerId;
XtSetArg(arglist[i], XtNeditType, XawtextEdit); i++;
XtSetArg(arglist[i], XtNwrap, XawtextWrapWord); i++;
XtSetArg(arglist[i], XtNresize, XawtextResizeHeight); i++;
- XtSetArg(arglist[i], XtNuseStringInPlace, True); i++;
selFileField = XtCreateManagedWidget("selFileField",
asciiTextWidgetClass, selFileForm, arglist, i);
}
void
+SFupdateTextBuffer()
+{
+ Arg arglist[2];
+ int i;
+ char *v;
+
+ i = 0;
+ XtSetArg(arglist[i], XtNstring, &v); i++;
+ XtGetValues(selFileField, arglist, i);
+ strncpy(SFtextBuffer, v, MAXPATHLEN);
+}
+
+void
+SFsetText(path)
+ char *path;
+{
+ Arg arglist[2];
+ int i;
+
+ i = 0;
+ XtSetArg(arglist[i], XtNstring, path); i++;
+ XtSetValues(selFileField, arglist, i);
+ XawTextSetInsertionPoint(selFileField, strlen(path));
+}
+
+void
SFtextChanged()
{
+ SFupdateTextBuffer();
if ((SFtextBuffer[0] == '/') || (SFtextBuffer[0] == '~')) {
(void) strncpy(SFcurrentPath, SFtextBuffer, MAXPATHLEN);
XtSetValues(filterField, arglist, i);
strncpy(SFfilterBuffer, filter, MAXPATHLEN-1);
+ SFupdateTextBuffer();
strncpy(SFlastPath, SFtextBuffer, MAXPATHLEN-1); // remember for cancel
SFpositionWidget(selFile);
break;
}
}
+
}