-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdmenu-mode-v30.patch
159 lines (147 loc) · 4.32 KB
/
dmenu-mode-v30.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
158
From 629d09e8070a2e7ed379ddc912a0acc0fc2963a0 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 2c4f4a7..12176e1 100644
--- a/commands.c
+++ b/commands.c
@@ -67,6 +67,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 74e2638..310765a 100644
--- a/commands.h
+++ b/commands.h
@@ -10,6 +10,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);
@@ -53,6 +54,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 1e102fe..f0fca1c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -84,6 +84,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.35.1
From 63adf4ae8c378ae587d5a4bf810387bb0a4ad4fc 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 | 6 +++++-
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/commands.c b/commands.c
index 12176e1..53da4fd 100644
--- a/commands.c
+++ b/commands.c
@@ -185,6 +185,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;
@@ -208,6 +210,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 f148250..2338714 100644
--- a/main.c
+++ b/main.c
@@ -351,6 +351,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 38e1d7b..fa4016b 100644
--- a/nsxiv.h
+++ b/nsxiv.h
@@ -238,6 +238,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 96cf092..1726f48 100644
--- a/options.c
+++ b/options.c
@@ -63,6 +63,7 @@ void parse_options(int argc, char **argv)
progname = progname ? progname + 1 : argv[0];
_options.from_stdin = false;
+ _options.dmenu = false;
_options.to_stdout = false;
_options.using_null = false;
_options.recursive = false;
@@ -86,7 +87,7 @@ void parse_options(int argc, char **argv)
_options.clean_cache = false;
_options.private_mode = false;
- while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:opqrS:s:T:tvZz:0")) != -1) {
+ while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:OopqrS:s:T:tvZz:0")) != -1) {
switch (opt) {
case '?':
print_usage();
@@ -139,6 +140,9 @@ void parse_options(int argc, char **argv)
case 'N':
_options.res_name = optarg;
break;
+ case 'O':
+ _options.dmenu = true;
+ break;
case 'o':
_options.to_stdout = true;
break;
--
2.35.1