forked from speedie/spmenu
powerline the prompt
TODO: powerline numbers and match count
This commit is contained in:
parent
b1f1afe192
commit
dc51707520
|
@ -157,6 +157,9 @@ You may use long, descriptive arguments or the shorter arguments.
|
||||||
`-hpr, --hide-prompt `
|
`-hpr, --hide-prompt `
|
||||||
: Hide prompt
|
: Hide prompt
|
||||||
|
|
||||||
|
`-hpl, --hide-powerline `
|
||||||
|
: Hide powerline
|
||||||
|
|
||||||
`-hc, --hide-cursor `
|
`-hc, --hide-cursor `
|
||||||
: Hide cursor
|
: Hide cursor
|
||||||
|
|
||||||
|
@ -181,6 +184,9 @@ You may use long, descriptive arguments or the shorter arguments.
|
||||||
`-spr, --show-prompt `
|
`-spr, --show-prompt `
|
||||||
: Show prompt
|
: Show prompt
|
||||||
|
|
||||||
|
`-spl, --show-powerline `
|
||||||
|
: Show powerline
|
||||||
|
|
||||||
`-sc, --show-cursor `
|
`-sc, --show-cursor `
|
||||||
: Show cursor
|
: Show cursor
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ spmenu.accuratewidth: 1
|
||||||
spmenu.borderwidth: 0
|
spmenu.borderwidth: 0
|
||||||
|
|
||||||
!! Lines and columns
|
!! Lines and columns
|
||||||
spmenu.lineheight: 5
|
spmenu.lineheight: 1
|
||||||
spmenu.lines: 0
|
spmenu.lines: 0
|
||||||
spmenu.columns: 10
|
spmenu.columns: 10
|
||||||
spmenu.preselected: 0
|
spmenu.preselected: 0
|
||||||
|
@ -103,6 +103,7 @@ spmenu.hidemode: 0
|
||||||
spmenu.hidelarrow: 0
|
spmenu.hidelarrow: 0
|
||||||
spmenu.hiderarrow: 0
|
spmenu.hiderarrow: 0
|
||||||
spmenu.hideprompt: 0
|
spmenu.hideprompt: 0
|
||||||
|
spmenu.hidepowerline: 0
|
||||||
spmenu.hidecursor: 0
|
spmenu.hidecursor: 0
|
||||||
spmenu.hidehighlight: 0
|
spmenu.hidehighlight: 0
|
||||||
spmenu.hideimage: 0
|
spmenu.hideimage: 0
|
||||||
|
|
|
@ -112,8 +112,12 @@ readargs(int argc, char *argv[])
|
||||||
hiderarrow = 0;
|
hiderarrow = 0;
|
||||||
} else if (!strcmp(argv[i], "-hpr") || (!strcmp(argv[i], "--hide-prompt"))) { // hide prompt
|
} else if (!strcmp(argv[i], "-hpr") || (!strcmp(argv[i], "--hide-prompt"))) { // hide prompt
|
||||||
hideprompt = 1;
|
hideprompt = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-hpl") || (!strcmp(argv[i], "--hide-powerline"))) { // hide powerline
|
||||||
|
hidepowerline = 1;
|
||||||
} else if (!strcmp(argv[i], "-spr") || (!strcmp(argv[i], "--show-prompt"))) { // show prompt
|
} else if (!strcmp(argv[i], "-spr") || (!strcmp(argv[i], "--show-prompt"))) { // show prompt
|
||||||
hideprompt = 0;
|
hideprompt = 0;
|
||||||
|
} else if (!strcmp(argv[i], "-spl") || (!strcmp(argv[i], "--show-powerline"))) { // show prompt
|
||||||
|
hidepowerline = 0;
|
||||||
} else if (!strcmp(argv[i], "-hc") || (!strcmp(argv[i], "--hide-cursor"))) { // hide cursor
|
} else if (!strcmp(argv[i], "-hc") || (!strcmp(argv[i], "--hide-cursor"))) { // hide cursor
|
||||||
hidecursor = 1;
|
hidecursor = 1;
|
||||||
} else if (!strcmp(argv[i], "-sc") || (!strcmp(argv[i], "--show-cursor"))) { // show cursor
|
} else if (!strcmp(argv[i], "-sc") || (!strcmp(argv[i], "--show-cursor"))) { // show cursor
|
||||||
|
@ -379,6 +383,7 @@ usage(void)
|
||||||
"spmenu -hla, --hide-left-arrow Hide left arrow\n"
|
"spmenu -hla, --hide-left-arrow Hide left arrow\n"
|
||||||
"spmenu -hra, --hide-right-arrow Hide right arrow\n"
|
"spmenu -hra, --hide-right-arrow Hide right arrow\n"
|
||||||
"spmenu -hpr, --hide-prompt Hide prompt\n"
|
"spmenu -hpr, --hide-prompt Hide prompt\n"
|
||||||
|
"spmenu -hpl, --hide-powerline Hide powerline\n"
|
||||||
"spmenu -hc, --hide-cursor Hide cursor\n"
|
"spmenu -hc, --hide-cursor Hide cursor\n"
|
||||||
"spmenu -hhl, --hide-highlighting Hide highlight\n"
|
"spmenu -hhl, --hide-highlighting Hide highlight\n"
|
||||||
"spmenu -hi, --hide-image Hide image\n"
|
"spmenu -hi, --hide-image Hide image\n"
|
||||||
|
|
14
libs/draw.c
14
libs/draw.c
|
@ -153,10 +153,13 @@ drawmenu(void)
|
||||||
struct item *item;
|
struct item *item;
|
||||||
int x = 0, y = 0, fh = drw->font->h, w;
|
int x = 0, y = 0, fh = drw->font->h, w;
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
int ox = 0;
|
int ox = 0; // original x position
|
||||||
#endif
|
#endif
|
||||||
char *censort;
|
char *censort; // censor text (password)
|
||||||
|
plw = hidepowerline ? 0 : drw->font->h / 2 + 1; // powerline size
|
||||||
|
Clr *prevscheme, *nextscheme;
|
||||||
|
|
||||||
|
// draw menu first using menu scheme
|
||||||
drw_setscheme(drw, scheme[SchemeMenu]);
|
drw_setscheme(drw, scheme[SchemeMenu]);
|
||||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
|
||||||
|
@ -165,17 +168,24 @@ drawmenu(void)
|
||||||
int larrowWidth = 0;
|
int larrowWidth = 0;
|
||||||
int rarrowWidth = 0;
|
int rarrowWidth = 0;
|
||||||
|
|
||||||
|
// add width
|
||||||
if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||||
if (!hidelarrow) larrowWidth = pango_leftarrow ? TEXTWM(leftarrow) : TEXTW(leftarrow);
|
if (!hidelarrow) larrowWidth = pango_leftarrow ? TEXTWM(leftarrow) : TEXTW(leftarrow);
|
||||||
if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow);
|
if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow);
|
||||||
|
|
||||||
if (prompt && *prompt) {
|
if (prompt && *prompt) {
|
||||||
|
prevscheme = scheme[SchemePrompt];
|
||||||
drw_setscheme(drw, scheme[SchemePrompt]);
|
drw_setscheme(drw, scheme[SchemePrompt]);
|
||||||
|
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
ox = x;
|
ox = x;
|
||||||
#endif
|
#endif
|
||||||
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False);
|
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0, pango_prompt ? True : False);
|
||||||
|
|
||||||
|
drw_settrans(drw, scheme[SchemePrompt], scheme[SchemeMenu]);
|
||||||
|
drw_arrow(drw, x, 0, plw, bh, 1, 0);
|
||||||
|
|
||||||
|
x += plw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw input
|
// draw input
|
||||||
|
|
|
@ -4,6 +4,11 @@ buttonpress(XEvent *e)
|
||||||
struct item *item;
|
struct item *item;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
int x = 0, y = 0, h = bh, w, item_num = 0;
|
int x = 0, y = 0, h = bh, w, item_num = 0;
|
||||||
|
int xpad = 0;
|
||||||
|
|
||||||
|
if (!hidepowerline) {
|
||||||
|
x = xpad = plw;
|
||||||
|
}
|
||||||
|
|
||||||
// if incorrect or wrong window, return
|
// if incorrect or wrong window, return
|
||||||
if (ev->window != win)
|
if (ev->window != win)
|
||||||
|
@ -14,7 +19,7 @@ buttonpress(XEvent *e)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
if (prompt && *prompt)
|
if (prompt && *prompt)
|
||||||
x += promptw;
|
x += promptw + plw;
|
||||||
|
|
||||||
// input field
|
// input field
|
||||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
Clr transcheme[3];
|
||||||
|
|
||||||
Drw *
|
Drw *
|
||||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +155,44 @@ drw_setscheme(Drw *drw, Clr *scm)
|
||||||
drw->scheme = scm;
|
drw->scheme = scm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
|
||||||
|
{
|
||||||
|
if (drw) {
|
||||||
|
transcheme[0] = psc[ColBg]; transcheme[1] = nsc[ColBg]; transcheme[2] = psc[ColPwl];
|
||||||
|
drw->scheme = transcheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->scheme)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x = direction ? x : x + w;
|
||||||
|
w = direction ? w : -w;
|
||||||
|
unsigned int hh = slash ? (direction ? 0 : h) : h/2;
|
||||||
|
|
||||||
|
XPoint points[] = {
|
||||||
|
{x , y },
|
||||||
|
{x + w, y + hh },
|
||||||
|
{x , y + h },
|
||||||
|
};
|
||||||
|
|
||||||
|
XPoint bg[] = {
|
||||||
|
{x , y },
|
||||||
|
{x + w, y },
|
||||||
|
{x + w, y + h},
|
||||||
|
{x , y + h},
|
||||||
|
};
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillPolygon(drw->dpy, drw->drawable, drw->gc, bg, 4, Convex, CoordModeOrigin);
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
|
||||||
|
XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ typedef struct Fnt {
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
} Fnt;
|
} Fnt;
|
||||||
|
|
||||||
enum { ColFg, ColBg }; /* Clr scheme index */
|
enum { ColFg, ColBg, ColPwl }; /* Clr scheme index */
|
||||||
typedef XftColor Clr;
|
typedef XftColor Clr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -55,3 +55,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
|
||||||
|
|
||||||
/* Map functions */
|
/* Map functions */
|
||||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||||
|
|
||||||
|
/* Powerline functions */
|
||||||
|
void drw_settrans(Drw *drw, Clr *psc, Clr *nsc);
|
||||||
|
void drw_arrow(Drw* drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash);
|
||||||
|
|
|
@ -16,6 +16,8 @@ static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}
|
||||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||||
|
|
||||||
|
Clr transcheme[3];
|
||||||
|
|
||||||
static long
|
static long
|
||||||
utf8decodebyte(const char c, size_t *i)
|
utf8decodebyte(const char c, size_t *i)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +229,44 @@ drw_setscheme(Drw *drw, Clr *scm)
|
||||||
drw->scheme = scm;
|
drw->scheme = scm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
|
||||||
|
{
|
||||||
|
if (drw) {
|
||||||
|
transcheme[0] = psc[ColBg]; transcheme[1] = nsc[ColBg]; transcheme[2] = psc[ColPwl];
|
||||||
|
drw->scheme = transcheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->scheme)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x = direction ? x : x + w;
|
||||||
|
w = direction ? w : -w;
|
||||||
|
unsigned int hh = slash ? (direction ? 0 : h) : h/2;
|
||||||
|
|
||||||
|
XPoint points[] = {
|
||||||
|
{x , y },
|
||||||
|
{x + w, y + hh },
|
||||||
|
{x , y + h },
|
||||||
|
};
|
||||||
|
|
||||||
|
XPoint bg[] = {
|
||||||
|
{x , y },
|
||||||
|
{x + w, y },
|
||||||
|
{x + w, y + h},
|
||||||
|
{x , y + h},
|
||||||
|
};
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||||
|
XFillPolygon(drw->dpy, drw->drawable, drw->gc, bg, 4, Convex, CoordModeOrigin);
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
|
||||||
|
XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||||
{
|
{
|
||||||
|
@ -422,3 +462,4 @@ drw_cur_free(Drw *drw, Cur *cursor)
|
||||||
XFreeCursor(drw->dpy, cursor->cursor);
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
free(cursor);
|
free(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ typedef struct Fnt {
|
||||||
struct Fnt *next;
|
struct Fnt *next;
|
||||||
} Fnt;
|
} Fnt;
|
||||||
|
|
||||||
enum { ColFg, ColBg }; /* Clr scheme index */
|
enum { ColFg, ColBg, ColPwl }; /* Clr scheme index */
|
||||||
typedef XftColor Clr;
|
typedef XftColor Clr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -58,3 +58,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
|
||||||
|
|
||||||
/* Map functions */
|
/* Map functions */
|
||||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||||
|
|
||||||
|
/* Powerline functions */
|
||||||
|
void drw_settrans(Drw *drw, Clr *psc, Clr *nsc);
|
||||||
|
void drw_arrow(Drw* drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash);
|
||||||
|
|
|
@ -120,6 +120,7 @@ ResourcePref resources[] = {
|
||||||
{ "hidelarrow", INTEGER, &hidelarrow },
|
{ "hidelarrow", INTEGER, &hidelarrow },
|
||||||
{ "hiderarrow", INTEGER, &hiderarrow },
|
{ "hiderarrow", INTEGER, &hiderarrow },
|
||||||
{ "hideprompt", INTEGER, &hideprompt },
|
{ "hideprompt", INTEGER, &hideprompt },
|
||||||
|
{ "hidepowerline", INTEGER, &hidepowerline },
|
||||||
{ "hidecursor", INTEGER, &hidecursor },
|
{ "hidecursor", INTEGER, &hidecursor },
|
||||||
{ "histnodup", INTEGER, &histnodup },
|
{ "histnodup", INTEGER, &histnodup },
|
||||||
{ "casesensitive", INTEGER, &casesensitive },
|
{ "casesensitive", INTEGER, &casesensitive },
|
||||||
|
|
|
@ -50,7 +50,7 @@ static int accuratewidth = 1; /* Enable accurate width. May have a
|
||||||
static int fuzzy = 1; /* Whether or not to enable fuzzy matching by default */
|
static int fuzzy = 1; /* Whether or not to enable fuzzy matching by default */
|
||||||
|
|
||||||
/* Line options */
|
/* Line options */
|
||||||
static int lineheight = 5; /* Line height (0: Calculate automatically) */
|
static int lineheight = 1; /* Line height (0: Calculate automatically) */
|
||||||
static int lines = 0; /* Default number of lines */
|
static int lines = 0; /* Default number of lines */
|
||||||
static int columns = 10; /* Default number of columns */
|
static int columns = 10; /* Default number of columns */
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ static unsigned int maxhist = 64; /* Max number of history entries */
|
||||||
static int histnodup = 1; /* If 0, record repeated histories */
|
static int histnodup = 1; /* If 0, record repeated histories */
|
||||||
|
|
||||||
/* Prompt options */
|
/* Prompt options */
|
||||||
|
static int promptheight = 10; /* Extra prompt height */
|
||||||
static int indentitems = 1; /* Indent items to prompt width? (0/1) */
|
static int indentitems = 1; /* Indent items to prompt width? (0/1) */
|
||||||
static char *prompt = NULL; /* Default prompt, set to NULL (nothing) */
|
static char *prompt = NULL; /* Default prompt, set to NULL (nothing) */
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ static int hidemode = 0; /* Hide mode (0/1) */
|
||||||
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
||||||
static int hiderarrow = 0; /* Hide right arrow (0/1) */
|
static int hiderarrow = 0; /* Hide right arrow (0/1) */
|
||||||
static int hideprompt = 0; /* Hide prompt (0/1) */
|
static int hideprompt = 0; /* Hide prompt (0/1) */
|
||||||
|
static int hidepowerline = 0; /* Hide powerline (0/1) */
|
||||||
static int hidecursor = 0; /* Hide cursor (0/1) */
|
static int hidecursor = 0; /* Hide cursor (0/1) */
|
||||||
static int hidehighlight = 0; /* Hide highlight (0/1) */
|
static int hidehighlight = 0; /* Hide highlight (0/1) */
|
||||||
static int hideimage = 0; /* Hide image (0/1) */
|
static int hideimage = 0; /* Hide image (0/1) */
|
||||||
|
|
1
spmenu.c
1
spmenu.c
|
@ -123,6 +123,7 @@ static int dmy = 0; // put spmenu at this y offset (measured from the bottom if
|
||||||
static unsigned int dmw = 0; // make spmenu this wide
|
static unsigned int dmw = 0; // make spmenu this wide
|
||||||
static int inputw = 0;
|
static int inputw = 0;
|
||||||
static int promptw;
|
static int promptw;
|
||||||
|
static int plw = 0;
|
||||||
static int passwd = 0;
|
static int passwd = 0;
|
||||||
static int lrpad; // sum of left and right padding
|
static int lrpad; // sum of left and right padding
|
||||||
static int vp; // vertical padding for bar
|
static int vp; // vertical padding for bar
|
||||||
|
|
Loading…
Reference in a new issue