aboutsummaryrefslogtreecommitdiff
path: root/package/ncmpc/0002-Global-Bindings-add-KeyBindings-constructor-to-simplify-initializers.patch
blob: 217fa9b55b8003403b890fe4e223e05a6efceaab (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
From da27fcc39e187671b5e4373848f701a3d910446c Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Wed, 26 Sep 2018 09:51:09 +0200
Subject: [PATCH] {Global,}Bindings: add KeyBindings constructor to simplify
 initializers

As a side effect, this works around a build failure with GCC 4.9.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Retrieved from 
https://github.com/MusicPlayerDaemon/ncmpc/commit/da27fcc39e187671b5e4373848f701a3d910446c
and updated for 0.31 (remove NEWS update)]
---
 src/Bindings.hxx       |   3 +
 src/GlobalBindings.cxx | 142 ++++++++++++++++++++---------------------
 3 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/src/Bindings.hxx b/src/Bindings.hxx
index 342d951..0c630dc 100644
--- a/src/Bindings.hxx
+++ b/src/Bindings.hxx
@@ -42,6 +42,9 @@ struct KeyBinding {
 	bool modified = false;
 #endif
 
+	constexpr KeyBinding(int a, int b=0, int c=0) noexcept
+		:keys{{a, b, c}} {}
+
 	gcc_pure
 	bool HasKey(int key) const {
 		return std::find(keys.begin(), keys.end(), key) != keys.end();
diff --git a/src/GlobalBindings.cxx b/src/GlobalBindings.cxx
index b565848..8049ed2 100644
--- a/src/GlobalBindings.cxx
+++ b/src/GlobalBindings.cxx
@@ -51,110 +51,110 @@
 
 static KeyBindings global_key_bindings{{{
 #ifdef ENABLE_KEYDEF_SCREEN
-	{ {'K', 0, 0 } },
+	{'K'},
 #endif
-	{ { 'q', 'Q', C('C') } },
+	{'q', 'Q', C('C')},
 
 	/* movement */
-	{ { UP, 'k', 0 } },
-	{ { DWN, 'j', 0 } },
-	{ { 'H', 0, 0 } },
-	{ { 'M', 0, 0 } },
-	{ { 'L', 0, 0 } },
-	{ { HOME, C('A'), 0 } },
-	{ { END, C('E'), 0 } },
-	{ { PGUP, 0, 0 } },
-	{ { PGDN, 0, 0 } },
-	{ { 'v',  0, 0 } },
-	{ { C('N'),  0, 0 } },
-	{ { C('B'),  0, 0 } },
-	{ { 'N',  0, 0 } },
-	{ { 'B',  0, 0 } },
-	{ { 'l', 0, 0 } },
+	{UP, 'k'},
+	{DWN, 'j'},
+	{'H'},
+	{'M'},
+	{'L'},
+	{HOME, C('A')},
+	{END, C('E')},
+	{PGUP},
+	{PGDN},
+	{'v',  0},
+	{C('N'),  0},
+	{C('B'),  0},
+	{'N',  0},
+	{'B',  0},
+	{'l'},
 
 	/* basic screens */
-	{ { '1', F1, 'h' } },
-	{ { '2', F2, 0 } },
-	{ { '3', F3, 0 } },
+	{'1', F1, 'h'},
+	{'2', F2},
+	{'3', F3},
 
 	/* player commands */
-	{ { RET, 0, 0 } },
-	{ { 'P', 0, 0 } },
-	{ { 's', BS, 0 } },
-	{ { 'o', 0, 0 } },
-	{ { '>', 0, 0 } },
-	{ { '<', 0, 0 } },
-	{ { 'f', 0, 0 } },
-	{ { 'b', 0, 0 } },
-	{ { '+', RGHT, 0 } },
-	{ { '-', LEFT, 0 } },
-	{ { ' ', 0, 0 } },
-	{ { 't', 0, 0 } },
-	{ { DEL, 'd', 0 } },
-	{ { 'Z', 0, 0 } },
-	{ { 'c', 0, 0 } },
-	{ { 'r', 0, 0 } },
-	{ { 'z', 0, 0 } },
-	{ { 'y', 0, 0 } },
-	{ { 'C', 0, 0 } },
-	{ { 'x', 0, 0 } },
-	{ { C('U'), 0, 0 } },
-	{ { 'S', 0, 0 } },
-	{ { 'a', 0, 0 } },
-
-	{ { '!', 0, 0 } },
-	{ { '"', 0, 0 } },
-
-	{ { 'G', 0, 0 } },
+	{RET},
+	{'P'},
+	{'s', BS},
+	{'o'},
+	{'>'},
+	{'<'},
+	{'f'},
+	{'b'},
+	{'+', RGHT},
+	{'-', LEFT},
+	{' '},
+	{'t'},
+	{DEL, 'd'},
+	{'Z'},
+	{'c'},
+	{'r'},
+	{'z'},
+	{'y'},
+	{'C'},
+	{'x'},
+	{C('U')},
+	{'S'},
+	{'a'},
+
+	{'!'},
+	{'"'},
+
+	{'G'},
 
 	/* lists */
-	{ { C('K'), 0, 0 } },
-	{ { C('J'), 0, 0 } },
-	{ { C('L'), 0, 0 } },
+	{C('K')},
+	{C('J')},
+	{C('L')},
 
 
 	/* ncmpc options */
-	{ { 'w', 0, 0 } },
-	{ { 'U', 0, 0 } },
+	{'w'},
+	{'U'},
 
 	/* change screen */
-	{ { TAB, 0, 0 } },
-	{ { STAB, 0, 0 } },
-	{ { '`', 0, 0 } },
+	{TAB},
+	{STAB},
+	{'`'},
 
 
 	/* find */
-	{ { '/', 0, 0 } },
-	{ { 'n', 0, 0 } },
-	{ { '?', 0, 0 } },
-	{ { 'p', 0, 0 } },
-	{ { '.', 0, 0 } },
+	{'/'},
+	{'n'},
+	{'?'},
+	{'p'},
+	{'.'},
 
 
 	/* extra screens */
 #ifdef ENABLE_ARTIST_SCREEN
-	{ {'4', F4, 0 } },
+	{'4', F4},
 #endif
 #ifdef ENABLE_SEARCH_SCREEN
-	{ {'5', F5, 0 } },
-	{ {'m', 0, 0 } },
+	{'5', F5},
+	{'m'},
 #endif
 #ifdef ENABLE_SONG_SCREEN
-	{ { 'i', 0, 0 } },
+	{'i'},
 #endif
 #ifdef ENABLE_LYRICS_SCREEN
-	{ {'7', F7, 0 } },
-	{ {ESC, 0, 0 } },
-	{ {'u', 0, 0 } },
-	{ {'e', 0, 0 } },
+	{'7', F7},
+	{ESC},
+	{'u'},
+	{'e'},
 #endif
 
 #ifdef ENABLE_OUTPUTS_SCREEN
-	{ {'8', F8, 0 } },
+	{'8', F8},
 #endif
 
 #ifdef ENABLE_CHAT_SCREEN
-	{ {'9', F9, 0} },
+	{'9', F9},
 #endif
 }}};