File: Shortcuts.h

package info (click to toggle)
lsp-plugins 1.2.21-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120,408 kB
  • sloc: cpp: 589,849; xml: 74,078; makefile: 13,396; php: 1,268; sh: 185
file content (287 lines) | stat: -rw-r--r-- 12,015 bytes parent folder | download
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*
 * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-plugins-referencer
 * Created on: 29 нояб. 2024 г.
 *
 * lsp-plugins-referencer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-plugins-referencer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-plugins-referencer. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_TK_UTIL_SHORTCUTS_H_
#define LSP_PLUG_IN_TK_UTIL_SHORTCUTS_H_

#ifndef LSP_PLUG_IN_TK_IMPL
    #error "use <lsp-plug.in/tk/tk.h>"
#endif

#include <lsp-plug.in/tk/prop/multi/Shortcut.h>

namespace lsp
{
    namespace tk
    {
        /**
         * Class that contains shortctucs, tracks events and executes shortcut handlers
         */
        class Shortcuts
        {
            protected:
                tk::prop::Listener         *pListener;
                lltl::parray<Shortcut>      vLinks;

            public:
                explicit Shortcuts(tk::prop::Listener *listener = NULL);
                Shortcuts(const Shortcuts &) = delete;
                Shortcuts(Shortcuts &&) = delete;
                virtual ~Shortcuts();

                Shortcuts(const Shortcut &) = delete;
                Shortcuts(Shortcut &&) = delete;

            public:
                /**
                 * Get number of elements
                 * @return number of elements
                 */
                size_t          size() const;

                /**
                 * Append one new shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *append();

                /**
                 * Append one new shotcut link
                 * @param scut shortcut combination to use
                 * @return new shortcut link or null on error
                 */
                Shortcut       *append(const Shortcut *scut);

                /**
                 * Append one new shortcut link
                 * @param scut shortcut combination to use
                 * @return new shortcut link or null on error
                 */
                Shortcut       *append(const Shortcut &scut);

                /**
                 * Append one new shortcut link
                 * @param key key code
                 * @param mod key modifiers
                 * @return new shortcut link or null on error
                 */
                Shortcut       *append(ws::code_t key, size_t mod);

                /**
                 * Prepend one new shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *prepend();

                /**
                 * Prepend one new shortcut link
                 * @param scut shortcut combination to use
                 * @return new shortcut link or null on error
                 */
                Shortcut       *prepend(const Shortcut *scut);

                /**
                 * Prepend one new shortcut link
                 * @param scut shortcut combination to use
                 * @return new shortcut link or null on error
                 */
                Shortcut       *prepend(const Shortcut &scut);

                /**
                 * Prepend one new shortcut link
                 * @param key key code
                 * @param mod key modifiers
                 * @return new shortcut link or null on error
                 */
                Shortcut       *prepend(ws::code_t key, size_t mod);

                /**
                 * Add one new shortcut link at the specified index
                 * @param index to add shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *insert(size_t index);

                /**
                 * Add one new shortcut link at the specified index
                 * @param scut shortcut combination to use
                 * @param index to add shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *insert(const Shortcut *scut, size_t index);

                /**
                 * Add one new shortcut link at the specified index
                 * @param scut shortcut combination to use
                 * @param index to add shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *insert(const Shortcut &scut, size_t index);

                /**
                 * Insert one new shortcut link
                 * @param key key code
                 * @param mod key modifiers
                 * @param index to add shortcut link
                 * @return new shortcut link or null on error
                 */
                Shortcut       *insert(ws::code_t key, size_t mod, size_t index);

                /**
                 * Get shortcut link at the specified position
                 * @param index index of the element
                 * @return shortcut link at the specified position
                 */
                Shortcut       *get(size_t index);

                /**
                 * Remove shotcut link at the specified position
                 * @param index index of item to remove
                 * @return true if item has been removed
                 */
                bool            remove(size_t index);

                /**
                 * Remove shotcut link that has exact key combination
                 * @param index index of item to remove
                 * @return true if item has been removed
                 */
                bool            remove(const Shortcut * scut);

                /**
                 * Remove shotcut link that has exact key combination
                 * @param index index of item to remove
                 * @return true if item has been removed
                 */
                bool            remove(const Shortcut & scut);

                /**
                 * Remove all shortcuts that are same to the specified one
                 * @param scut the shortcut to look for
                 * @return number of removed items
                 */
                size_t          remove_all(const Shortcut * scut);

                /**
                 * Remove all shortcuts that are same to the specified one
                 * @param scut the shortcut to look for
                 * @return number of removed items
                 */
                size_t          remove_all(const Shortcut & scut);

                /**
                 * Remove shotcut instance from the list
                 * @param item pointer to the shotcut link to remove
                 * @return true if item has been removed
                 */
                bool            premove(Shortcut *item);

                /**
                 * Get the index of the spcified shortcut link instance
                 * @param item item tho check
                 * @return true if list contains the specified shotcut link
                 */
                ssize_t         index_of_instance(const Shortcut *item) const;

                /**
                 * Check whether list contains the specific shortcut instance
                 * @param shortcut shortcut to search
                 * @return true if shortcut contains the specific shortctut
                 */
                bool            contains_instance(const Shortcut *shortcut) const;

                /**
                 * Check if list contains the specified shortcut
                 * @param item item tho check
                 * @return true if list contains the specified shotcut link
                 */
                bool            contains(const Shortcut *item) const;

                /**
                 * Find first matching handler for the shortcut and return the handling slot.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return pointer to the handling slot or null if not found.
                 */
                Slot           *handler_of(const Shortcut *shortcut, size_t first=0);

                /**
                 * Find first handler for the shortcut and return the handling slot.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return pointer to the handling slot or null if not found.
                 */
                Slot           *handler_match(const Shortcut *shortcut, size_t first=0);

                /**
                 * Find first handler with the same shortcut and return the index of the record.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return index of the first occurrence or negative value if not found.
                 */
                ssize_t         index_of(const Shortcut *shortcut, size_t first=0) const;

                /**
                 * Find first handler with the same shortcut and return the index of the record.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return index of the first occurrence or negative value if not found.
                 */
                ssize_t         index_of(const Shortcut & shortcut, size_t first=0) const;

                /**
                 * Find first matching handler for the shortcut and return the index of the record.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return index of the first occurrence or negative value if not found.
                 */
                ssize_t         index_match(const Shortcut *shortcut, size_t first=0) const;

                /**
                 * Find first matching handler for the shortcut and return the index of the record.
                 * Note that there can be multiple shortcuts, so use the 'first' parameter to
                 * look for next elements.
                 * @param shortcut shortcut to test
                 * @param first the index to start searching from
                 * @return index of the first occurrence or negative value if not found.
                 */
                ssize_t         index_match(const Shortcut & shortcut, size_t first=0) const;

                /**
                 * Remove all shortcut links
                 */
                void            clear();

        };
    } /* namespace tk */
} /* namespace lsp */

#endif /* MODULES_LSP_TK_LIB_INCLUDE_LSP_PLUG_IN_TK_UTIL_SHORTCUTS_H_ */