2023-05-14 00:21:16 +02:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveleft(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
struct item *tmpsel;
|
|
|
|
int i, offscreen = 0;
|
2023-03-20 18:05:53 +01:00
|
|
|
int argu = arg->i ? arg->i : 1;
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-03-20 18:05:53 +01:00
|
|
|
if (columns > 1) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (!sel)
|
|
|
|
return;
|
|
|
|
tmpsel = sel;
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
if (!tmpsel->left || tmpsel->left->right != tmpsel) {
|
|
|
|
if (offscreen)
|
|
|
|
drawmenu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (tmpsel == curr)
|
|
|
|
offscreen = 1;
|
|
|
|
tmpsel = tmpsel->left;
|
|
|
|
}
|
|
|
|
sel = tmpsel;
|
|
|
|
if (offscreen) {
|
2023-03-20 18:05:53 +01:00
|
|
|
for (int j = 0; j < argu; j++) {
|
|
|
|
curr = prev;
|
|
|
|
}
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-20 18:05:53 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
drawmenu();
|
2023-03-20 18:05:53 +01:00
|
|
|
calcoffsets();
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-20 18:05:53 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveright(Arg *arg) {
|
2023-03-20 18:05:53 +01:00
|
|
|
struct item *tmpsel;
|
|
|
|
int i, offscreen = 0;
|
|
|
|
int argu = arg->i ? arg->i : 1;
|
|
|
|
|
|
|
|
if (columns > 1) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (!sel)
|
|
|
|
return;
|
|
|
|
tmpsel = sel;
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
if (!tmpsel->right || tmpsel->right->left != tmpsel) {
|
|
|
|
if (offscreen)
|
|
|
|
drawmenu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tmpsel = tmpsel->right;
|
|
|
|
if (tmpsel == next)
|
|
|
|
offscreen = 1;
|
|
|
|
}
|
|
|
|
sel = tmpsel;
|
|
|
|
if (offscreen) {
|
2023-03-20 18:05:53 +01:00
|
|
|
for (int j = 0; j < argu; j++)
|
|
|
|
curr = next;
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
|
|
|
calcoffsets();
|
|
|
|
}
|
2023-03-20 18:05:53 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
drawmenu();
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void movedown(Arg *arg) {
|
2023-03-20 18:05:53 +01:00
|
|
|
int argu = arg->i ? arg->i : 1;
|
|
|
|
|
|
|
|
for (int j = 0; j < argu; j++) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (sel && sel->right && (sel = sel->right) == next) {
|
|
|
|
curr = next;
|
|
|
|
}
|
2023-03-20 16:33:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
calcoffsets();
|
2023-05-08 23:00:45 +02:00
|
|
|
drawmenu();
|
2023-03-20 16:33:23 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveup(Arg *arg) {
|
2023-03-20 18:05:53 +01:00
|
|
|
int argu = arg->i ? arg->i : 1;
|
|
|
|
|
|
|
|
for (int j = 0; j < argu; j++) {
|
|
|
|
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
2023-05-08 23:00:45 +02:00
|
|
|
curr = prev;
|
|
|
|
}
|
2023-03-20 16:33:23 +01:00
|
|
|
}
|
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
calcoffsets();
|
2023-03-20 16:33:23 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void complete(Arg *arg) {
|
2023-04-07 22:54:56 +02:00
|
|
|
if (hideitem) return;
|
2023-05-06 14:29:45 +02:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
strncpy(text, sel->clntext, sizeof text - 1);
|
|
|
|
text[sizeof text - 1] = '\0';
|
|
|
|
cursor = strlen(text);
|
2023-05-06 14:29:45 +02:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
match();
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void movenext(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (!next)
|
|
|
|
return;
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
sel = curr = next;
|
|
|
|
calcoffsets();
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveprev(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
if (!prev)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sel = curr = prev;
|
|
|
|
calcoffsets();
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void movestart(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (sel == matches) {
|
|
|
|
cursor = 0;
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
return;
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
sel = curr = matches;
|
|
|
|
calcoffsets();
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveend(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
if (text[cursor] != '\0') {
|
2023-05-08 23:00:45 +02:00
|
|
|
cursor = strlen(text);
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
return;
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
if (next) {
|
|
|
|
curr = matchend;
|
|
|
|
calcoffsets();
|
|
|
|
curr = prev;
|
|
|
|
calcoffsets();
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
while (next && (curr = curr->right))
|
|
|
|
calcoffsets();
|
|
|
|
}
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
sel = matchend;
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void paste(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
int clipboard;
|
|
|
|
|
|
|
|
if (arg->i == 1) {
|
|
|
|
clipboard = XA_PRIMARY;
|
|
|
|
} else {
|
|
|
|
clipboard = clip;
|
|
|
|
}
|
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
XConvertSelection(dpy, clipboard, utf8, utf8, win, CurrentTime);
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-05-13 17:37:37 +02:00
|
|
|
return;
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void viewhist(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (histfile) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (!backup_items) {
|
|
|
|
backup_items = items;
|
|
|
|
items = calloc(histsz + 1, sizeof(struct item));
|
|
|
|
|
|
|
|
if (!items) {
|
|
|
|
die("spmenu: cannot allocate memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < histsz; i++) {
|
|
|
|
items[i].text = history[i];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
free(items);
|
|
|
|
items = backup_items;
|
|
|
|
backup_items = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match();
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void deleteword(Arg *arg) {
|
2023-03-24 03:14:24 +01:00
|
|
|
if (cursor == 0) return;
|
2023-03-20 12:14:12 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) {
|
2023-03-20 12:14:12 +01:00
|
|
|
insert(NULL, nextrune(-1) - cursor);
|
2023-03-24 03:14:24 +01:00
|
|
|
} while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) {
|
2023-03-20 12:14:12 +01:00
|
|
|
insert(NULL, nextrune(-1) - cursor);
|
2023-03-24 03:14:24 +01:00
|
|
|
}
|
2023-03-20 12:14:12 +01:00
|
|
|
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void moveword(Arg *arg) {
|
2023-03-20 12:14:12 +01:00
|
|
|
if (arg->i < 0) { // move cursor to the start of the word
|
2023-05-08 23:00:45 +02:00
|
|
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) {
|
|
|
|
cursor = nextrune(-1);
|
2023-03-24 03:14:24 +01:00
|
|
|
} while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) {
|
2023-05-08 23:00:45 +02:00
|
|
|
cursor = nextrune(-1);
|
2023-03-24 03:14:24 +01:00
|
|
|
}
|
2023-05-08 23:00:45 +02:00
|
|
|
} else { // move cursor to the end of the word
|
|
|
|
while (text[cursor] && strchr(worddelimiters, text[cursor])) {
|
|
|
|
cursor = nextrune(+1);
|
2023-03-24 03:14:24 +01:00
|
|
|
} while (text[cursor] && !strchr(worddelimiters, text[cursor])) {
|
2023-05-08 23:00:45 +02:00
|
|
|
cursor = nextrune(+1);
|
2023-03-24 03:14:24 +01:00
|
|
|
}
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-20 12:14:12 +01:00
|
|
|
|
2023-03-06 21:03:06 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void movecursor(Arg *arg) {
|
2023-03-24 14:38:28 +01:00
|
|
|
if (arg->i < 0) {
|
2023-05-08 23:00:45 +02:00
|
|
|
if (cursor > 0) {
|
|
|
|
cursor = nextrune(-1);
|
2023-03-24 14:38:28 +01:00
|
|
|
}
|
2023-05-08 23:00:45 +02:00
|
|
|
} else {
|
|
|
|
if (text[cursor]) {
|
|
|
|
cursor = nextrune(+1);
|
2023-03-24 14:38:28 +01:00
|
|
|
}
|
2023-05-08 23:00:45 +02:00
|
|
|
}
|
2023-03-24 14:38:28 +01:00
|
|
|
|
2023-03-20 11:59:04 +01:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void backspace(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
if (cursor == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
insert(NULL, nextrune(-1) - cursor);
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-16 18:54:26 +02:00
|
|
|
void markitem(Arg *arg) {
|
2023-05-19 02:13:13 +02:00
|
|
|
if (!mark) return;
|
2023-05-16 18:54:26 +02:00
|
|
|
if (sel && is_selected(sel->index)) {
|
|
|
|
for (int i = 0; i < sel_size; i++) {
|
|
|
|
if (sel_index[i] == sel->index) {
|
|
|
|
sel_index[i] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < sel_size; i++) {
|
|
|
|
if (sel_index[i] == -1) {
|
|
|
|
sel_index[i] = sel->index;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sel_size++;
|
|
|
|
sel_index = realloc(sel_index, (sel_size + 1) * sizeof(int));
|
|
|
|
sel_index[sel_size - 1] = sel->index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void selectitem(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
char *selection;
|
|
|
|
|
2023-05-06 23:29:41 +02:00
|
|
|
// print index
|
|
|
|
if (printindex && sel && arg->i) {
|
|
|
|
fprintf(stdout, "%d\n", sel->index);
|
|
|
|
cleanup();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// selected item or input?
|
2023-04-07 22:54:56 +02:00
|
|
|
if (sel && arg->i && !hideitem) {
|
2023-03-06 21:03:06 +01:00
|
|
|
selection = sel->text;
|
|
|
|
} else {
|
|
|
|
selection = text;
|
|
|
|
}
|
|
|
|
|
2023-05-16 18:54:26 +02:00
|
|
|
for (int i = 0; i < sel_size; i++) {
|
|
|
|
if (sel_index[i] != -1 && (!sel || sel->index != sel_index[i])) {
|
|
|
|
puts(items[sel_index[i]].text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-06 21:03:06 +01:00
|
|
|
if (!selection)
|
|
|
|
return;
|
|
|
|
|
|
|
|
puts(selection);
|
|
|
|
savehistory(selection);
|
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
cleanup();
|
|
|
|
exit(0);
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void navhistory(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
navigatehistfile(arg->i);
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void restoresel(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
text[cursor] = '\0';
|
|
|
|
match();
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void clear(Arg *arg) {
|
2023-03-06 21:03:06 +01:00
|
|
|
insert(NULL, 0 - cursor);
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void clearins(Arg *arg) {
|
2023-03-26 20:34:41 +02:00
|
|
|
insert(NULL, 0 - cursor);
|
|
|
|
|
|
|
|
curMode = 1;
|
|
|
|
allowkeys = 0;
|
2023-04-29 22:53:00 +02:00
|
|
|
strncpy(modetext, instext, 15);
|
2023-03-26 20:34:41 +02:00
|
|
|
|
2023-04-21 09:49:38 +02:00
|
|
|
calcoffsets();
|
2023-03-26 20:34:41 +02:00
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void quit(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
cleanup();
|
|
|
|
exit(0);
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void savehistory(char *input) {
|
2023-05-08 23:00:45 +02:00
|
|
|
unsigned int i;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if (!histfile ||
|
|
|
|
0 == maxhist ||
|
|
|
|
0 == strlen(input)) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp = fopen(histfile, "w");
|
|
|
|
if (!fp) {
|
|
|
|
die("spmenu: failed to open %s", histfile);
|
|
|
|
}
|
|
|
|
for (i = histsz < maxhist ? 0 : histsz - maxhist; i < histsz; i++) {
|
|
|
|
if (0 >= fprintf(fp, "%s\n", history[i])) {
|
|
|
|
die("spmenu: failed to write to %s", histfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (histsz == 0 || histdup || (histsz > 0 && strcmp(input, history[histsz-1]) != 0)) {
|
|
|
|
if (0 >= fputs(input, fp)) {
|
|
|
|
die("spmenu: failed to write to %s", histfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fclose(fp)) {
|
|
|
|
die("spmenu: failed to close file %s", histfile);
|
|
|
|
}
|
2023-03-06 21:03:06 +01:00
|
|
|
|
|
|
|
out:
|
2023-05-08 23:00:45 +02:00
|
|
|
for (i = 0; i < histsz; i++) {
|
|
|
|
free(history[i]);
|
|
|
|
}
|
|
|
|
free(history);
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setimgsize(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-08 17:50:58 +01:00
|
|
|
setimagesize(imagewidth + arg->i, imageheight + arg->i);
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void flipimg(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-06 21:03:06 +01:00
|
|
|
|
|
|
|
if (!image) return;
|
|
|
|
|
|
|
|
flip = flip ? 0 : arg->i ? 1 : 2;
|
|
|
|
|
|
|
|
drawmenu();
|
2023-03-08 21:12:37 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setimgpos(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-08 20:18:03 +01:00
|
|
|
if (!image || hideimage) return;
|
|
|
|
|
2023-03-08 20:13:39 +01:00
|
|
|
if (imageposition < 3) {
|
|
|
|
imageposition += arg->i;
|
2023-03-08 19:41:59 +01:00
|
|
|
} else {
|
2023-03-08 20:13:39 +01:00
|
|
|
imageposition = 0;
|
2023-03-08 19:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
drawmenu();
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-08 19:41:59 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setimggaps(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-08 20:13:39 +01:00
|
|
|
imagegaps += arg->i;
|
|
|
|
|
2023-03-08 20:18:03 +01:00
|
|
|
if (!image || hideimage) return;
|
|
|
|
|
2023-03-08 20:13:39 +01:00
|
|
|
if (imagegaps < 0)
|
|
|
|
imagegaps = 0;
|
|
|
|
|
2023-03-16 16:54:36 +01:00
|
|
|
// limitation to make sure we have a reasonable gap size
|
2023-03-08 20:13:39 +01:00
|
|
|
if (imagegaps > imagewidth / 2)
|
|
|
|
imagegaps -= arg->i;
|
|
|
|
|
|
|
|
drawmenu();
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-08 20:13:39 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void rotateimg(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-03-08 20:18:03 +01:00
|
|
|
if (!image || hideimage) return;
|
2023-03-06 21:03:06 +01:00
|
|
|
|
2023-03-08 19:46:33 +01:00
|
|
|
rotation += arg->i ? arg->i : 1;
|
2023-03-06 21:03:06 +01:00
|
|
|
|
|
|
|
drawmenu();
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void toggleimg(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-06 21:03:06 +01:00
|
|
|
|
|
|
|
hideimage = !hideimage;
|
|
|
|
|
|
|
|
drawmenu();
|
2023-03-08 21:12:37 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
|
|
|
|
2023-05-14 00:10:24 +02:00
|
|
|
void togglefullimg(Arg *arg) {
|
|
|
|
#if USEIMAGE
|
|
|
|
fullscreen = image ? !fullscreen : 0;
|
|
|
|
|
|
|
|
if (fullscreen) {
|
|
|
|
ow = imagewidth;
|
|
|
|
oh = imageheight;
|
|
|
|
|
|
|
|
imagewidth = mw;
|
|
|
|
imageheight = mh;
|
|
|
|
} else {
|
|
|
|
imagewidth = ow;
|
|
|
|
imageheight = oh;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawmenu();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void defaultimg(Arg *arg) {
|
2023-05-08 23:00:45 +02:00
|
|
|
#if USEIMAGE
|
2023-03-06 21:03:06 +01:00
|
|
|
|
|
|
|
if (hideimage || !image) return;
|
|
|
|
|
|
|
|
if (imagew) {
|
|
|
|
imagewidth = imagew;
|
|
|
|
imageheight = imageh;
|
|
|
|
imagegaps = imageg;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawmenu();
|
2023-05-08 23:00:45 +02:00
|
|
|
#endif
|
2023-03-06 21:03:06 +01:00
|
|
|
}
|
2023-03-13 22:45:04 +01:00
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setlines(Arg *arg) {
|
2023-05-14 00:10:24 +02:00
|
|
|
if (fullscreen) return;
|
2023-05-16 21:04:32 +02:00
|
|
|
|
2023-03-13 22:45:04 +01:00
|
|
|
lines += arg->i;
|
|
|
|
|
2023-05-16 21:04:32 +02:00
|
|
|
if (lines < 0) {
|
|
|
|
lines = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lines == 0) {
|
|
|
|
match();
|
|
|
|
}
|
|
|
|
|
2023-03-13 22:45:04 +01:00
|
|
|
resizeclient();
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setcolumns(Arg *arg) {
|
2023-05-14 00:10:24 +02:00
|
|
|
if (fullscreen) return;
|
2023-05-16 21:04:32 +02:00
|
|
|
|
2023-03-13 22:45:04 +01:00
|
|
|
columns += arg->i;
|
|
|
|
|
2023-05-16 21:04:32 +02:00
|
|
|
if (columns < 1) {
|
|
|
|
columns = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lines == 0) {
|
|
|
|
match();
|
|
|
|
}
|
|
|
|
|
2023-03-13 22:45:04 +01:00
|
|
|
resizeclient();
|
|
|
|
drawmenu();
|
|
|
|
}
|
2023-03-29 23:45:54 +02:00
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void spawn(Arg *arg) {
|
2023-04-23 20:08:34 +02:00
|
|
|
if (!system(arg->c))
|
|
|
|
die("spmenu: failed to execute command '%s'", arg->c);
|
|
|
|
else
|
|
|
|
exit(0);
|
2023-04-21 09:49:38 +02:00
|
|
|
}
|
2023-04-21 12:10:02 +02:00
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void togglehighlight(Arg *arg) {
|
2023-04-21 12:10:02 +02:00
|
|
|
hidehighlight = !hidehighlight;
|
|
|
|
drawmenu();
|
|
|
|
}
|
2023-04-26 10:01:11 +02:00
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
void setprofile(Arg *arg) {
|
|
|
|
if (!system("command -v spmenu_profile > /dev/null && spmenu_profile --spmenu-set-profile")) {
|
2023-04-26 10:01:11 +02:00
|
|
|
die("spmenu: failed to run profile menu\n");
|
2023-05-06 14:29:45 +02:00
|
|
|
} else {
|
2023-04-26 10:01:11 +02:00
|
|
|
exit(0);
|
2023-05-06 14:29:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void switchmode(Arg *arg) {
|
|
|
|
curMode = !curMode;
|
2023-05-07 15:38:51 +02:00
|
|
|
|
|
|
|
if (!type) curMode = 0; // only normal mode allowed
|
|
|
|
|
2023-05-06 14:29:45 +02:00
|
|
|
allowkeys = !curMode;
|
|
|
|
|
|
|
|
strncpy(modetext, curMode ? instext : normtext, 15);
|
|
|
|
drawmenu();
|
2023-04-26 10:01:11 +02:00
|
|
|
}
|