diff --git a/.vscode/settings.json b/.vscode/settings.json index 81deca8f9..d37702476 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,58 @@ }, "[powershell]": { "editor.defaultFormatter": "ms-vscode.powershell" + }, + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "map": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" } } diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index a23218663..1ca305746 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1118,27 +1118,29 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 std::vector lines; lines.push_back(std::string(headerStr)); // Header line is always first - std::string word, line; - int msgLen = strlen(messageBuf); - for (int i = 0; i <= msgLen; ++i) { + std::string line, word; + for (int i = 0; messageBuf[i]; ++i) { char ch = messageBuf[i]; - if (ch == ' ' || ch == '\0') { - if (!word.empty()) { - if (display->getStringWidth((line + word).c_str()) > textWidth) { - lines.push_back(line); - line = word + ' '; - } else { - line += word + ' '; - } - word.clear(); - } - if (ch == '\0' && !line.empty()) { - lines.push_back(line); - } + if (ch == '\n') { + if (!word.empty()) line += word; + if (!line.empty()) lines.push_back(line); + line.clear(); + word.clear(); + } else if (ch == ' ') { + line += word + ' '; + word.clear(); } else { word += ch; + std::string test = line + word; + if (display->getStringWidth(test.c_str()) > textWidth + 4) { + if (!line.empty()) lines.push_back(line); + line = word; + word.clear(); + } } } + if (!word.empty()) line += word; + if (!line.empty()) lines.push_back(line); // === Scrolling logic === const float rowHeight = FONT_HEIGHT_SMALL - 1;