Hello,

here is a patch allowing key undos. I hope that I test the right thing
when I am looking at the "break_status_dir_".

I think that there are problems with transposition in the relative mode, 
caused by "octave_i_ ++" (eg. b \transpose d => cis):
  Musical_pitch::transpose (Musical_pitch delta)
  {
    int old_pitch = semitone_pitch ();
    int delta_pitch = delta.semitone_pitch ();
    octave_i_ += delta.octave_i_;
    notename_i_ += delta.notename_i_;

    while  (notename_i_ >= 7)
      {
        notename_i_ -= 7;
==>     octave_i_ ++;
      }
   

Eric

=====================================================
diff -urN lilypond-0.1.84/NEWS lilypond-0.1.84.eb1/NEWS
--- lilypond-0.1.84/NEWS        Mon Jul 27 16:14:14 1998
+++ lilypond-0.1.84.eb1/NEWS    Tue Jul 28 22:02:13 1998
@@ -1,3 +1,11 @@
+pl 84.eb1
+       - key undo    
+
+********
+july 27
+
+pl 84
+
 pl 83.jcn4
        - bf: typo mudela-doc
        - long getopt all the way
diff -urN lilypond-0.1.84/TODO lilypond-0.1.84.eb1/TODO
--- lilypond-0.1.84/TODO        Mon Jul 27 15:24:30 1998
+++ lilypond-0.1.84.eb1/TODO    Tue Jul 28 22:00:43 1998
@@ -451,7 +451,6 @@
        * Keys:
        - merge key{item} & localkey{item}?
        - Major/Minor
-       - key undo: \key bes; .. . \key; should print natural   
        - spacing, national styles?
 
        * Support for TAB
diff -urN lilypond-0.1.84/VERSION lilypond-0.1.84.eb1/VERSION
--- lilypond-0.1.84/VERSION     Mon Jul 27 16:15:31 1998
+++ lilypond-0.1.84.eb1/VERSION Wed Jul 29 13:14:33 1998
@@ -2,7 +2,7 @@
 MAJOR_VERSION=0
 MINOR_VERSION=1
 PATCH_LEVEL=84
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=eb1
 
 # use the above to send patches, always empty for released version:
 # please don't move these comments up; the patch should fail if 
diff -urN lilypond-0.1.84/lily/VERSION lilypond-0.1.84.eb1/lily/VERSION
--- lilypond-0.1.84/lily/VERSION        Mon Jul 27 16:16:12 1998
+++ lilypond-0.1.84.eb1/lily/VERSION    Wed Jul 29 13:17:19 1998
@@ -2,7 +2,7 @@
 MAJOR_VERSION=0
 MINOR_VERSION=1
 PATCH_LEVEL=84
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=eb1
 
 # use the above to send patches, always empty for released version:
 # please don't move these comments up; the patch should fail if 
diff -urN lilypond-0.1.84/lily/include/key-engraver.hh 
lilypond-0.1.84.eb1/lily/include/key-engraver.hh
--- lilypond-0.1.84/lily/include/key-engraver.hh        Thu Jul 23 15:28:07 1998
+++ lilypond-0.1.84.eb1/lily/include/key-engraver.hh    Tue Jul 28 21:32:19 1998
@@ -29,6 +29,7 @@
   Key_change_req * keyreq_l_;
   Key_item * kit_p_;
   Array<Musical_pitch> accidental_idx_arr_;
+  Array<Musical_pitch> old_accidental_idx_arr_;
   bool default_key_b_;
   bool change_key_b_;
     
diff -urN lilypond-0.1.84/lily/include/key-item.hh 
lilypond-0.1.84.eb1/lily/include/key-item.hh
--- lilypond-0.1.84/lily/include/key-item.hh    Sat Jul 25 13:31:09 1998
+++ lilypond-0.1.84.eb1/lily/include/key-item.hh        Tue Jul 28 21:32:43 1998
@@ -15,6 +15,8 @@
 struct Key_item : Item {
   Array<int> pitch;
   Array<int> acc;
+  Array<int> old_pitch;
+  Array<int> old_acc;
   int c_position;
   int c0_position;
   bool default_b_;
@@ -26,6 +28,8 @@
   Key_item ();
   void add (int pitch, int acc);
   void add (const Musical_pitch&);
+  void add_old (int pitch, int acc);
+  void add_old (const Musical_pitch&);
   void read (const Key_engraver&);
   void set_c_position (int);
   int Key_item::calculate_position(int p, int a) const;
diff -urN lilypond-0.1.84/lily/key-engraver.cc lilypond-0.1.84.eb1/lily/key-engraver.cc
--- lilypond-0.1.84/lily/key-engraver.cc        Thu Jul 23 15:29:38 1998
+++ lilypond-0.1.84.eb1/lily/key-engraver.cc    Tue Jul 28 21:40:26 1998
@@ -6,7 +6,7 @@
   (c)  1997--1998 Han-Wen Nienhuys <[EMAIL PROTECTED]>
 
   
-  Todo: key undo, special keys.
+  Todo: special keys.
   
   */
 #include "key-engraver.hh"
@@ -92,6 +92,7 @@
 void
 Key_engraver::read_req (Key_change_req const * r)
 {
+  old_accidental_idx_arr_ = accidental_idx_arr_;
   key_.clear ();
   Scalar prop = get_property ("specialaccidentals");
   if (prop.length_i () > 0)
diff -urN lilypond-0.1.84/lily/key-item.cc lilypond-0.1.84.eb1/lily/key-item.cc
--- lilypond-0.1.84/lily/key-item.cc    Sat Jul 25 12:56:49 1998
+++ lilypond-0.1.84.eb1/lily/key-item.cc        Tue Jul 28 21:57:37 1998
@@ -30,8 +30,8 @@
 void
 Key_item::read (Key_engraver const & key_grav_r)
 {
-   multi_octave_b_ = key_grav_r.key_.multi_octave_b_;
-  const Array<Musical_pitch> &idx_arr =key_grav_r.accidental_idx_arr_; 
+  multi_octave_b_ = key_grav_r.key_.multi_octave_b_;
+  const Array<Musical_pitch> &idx_arr = key_grav_r.accidental_idx_arr_; 
   for (int i = 0 ; i< idx_arr.size(); i++) 
     {
       Musical_pitch m_l =idx_arr[i];
@@ -40,6 +40,15 @@
       else
        add (m_l.notename_i_, m_l.accidental_i_);
     }
+  const Array<Musical_pitch> &old_idx_arr = key_grav_r.old_accidental_idx_arr_; 
+  for (int i = 0 ; i< old_idx_arr.size(); i++) 
+    {
+      Musical_pitch m_l =old_idx_arr[i];
+      if (multi_octave_b_)
+        add_old (m_l);
+      else
+       add_old (m_l.notename_i_, m_l.accidental_i_);
+    }
 }
 
 void 
@@ -68,6 +77,20 @@
   acc.push (pitch_r.accidental_i_);
 }
 
+void
+Key_item::add_old (int p, int a)
+{
+  old_pitch.push (p);
+  old_acc.push (a);
+}
+
+void
+Key_item::add_old (const Musical_pitch& pitch_r)
+{
+  old_pitch.push (pitch_r.steps());
+  old_acc.push (pitch_r.accidental_i_);
+}
+
 int
 Key_item::calculate_position(int p, int a) const
 {
@@ -92,6 +115,24 @@
   Molecule*output = new Molecule;
   Real inter = paper()->internote_f ();
   
+  int j;
+  if ((break_status_dir_ == LEFT) || (break_status_dir_ == CENTER))
+    {
+      for (int i =0; i < old_pitch.size(); i++) 
+        {
+          for (j =0; (j < pitch.size()) && (old_pitch[i] != pitch[j]); j++) 
+            {    
+            }
+          if ((j == pitch.size()) || ((old_pitch[i] == pitch[j]) && (old_acc[i] != 
+acc[j])))
+            {
+              Atom a =lookup_l ()->accidental (0);
+              a.translate_axis (calculate_position(old_pitch[i], old_acc[i]) * inter, 
+Y_AXIS);
+              Molecule m (a);
+              output->add_at_edge (X_AXIS, RIGHT, m);  
+            }
+        }
+    }
+ 
   for (int i =0; i < pitch.size(); i++) 
     {
       Atom a =lookup_l ()->accidental (acc[i]);

Reply via email to