[apps/graph] Display the function's whole name

This commit is contained in:
Léa Saviot
2018-10-04 16:29:12 +02:00
committed by Émilie Feral
parent a1a0d0f599
commit ac1e79f907
3 changed files with 17 additions and 3 deletions

View File

@@ -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);

View File

@@ -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];
};

View File

@@ -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);