From 5aa2b7867031f931b64b99726a25bf5d980a0412 Mon Sep 17 00:00:00 2001
From: c vw <dl1ycf@darc.de>
Date: Thu, 27 Jan 2022 09:20:31 +0100
Subject: [PATCH] Corrections to the MIDI menu

---
 ext.h       |  2 --
 midi_menu.c | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ext.h b/ext.h
index 6c42802..1d87701 100644
--- a/ext.h
+++ b/ext.h
@@ -82,8 +82,6 @@ extern int ext_agc_update(void *data);
 extern int ext_split_toggle(void *data);
 
 
-extern int ext_cw_key(void *data);
-
 extern int ext_update_squelch(void *data);
 
 extern int ext_sliders_update(void *data);
diff --git a/midi_menu.c b/midi_menu.c
index 3141e93..e7f2bbd 100644
--- a/midi_menu.c
+++ b/midi_menu.c
@@ -1434,6 +1434,7 @@ void midi_save_state() {
   struct desc *cmd;
   gint entry;
   int i;
+  char *cp;
 
   entry=0;
   for (i=0; i<n_midi_devices; i++) {
@@ -1461,6 +1462,14 @@ void midi_save_state() {
         setProperty(name,value);
         sprintf(name,"midi[%d].entry[%d].channel[%d].action",i,entry,cmd->channel);
         sprintf(value,"%s",ActionTable[cmd->action].str);
+        //
+        // ActionTable strings may contain '\n', convert this to '$'
+        //
+        cp=value;
+        while (*cp ) {
+          if (*cp == '\n') *cp='$';
+          cp++;
+        }
         setProperty(name,value);
         sprintf(name,"midi[%d].entry[%d].channel[%d].type",i,entry,cmd->channel);
         sprintf(value,"%s",midi_types[cmd->type]);
@@ -1552,6 +1561,7 @@ void midi_restore_state() {
   gint fr1, fr2;
   gint vfr1, vfr2;
   int i,j;
+  char *cp;
 
   get_midi_devices();
   MidiReleaseCommands();
@@ -1612,6 +1622,12 @@ void midi_restore_state() {
 	  }
           sprintf(name,"midi[%d].entry[%d].channel[%d].action",i,entry,channel);
           value=getProperty(name);
+          // convert '$' back to '\n' in action name before comparing
+          cp=value;
+          while (*cp) {
+            if (*cp == '$') *cp='\n';
+            cp++;
+          }
 	  action=NO_ACTION;
           if(value) {
 	    for(j=0;j<ACTIONS;j++) {
-- 
2.45.2