forked from speedie/spmenu
Expose caret width, height and add a padding option
This commit is contained in:
parent
894667faec
commit
3bc300d029
|
@ -124,6 +124,11 @@ spmenu.indentitems: 0
|
||||||
spmenu.maxhist: 64
|
spmenu.maxhist: 64
|
||||||
spmenu.histdup: 0
|
spmenu.histdup: 0
|
||||||
|
|
||||||
|
!! Caret
|
||||||
|
spmenu.caretwidth: 0
|
||||||
|
spmenu.caretheight: 0
|
||||||
|
spmenu.caretpadding: 0
|
||||||
|
|
||||||
!! Matches
|
!! Matches
|
||||||
spmenu.type: 1
|
spmenu.type: 1
|
||||||
spmenu.passwd: 0
|
spmenu.passwd: 0
|
||||||
|
|
|
@ -216,6 +216,12 @@ spmenu = {
|
||||||
password = 0; // Don't read standard input and replace all characters with the password character (0/1)
|
password = 0; // Don't read standard input and replace all characters with the password character (0/1)
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
/* Caret options */
|
||||||
|
caret = ( { width = 0; // Caret width (0: Default) (px)
|
||||||
|
height = 0; // Caret height (0: Default) (px)
|
||||||
|
padding = 0; // Caret padding (px)
|
||||||
|
} );
|
||||||
|
|
||||||
/* Output options */
|
/* Output options */
|
||||||
output = ( { printindex = 0; // Print index instead of actual text (0/1)
|
output = ( { printindex = 0; // Print index instead of actual text (0/1)
|
||||||
incremental = 0; // Print text on every keypress (0/1)
|
incremental = 0; // Print text on every keypress (0/1)
|
||||||
|
|
|
@ -454,6 +454,19 @@ void conf_init(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load options spmenu.caret
|
||||||
|
config_setting_t *caret_setting = config_lookup(&cfg, "spmenu.caret");
|
||||||
|
if (caret_setting != NULL && loadconfig) {
|
||||||
|
for (unsigned int i = 0; i < config_setting_length(caret_setting); ++i) {
|
||||||
|
config_setting_t *conf = config_setting_get_elem(caret_setting, i);
|
||||||
|
|
||||||
|
// look up
|
||||||
|
config_setting_lookup_int(conf, "width", &caretwidth); // spmenu.caret.width
|
||||||
|
config_setting_lookup_int(conf, "height", &caretheight); // spmenu.caret.height
|
||||||
|
config_setting_lookup_int(conf, "padding", &caretpadding); // spmenu.caret.padding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load options spmenu.output
|
// load options spmenu.output
|
||||||
config_setting_t *output_setting = config_lookup(&cfg, "spmenu.output");
|
config_setting_t *output_setting = config_lookup(&cfg, "spmenu.output");
|
||||||
if (output_setting != NULL && loadconfig) {
|
if (output_setting != NULL && loadconfig) {
|
||||||
|
|
13
libs/draw.c
13
libs/draw.c
|
@ -375,7 +375,15 @@ int drawprompt(int x, int y, int w) {
|
||||||
int drawinput(int x, int y, int w) {
|
int drawinput(int x, int y, int w) {
|
||||||
char *censort; // censor text (password)
|
char *censort; // censor text (password)
|
||||||
unsigned int curpos = 0;
|
unsigned int curpos = 0;
|
||||||
int fh = drw->font->h;
|
int fh = caretheight;
|
||||||
|
int fw = MAX(2, caretwidth);
|
||||||
|
int fp = caretpadding;
|
||||||
|
|
||||||
|
if (fh > bh) {
|
||||||
|
fh = bh;
|
||||||
|
} else if (!fh) {
|
||||||
|
fh = drw->font->h;
|
||||||
|
}
|
||||||
|
|
||||||
if (passwd) {
|
if (passwd) {
|
||||||
censort = ecalloc(1, sizeof(text));
|
censort = ecalloc(1, sizeof(text));
|
||||||
|
@ -397,7 +405,8 @@ int drawinput(int x, int y, int w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((curpos += lrpad / 2 - 1) < w && !hidecaret && cursorstate) {
|
if ((curpos += lrpad / 2 - 1) < w && !hidecaret && cursorstate) {
|
||||||
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2 + y, 2, fh - 4, 1, 0, col_caretfg, col_caretbg, alpha_caretfg, alpha_caretbg);
|
curpos += fp;
|
||||||
|
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2 + y, fw, fh - 4, 1, 0, col_caretfg, col_caretbg, alpha_caretfg, alpha_caretbg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
|
|
|
@ -25,8 +25,8 @@ static char *bindsfile = NULL; /* Keybind file path. Default is
|
||||||
/* Window options */
|
/* Window options */
|
||||||
static int alpha = 1; /* Enable alpha */
|
static int alpha = 1; /* Enable alpha */
|
||||||
static int menuposition = 2; /* Position of the menu (0: Bottom, 1: Top, 2: Center */
|
static int menuposition = 2; /* Position of the menu (0: Bottom, 1: Top, 2: Center */
|
||||||
static int menupaddingv = 0; /* Vertical padding inside the menu (in pixels) */
|
static int menupaddingv = 0; /* Vertical padding inside the menu (px) */
|
||||||
static int menupaddingh = 0; /* Horizontal padding inside the menu (in pixels) */
|
static int menupaddingh = 0; /* Horizontal padding inside the menu (px) */
|
||||||
static int menuwidth = 0; /* spmenu width */
|
static int menuwidth = 0; /* spmenu width */
|
||||||
static int menumarginv = 0; /* Vertical padding around the menu */
|
static int menumarginv = 0; /* Vertical padding around the menu */
|
||||||
static int menumarginh = 0; /* Horizontal padding around the menu */
|
static int menumarginh = 0; /* Horizontal padding around the menu */
|
||||||
|
@ -103,6 +103,11 @@ static int histdup = 0; /* If 1, record repeated histories *
|
||||||
/* Prompt options */
|
/* Prompt options */
|
||||||
static int indentitems = 0; /* Indent items to prompt width? (0/1) */
|
static int indentitems = 0; /* Indent items to prompt width? (0/1) */
|
||||||
|
|
||||||
|
/* Caret options */
|
||||||
|
static int caretwidth = 0; /* Caret width (0: Calculate automatically) */
|
||||||
|
static int caretheight = 0; /* Caret height (0: Calculate automatically) */
|
||||||
|
static int caretpadding = 0; /* Caret padding (px) */
|
||||||
|
|
||||||
/* Hide options */
|
/* Hide options */
|
||||||
static int hideinput = 0; /* Hide input (0/1) */
|
static int hideinput = 0; /* Hide input (0/1) */
|
||||||
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
||||||
|
|
|
@ -74,6 +74,19 @@ void theme_load(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load options theme.caret
|
||||||
|
config_setting_t *caret_setting = config_lookup(&cfg, "theme.caret");
|
||||||
|
if (caret_setting != NULL && loadconfig) {
|
||||||
|
for (unsigned int i = 0; i < config_setting_length(caret_setting); ++i) {
|
||||||
|
config_setting_t *conf = config_setting_get_elem(caret_setting, i);
|
||||||
|
|
||||||
|
// look up
|
||||||
|
config_setting_lookup_int(conf, "width", &caretwidth); // spmenu.caret.width
|
||||||
|
config_setting_lookup_int(conf, "height", &caretheight); // spmenu.caret.height
|
||||||
|
config_setting_lookup_int(conf, "padding", &caretpadding); // spmenu.caret.padding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load options theme.powerline
|
// load options theme.powerline
|
||||||
config_setting_t *pwl_setting = config_lookup(&cfg, "theme.powerline");
|
config_setting_t *pwl_setting = config_lookup(&cfg, "theme.powerline");
|
||||||
if (pwl_setting != NULL) {
|
if (pwl_setting != NULL) {
|
||||||
|
|
|
@ -110,6 +110,9 @@ ResourcePref resources[] = {
|
||||||
{ "menuposition", INTEGER, &menuposition },
|
{ "menuposition", INTEGER, &menuposition },
|
||||||
{ "xpos", INTEGER, &xpos },
|
{ "xpos", INTEGER, &xpos },
|
||||||
{ "ypos", INTEGER, &ypos },
|
{ "ypos", INTEGER, &ypos },
|
||||||
|
{ "caretpadding", INTEGER, &caretpadding },
|
||||||
|
{ "caretwidth", INTEGER, &caretwidth },
|
||||||
|
{ "caretheight", INTEGER, &caretheight },
|
||||||
{ "menuwidth", INTEGER, &menuwidth },
|
{ "menuwidth", INTEGER, &menuwidth },
|
||||||
{ "menupaddingv", INTEGER, &menupaddingv },
|
{ "menupaddingv", INTEGER, &menupaddingv },
|
||||||
{ "menupaddingh", INTEGER, &menupaddingh },
|
{ "menupaddingh", INTEGER, &menupaddingh },
|
||||||
|
|
Loading…
Reference in a new issue