diff options
Diffstat (limited to 'xfontsel.c')
-rw-r--r-- | xfontsel.c | 161 |
1 files changed, 58 insertions, 103 deletions
@@ -66,22 +66,22 @@ Modified: Mark Leisher <mleisher@crl.nmsu.edu> to deal with UCS sample text. #define NZ NULL,ZERO #define BACKGROUND 10 -void GetFontNames(); -Boolean Matches(); -Boolean DoWorkPiece(); -void Quit(); -void OwnSelection(); -void SelectField(); -void ParseFontNames(); -void SortFields(); -void FixScalables(); -void MakeFieldMenu(); -void SelectValue(); -void AnyValue(); -void EnableOtherValues(); -void EnableMenu(); -void SetCurrentFont(); -void QuitAction(); +void GetFontNames(XtPointer closure); +Boolean Matches(String pattern, String fontName, Boolean fields[], int *maxfields); +Boolean DoWorkPiece(XtPointer closure); +void Quit(Widget w, XtPointer closure, XtPointer callData); +void OwnSelection(Widget w, XtPointer closure, XtPointer callData); +void SelectField(Widget w, XtPointer closure, XtPointer callData); +void ParseFontNames(XtPointer closure); +void SortFields(XtPointer closure); +void FixScalables(XtPointer closure); +void MakeFieldMenu(XtPointer closure); +void SelectValue(Widget w, XtPointer closure, XtPointer callData); +void AnyValue(Widget w, XtPointer closure, XtPointer callData); +void EnableOtherValues(Widget w, XtPointer closure, XtPointer callData); +void EnableMenu(XtPointer closure); +void SetCurrentFont(XtPointer closure); +void QuitAction(Widget w, XEvent *event, String *params, Cardinal *num_params); XtActionsRec xfontsel_actions[] = { {"Quit", QuitAction} @@ -89,9 +89,9 @@ XtActionsRec xfontsel_actions[] = { Atom wm_delete_window; -Boolean IsXLFDFontName(); +Boolean IsXLFDFontName(String fontName); -typedef void (*XtProc)(); +typedef void (*XtProc)(XtPointer closure); static struct _appRes { int app_defaults_version; @@ -150,8 +150,7 @@ static XrmOptionDescRec options[] = { {"-scaled", "scaledFonts", XrmoptionNoArg, "True"}, }; -static void Syntax(call) - char *call; +static void Syntax(char *call) { fprintf (stderr, "usage: %s [-options ...] -fn font\n\n", call); fprintf (stderr, "where options include:\n"); @@ -260,9 +259,7 @@ int enabledMenuIndex; static Boolean patternFieldSpecified[FIELD_COUNT]; /* = 0 */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { Widget topLevel, pane; @@ -328,7 +325,7 @@ see 'xfontsel' manual page." makeRec->field = f; makeRec->button = field; ScheduleWork(MakeFieldMenu, (XtPointer)makeRec, 2); - ScheduleWork(XtFree, (XtPointer)makeRec, 2); + ScheduleWork((XtProc)XtFree, (XtPointer)makeRec, 2); } } @@ -397,10 +394,7 @@ static WorkPiece workQueue = NULL; * Xt knows we have (background) work to do. */ -static void ScheduleWork( proc, closure, priority ) - XtProc proc; - XtPointer closure; - int priority; +static void ScheduleWork(XtProc proc, XtPointer closure, int priority) { WorkPiece piece = XtNew(WorkPieceRec); @@ -427,8 +421,7 @@ static void ScheduleWork( proc, closure, priority ) } /* ARGSUSED */ -Boolean DoWorkPiece(closure) - XtPointer closure; /* unused */ +Boolean DoWorkPiece(XtPointer closure) { WorkPiece piece = workQueue; @@ -450,7 +443,7 @@ Boolean DoWorkPiece(closure) * Foreground == (priority < BACKGROUND) */ -void FinishWork() +static void FinishWork(void) { while (workQueue && workQueue->priority < BACKGROUND) DoWorkPiece(NULL); @@ -467,8 +460,7 @@ struct ParseRec { }; -void GetFontNames( closure ) - XtPointer closure; +void GetFontNames(XtPointer closure) { Display *dpy = (Display*)closure; ParseRec *parseRec = XtNew(ParseRec); @@ -502,7 +494,7 @@ void GetFontNames( closure ) ParseRec *prevRec = parseRec; parseRec->end = parseRec->start + PARSE_QUANTUM; ScheduleWork(ParseFontNames, (XtPointer)parseRec, work_priority); - ScheduleWork(XtFree, (XtPointer)parseRec, work_priority); + ScheduleWork((XtProc)XtFree, (XtPointer)parseRec, work_priority); parseRec = XtNew(ParseRec); *parseRec = *prevRec; parseRec->start += PARSE_QUANTUM; @@ -514,7 +506,7 @@ void GetFontNames( closure ) parseRec->end = numFonts; ScheduleWork(ParseFontNames,(XtPointer)parseRec,work_priority); ScheduleWork((XtProc)XFreeFontNames,(XtPointer)fontNames,work_priority); - ScheduleWork(XtFree, (XtPointer)parseRec, work_priority); + ScheduleWork((XtProc)XtFree, (XtPointer)parseRec, work_priority); if (AppRes.scaled_fonts) ScheduleWork(FixScalables,(XtPointer)0,work_priority); ScheduleWork(SortFields,(XtPointer)0,work_priority); @@ -543,8 +535,7 @@ void GetFontNames( closure ) } -void ParseFontNames( closure ) - XtPointer closure; +void ParseFontNames(XtPointer closure) { ParseRec *parseRec = (ParseRec*)closure; char **fontNames = parseRec->fontNames; @@ -629,8 +620,7 @@ void ParseFontNames( closure ) * since we need to do this for resolution fields which can be nonzero in * the scalable fonts. */ -void AddScalables(f) - int f; +static void AddScalables(int f) { int i; int max = fieldValues[f]->count; @@ -683,9 +673,7 @@ void AddScalables(f) * for field f. Weed out duplicates. The set of matching fonts is just * the set of scalable fonts. */ -void NewScalables(f, slist) - int f; - char *slist; +static void NewScalables(int f, char *slist) { char endc = 1; char *str; @@ -732,8 +720,7 @@ void NewScalables(f, slist) * in resources. */ /*ARGSUSED*/ -void FixScalables( closure ) - XtPointer closure; +void FixScalables(XtPointer closure) { int i; FieldValue *fval = fieldValues[6]->value; @@ -797,7 +784,7 @@ static int strcmpn(const char *s1, const char *s2) /* Order is *, (nil), rest */ -int AlphabeticSort(_Xconst void *fval1, _Xconst void *fval2) +static int AlphabeticSort(_Xconst void *fval1, _Xconst void *fval2) { # define fval1 ((_Xconst FieldValue *)fval1) # define fval2 ((_Xconst FieldValue *)fval2) @@ -819,7 +806,7 @@ int AlphabeticSort(_Xconst void *fval1, _Xconst void *fval2) /* Order is *, (nil), rest */ -int NumericSort(_Xconst void *fval1, _Xconst void *fval2) +static int NumericSort(_Xconst void *fval1, _Xconst void *fval2) { # define fval1 ((_Xconst FieldValue *)fval1) # define fval2 ((_Xconst FieldValue *)fval2) @@ -846,8 +833,7 @@ int NumericSort(_Xconst void *fval1, _Xconst void *fval2) * sort. */ /*ARGSUSED*/ -void SortFields( closure ) - XtPointer closure; +void SortFields(XtPointer closure) { int i, j, count; FieldValue *vals; @@ -883,8 +869,7 @@ void SortFields( closure ) } -Boolean IsXLFDFontName(fontName) - String fontName; +Boolean IsXLFDFontName(String fontName) { int f; for (f = 0; *fontName;) if (*fontName++ == DELIM) f++; @@ -892,8 +877,7 @@ Boolean IsXLFDFontName(fontName) } -void MakeFieldMenu(closure) - XtPointer closure; +void MakeFieldMenu(XtPointer closure) { FieldMenuRec *makeRec = (FieldMenuRec*)closure; Widget menu; @@ -948,10 +932,8 @@ static void SetNoFonts(void) } -Boolean Matches(pattern, fontName, fields, maxField) - register String pattern, fontName; - Boolean fields[/*FIELD_COUNT*/]; - int *maxField; +Boolean Matches(register String pattern, register String fontName, + Boolean fields[/*FIELD_COUNT*/], int *maxField) { register int field = (*fontName == DELIM) ? -1 : 0; register Boolean marked_this_field = False; @@ -999,9 +981,7 @@ Boolean Matches(pattern, fontName, fields, maxField) /* ARGSUSED */ -void SelectValue(w, closure, callData) - Widget w; - XtPointer closure, callData; +void SelectValue(Widget w, XtPointer closure, XtPointer callData) { FieldValue *val = (FieldValue*)closure; #ifdef LOG_CHOICES @@ -1031,9 +1011,7 @@ void SelectValue(w, closure, callData) /* ARGSUSED */ -void AnyValue(w, closure, callData) - Widget w; - XtPointer closure, callData; +void AnyValue(Widget w, XtPointer closure, XtPointer callData) { int field = (long)closure; currentFont.value_index[field] = -1; @@ -1072,9 +1050,7 @@ static void SetParsingFontCount(int count) } /* ARGSUSED */ -static Boolean IsISO10646(dpy, font) - Display *dpy; - XFontStruct *font; +static Boolean IsISO10646(Display *dpy, XFontStruct *font) { Boolean ok; int i; @@ -1099,8 +1075,7 @@ static Boolean IsISO10646(dpy, font) } /* ARGSUSED */ -void SetCurrentFont(closure) - XtPointer closure; /* unused */ +void SetCurrentFont(XtPointer closure) { int f; Boolean *b; @@ -1200,9 +1175,7 @@ void SetCurrentFont(closure) } -static void MarkInvalidFonts( set, val ) - Boolean *set; - FieldValue *val; +static void MarkInvalidFonts(Boolean *set, FieldValue *val) { int fi = 0, vi; int *fp = val->font; @@ -1220,8 +1193,7 @@ static void MarkInvalidFonts( set, val ) } -static void EnableRemainingItems(current_field_action) - ValidateAction current_field_action; +static void EnableRemainingItems(ValidateAction current_field_action) { if (matchingFontCount == 0 || matchingFontCount == numFonts) { if (anyDisabled) { @@ -1275,9 +1247,7 @@ static void EnableAllItems(int field) /* ARGSUSED */ -void SelectField(w, closure, callData) - Widget w; - XtPointer closure, callData; +void SelectField(Widget w, XtPointer closure, XtPointer callData) { int field = (long)closure; FieldValue *values = fieldValues[field]->value; @@ -1297,8 +1267,7 @@ void SelectField(w, closure, callData) * will almost always produce an illegal font name, and it isn't worth * trying to compute which choices might be legal to the font scaler. */ -void DisableScaled(f, f1, f2) - int f, f1, f2; +static void DisableScaled(int f, int f1, int f2) { int i, j; FieldValue *v; @@ -1321,9 +1290,7 @@ void DisableScaled(f, f1, f2) } /* ARGSUSED */ -void EnableOtherValues(w, closure, callData) - Widget w; - XtPointer closure, callData; +void EnableOtherValues(Widget w, XtPointer closure, XtPointer callData) { int field = (long)closure; Boolean *font_in_set = (Boolean*)XtMalloc(numFonts*sizeof(Boolean)); @@ -1386,8 +1353,7 @@ void EnableOtherValues(w, closure, callData) } -void EnableMenu(closure) - XtPointer closure; +void EnableMenu(XtPointer closure) { int field = (long)closure; FieldValue *val = fieldValues[field]->value; @@ -1434,8 +1400,7 @@ void EnableMenu(closure) } -static void FlushXqueue(dpy) - Display *dpy; +static void FlushXqueue(Display *dpy) { XSync(dpy, False); while (XtAppPending(appCtx)) XtAppProcessEvent(appCtx, XtIMAll); @@ -1443,9 +1408,7 @@ static void FlushXqueue(dpy) /* ARGSUSED */ -void Quit(w, closure, callData) - Widget w; - XtPointer closure, callData; +void Quit(Widget w, XtPointer closure, XtPointer callData) { XtCloseDisplay(XtDisplay(w)); if (AppRes.print_on_quit) printf( "%s", currentFontNameString ); @@ -1453,12 +1416,9 @@ void Quit(w, closure, callData) } -Boolean ConvertSelection(w, selection, target, type, value, length, format) - Widget w; - Atom *selection, *target, *type; - XtPointer *value; - unsigned long *length; - int *format; +static Boolean +ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, + XtPointer *value, unsigned long *length, int *format) { /* XmuConvertStandardSelection will use the second parameter only when * converting to the target TIMESTAMP. However, it will never be @@ -1485,9 +1445,7 @@ static AtomPtr _XA_PRIMARY_FONT = NULL; #define XA_PRIMARY_FONT XmuInternAtom(XtDisplay(w),_XA_PRIMARY_FONT) /* ARGSUSED */ -void LoseSelection(w, selection) - Widget w; - Atom *selection; +static void LoseSelection(Widget w, Atom *selection) { Arg args[1]; XtSetArg( args[0], XtNstate, False ); @@ -1499,18 +1457,14 @@ void LoseSelection(w, selection) /* ARGSUSED */ -void DoneSelection(w, selection, target) - Widget w; - Atom *selection, *target; +static void DoneSelection(Widget w, Atom *selection, Atom *target) { /* do nothing */ } /* ARGSUSED */ -void OwnSelection(w, closure, callData) - Widget w; - XtPointer closure, callData; +void OwnSelection(Widget w, XtPointer closure, XtPointer callData) { Time time = XtLastTimestampProcessed(XtDisplay(w)); Boolean primary = (Boolean) (long) closure; @@ -1537,8 +1491,9 @@ void OwnSelection(w, closure, callData) } } +/*ARGSUSED*/ void -QuitAction () +QuitAction(Widget w, XEvent *event, String *params, Cardinal *num_params) { exit (0); } |