mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph] Fix function renaming
Scenario: Funciton renamed f123456 would be saved as f12345 due to buffer size problem
This commit is contained in:
@@ -30,6 +30,7 @@ void TextFieldFunctionTitleCell::setEditing(bool editing) {
|
||||
m_textField.setExtensionLength(extensionLength);
|
||||
m_textField.setEditing(true);
|
||||
m_textField.setText(previousText);
|
||||
m_textField.setDraftTextBufferSize(Poincare::SymbolAbstract::k_maxNameSize+extensionLength);
|
||||
}
|
||||
|
||||
bool TextFieldFunctionTitleCell::isEditing() const {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <apps/shared/function_title_cell.h>
|
||||
#include <apps/shared/function.h>
|
||||
#include <apps/shared/text_field_with_extension.h>
|
||||
#include "text_field_with_max_length_and_extension.h"
|
||||
|
||||
namespace Graph {
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
constexpr static KDCoordinate k_textFieldRightMargin = 4;
|
||||
constexpr static int k_textFieldBufferSize = Shared::Function::k_maxNameWithArgumentSize;
|
||||
float verticalAlignmentGivenExpressionBaselineAndRowHeight(KDCoordinate expressionBaseline, KDCoordinate rowHeight) const override;
|
||||
Shared::TextFieldWithExtension m_textField;
|
||||
TextFieldWithMaxLengthAndExtension m_textField;
|
||||
char m_textFieldBuffer[k_textFieldBufferSize];
|
||||
};
|
||||
|
||||
|
||||
28
apps/graph/list/text_field_with_max_length_and_extension.h
Normal file
28
apps/graph/list/text_field_with_max_length_and_extension.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef GRAPH_TEXT_FIELD_WITH_MAX_LENGTH_AND_EXTENSION_H
|
||||
#define GRAPH_TEXT_FIELD_WITH_MAX_LENGTH_AND_EXTENSION_H
|
||||
|
||||
#include <apps/shared/text_field_with_extension.h>
|
||||
|
||||
namespace Graph {
|
||||
|
||||
class TextFieldWithMaxLengthAndExtension : public Shared::TextFieldWithExtension {
|
||||
public:
|
||||
TextFieldWithMaxLengthAndExtension(size_t extensionLength,
|
||||
Responder * parentResponder,
|
||||
char * textBuffer,
|
||||
size_t textBufferSize,
|
||||
size_t draftTextBufferSize,
|
||||
::InputEventHandlerDelegate * inputEventHandlerDelegate,
|
||||
::TextFieldDelegate * delegate = nullptr,
|
||||
const KDFont * size = KDFont::LargeFont,
|
||||
float horizontalAlignment = 0.0f,
|
||||
float verticalAlignment = 0.5f,
|
||||
KDColor textColor = KDColorBlack,
|
||||
KDColor backgroundColor = KDColorWhite) :
|
||||
TextFieldWithExtension(extensionLength, parentResponder, textBuffer, textBufferSize, draftTextBufferSize, inputEventHandlerDelegate, delegate, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor) {}
|
||||
void setDraftTextBufferSize(size_t size) { m_contentView.setDraftTextBufferSize(size); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
constexpr static int k_parenthesedArgumentCodePointLength = 3;
|
||||
constexpr static int k_parenthesedThetaArgumentByteLength = 4;
|
||||
constexpr static int k_parenthesedXNTArgumentByteLength = 3;
|
||||
constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + k_parenthesedThetaArgumentByteLength; /* Function name and null-terminating char + "(x)" */;
|
||||
constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + k_parenthesedThetaArgumentByteLength; /* Function name and null-terminating char + "(θ)" */;
|
||||
static bool BaseNameCompliant(const char * baseName, NameNotCompliantError * error = nullptr);
|
||||
|
||||
// Constructors
|
||||
|
||||
@@ -55,6 +55,7 @@ protected:
|
||||
void setAlignment(float horizontalAlignment, float verticalAlignment);
|
||||
void setEditing(bool isEditing);
|
||||
void reinitDraftTextBuffer();
|
||||
void setDraftTextBufferSize(size_t size) { m_draftTextBufferSize = size; }
|
||||
/* If the text to be appended is too long to be added without overflowing the
|
||||
* buffer, nothing is done (not even adding few letters from the text to reach
|
||||
* the maximum buffer capacity) and false is returned. */
|
||||
|
||||
Reference in New Issue
Block a user