-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdmenu-mode-v31.patch
158 lines (147 loc) · 4.34 KB
/
dmenu-mode-v31.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From 51b8e387d77f892b01e74fed95ec99ffd2c7fc3e Mon Sep 17 00:00:00 2001
From: NRK <[email protected]>
Date: Fri, 17 Sep 2021 04:03:14 +0600
Subject: [PATCH 1/2] new keybind Shift-Return, print to stdout and exit
---
commands.c | 6 ++++++
commands.h | 2 ++
config.def.h | 1 +
3 files changed, 9 insertions(+)
diff --git a/commands.c b/commands.c
index 1ba0363..1de8ed1 100644
--- a/commands.c
+++ b/commands.c
@@ -82,6 +82,12 @@ bool cg_switch_mode(arg_t _)
return true;
}
+bool cg_pick_quit(arg_t _)
+{
+ printf("%s\n", files[fileidx].name);
+ exit(EXIT_SUCCESS);
+}
+
bool cg_toggle_fullscreen(arg_t _)
{
win_toggle_fullscreen(&win);
diff --git a/commands.h b/commands.h
index 76b1330..4e694f0 100644
--- a/commands.h
+++ b/commands.h
@@ -12,6 +12,7 @@ bool cg_n_or_last(arg_t);
bool cg_navigate_marked(arg_t);
bool cg_prefix_external(arg_t);
bool cg_quit(arg_t);
+bool cg_pick_quit(arg_t);
bool cg_reload_image(arg_t);
bool cg_remove_image(arg_t);
bool cg_reverse_marks(arg_t);
@@ -57,6 +58,7 @@ bool ct_select(arg_t);
#define g_navigate_marked { cg_navigate_marked, MODE_ALL }
#define g_prefix_external { cg_prefix_external, MODE_ALL }
#define g_quit { cg_quit, MODE_ALL }
+#define g_pick_quit { cg_pick_quit, MODE_ALL }
#define g_reload_image { cg_reload_image, MODE_ALL }
#define g_remove_image { cg_remove_image, MODE_ALL }
#define g_reverse_marks { cg_reverse_marks, MODE_ALL }
diff --git a/config.def.h b/config.def.h
index 198c696..2c172f5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -93,6 +93,7 @@ static const keymap_t keys[] = {
/* modifiers key function argument */
{ 0, XK_q, g_quit, 0 },
{ 0, XK_Return, g_switch_mode, None },
+ { ShiftMask, XK_Return, g_pick_quit, None },
{ 0, XK_f, g_toggle_fullscreen, None },
{ 0, XK_b, g_toggle_bar, None },
{ ControlMask, XK_x, g_prefix_external, None },
--
2.38.1
From 093e06fcb731393104cb8ecffe7b1686b427f0d4 Mon Sep 17 00:00:00 2001
From: NRK <[email protected]>
Date: Fri, 17 Sep 2021 04:04:15 +0600
Subject: [PATCH 2/2] new flag -O for dmenu mode
---
commands.c | 4 ++++
main.c | 4 ++++
nsxiv.h | 1 +
options.c | 5 +++++
4 files changed, 14 insertions(+)
diff --git a/commands.c b/commands.c
index 1de8ed1..7912e76 100644
--- a/commands.c
+++ b/commands.c
@@ -180,6 +180,8 @@ bool cg_reverse_marks(arg_t _)
{
int i;
+ if (options->dmenu)
+ return false;
for (i = 0; i < filecnt; i++) {
files[i].flags ^= FF_MARK;
markcnt += files[i].flags & FF_MARK ? 1 : -1;
@@ -203,6 +205,8 @@ bool cg_unmark_all(arg_t _)
{
int i;
+ if (options->dmenu)
+ return false;
for (i = 0; i < filecnt; i++)
files[i].flags &= ~FF_MARK;
markcnt = 0;
diff --git a/main.c b/main.c
index 13d8933..c3c284c 100644
--- a/main.c
+++ b/main.c
@@ -398,6 +398,10 @@ void load_image(int new)
bool mark_image(int n, bool on)
{
markidx = n;
+ if (options->dmenu) {
+ on = true;
+ printf("%s\n", files[n].name);
+ }
if (!!(files[n].flags & FF_MARK) != on) {
files[n].flags ^= FF_MARK;
markcnt += on ? 1 : -1;
diff --git a/nsxiv.h b/nsxiv.h
index 19e5399..73fb2a0 100644
--- a/nsxiv.h
+++ b/nsxiv.h
@@ -230,6 +230,7 @@ struct opt {
/* file list: */
char **filenames;
bool from_stdin;
+ bool dmenu;
bool to_stdout;
bool using_null;
bool recursive;
diff --git a/options.c b/options.c
index ac91c63..8248999 100644
--- a/options.c
+++ b/options.c
@@ -82,6 +82,7 @@ void parse_options(int argc, char **argv)
{ "stdin", 'i', OPTPARSE_NONE },
{ "class", 'N', OPTPARSE_REQUIRED },
{ "start-at", 'n', OPTPARSE_REQUIRED },
+ { NULL, 'O', OPTPARSE_NONE },
{ "stdout", 'o', OPTPARSE_NONE },
{ "private", 'p', OPTPARSE_NONE },
{ "quiet", 'q', OPTPARSE_NONE },
@@ -107,6 +108,7 @@ void parse_options(int argc, char **argv)
options = &_options;
_options.from_stdin = false;
+ _options.dmenu = false;
_options.to_stdout = false;
_options.using_null = false;
_options.recursive = false;
@@ -195,6 +197,9 @@ void parse_options(int argc, char **argv)
case 'N':
_options.res_name = op.optarg;
break;
+ case 'O':
+ _options.dmenu = true;
+ break;
case 'o':
_options.to_stdout = true;
break;
--
2.38.1