From baf9c73626454fee0451a4ccf74507349ac34de1 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 4 Apr 2024 15:51:56 -0500 Subject: [PATCH] GUI: store note binds in exported keybind file issue #1837 --- src/gui/settings.cpp | 58 ++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 4476c07fd..c68e48074 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -4836,41 +4836,22 @@ bool FurnaceGUI::exportColors(String path) { } bool FurnaceGUI::importKeybinds(String path) { - FILE* f=ps_fopen(path.c_str(),"rb"); - if (f==NULL) { + DivConfig c; + if (!c.loadFromFile(path.c_str(),false,false)) { logW("error while opening keybind file for import: %s",strerror(errno)); return false; } resetKeybinds(); - char line[4096]; - while (!feof(f)) { - String key=""; - String value=""; - bool keyOrValue=false; - if (fgets(line,4095,f)==NULL) { - break; - } - for (char* i=line; *i; i++) { - if (*i=='\n') continue; - if (keyOrValue) { - value+=*i; - } else { - if (*i=='=') { - keyOrValue=true; - } else { - key+=*i; - } - } - } - if (keyOrValue) { - // unoptimal - const char* cs=key.c_str(); - bool found=false; + if (c.has("configVersion")) { + // new + readConfig(c,GUI_SETTINGS_KEYBOARD); + } else { + // unoptimal + for (auto& key: c.configMap()) { for (int i=0; i