1 /* keyresponses.c
2  * for Denemo, a gtk+ frontend to GNU Lilypond
3  * (c) 1999-2005 Matthew Hiller
4  */
5 
6 #include <string.h>
7 #include "core/kbd-custom.h"
8 #include "command/keyresponses.h"
9 #include "core/utils.h"
10 #include "command/tuplet.h"
11 #include "core/view.h"
12 #include "command/commandfuncs.h"
13 #include "core/kbd-custom.h"
14 #include "audio/audiointerface.h"
15 #if GTK_MAJOR_VERSION==3
16 #include <gdk/gdkkeysyms-compat.h>      //FIXME Look for something more gtk3 like
17 #endif
18 static GdkEventKey **divert_key_event;  /* Non null if key events are being intercepted by a function
19                                          * (which is running a gtk_mail_loop() for this reason).
20                                          * return TRUE if a key press successfully captured
21                                          * in which case the kyval, state pair are returned
22                                          */
23 
24 static gint divert_key_id = 0;
25 gboolean
intercept_scorearea_keypress(GdkEventKey * pevent)26 intercept_scorearea_keypress (GdkEventKey * pevent)
27 {
28   if (divert_key_event)
29     {
30       warningdialog (_("Recursive key capture not possible!"));    /* we could make a stack of them instead ... */
31       return FALSE;
32     }
33   GdkEventKey *event;
34   divert_key_id = Denemo.project->id;
35   divert_key_event = &event;
36   gtk_main ();
37   divert_key_event = NULL;
38   // *keyval = event->keyval;
39   // *state = dnm_sanitize_key_state(event);
40   memcpy (pevent, event, sizeof (GdkEventKey));
41   return TRUE;
42 }
43 
44 
45 
46 static guint
lock_mask(gint keyval)47 lock_mask (gint keyval)
48 {
49 
50   if ((keyval == GDK_Shift_L) || (keyval == GDK_Shift_R))
51     return GDK_SHIFT_MASK;
52 
53   if (keyval == GDK_Caps_Lock)
54     return GDK_LOCK_MASK;
55 
56   if ((keyval == GDK_Control_L) || (keyval == GDK_Control_R))
57     return GDK_CONTROL_MASK;
58 
59 
60   if (keyval == GDK_Alt_L)
61     return GDK_MOD1_MASK;
62 
63 
64 
65   if (keyval == GDK_Num_Lock)
66     return GDK_MOD2_MASK;
67 
68   /*penguin/windows */
69   if ((keyval == GDK_Super_L) || (keyval == GDK_Super_R))
70     return GDK_MOD4_MASK;
71 
72   if (keyval == GDK_Alt_R || GDK_ISO_Level3_Shift)
73     return GDK_MOD5_MASK;
74 
75   return 0;
76 
77 }
78 
79 static guint
klock_mask(gint keyval)80 klock_mask (gint keyval)
81 {
82 
83   if ((keyval == GDK_Shift_L) || (keyval == GDK_Shift_R))
84     return GDK_SHIFT_MASK;
85 
86   if ((keyval == GDK_Control_L) || (keyval == GDK_Control_R))
87     return GDK_CONTROL_MASK;
88 
89 
90   if (keyval == GDK_Alt_L)
91     return GDK_MOD1_MASK;
92 
93 
94   /*penguin/windows */
95   if ((keyval == GDK_Super_L) || (keyval == GDK_Super_R))
96     return GDK_MOD4_MASK;
97 
98   if (keyval == GDK_Alt_R || GDK_ISO_Level3_Shift)
99     return GDK_MOD5_MASK;
100 
101   return 0;
102 
103 }
104 
105 static guint
llock_mask(gint keyval)106 llock_mask (gint keyval)
107 {
108   if (keyval == GDK_Caps_Lock)
109     return GDK_LOCK_MASK;
110 
111 
112   if (keyval == GDK_Num_Lock)
113     return GDK_MOD2_MASK;
114 
115   return 0;
116 
117 }
118 
119 
120 /**
121  * keyrelease event callback
122  * sets cursor if a modifier
123  */
124 
125 gint
scorearea_keyrelease_event(GtkWidget * widget,GdkEventKey * event)126 scorearea_keyrelease_event (GtkWidget * widget, GdkEventKey * event)
127 {
128      if(!Denemo.keyboard_state_locked)
129           {
130               Denemo.keyboard_state ^= (0xf & klock_mask (event->keyval));
131               if ((event->keyval == GDK_Alt_L) || (event->keyval == GDK_Alt_R))
132                 {
133                   if ((Denemo.keyboard_state & CHORD_MASK)) //At least one note has been entered in a chord
134                     next_insert_or_editable_note ();
135                   Denemo.keyboard_state &= ~CHORD_MASK;
136                 }
137               set_midi_in_status ();
138         }
139   //g_print("release %x state %x\n", Denemo.keyboard_state, event->state);
140   // set_cursor_for(keyrelease_modify(event->state), event->keyval);
141   gint state;
142   if ((event->keyval == GDK_Caps_Lock) || (event->keyval == GDK_Num_Lock))
143     return TRUE;
144   state = (lock_mask (event->keyval) ^ event->state);
145 
146   set_cursor_for (state);
147   return TRUE;
148 }
149 
150 /* perform the command of the given name and store the event that triggered it */
151 static gchar *
perform_command(const gchar * command_name,GdkEventKey * event)152 perform_command (const gchar * command_name, GdkEventKey * event)
153 {
154   Denemo.last_keyval = event->keyval;
155   Denemo.last_keystate = dnm_sanitize_key_state (event);
156   call_out_to_guile ("(define DenemoKeypressActivatedCommand #t)");
157   execute_callback_from_name (command_name);
158   call_out_to_guile ("(define DenemoKeypressActivatedCommand #f)");
159   // note Denemo.project = Denemo.project; may have changed as a result of executing the command
160 #ifdef TESTING_REPEATED_XPOSITION_UPDATE
161   if (Denemo.project->movement)
162     displayhelper (Denemo.project);
163 #endif
164   return NULL;
165 }
166 
167 //return the value of perform_command if executed or "" if keypress is part of a two-key shortcut, or NULL toherwise
168 gchar *
process_key_event(GdkEventKey * event,gchar * perform_command ())169 process_key_event (GdkEventKey * event, gchar * perform_command ())
170 {
171   keymap *the_keymap = Denemo.map;
172   //g_debug("\n********\nCaps Lock %x?\n\n********\nShifted %x?\n", event->state&GDK_LOCK_MASK,          event->state&GDK_SHIFT_MASK     );
173   {
174     gint state;
175     state = (lock_mask (event->keyval) ^ event->state);
176     if (state || ((event->keyval == GDK_Caps_Lock) || (event->keyval == GDK_Num_Lock)))
177       set_cursor_for (state);   // MUST LOOK AHEAD to state after keypress HERE CATCH modifiers and set the cursor for them.....
178   }
179   dnm_clean_event (event);
180 
181 
182   if (isModifier (event))
183     return NULL;
184 
185   /* Look up the keystroke in the keymap and execute the appropriate
186    * function */
187   static GString *prefix_store = NULL;
188   if (!prefix_store)
189     prefix_store = g_string_new ("");
190 
191   gint command_idx = lookup_command_for_keyevent (event);
192   if ((prefix_store->len == 0) && (command_idx != -1))
193     {
194       const gchar *command_name = lookup_name_from_idx (the_keymap, command_idx);
195       if (command_name)
196         {
197           if (Denemo.prefs.learning)
198             {
199               gchar *name = dnm_accelerator_name (event->keyval, event->state);
200               KeyStrokeShow (name, command_idx, TRUE);
201               g_free (name);
202             }
203           if (Denemo.ScriptRecording)
204                         if (idx_has_callback (the_keymap, command_idx))
205                             {
206                                 append_scheme_call ((gchar *) command_name);
207                             }
208           //g_debug("Single Key shortcut %s invokes %s\n", dnm_accelerator_name(event->keyval, event->state), command_name);
209           return perform_command (command_name, event);
210         }
211       else
212         {
213           g_warning ("Error: action %i has no name", command_idx);
214           return NULL;
215         }
216     }
217 
218   /*  we create a store for the prefix char and look to see if it is populated when a keystroke is received. If it is populated, we try for the two-key combination, {???else we try for the single key, and if that fails populate the store. OR if it fails clear store}. If the two-key combination works we clear the store. If the two-key combination fails we try for the single key, if that succeeds we clear the store if it fails we set the store to the unresolved keystroke.  */
219 
220   gchar *ret = NULL;
221   if (prefix_store->len)
222     {
223       gchar *name = dnm_accelerator_name (event->keyval, event->state);
224       //g_debug("second key %s\n", name);
225       g_string_append_printf (prefix_store, "%c%s", ',', name);
226       command_idx = lookup_command_for_keybinding_name (Denemo.map, prefix_store->str);
227 
228       if (command_idx != -1)
229         {
230           const gchar *command_name = lookup_name_from_idx (the_keymap, command_idx);
231           if (command_name)
232             {
233               if (Denemo.prefs.learning)
234                 {
235                   KeyStrokeShow (prefix_store->str, command_idx, FALSE);
236                 }
237                     if (Denemo.ScriptRecording)
238                             if (idx_has_callback (the_keymap, command_idx))
239                                 {
240                                     append_scheme_call ((gchar *) command_name);
241                                 }
242               ret = perform_command (command_name, event);
243             }
244         }
245       else
246         {                       //Two key name was not a binding
247           ret = NULL;
248           write_status (Denemo.project);
249           if ((Denemo.project->view != DENEMO_MENU_VIEW) || Denemo.prefs.learning)
250             {
251                             Denemo.prefs.learning = TRUE;
252               KeyStrokeDecline (prefix_store->str);
253             }
254           toggle_to_drawing_area (TRUE);        //restore menus, in case the user is lost and needs to look up a keypress
255           if (Denemo.project->view != DENEMO_MENU_VIEW)
256                         toggle_to_drawing_area (TRUE);
257         }
258       g_string_assign (prefix_store, "");
259       Denemo.continuations = NULL;
260       return ret;
261     }
262   else
263     {                           //no prefix stored
264       gchar *name = dnm_accelerator_name (event->keyval, event->state); //FIXME free name
265 
266       if ((Denemo.continuations = (GList *) g_hash_table_lookup (Denemo.map->continuations_table, name)))
267         {
268           GList *g;
269           GString *continuations = g_string_new ("");
270           for (g = Denemo.continuations; g; g = g->next)
271             g_string_append_printf (continuations, "%s%s", (gchar *) g->data, _(", or "));
272           g_string_printf (prefix_store, _( "Prefix Key %s, waiting for key %stype Esc to abort"), name, continuations->str);
273           g_string_free (continuations, TRUE);
274           if (Denemo.prefs.immediateplayback)
275               play_note (DEFAULT_BACKEND, 0, 9, 61, 300, 127 * Denemo.project->movement->master_volume);
276           //gtk_statusbar_pop (GTK_STATUSBAR (Denemo.statusbar), Denemo.status_context_id);
277           gtk_label_set_text (GTK_LABEL (Denemo.statuslabel), prefix_store->str);
278           g_string_assign (prefix_store, name);
279           if (Denemo.prefs.learning)
280             {
281               KeyStrokeAwait (name);
282             }
283           return "";            //continuation available
284         }
285       else
286         {
287           if ((Denemo.project->view != DENEMO_MENU_VIEW) || Denemo.prefs.learning)
288             {
289                             Denemo.prefs.learning = TRUE;
290               KeyStrokeDecline (name);
291             }
292           toggle_to_drawing_area (TRUE);  //restore menus, in case the user is lost and needs to look up a keypress
293           if (Denemo.project->view != DENEMO_MENU_VIEW)
294                         toggle_to_drawing_area (TRUE);
295         }
296       return NULL;
297     }
298   return NULL;
299 }
300 
301 
302 /**
303  * keypress event callback
304  * looks up the key press and executes the correct function
305  */
306 
307 gint
scorearea_keypress_event(GtkWidget * widget,GdkEventKey * event)308 scorearea_keypress_event (GtkWidget * widget, GdkEventKey * event)
309 {
310       if(!Denemo.keyboard_state_locked)
311           {
312               Denemo.keyboard_state |= (0xf & klock_mask (event->keyval));
313               Denemo.keyboard_state ^= llock_mask (event->keyval);
314               // if((event->keyval==GDK_Alt_L)||(event->keyval==GDK_Alt_R))
315               //  Denemo.keyboard_state |= CHORD_MASK;
316               set_midi_in_status ();
317           }
318   //g_print("press Denemo %x state %x klock %x\n", Denemo.keyboard_state, event->state, klock_mask(event->keyval));
319 
320   //g_debug("State eored %x\n", (lock_mask(event->keyval)^event->state));
321   if (divert_key_event && !isModifier (event) && divert_key_id == Denemo.project->id)
322     {
323       dnm_clean_event (event);
324       *divert_key_event = event;
325       //g_object_ref(event); FIXME do we need to keep it around?
326       gtk_main_quit ();
327       return TRUE;              //*is* reached main loop exits to the caller of the loop when it next gains control
328     }
329 
330   (void) process_key_event (event, perform_command);
331   return TRUE;                  //I think this means do not run any other handlers after this.
332 }
333 
334 /**
335  * Reduce the measure width by 10 pixels
336  */
337 void
adjust_measure_less_width_key(GtkAction * action,DenemoScriptParam * param)338 adjust_measure_less_width_key (GtkAction* action, DenemoScriptParam *param)
339 {
340   adjustmeasurewidth (Denemo.project->movement, -10);
341 }
342 
343 /**
344  * Enlarge the measure width by 10 pixels
345  */
346 void
adjust_measure_more_width_key(GtkAction * action,DenemoScriptParam * param)347 adjust_measure_more_width_key (GtkAction* action, DenemoScriptParam *param)
348 {
349   adjustmeasurewidth (Denemo.project->movement, 10);
350 }
351 
352 /**
353  * Reduce the staff height by 10 pixels
354  */
355 void
adjust_staff_less_height_key(GtkAction * action,DenemoScriptParam * param)356 adjust_staff_less_height_key (GtkAction* action, DenemoScriptParam *param)
357 {
358   adjuststaffheight (Denemo.project->movement, -10);
359 }
360 
361 /**
362  * Enlarge the staff height by 10 pixels
363  */
364 void
adjust_staff_more_height_key(GtkAction * action,DenemoScriptParam * param)365 adjust_staff_more_height_key (GtkAction* action, DenemoScriptParam *param)
366 {
367   adjuststaffheight (Denemo.project->movement, 10);
368 
369 }
370 
371 /**
372  * Remove selection marker
373  */
374 void
unset_selection_key(DenemoScriptParam * param)375 unset_selection_key (DenemoScriptParam *param)
376 {
377   Denemo.project->movement->markstaffnum = 0;
378 }
379 
380 /**
381  * Insert quarter note into score
382  */
383 void
insert_chord_key(DenemoScriptParam * param)384 insert_chord_key (DenemoScriptParam *param)
385 {
386   dnm_insertchord (Denemo.project, 2, Denemo.project->mode, FALSE);
387 }
388 
389 void
go_to_key(gchar note,DenemoScriptParam * param)390 go_to_key(gchar note, DenemoScriptParam *param)
391 {
392   Denemo.project->last_source = INPUTKEYBOARD;
393   shiftcursor (Denemo.project, ((note + 5 - 'A') % 7));
394 }
395 
396 /**
397  * Goto the nearest a
398  *
399  */
400 void
go_to_A_key(GtkAction * action,DenemoScriptParam * param)401 go_to_A_key (GtkAction* action, DenemoScriptParam *param)
402 {
403   Denemo.project->last_source = INPUTKEYBOARD;
404   shiftcursor (Denemo.project, 5);
405 }
406 
407 /**
408  * Goto the nearest b
409  *
410  */
411 void
go_to_B_key(GtkAction * action,DenemoScriptParam * param)412 go_to_B_key (GtkAction* action, DenemoScriptParam *param)
413 {
414   Denemo.project->last_source = INPUTKEYBOARD;
415   shiftcursor (Denemo.project, 6);
416 }
417 
418 /**
419  * Goto the nearest c
420  *
421  */
422 void
go_to_C_key(GtkAction * action,DenemoScriptParam * param)423 go_to_C_key (GtkAction* action, DenemoScriptParam *param)
424 {
425   Denemo.project->last_source = INPUTKEYBOARD;
426   shiftcursor (Denemo.project, 0);
427 }
428 
429 /**
430  * Goto the nearest d
431  *
432  */
433 void
go_to_D_key(GtkAction * action,DenemoScriptParam * param)434 go_to_D_key (GtkAction* action, DenemoScriptParam *param)
435 {
436   shiftcursor (Denemo.project, 1);
437 }
438 
439 /**
440  * Goto the nearest e
441  *
442  */
443 void
go_to_E_key(GtkAction * action,DenemoScriptParam * param)444 go_to_E_key (GtkAction* action, DenemoScriptParam *param)
445 {
446   Denemo.project->last_source = INPUTKEYBOARD;
447   shiftcursor (Denemo.project, 2);
448 }
449 
450 /**
451  * Goto the nearest f
452  *
453  */
454 void
go_to_F_key(GtkAction * action,DenemoScriptParam * param)455 go_to_F_key (GtkAction* action, DenemoScriptParam *param)
456 {
457   Denemo.project->last_source = INPUTKEYBOARD;
458   shiftcursor (Denemo.project, 3);
459 }
460 
461 /**
462  * Goto the nearest g
463  *
464  */
465 void
go_to_G_key(GtkAction * action,DenemoScriptParam * param)466 go_to_G_key (GtkAction* action, DenemoScriptParam *param)
467 {
468   Denemo.project->last_source = INPUTKEYBOARD;
469   shiftcursor (Denemo.project, 4);
470 }
471 
472 
473 /**
474  * Move cursor by amount or in EDIT mode change the note by the amount
475  */
476 static void
octave_shift_key(DenemoScriptParam * param,gint amount)477 octave_shift_key (DenemoScriptParam *param, gint amount)
478 {
479   if (((DenemoStaff *) Denemo.project->movement->currentstaff->data)->tone_store)
480     {
481       return;                   //FIXME create a function modify_tone, like delete_tone in pitchentry.c to do this sort of thing
482     }
483   else
484     {
485       if (Denemo.project->mode & (INPUTEDIT))
486         {
487           if (Denemo.project->movement->currentobject)
488             {
489               objnode *thenote = nearestnote (Denemo.project->movement->currentobject->data, Denemo.project->movement->cursor_y);
490               if (thenote)
491                 {
492                   note copy = *((note *) thenote->data);
493                   GList *direcs = ((note *) thenote->data)->directives;
494                   store_for_undo_change (Denemo.project->movement, Denemo.project->movement->currentobject->data);
495                   Denemo.project->movement->undo_guard++;
496                   delete_chordnote (Denemo.project);       //does not delete the directives.
497                   Denemo.project->movement->cursor_y = copy.mid_c_offset + amount;
498                   insert_chordnote (Denemo.project);
499                   changeenshift (Denemo.project->movement->currentobject->data, Denemo.project->movement->cursor_y, copy.enshift);
500                   thenote = nearestnote (Denemo.project->movement->currentobject->data, Denemo.project->movement->cursor_y);
501                   if (thenote)
502                     ((note *) thenote->data)->directives = direcs;
503                   Denemo.project->movement->undo_guard--;
504                   score_status (Denemo.project, TRUE);
505                 }
506             }
507         }
508       else
509         Denemo.project->movement->cursor_y += amount;
510     }
511   if(!Denemo.non_interactive)
512     gtk_widget_queue_draw(Denemo.scorearea);
513 }
514 
515 /**
516  * Move cursor an octave up
517  */
518 void
octave_up_key(GtkAction * action,DenemoScriptParam * param)519 octave_up_key (GtkAction* action, DenemoScriptParam *param)
520 {
521   octave_shift_key (param, 7);
522 }
523 
524 
525 
526 
527 /**
528  * Move cursor an octave down
529  */
530 void
octave_down_key(GtkAction * action,DenemoScriptParam * param)531 octave_down_key (GtkAction* action, DenemoScriptParam *param)
532 {
533   octave_shift_key (param, -7);
534 }
535 
536 /**
537  * change to read only mode
538  * only score traversal available FIXME wrong name
539  */
540 void
default_mode(DenemoScriptParam * param)541 default_mode (DenemoScriptParam *param)
542 {
543   Denemo.project->mode ^= TRAVERSE;
544   if (Denemo.project->mode & TRAVERSE)
545     gtk_label_set_text (GTK_LABEL (Denemo.statuslabel), "Read Only");
546   g_debug ("Mode %d\n", Denemo.project->mode);
547   displayhelper (Denemo.project);
548 }
549 
550 
551 
552 
553 /**
554  * Toggle into rest mode
555  *
556  */
557 void
rest_toggle_key(GtkAction * action,DenemoScriptParam * param)558 rest_toggle_key (GtkAction* action, DenemoScriptParam *param)
559 {
560   GtkAction *mode = gtk_ui_manager_get_action (Denemo.ui_manager, "/MainMenu/ModeMenu/Rest");
561   gtk_action_activate (mode);
562   displayhelper (Denemo.project);
563   score_status(Denemo.project, TRUE);
564 }
565 
566 /**
567  * Toggle blank mode FIXME bitfields!!!
568  *
569  */
570 void
toggle_blank(GtkAction * action,DenemoScriptParam * param)571 toggle_blank (GtkAction* action, DenemoScriptParam *param)
572 {
573   GtkAction *mode = gtk_ui_manager_get_action (Denemo.ui_manager, "/MainMenu/ModeMenu/Blank");
574   gtk_action_activate (mode);
575   displayhelper (Denemo.project);
576   score_status(Denemo.project, TRUE);
577 }
578 
579 /**
580  * Add measure to end of staff / score
581  */
582 void
append_measure_key(GtkAction * action,DenemoScriptParam * param)583 append_measure_key (GtkAction* action, DenemoScriptParam *param)
584 {
585   appendmeasures (Denemo.project->movement, 1);
586 }
587 
588 void
append_measure_score(GtkAction * action,DenemoScriptParam * param)589 append_measure_score (GtkAction* action, DenemoScriptParam *param)
590 {
591   appendmeasurestoentirescore (Denemo.project->movement, 1);
592 }
593 
594 /**
595  * Insert measure at the current
596  */
597 void
insert_measure_key(GtkAction * action,DenemoScriptParam * param)598 insert_measure_key (GtkAction* action, DenemoScriptParam *param)
599 {
600   dnm_insertmeasures (Denemo.project->movement, 1);
601 }
602 
603 void
insert_chord_xkey(gint duration,DenemoScriptParam * param)604 insert_chord_xkey (gint duration, DenemoScriptParam *param)
605 {
606   dnm_insertchord (Denemo.project, duration, Denemo.project->mode, FALSE);
607   displayhelper (Denemo.project);
608   score_status(Denemo.project, TRUE);
609 }
610 
611 void
insert_chord_0key(GtkAction * action,DenemoScriptParam * param)612 insert_chord_0key (GtkAction* action, DenemoScriptParam *param)
613 {
614   insert_chord_xkey(0, param);
615 }
616 
617 void
insert_chord_1key(GtkAction * action,DenemoScriptParam * param)618 insert_chord_1key (GtkAction* action, DenemoScriptParam *param)
619 {
620   insert_chord_xkey(1, param);
621 }
622 
623 void
insert_chord_2key(GtkAction * action,DenemoScriptParam * param)624 insert_chord_2key (GtkAction* action, DenemoScriptParam *param)
625 {
626   insert_chord_xkey(2, param);
627 }
628 
629 void
insert_chord_3key(GtkAction * action,DenemoScriptParam * param)630 insert_chord_3key (GtkAction* action, DenemoScriptParam *param)
631 {
632   insert_chord_xkey(3, param);
633 }
634 
635 void
insert_chord_4key(GtkAction * action,DenemoScriptParam * param)636 insert_chord_4key (GtkAction* action, DenemoScriptParam *param)
637 {
638   insert_chord_xkey(4, param);
639 }
640 
641 void
insert_chord_5key(GtkAction * action,DenemoScriptParam * param)642 insert_chord_5key (GtkAction* action, DenemoScriptParam *param)
643 {
644   insert_chord_xkey(5, param);
645 }
646 
647 void
insert_chord_6key(GtkAction * action,DenemoScriptParam * param)648 insert_chord_6key (GtkAction* action, DenemoScriptParam *param)
649 {
650   insert_chord_xkey(6, param);
651 }
652 
653 void
insert_chord_7key(GtkAction * action,DenemoScriptParam * param)654 insert_chord_7key (GtkAction* action, DenemoScriptParam *param)
655 {
656   insert_chord_xkey(7, param);
657 }
658 
659 void
insert_chord_8key(GtkAction * action,DenemoScriptParam * param)660 insert_chord_8key (GtkAction* action, DenemoScriptParam *param)
661 {
662   insert_chord_xkey(8, param);
663 }
664 
665 void
insert_rest_xkey(gint duration,DenemoScriptParam * param)666 insert_rest_xkey(gint duration, DenemoScriptParam* param)
667 {
668   dnm_insertchord (Denemo.project, duration, INPUTREST, TRUE);
669   displayhelper (Denemo.project);
670   score_status(Denemo.project, TRUE);
671 }
672 
673 
674 void
insert_rest_0key(GtkAction * action,DenemoScriptParam * param)675 insert_rest_0key (GtkAction* action, DenemoScriptParam *param)
676 {
677   insert_rest_xkey(0, param);
678 }
679 
680 void
insert_rest_1key(GtkAction * action,DenemoScriptParam * param)681 insert_rest_1key (GtkAction* action, DenemoScriptParam *param)
682 {
683   insert_rest_xkey(1, param);
684 }
685 
686 void
insert_rest_2key(GtkAction * action,DenemoScriptParam * param)687 insert_rest_2key (GtkAction* action, DenemoScriptParam *param)
688 {
689   insert_rest_xkey(2, param);
690 }
691 
692 void
insert_rest_3key(GtkAction * action,DenemoScriptParam * param)693 insert_rest_3key (GtkAction* action, DenemoScriptParam *param)
694 {
695   insert_rest_xkey(3, param);
696 }
697 
698 void
insert_rest_4key(GtkAction * action,DenemoScriptParam * param)699 insert_rest_4key (GtkAction* action, DenemoScriptParam *param)
700 {
701   insert_rest_xkey(4, param);
702 }
703 
704 void
insert_rest_5key(GtkAction * action,DenemoScriptParam * param)705 insert_rest_5key (GtkAction* action, DenemoScriptParam *param)
706 {
707   insert_rest_xkey(5, param);
708 }
709 
710 void
insert_rest_6key(GtkAction * action,DenemoScriptParam * param)711 insert_rest_6key (GtkAction* action, DenemoScriptParam *param)
712 {
713   insert_rest_xkey(6, param);
714 }
715 
716 void
insert_rest_7key(GtkAction * action,DenemoScriptParam * param)717 insert_rest_7key (GtkAction* action, DenemoScriptParam *param)
718 {
719   insert_rest_xkey(7, param);
720 }
721 
722 void
insert_rest_8key(GtkAction * action,DenemoScriptParam * param)723 insert_rest_8key (GtkAction* action, DenemoScriptParam *param)
724 {
725   insert_rest_xkey(8, param);
726 }
727 
728 void
insert_blankchord_xkey(gint duration,DenemoScriptParam * param)729 insert_blankchord_xkey (gint duration, DenemoScriptParam *param)
730 {
731   dnm_insertchord (Denemo.project, duration, INPUTBLANK, FALSE);
732   displayhelper (Denemo.project);
733   score_status(Denemo.project, TRUE);
734 }
735 
736 void
insert_blankchord_0key(GtkAction * action,DenemoScriptParam * param)737 insert_blankchord_0key (GtkAction* action, DenemoScriptParam *param)
738 {
739   insert_blankchord_xkey(0, param);
740 }
741 
742 void
insert_blankchord_1key(GtkAction * action,DenemoScriptParam * param)743 insert_blankchord_1key (GtkAction* action, DenemoScriptParam *param)
744 {
745   insert_blankchord_xkey(1, param);
746 }
747 
748 void
insert_blankchord_2key(GtkAction * action,DenemoScriptParam * param)749 insert_blankchord_2key (GtkAction* action, DenemoScriptParam *param)
750 {
751   insert_blankchord_xkey(2, param);
752 }
753 
754 void
insert_blankchord_3key(GtkAction * action,DenemoScriptParam * param)755 insert_blankchord_3key (GtkAction* action, DenemoScriptParam *param)
756 {
757   insert_blankchord_xkey(3, param);
758 }
759 
760 void
insert_blankchord_4key(GtkAction * action,DenemoScriptParam * param)761 insert_blankchord_4key (GtkAction* action, DenemoScriptParam *param)
762 {
763   insert_blankchord_xkey(4, param);
764 }
765 
766 void
insert_blankchord_5key(GtkAction * action,DenemoScriptParam * param)767 insert_blankchord_5key (GtkAction* action, DenemoScriptParam *param)
768 {
769   insert_blankchord_xkey(5, param);
770 }
771 
772 void
insert_blankchord_6key(GtkAction * action,DenemoScriptParam * param)773 insert_blankchord_6key (GtkAction* action, DenemoScriptParam *param)
774 {
775   insert_blankchord_xkey(6, param);
776 }
777 
778 void
insert_blankchord_7key(GtkAction * action,DenemoScriptParam * param)779 insert_blankchord_7key (GtkAction* action, DenemoScriptParam *param)
780 {
781   insert_blankchord_xkey(7, param);
782 }
783 
784 void
insert_blankchord_8key(GtkAction * action,DenemoScriptParam * param)785 insert_blankchord_8key (GtkAction* action, DenemoScriptParam *param)
786 {
787   insert_blankchord_xkey(8, param);
788 }
789 
790 gboolean
add_tone_key(GtkAction * action,DenemoScriptParam * param)791 add_tone_key (GtkAction* action, DenemoScriptParam *param)
792 {
793   return insert_chordnote (Denemo.project);
794 }
795 
796 gboolean
remove_tone_key(GtkAction * action,DenemoScriptParam * param)797 remove_tone_key (GtkAction* action, DenemoScriptParam *param)
798 {
799   return delete_chordnote (Denemo.project);
800 }
801 
802 // Note this function is RECURSIVE.
803 // deletes the object before the cursor. If the measure is empty it moves to the end of the previous measure and calls itself.
804 // after deleting an object it backs-up on any rhythm pattern being followed.
805 void
deletepreviousobject(GtkAction * action,DenemoScriptParam * param)806 deletepreviousobject (GtkAction* action, DenemoScriptParam *param)
807 {
808 
809   /* remove the object preceding the cursor, within the current measure */
810   if (Denemo.project->movement->cursor_x)
811     {
812       /* Then move the cursor back */
813       movecursorleft (NULL, NULL);
814       DenemoObject *curObj = (DenemoObject*)Denemo.project->movement->currentobject->data;
815       gboolean anote = (curObj->type == CHORD) && ((chord*)curObj->object)->notes;
816       /* And delete */
817       deleteobject (NULL, NULL);
818       /* if you are following a rhythmic pattern then backup the pattern */
819       if ((Denemo.project->mode & (INPUTEDIT) && Denemo.project->rstep))
820         {
821           if (anote)
822             Denemo.project->rstep = Denemo.project->rstep->prev;          /* rstep list of elements is circular */
823           if (Denemo.project->cstep)
824             {
825               RhythmPattern *cursnip = (RhythmPattern *)Denemo.project->currhythm->data;
826               Denemo.project->cstep = Denemo.project->cstep->prev ? Denemo.project->cstep->prev : g_list_last (Denemo.project->cstep);// cstep list of DenemoObjects is not circular
827             }
828           if (((RhythmElement *) Denemo.project->rstep->data)->highlightlabel)
829             {
830                 RhythmPattern *cursnip = (RhythmPattern *)Denemo.project->currhythm->data;
831                 set_rhythm_label (cursnip, ((RhythmElement *) Denemo.project->rstep->data)->highlightlabel);
832             }
833         }
834 
835     }
836   else
837     {                           /* go to the previous measure, go to end of it, and start deleting there */
838       if (Denemo.project->movement->currentmeasure->prev)
839         {
840           DenemoScriptParam param;
841 
842           do
843             {
844               movetomeasureleft (NULL, &param);
845               //go to end
846               while (Denemo.project->movement->currentobject && (Denemo.project->movement->currentobject->next))
847                 {
848                   Denemo.project->movement->currentobject = Denemo.project->movement->currentobject->next;
849                   Denemo.project->movement->cursor_x++;
850                 }
851             }
852           while (param.status && !Denemo.project->movement->currentobject);
853 
854 
855           if (Denemo.project->movement->currentobject)
856             {
857               movecursorright (NULL, NULL);
858               deletepreviousobject (NULL, NULL);//RECURSIVE!!
859             }
860         }
861     }
862 }
863 
864 void
sharpen_key(GtkAction * action,DenemoScriptParam * param)865 sharpen_key (GtkAction* action, DenemoScriptParam *param)
866 {
867   DenemoObject *curmudelaobj = (DenemoObject *) (Denemo.project->movement->currentobject ? Denemo.project->movement->currentobject->data : NULL);
868 
869   if (curmudelaobj && curmudelaobj->type == STEMDIRECTIVE)
870     change_stem_directive (Denemo.project->movement, DENEMO_STEMUP);
871   else
872     incrementenshift (Denemo.project, 1);
873 }
874 
875 void
stem_up(GtkAction * action,DenemoScriptParam * param)876 stem_up (GtkAction* action, DenemoScriptParam *param)
877 {
878   sharpen_key (action, param);
879 }
880 
881 void
flatten_key(GtkAction * action,DenemoScriptParam * param)882 flatten_key (GtkAction* action, DenemoScriptParam *param)
883 {
884   DenemoObject *curmudelaobj = (DenemoObject *) (Denemo.project->movement->currentobject ? Denemo.project->movement->currentobject->data : NULL);
885 
886   if (curmudelaobj && curmudelaobj->type == STEMDIRECTIVE)
887     change_stem_directive (Denemo.project->movement, DENEMO_STEMDOWN);
888   else
889     incrementenshift (Denemo.project, -1);
890 }
891 
892 void
pending_sharpen(GtkAction * action,DenemoScriptParam * param)893 pending_sharpen (GtkAction* action, DenemoScriptParam *param)
894 {
895   Denemo.project->movement->pending_enshift++;
896   if (Denemo.project->movement->pending_enshift > 2)
897     Denemo.project->movement->pending_enshift = 2;
898   displayhelper (Denemo.project);
899   score_status(Denemo.project, TRUE);
900 }
901 
902 void
pending_flatten(GtkAction * action,DenemoScriptParam * param)903 pending_flatten (GtkAction* action, DenemoScriptParam *param)
904 {
905   Denemo.project->movement->pending_enshift--;
906   if (Denemo.project->movement->pending_enshift < -2)
907     Denemo.project->movement->pending_enshift = -2;
908   displayhelper (Denemo.project);
909   score_status(Denemo.project, TRUE);
910 }
911 
912 void
stem_down(GtkAction * action,DenemoScriptParam * param)913 stem_down (GtkAction* action, DenemoScriptParam *param)
914 {
915   flatten_key (action, param);
916 }
917 
918 /* insert a duplicate note and tie to it */
919 void
tie_notes_key(GtkAction * action,DenemoScriptParam * param)920 tie_notes_key (GtkAction* action, DenemoScriptParam *param)
921 {
922   DenemoObject *curObj = (DenemoObject *) (Denemo.project->movement->currentobject ? Denemo.project->movement->currentobject->data : NULL);
923 
924   /* Equals - toggle whether this note is tied */
925   if (curObj && curObj->type == CHORD && ((chord *) curObj->object)->notes)
926     {
927         if (Denemo.project->movement->cursor_appending)
928             {
929               DenemoMovement *si = Denemo.project->movement;
930               gint tickspermeasure =  WHOLE_NUMTICKS * ((DenemoMeasure*)si->currentmeasure->data)->timesig->time1 / ((DenemoMeasure*)si->currentmeasure->data)->timesig->time2;
931               si->cursoroffend = (curObj->starttickofnextnote >= tickspermeasure);
932               insertion_point (Denemo.project->movement);
933               object_insert (Denemo.project, dnm_clone_object (curObj));
934               movecursorleft (NULL, NULL);
935               movecursorleft (NULL, NULL);
936               toggle_tie (NULL, NULL);
937               movecursorright (NULL, NULL);
938               movecursorright (NULL, NULL);
939           } else
940           {
941               object_insert (Denemo.project, dnm_clone_object (curObj));
942               movecursorleft (NULL, NULL);
943               ((chord *) ((DenemoObject *)Denemo.project->movement->currentobject->data)->object)->is_tied = 1;
944               movecursorright (NULL, NULL);
945               movecursorright (NULL, NULL);
946           }
947     }
948 }
949 
950 void
add_dot_key(GtkAction * action,DenemoScriptParam * param)951 add_dot_key (GtkAction* action, DenemoScriptParam *param)
952 {
953   changedots (Denemo.project->movement, 1);
954 }
955 
956 void
remove_dot_key(GtkAction * action,DenemoScriptParam * param)957 remove_dot_key (GtkAction* action, DenemoScriptParam *param)
958 {
959   changedots (Denemo.project->movement, -1);
960 }
961 
962 
963 void
force_cautionary(GtkAction * action,DenemoScriptParam * param)964 force_cautionary (GtkAction* action, DenemoScriptParam *param)
965 {
966   DenemoObject *theobj = Denemo.project->movement->currentobject ? (DenemoObject *) Denemo.project->movement->currentobject->data : NULL;
967   if (theobj && theobj->type == CHORD)
968     caution (Denemo.project->movement);
969 }
970 
971 void
change_pitch(GtkAction * action,DenemoScriptParam * param)972 change_pitch (GtkAction* action, DenemoScriptParam *param)
973 {
974   if (Denemo.project->mode & INPUTEDIT)
975     {
976       //DenemoObject *theobj =
977       //  si->currentobject ? (DenemoObject *) si->currentobject->data : NULL;
978       delete_chordnote (Denemo.project);
979       insert_chordnote (Denemo.project);
980     }
981   // addtone(theobj, si->cursor_y, si->cursoraccs[si->staffletter_y],
982   //       si->cursorclef);
983 
984 }
985 
986 /*******************************************************************************
987 * DURATION COMMANDS
988 ******************************************************************************/
989 
InsertRest(gint duration)990 void InsertRest(gint duration){
991   highlight_rest(Denemo.project, duration);
992   gint mode = Denemo.project->mode;
993   Denemo.project->mode = INPUTINSERT|INPUTREST;
994   insert_chord_xkey(duration, NULL);
995   Denemo.project->mode = mode;
996   score_status(Denemo.project, TRUE);
997   displayhelper(Denemo.project);
998 }
999 
InsertDur(gint duration)1000 void InsertDur(gint duration){
1001   highlight_duration(Denemo.project, duration);
1002   gint mode = Denemo.project->mode;
1003   Denemo.project->mode = INPUTINSERT|INPUTNORMAL;
1004   insert_chord_xkey(duration, NULL);
1005   Denemo.project->mode = mode;
1006   score_status(Denemo.project, TRUE);
1007   displayhelper(Denemo.project);
1008 }
1009 
ChangeDur(gint duration)1010 void ChangeDur(gint duration){
1011   gint mode = Denemo.project->mode;
1012   gboolean appending = Denemo.project->movement->cursor_appending;
1013   if(appending)
1014     movecursorleft(NULL, NULL);
1015   Denemo.project->mode = INPUTEDIT|INPUTNORMAL;
1016   insert_chord_xkey(duration, NULL);
1017   Denemo.project->mode = mode;
1018   if(appending)
1019     movecursorright(NULL, NULL);
1020   score_status(Denemo.project, TRUE);
1021   displayhelper(Denemo.project);
1022 }
1023 
SetDur(gint duration)1024 void SetDur(gint duration){
1025   highlight_duration(Denemo.project, duration);
1026 }
1027 
Dur(gint duration)1028 void Dur (gint duration) {
1029   DenemoProject *gui = Denemo.project;
1030  if(Denemo.project->mode&INPUTINSERT)
1031    highlight_duration(Denemo.project, duration);
1032  else
1033  if( !(Denemo.project->mode&INPUTRHYTHM) && (Denemo.project->mode&INPUTEDIT) && (!Denemo.project->movement->cursor_appending))
1034    ChangeDur (duration);
1035 else {
1036  insert_chord_xkey(duration, NULL);
1037    highlight_duration(Denemo.project, duration);
1038   score_status(Denemo.project, TRUE);
1039  displayhelper(Denemo.project);
1040  }
1041 }
1042 
1043 /*******************************************************************************
1044 * NOTE COMMANDS
1045 ******************************************************************************/
1046 
ChangeTo(gchar note)1047 void ChangeTo(gchar note){
1048   gboolean appending = Denemo.project->movement->cursor_appending;
1049   if(appending)
1050     movecursorleft(NULL, NULL);
1051   gint mode = Denemo.project->mode;
1052   Denemo.project->mode = INPUTEDIT|INPUTNORMAL;
1053   go_to_key(note, NULL);
1054   Denemo.project->mode = mode;
1055   if(appending)
1056     movecursorright(NULL, NULL);
1057   score_status(Denemo.project, TRUE);
1058   displayhelper(Denemo.project);
1059 }
1060 
MoveTo(gchar note)1061 void MoveTo(gchar note){
1062   gint mode = Denemo.project->mode;
1063   Denemo.project->mode = INPUTCLASSIC|INPUTNORMAL;
1064   go_to_key(note, NULL);
1065   Denemo.project->mode = mode;
1066   displayhelper(Denemo.project);
1067 }
1068 
Insert(gchar note)1069 void Insert(gchar note){
1070   gint mode = Denemo.project->mode;
1071   Denemo.project->mode = INPUTINSERT|INPUTNORMAL;
1072   go_to_key(note, NULL);
1073   Denemo.project->mode = mode;
1074   score_status(Denemo.project, TRUE);
1075   displayhelper(Denemo.project);
1076 }
1077 
AddNote(gchar note)1078 void AddNote(gchar note){
1079   movecursorright(NULL, NULL);
1080   gint mode = Denemo.project->mode;
1081   Denemo.project->mode = INPUTINSERT|INPUTNORMAL;
1082   go_to_key(note, NULL);
1083   Denemo.project->mode = mode;
1084   movecursorleft(NULL, NULL);
1085   score_status(Denemo.project, TRUE);
1086   displayhelper(Denemo.project);
1087 }
1088 
Add(gchar note)1089 void Add(gchar note){
1090   gint mode = Denemo.project->mode;
1091   Denemo.project->mode = INPUTCLASSIC|INPUTNORMAL;
1092   go_to_key(note, NULL);
1093   add_tone_key(NULL, NULL);
1094   Denemo.project->mode = mode;
1095   score_status(Denemo.project, TRUE);
1096   displayhelper(Denemo.project);
1097 }
1098 
Dur0(GtkAction * action,gpointer param)1099 void Dur0(GtkAction *action, gpointer param) {
1100   Dur(0);
1101 }
ChangeDur0(GtkAction * action,gpointer param)1102 void ChangeDur0(GtkAction *action, gpointer param){
1103   ChangeDur(0);
1104 }
InsertDur0(GtkAction * action,gpointer param)1105 void InsertDur0(GtkAction *action, gpointer param){
1106   InsertDur(0);
1107 }
InsertRest0(GtkAction * action,gpointer param)1108 void InsertRest0(GtkAction *action, gpointer param){
1109   InsertRest(0);
1110 }
SetDur0(GtkAction * action,gpointer param)1111 void SetDur0(GtkAction *action, gpointer param){
1112   SetDur(0);
1113 }
Dur1(GtkAction * action,gpointer param)1114 void Dur1(GtkAction *action, gpointer param) {
1115   Dur(1);
1116 }
ChangeDur1(GtkAction * action,gpointer param)1117 void ChangeDur1(GtkAction *action, gpointer param){
1118   ChangeDur(1);
1119 }
InsertDur1(GtkAction * action,gpointer param)1120 void InsertDur1(GtkAction *action, gpointer param){
1121   InsertDur(1);
1122 }
InsertRest1(GtkAction * action,gpointer param)1123 void InsertRest1(GtkAction *action, gpointer param){
1124   InsertRest(1);
1125 }
SetDur1(GtkAction * action,gpointer param)1126 void SetDur1(GtkAction *action, gpointer param){
1127   SetDur(1);
1128 }
Dur2(GtkAction * action,gpointer param)1129 void Dur2(GtkAction *action, gpointer param) {
1130   Dur(2);
1131 }
ChangeDur2(GtkAction * action,gpointer param)1132 void ChangeDur2(GtkAction *action, gpointer param){
1133   ChangeDur(2);
1134 }
InsertDur2(GtkAction * action,gpointer param)1135 void InsertDur2(GtkAction *action, gpointer param){
1136   InsertDur(2);
1137 }
InsertRest2(GtkAction * action,gpointer param)1138 void InsertRest2(GtkAction *action, gpointer param){
1139   InsertRest(2);
1140 }
SetDur2(GtkAction * action,gpointer param)1141 void SetDur2(GtkAction *action, gpointer param){
1142   SetDur(2);
1143 }
Dur3(GtkAction * action,gpointer param)1144 void Dur3(GtkAction *action, gpointer param) {
1145   Dur(3);
1146 }
ChangeDur3(GtkAction * action,gpointer param)1147 void ChangeDur3(GtkAction *action, gpointer param){
1148   ChangeDur(3);
1149 }
InsertDur3(GtkAction * action,gpointer param)1150 void InsertDur3(GtkAction *action, gpointer param){
1151   InsertDur(3);
1152 }
InsertRest3(GtkAction * action,gpointer param)1153 void InsertRest3(GtkAction *action, gpointer param){
1154   InsertRest(3);
1155 }
SetDur3(GtkAction * action,gpointer param)1156 void SetDur3(GtkAction *action, gpointer param){
1157   SetDur(3);
1158 }
Dur4(GtkAction * action,gpointer param)1159 void Dur4(GtkAction *action, gpointer param) {
1160   Dur(4);
1161 }
ChangeDur4(GtkAction * action,gpointer param)1162 void ChangeDur4(GtkAction *action, gpointer param){
1163   ChangeDur(4);
1164 }
InsertDur4(GtkAction * action,gpointer param)1165 void InsertDur4(GtkAction *action, gpointer param){
1166   InsertDur(4);
1167 }
InsertRest4(GtkAction * action,gpointer param)1168 void InsertRest4(GtkAction *action, gpointer param){
1169   InsertRest(4);
1170 }
SetDur4(GtkAction * action,gpointer param)1171 void SetDur4(GtkAction *action, gpointer param){
1172   SetDur(4);
1173 }
Dur5(GtkAction * action,gpointer param)1174 void Dur5(GtkAction *action, gpointer param) {
1175   Dur(5);
1176 }
ChangeDur5(GtkAction * action,gpointer param)1177 void ChangeDur5(GtkAction *action, gpointer param){
1178   ChangeDur(5);
1179 }
InsertDur5(GtkAction * action,gpointer param)1180 void InsertDur5(GtkAction *action, gpointer param){
1181   InsertDur(5);
1182 }
InsertRest5(GtkAction * action,gpointer param)1183 void InsertRest5(GtkAction *action, gpointer param){
1184   InsertRest(5);
1185 }
SetDur5(GtkAction * action,gpointer param)1186 void SetDur5(GtkAction *action, gpointer param){
1187   SetDur(5);
1188 }
Dur6(GtkAction * action,gpointer param)1189 void Dur6(GtkAction *action, gpointer param) {
1190   Dur(6);
1191 }
ChangeDur6(GtkAction * action,gpointer param)1192 void ChangeDur6(GtkAction *action, gpointer param){
1193   ChangeDur(6);
1194 }
InsertDur6(GtkAction * action,gpointer param)1195 void InsertDur6(GtkAction *action, gpointer param){
1196   InsertDur(6);
1197 }
InsertRest6(GtkAction * action,gpointer param)1198 void InsertRest6(GtkAction *action, gpointer param){
1199   InsertRest(6);
1200 }
SetDur6(GtkAction * action,gpointer param)1201 void SetDur6(GtkAction *action, gpointer param){
1202   SetDur(6);
1203 }
Dur7(GtkAction * action,gpointer param)1204 void Dur7(GtkAction *action, gpointer param) {
1205   Dur(7);
1206 }
ChangeDur7(GtkAction * action,gpointer param)1207 void ChangeDur7(GtkAction *action, gpointer param){
1208   ChangeDur(7);
1209 }
InsertDur7(GtkAction * action,gpointer param)1210 void InsertDur7(GtkAction *action, gpointer param){
1211   InsertDur(7);
1212 }
InsertRest7(GtkAction * action,gpointer param)1213 void InsertRest7(GtkAction *action, gpointer param){
1214   InsertRest(7);
1215 }
SetDur7(GtkAction * action,gpointer param)1216 void SetDur7(GtkAction *action, gpointer param){
1217   SetDur(7);
1218 }
Dur8(GtkAction * action,gpointer param)1219 void Dur8(GtkAction *action, gpointer param) {
1220   Dur(8);
1221 }
ChangeDur8(GtkAction * action,gpointer param)1222 void ChangeDur8(GtkAction *action, gpointer param){
1223   ChangeDur(8);
1224 }
InsertDur8(GtkAction * action,gpointer param)1225 void InsertDur8(GtkAction *action, gpointer param){
1226   InsertDur(8);
1227 }
InsertRest8(GtkAction * action,gpointer param)1228 void InsertRest8(GtkAction *action, gpointer param){
1229   InsertRest(8);
1230 }
SetDur8(GtkAction * action,gpointer param)1231 void SetDur8(GtkAction *action, gpointer param){
1232   SetDur(8);
1233 }
InsertA(GtkAction * action,gpointer param)1234 void InsertA(GtkAction *action, gpointer param){
1235   Insert('A');
1236 }
AddNoteA(GtkAction * action,gpointer param)1237 void AddNoteA(GtkAction *action, gpointer param){
1238   AddNote('A');
1239 }
AddA(GtkAction * action,gpointer param)1240 void AddA(GtkAction *action, gpointer param){
1241   Add('A');
1242 }
ChangeToA(GtkAction * action,gpointer param)1243 void ChangeToA(GtkAction *action, gpointer param){
1244   ChangeTo('A');
1245 }
MoveToA(GtkAction * action,gpointer param)1246 void MoveToA(GtkAction *action, gpointer param){
1247   MoveTo('A');
1248 }
InsertB(GtkAction * action,gpointer param)1249 void InsertB(GtkAction *action, gpointer param){
1250   Insert('B');
1251 }
AddNoteB(GtkAction * action,gpointer param)1252 void AddNoteB(GtkAction *action, gpointer param){
1253   AddNote('B');
1254 }
AddB(GtkAction * action,gpointer param)1255 void AddB(GtkAction *action, gpointer param){
1256   Add('B');
1257 }
ChangeToB(GtkAction * action,gpointer param)1258 void ChangeToB(GtkAction *action, gpointer param){
1259   ChangeTo('B');
1260 }
MoveToB(GtkAction * action,gpointer param)1261 void MoveToB(GtkAction *action, gpointer param){
1262   MoveTo('B');
1263 }
InsertC(GtkAction * action,gpointer param)1264 void InsertC(GtkAction *action, gpointer param){
1265   Insert('C');
1266 }
AddNoteC(GtkAction * action,gpointer param)1267 void AddNoteC(GtkAction *action, gpointer param){
1268   AddNote('C');
1269 }
AddC(GtkAction * action,gpointer param)1270 void AddC(GtkAction *action, gpointer param){
1271   Add('C');
1272 }
ChangeToC(GtkAction * action,gpointer param)1273 void ChangeToC(GtkAction *action, gpointer param){
1274   ChangeTo('C');
1275 }
MoveToC(GtkAction * action,gpointer param)1276 void MoveToC(GtkAction *action, gpointer param){
1277   MoveTo('C');
1278 }
InsertD(GtkAction * action,gpointer param)1279 void InsertD(GtkAction *action, gpointer param){
1280   Insert('D');
1281 }
AddNoteD(GtkAction * action,gpointer param)1282 void AddNoteD(GtkAction *action, gpointer param){
1283   AddNote('D');
1284 }
AddD(GtkAction * action,gpointer param)1285 void AddD(GtkAction *action, gpointer param){
1286   Add('D');
1287 }
ChangeToD(GtkAction * action,gpointer param)1288 void ChangeToD(GtkAction *action, gpointer param){
1289   ChangeTo('D');
1290 }
MoveToD(GtkAction * action,gpointer param)1291 void MoveToD(GtkAction *action, gpointer param){
1292   MoveTo('D');
1293 }
InsertE(GtkAction * action,gpointer param)1294 void InsertE(GtkAction *action, gpointer param){
1295   Insert('E');
1296 }
AddNoteE(GtkAction * action,gpointer param)1297 void AddNoteE(GtkAction *action, gpointer param){
1298   AddNote('E');
1299 }
AddE(GtkAction * action,gpointer param)1300 void AddE(GtkAction *action, gpointer param){
1301   Add('E');
1302 }
ChangeToE(GtkAction * action,gpointer param)1303 void ChangeToE(GtkAction *action, gpointer param){
1304   ChangeTo('E');
1305 }
MoveToE(GtkAction * action,gpointer param)1306 void MoveToE(GtkAction *action, gpointer param){
1307   MoveTo('E');
1308 }
InsertF(GtkAction * action,gpointer param)1309 void InsertF(GtkAction *action, gpointer param){
1310   Insert('F');
1311 }
AddNoteF(GtkAction * action,gpointer param)1312 void AddNoteF(GtkAction *action, gpointer param){
1313   AddNote('F');
1314 }
AddF(GtkAction * action,gpointer param)1315 void AddF(GtkAction *action, gpointer param){
1316   Add('F');
1317 }
ChangeToF(GtkAction * action,gpointer param)1318 void ChangeToF(GtkAction *action, gpointer param){
1319   ChangeTo('F');
1320 }
MoveToF(GtkAction * action,gpointer param)1321 void MoveToF(GtkAction *action, gpointer param){
1322   MoveTo('F');
1323 }
InsertG(GtkAction * action,gpointer param)1324 void InsertG(GtkAction *action, gpointer param){
1325   Insert('G');
1326 }
AddNoteG(GtkAction * action,gpointer param)1327 void AddNoteG(GtkAction *action, gpointer param){
1328   AddNote('G');
1329 }
AddG(GtkAction * action,gpointer param)1330 void AddG(GtkAction *action, gpointer param){
1331   Add('G');
1332 }
ChangeToG(GtkAction * action,gpointer param)1333 void ChangeToG(GtkAction *action, gpointer param){
1334   ChangeTo('G');
1335 }
MoveToG(GtkAction * action,gpointer param)1336 void MoveToG(GtkAction *action, gpointer param){
1337   MoveTo('G');
1338 }
1339