diff --git a/apps/graph/list/storage_list_controller.cpp b/apps/graph/list/storage_list_controller.cpp index 1ad4dfcbd..b13590f24 100644 --- a/apps/graph/list/storage_list_controller.cpp +++ b/apps/graph/list/storage_list_controller.cpp @@ -44,7 +44,21 @@ HighlightCell * StorageListController::expressionCells(int index) { void StorageListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell; StorageCartesianFunction function = m_functionStore->modelAtIndex(j); - char bufferName[5] = {*function.name(),'(', m_functionStore->symbol(),')', 0}; + char bufferName[BufferTextView::k_maxNumberOfChar]; + const char * functionName = function.name(); + int index = 0; + const char ofXSring[4] = {'(', m_functionStore->symbol(),')', 0}; + size_t ofXSringSize = strlen(ofXSring); + while (*functionName != Ion::Storage::k_dotChar + && index < BufferTextView::k_maxNumberOfChar - ofXSringSize) + { + // We keep room to write the final "(x)" //TODO should we? + assert(functionName < function.name() + strlen(function.name())); + bufferName[index] = *functionName; + functionName++; + index++; + } + strlcpy(&bufferName[index], ofXSring, ofXSringSize); myFunctionCell->setText(bufferName); KDColor functionNameColor = function.isActive() ? function.color() : Palette::GreyDark; myFunctionCell->setColor(functionNameColor); diff --git a/escher/include/escher/buffer_text_view.h b/escher/include/escher/buffer_text_view.h index 739041cc7..5c2e0323e 100644 --- a/escher/include/escher/buffer_text_view.h +++ b/escher/include/escher/buffer_text_view.h @@ -5,6 +5,7 @@ class BufferTextView : public TextView { public: + static constexpr int k_maxNumberOfChar = 256; BufferTextView(const KDFont * font = KDFont::LargeFont, float horizontalAlignment = 0.5f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; @@ -12,7 +13,6 @@ public: void appendText(const char * text); static int maxNumberOfCharsInBuffer() { return k_maxNumberOfChar; } private: - static constexpr int k_maxNumberOfChar = 256; char m_buffer[k_maxNumberOfChar]; }; diff --git a/ion/include/ion/storage.h b/ion/include/ion/storage.h index 159e10994..14ada4164 100644 --- a/ion/include/ion/storage.h +++ b/ion/include/ion/storage.h @@ -16,6 +16,7 @@ public: typedef uint16_t record_size_t; constexpr static size_t k_storageSize = 16384; static Storage * sharedStorage(); + constexpr static char k_dotChar = '.'; class Record { /* A Record is identified by the CRC32 on its fullName because: @@ -88,7 +89,6 @@ public: private: constexpr static uint32_t Magic = 0xEE0BDDBA; constexpr static size_t k_maxRecordSize = (1 << sizeof(record_size_t)*8); - constexpr static char k_dotChar = '.'; /* Getters/Setters on recordID */ const char * fullNameOfRecord(const Record record);