diff options
-rw-r--r-- | man/xfontsel.man | 18 | ||||
-rw-r--r-- | xfontsel.c | 22 |
2 files changed, 30 insertions, 10 deletions
diff --git a/man/xfontsel.man b/man/xfontsel.man index 8abe62f..9084479 100644 --- a/man/xfontsel.man +++ b/man/xfontsel.man @@ -42,13 +42,11 @@ xfontsel \- point and click selection of X11 font names .SH SYNTAX .PP -\fBxfontsel\fP [-\fItoolkitoption\fP ...] -[\fB-pattern \fIfontname\fP] -[\fB-print\fP] -[\fB-sample \fItext\fP] -[\fB-sample16 \fItext16\fP] -[\fB-sampleUCS \fItextUCS\fP] -[\fB-scaled\fP] +.nf +\fBxfontsel\fP [-\fItoolkitoption\fP ...] [\fB-help\fP] [\fB-pattern\fP \fIfontname\fP] [\fB-print\fP] + [\fB-sample\fP \fItext\fP] [\fB-sample16\fP \fItext16\fP] [\fB-sampleUCS\fP \fItextUCS\fP] + [\fB-scaled\fP] [\fB-version\fP] +.fi .PP .SH DESCRIPTION .PP @@ -85,6 +83,12 @@ CHARSET_REGISTRY of ISO10646, overriding the default. The \fB-scaled\fP option enables the ability to select scaled fonts at arbitrary pixel or point sizes. .PP +The \fB\-help\fP option specifies that \fIxfontsel\fP should +print a usage message and exit. +.PP +The \fB\-version\fP option specifies that \fIxfontsel\fP should +print version info and exit. +.PP .SH INTERACTIONS .PP Clicking any pointer button in one of the XLFD field names will pop up @@ -187,7 +187,7 @@ static XrmOptionDescRec options[] = { {"-scaled", "scaledFonts", XrmoptionNoArg, "True"}, }; -static void Syntax(const char *call) +static void Syntax(const char *call, int exitval) { fprintf (stderr, "usage: %s [-options ...] -fn font\n\n%s\n", call, gettext( @@ -201,7 +201,7 @@ static void Syntax(const char *call) " -sampleUCS string sample text to use for ISO10646 fonts\n" " -scaled use scaled instances of fonts\n" "plus any standard toolkit options\n")); - exit (1); + exit (exitval); } @@ -297,6 +297,22 @@ main(int argc, char **argv) XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); + /* Handle args that don't require opening a display */ + for (int n = 1; n < argc; n++) { + const char *argn = argv[n]; + /* accept single or double dash for -help & -version */ + if (argn[0] == '-' && argn[1] == '-') { + argn++; + } + if (strcmp(argn, "-help") == 0) { + Syntax(argv[0], 0); + } + if (strcmp(argn, "-version") == 0) { + puts(PACKAGE_STRING); + exit(0); + } + } + topLevel = XtAppInitialize(&appCtx, "XFontSel", options, XtNumber(options), &argc, argv, NULL, NULL, 0); @@ -325,7 +341,7 @@ main(int argc, char **argv) fprintf(stderr, " %s", argv[n]); } fputs("\n\n", stderr); - Syntax(argv[0]); + Syntax(argv[0], 1); } XtAppAddActions(appCtx, xfontsel_actions, XtNumber(xfontsel_actions)); |