File: command.h

package info (click to toggle)
din 5.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,180 kB
  • ctags: 2,511
  • sloc: cpp: 9,369; sh: 6,563; ansic: 2,977; tcl: 1,770; makefile: 283
file content (363 lines) | stat: -rw-r--r-- 9,709 bytes parent folder | download | duplicates (3)
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/*
 * This file is part of din.
 *
 * din is copyright (c) 2006 - 2012 S Jagannathan <jag@dinisnoise.org>
 * For more information, please visit http://dinisnoise.org
 *
 * din is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * din 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 General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with din.  If not, see <http://www.gnu.org/licenses/>.
 *
*/
#ifndef __command
#define __command

#include "help.h"

struct tokenizer;

struct command {

  std::string longname;
  std::string shortname;

  command (const std::string& ln, const std::string& sn) : longname (ln), shortname (sn) {}
  virtual bool operator() (tokenizer& tz) { return true; }
  virtual ~command () {}

};

struct cmdlist {

  std::vector<command*> cmds;
  int ncmds;

  std::string result; // holds last run command output

  static const int size = 2048;
  char buf [size]; // for console printing

  void add (command* cmd);

};

struct din;

struct set_var : command { // set var
  din* d;
  public:
    set_var (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
    bool operator() (tokenizer& tz);
    int set_scroll (std::string& varn, tokenizer& tz);
    int set_zoom_pan (int& rate, float& amount, std::string& varn, tokenizer& tz);
    ~set_var () {}
};

struct get_var : command { // get var
  din* d;
  public:
    get_var (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
    bool operator() (tokenizer& tz);
    ~get_var () {}
};

struct delay;
struct set_delay: command { // set delay time
  delay* left;
  delay* right;
  public:
    set_delay (delay* l, delay* r, const std::string& ln, const std::string& sn) : command (ln, sn), left(l), right(r) {}
    bool operator() (tokenizer& tz);
    ~set_delay () {}
};

struct get_delay: command { // get delay time
  delay* left;
  delay* right;
  public:
    get_delay (delay* l, delay* r, const std::string& ln, const std::string& sn) : command (ln, sn), left(l), right(r) {}
    bool operator() (tokenizer& tz);
    ~get_delay () {}
};

struct beat2value;

// bpm
//
struct bpm_com {
  static const int NUM = 4;
  static const char* str [NUM];
  static beat2value* bv [NUM];
  int getid (const std::string& name);
};

struct ls_bpm: command, bpm_com { // list bpmable components
  ls_bpm (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~ls_bpm () {}
};

struct set_bpm: command, bpm_com {
  set_bpm (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~set_bpm () {}
};

struct get_bpm: command, bpm_com {
  get_bpm (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~get_bpm () {}
};

struct set_style : command, bpm_com {
  set_style (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~set_style () {}
};

struct get_style : command, bpm_com {
  get_style (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~get_style () {}
};

struct set_beat : command, bpm_com {
  set_beat (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~set_beat () {}
};

struct get_beat : command, bpm_com {
  get_beat (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~get_beat () {}
};

struct add_scale: command {
  public:
    add_scale (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator () (tokenizer& tz);
    ~add_scale () {}
};

struct remove_scale : command {
  public:
    remove_scale (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator () (tokenizer& tz);
    ~remove_scale () {}
};

struct ls_scales: command {
  public:
    ls_scales (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator () (tokenizer& tz);
    ~ls_scales () {}
};

struct ls_notes: command {
  public:
    ls_notes (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator () (tokenizer& tz);
    ~ls_notes () {}
};

struct load_scale : command {
  din* d;
  int reentry;
  public:
    load_scale (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
    bool operator () (tokenizer& tz);
    ~load_scale () {}
};

struct key : command {
  din* d;
  public:
    key (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
    bool operator() (tokenizer& tz);
    ~key () {}
    void find_nearest_note (std::string& note, float& frequency, float& dist);
};

struct load_tuning: command {
  din* d;
  public:
    load_tuning (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
    bool operator() (tokenizer& tz);
    ~load_tuning () {}
};

struct notation : command {

  din* d;
  notation (din* dd, const std::string& ln, const std::string& sn) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~notation () {}
};

struct note_distance: command {
  public:
    note_distance (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~note_distance () {}
};

struct chord: command {
  public:
    chord (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~chord () {}
};

struct set_font_size: command {

  public:
    set_font_size (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~set_font_size () {}

};

struct get_font_size: command {

  public:
    get_font_size (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~get_font_size () {}

};

struct set_kern: command {

  public:
    set_kern (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~set_kern () {}

};

struct get_kern: command {

  public:
    get_kern (const std::string& ln, const std::string& sn) : command (ln, sn) {}
    bool operator() (tokenizer& tz);
    ~get_kern () {}

};

struct curve_name : command { // change picked curve name
  curve_name (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~curve_name () {}
};

struct multi_curve;

struct paste_gater: command {
  paste_gater (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~paste_gater () {}
};

struct curve_value : command { // change curve value (vertex, tangent)

  curve_value (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  ~curve_value () {}
  bool operator() (tokenizer& tz);

};

struct curve__library : command { // edit curve library attached to current curve editor
  curve__library (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~curve__library () {}
};

struct set_curve_editor : command {
  set_curve_editor (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~set_curve_editor () {}
};

struct set_scope : command {
  din* d;
  set_scope (const std::string& ln, const std::string& sn, din* dd) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~set_scope () {}
};

struct get_scope : command {
  din* d;
  get_scope (const std::string& ln, const std::string& sn, din* dd) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~get_scope () {}
};

struct echo : command {
  echo (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~echo () {}
};

struct set_text_color: command {
  set_text_color (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~set_text_color () {}
};

struct get_selection : command {
  get_selection (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~get_selection () {}
};

struct set_drone : command {
  din& d;
  set_drone (const std::string& ln, const std::string& sn, din& dd) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~set_drone () {}
};

struct get_drone : command {
  din& d;
  get_drone (const std::string& ln, const std::string& sn, din& dd) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~get_drone () {}
};

struct get_intervals : command {
  get_intervals (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~get_intervals () {}
};

struct num_octaves : command {
  din& d;
  num_octaves (const std::string& ln, const std::string& sn, din& dd) : command (ln, sn), d(dd) {}
  bool operator() (tokenizer& tz);
  ~num_octaves () {}
};

struct quit : command {
  quit (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~quit () {}
};

/*
struct template : command {
  template (const std::string& ln, const std::string& sn) : command (ln, sn) {}
  bool operator() (tokenizer& tz);
  ~template () {}
};*/

#endif