commit 8ed9b308f381bbaeaa5d25c351d76d377aa91e56
parent b7bb9afceab3a4a637b941efbe01dab2160c6522
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Fri, 2 Aug 2024 13:29:04 +0200
fix LCD when dots are in the string
Diffstat:
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/source/nord/n2x/n2xJucePlugin/n2xLcd.cpp b/source/nord/n2x/n2xJucePlugin/n2xLcd.cpp
@@ -85,9 +85,29 @@ namespace n2xJucePlugin
m_label->setText(t, juce::dontSendNotification);
}
+ std::string Lcd::substring(const std::string& _text, uint32_t _offset, uint32_t _len)
+ {
+ auto findIndex = [&_text](const uint32_t _off)
+ {
+ uint32_t o = _off;
+
+ for(uint32_t i=0; i<_text.size(); ++i)
+ {
+ if(_text[i] == '.' && i < o)
+ ++o;
+ }
+ return o;
+ };
+
+ const auto start = findIndex(_offset);
+ const auto end = findIndex(_offset + _len);
+
+ return _text.substr(start, end - start);
+ }
+
bool Lcd::updateClippedText(const std::string& _text, const uint32_t _offset)
{
- const auto str = _text.substr(_offset, 3);
+ const auto str = substring(_text, _offset, 3);
if(str.size() < 3)
return false;
setClippedText(str);