adding tests, removing -f (it was too clumsy)
This commit is contained in:
parent
6d56f2796c
commit
a48473fd8d
9
xmenu.1
9
xmenu.1
|
@ -3,7 +3,7 @@
|
||||||
xmenu \- menu utility for X
|
xmenu \- menu utility for X
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B xmenu
|
.B xmenu
|
||||||
.RB [ \-fiw ]
|
.RB [ \-iw ]
|
||||||
.RB [ -p
|
.RB [ -p
|
||||||
.IR position ]
|
.IR position ]
|
||||||
.RI [ title ]
|
.RI [ title ]
|
||||||
|
@ -16,13 +16,6 @@ and outputs the item selected to stdout.
|
||||||
.PP
|
.PP
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.TP
|
.TP
|
||||||
.B -f
|
|
||||||
Make glyphs align based solely on the first font specified.
|
|
||||||
Without this option, glyphs are aligned based on the font in which they are found.
|
|
||||||
This option may correct alignment of CJK glyphs
|
|
||||||
if a CJK font is specified after a Latin font,
|
|
||||||
but may break the alignment of other glyphs in some cases.
|
|
||||||
.TP
|
|
||||||
.B -i
|
.B -i
|
||||||
Disable icons.
|
Disable icons.
|
||||||
This makes xmenu loading faster when not using icons.
|
This makes xmenu loading faster when not using icons.
|
||||||
|
|
44
xmenu.c
44
xmenu.c
|
@ -96,7 +96,6 @@ static Atom wmdelete;
|
||||||
static Atom netatom[NetLast];
|
static Atom netatom[NetLast];
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
static int fflag = 0; /* whether glyphs should align based on the first font */
|
|
||||||
static int iflag = 0; /* whether to disable icons */
|
static int iflag = 0; /* whether to disable icons */
|
||||||
static int mflag = 0; /* whether the user specified a monitor with -p */
|
static int mflag = 0; /* whether the user specified a monitor with -p */
|
||||||
static int pflag = 0; /* whether the user specified a position with -p */
|
static int pflag = 0; /* whether the user specified a position with -p */
|
||||||
|
@ -118,11 +117,8 @@ main(int argc, char *argv[])
|
||||||
XClassHint classh;
|
XClassHint classh;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "fip:w")) != -1) {
|
while ((ch = getopt(argc, argv, "ip:w")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'f':
|
|
||||||
fflag = 1;
|
|
||||||
break;
|
|
||||||
case 'i':
|
case 'i':
|
||||||
iflag = 1;
|
iflag = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -648,11 +644,11 @@ getnextutf8char(const char *s, const char **next_ret)
|
||||||
static XftFont *
|
static XftFont *
|
||||||
getfontucode(FcChar32 ucode)
|
getfontucode(FcChar32 ucode)
|
||||||
{
|
{
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset = NULL;
|
||||||
FcPattern *fcpattern;
|
FcPattern *fcpattern = NULL;
|
||||||
FcPattern *match;
|
FcPattern *match = NULL;
|
||||||
|
XftFont *retfont = NULL;
|
||||||
XftResult result;
|
XftResult result;
|
||||||
XftFont *retfont;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < dc.nfonts; i++)
|
for (i = 0; i < dc.nfonts; i++)
|
||||||
|
@ -663,14 +659,18 @@ getfontucode(FcChar32 ucode)
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, ucode);
|
FcCharSetAddChar(fccharset, ucode);
|
||||||
|
|
||||||
/* create a pattern akin to the dc.pattern but containing our code point */
|
/* create a pattern akin to the dc.pattern but containing our charset */
|
||||||
fcpattern = FcPatternDuplicate(dc.pattern);
|
if (fccharset) {
|
||||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
fcpattern = FcPatternDuplicate(dc.pattern);
|
||||||
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
|
}
|
||||||
|
|
||||||
/* find pattern matching fcpattern */
|
/* find pattern matching fcpattern */
|
||||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
if (fcpattern) {
|
||||||
FcDefaultSubstitute(fcpattern);
|
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||||
match = XftFontMatch(dpy, screen, fcpattern, &result);
|
FcDefaultSubstitute(fcpattern);
|
||||||
|
match = XftFontMatch(dpy, screen, fcpattern, &result);
|
||||||
|
}
|
||||||
|
|
||||||
/* if found a pattern, open its font */
|
/* if found a pattern, open its font */
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -678,8 +678,8 @@ getfontucode(FcChar32 ucode)
|
||||||
if (retfont && XftCharExists(dpy, retfont, ucode) == FcTrue) {
|
if (retfont && XftCharExists(dpy, retfont, ucode) == FcTrue) {
|
||||||
if ((dc.fonts = realloc(dc.fonts, dc.nfonts+1)) == NULL)
|
if ((dc.fonts = realloc(dc.fonts, dc.nfonts+1)) == NULL)
|
||||||
err(1, "realloc");
|
err(1, "realloc");
|
||||||
dc.fonts[dc.nfonts++] = retfont;
|
dc.fonts[dc.nfonts] = retfont;
|
||||||
return retfont;
|
return dc.fonts[dc.nfonts++];
|
||||||
} else {
|
} else {
|
||||||
XftFontClose(dpy, retfont);
|
XftFontClose(dpy, retfont);
|
||||||
}
|
}
|
||||||
|
@ -694,9 +694,6 @@ static int
|
||||||
drawtext(XftDraw *draw, XftColor *color, int x, int y, unsigned h, const char *text)
|
drawtext(XftDraw *draw, XftColor *color, int x, int y, unsigned h, const char *text)
|
||||||
{
|
{
|
||||||
int textwidth = 0;
|
int textwidth = 0;
|
||||||
int texty;
|
|
||||||
|
|
||||||
texty = y + (h - (dc.fonts[0]->ascent + dc.fonts[0]->descent))/2 + dc.fonts[0]->ascent;
|
|
||||||
|
|
||||||
while (*text) {
|
while (*text) {
|
||||||
XftFont *currfont;
|
XftFont *currfont;
|
||||||
|
@ -713,8 +710,9 @@ drawtext(XftDraw *draw, XftColor *color, int x, int y, unsigned h, const char *t
|
||||||
textwidth += ext.xOff;
|
textwidth += ext.xOff;
|
||||||
|
|
||||||
if (draw) {
|
if (draw) {
|
||||||
if (!fflag)
|
int texty;
|
||||||
texty = y + (h - (currfont->ascent + currfont->descent))/2 + currfont->ascent;
|
|
||||||
|
texty = y + (h - (currfont->ascent + currfont->descent))/2 + currfont->ascent;
|
||||||
XftDrawStringUtf8(draw, color, currfont, x, texty, (XftChar8 *)text, len);
|
XftDrawStringUtf8(draw, color, currfont, x, texty, (XftChar8 *)text, len);
|
||||||
x += ext.xOff;
|
x += ext.xOff;
|
||||||
}
|
}
|
||||||
|
@ -1316,6 +1314,6 @@ cleanup(void)
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: xmenu [-fiw] [-p position] [title]\n");
|
(void)fprintf(stderr, "usage: xmenu [-iw] [-p position] [title]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user