diff --git a/apps/graph/list/storage_list_controller.cpp b/apps/graph/list/storage_list_controller.cpp index df2e0865c..391dff9b1 100644 --- a/apps/graph/list/storage_list_controller.cpp +++ b/apps/graph/list/storage_list_controller.cpp @@ -45,20 +45,7 @@ void StorageListController::willDisplayTitleCellAtIndex(HighlightCell * cell, in Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell; StorageFunction * function = m_functionStore->modelAtIndex(j); char bufferName[BufferTextView::k_maxNumberOfChar]; - const char * functionName = function->fullName(); - 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->fullName() + strlen(function->fullName())); - bufferName[index] = *functionName; - functionName++; - index++; - } - strlcpy(&bufferName[index], ofXSring, ofXSringSize+1); + function->nameWithArgument(bufferName, BufferTextView::k_maxNumberOfChar, m_functionStore->symbol()); myFunctionCell->setText(bufferName); KDColor functionNameColor = function->isActive() ? function->color() : Palette::GreyDark; myFunctionCell->setColor(functionNameColor); diff --git a/apps/shared/storage_function.cpp b/apps/shared/storage_function.cpp index 848c45db2..44ef8da59 100644 --- a/apps/shared/storage_function.cpp +++ b/apps/shared/storage_function.cpp @@ -29,6 +29,21 @@ void StorageFunction::setColor(KDColor color) { recordData()->setColor(color); } +int StorageFunction::nameWithArgument(char * buffer, size_t bufferSize, char arg) { + const char * functionName = fullName(); + int index = 0; + const char ofXSring[4] = {'(',arg,')', 0}; + size_t ofXSringLength = strlen(ofXSring); + while (*functionName != Ion::Storage::k_dotChar + && index < bufferSize - ofXSringLength - 1) + { + // We keep room to write the final "(x)" //TODO should we? + assert(functionName < fullName() + strlen(fullName())); + buffer[index++] = *functionName++; + } + return index - 1 + strlcpy(&buffer[index], ofXSring, bufferSize); +} + template T StorageFunction::templatedApproximateAtAbscissa(T x, Poincare::Context * context) const { const char unknownX[2] = {Poincare::Symbol::UnknownX, 0}; diff --git a/apps/shared/storage_function.h b/apps/shared/storage_function.h index d1c6d1910..42b8ff800 100644 --- a/apps/shared/storage_function.h +++ b/apps/shared/storage_function.h @@ -21,6 +21,9 @@ public: void setActive(bool active); void setColor(KDColor color); + // Name + int nameWithArgument(char * buffer, size_t bufferSize, char arg); + // Evaluation virtual float evaluateAtAbscissa(float x, Poincare::Context * context) const { return templatedApproximateAtAbscissa(x, context);