mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher/text_input] insertTextAtLocation location parameter not const anymore
This commit is contained in:
committed by
Léa Saviot
parent
742ee475ea
commit
09e1c2eb8b
@@ -115,7 +115,7 @@ protected:
|
||||
const char * editedText() const override { return m_text.text(); }
|
||||
size_t editedTextLength() const override { return m_text.textLength(); }
|
||||
const Text * getText() const { return &m_text; }
|
||||
bool insertTextAtLocation(const char * text, const char * location) override;
|
||||
bool insertTextAtLocation(const char * text, char * location) override;
|
||||
void moveCursorGeo(int deltaX, int deltaY);
|
||||
bool removePreviousGlyph() override;
|
||||
bool removeEndOfLine() override;
|
||||
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
/* 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. */
|
||||
bool insertTextAtLocation(const char * text, const char * location) override;
|
||||
bool insertTextAtLocation(const char * text, char * location) override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
bool removePreviousGlyph() override;
|
||||
bool removeEndOfLine() override;
|
||||
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
|
||||
// Virtual text get/add/remove
|
||||
virtual const char * text() const = 0;
|
||||
virtual bool insertTextAtLocation(const char * text, const char * location) = 0;
|
||||
virtual bool insertTextAtLocation(const char * text, char * location) = 0;
|
||||
virtual bool removePreviousGlyph() = 0;
|
||||
virtual bool removeEndOfLine() = 0;
|
||||
|
||||
@@ -90,7 +90,7 @@ protected:
|
||||
/* 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. */
|
||||
bool insertTextAtLocation(const char * textBuffer, const char * location);
|
||||
bool insertTextAtLocation(const char * textBuffer, char * location);
|
||||
bool removeEndOfLine();
|
||||
ContentView * contentView() {
|
||||
return const_cast<ContentView *>(nonEditableContentView());
|
||||
|
||||
@@ -458,7 +458,7 @@ void TextArea::ContentView::setText(char * textBuffer, size_t textBufferSize) {
|
||||
m_cursorLocation = text();
|
||||
}
|
||||
|
||||
bool TextArea::ContentView::insertTextAtLocation(const char * text, const char * location) {
|
||||
bool TextArea::ContentView::insertTextAtLocation(const char * text, char * location) {
|
||||
int textSize = strlen(text);
|
||||
if (m_text.textLength() + textSize >= m_text.bufferSize() || textSize == 0) {
|
||||
return false;
|
||||
@@ -475,9 +475,9 @@ bool TextArea::ContentView::insertTextAtLocation(const char * text, const char *
|
||||
&lineBreak, 0);
|
||||
|
||||
assert(UTF8Helper::CodePointIs(nullLocation, 0));
|
||||
m_text.insertText(text, nullLocation - text, const_cast<char *>(location));
|
||||
m_text.insertText(text, nullLocation - text, location);
|
||||
// Replace System parentheses (used to keep layout tree structure) by normal parentheses
|
||||
Poincare::SerializationHelper::ReplaceSystemParenthesesByUserParentheses(const_cast<char *>(location), nullLocation - text);
|
||||
Poincare::SerializationHelper::ReplaceSystemParenthesesByUserParentheses(location, nullLocation - text);
|
||||
reloadRectFromPosition(location, lineBreak);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void TextField::ContentView::reinitDraftTextBuffer() {
|
||||
setCursorLocation(s_draftTextBuffer);
|
||||
}
|
||||
|
||||
bool TextField::ContentView::insertTextAtLocation(const char * text, const char * location) {
|
||||
bool TextField::ContentView::insertTextAtLocation(const char * text, char * location) {
|
||||
assert(m_isEditing);
|
||||
|
||||
int textLength = strlen(text);
|
||||
@@ -121,12 +121,12 @@ bool TextField::ContentView::insertTextAtLocation(const char * text, const char
|
||||
return false;
|
||||
}
|
||||
|
||||
memmove(const_cast<char *>(location + textLength), location, (s_draftTextBuffer + m_currentDraftTextLength + 1) - location);
|
||||
memmove(location + textLength, location, (s_draftTextBuffer + m_currentDraftTextLength + 1) - location);
|
||||
|
||||
// Caution! One byte will be overridden by the null-terminating char of strlcpy
|
||||
char * overridenByteLocation = const_cast<char *>(location + strlen(text));
|
||||
char * overridenByteLocation = location + textLength;
|
||||
char overridenByte = *overridenByteLocation;
|
||||
strlcpy(const_cast<char *>(location), text, (s_draftTextBuffer + m_draftTextBufferSize) - location);
|
||||
strlcpy(location, text, (s_draftTextBuffer + m_draftTextBufferSize) - location);
|
||||
assert(overridenByteLocation < s_draftTextBuffer + m_draftTextBufferSize);
|
||||
*overridenByteLocation = overridenByte;
|
||||
m_currentDraftTextLength += textLength;
|
||||
@@ -512,7 +512,7 @@ bool TextField::handleEventWithText(const char * eventText, bool indentation, bo
|
||||
Poincare::SerializationHelper::ReplaceSystemParenthesesByUserParentheses(buffer);
|
||||
|
||||
const char * nextCursorLocation = m_contentView.editedText() + draftTextLength();
|
||||
if (insertTextAtLocation(buffer, cursorLocation())) {
|
||||
if (insertTextAtLocation(buffer, const_cast<char *>(cursorLocation()))) {
|
||||
/* The cursor position depends on the text as we sometimes want to position
|
||||
* the cursor at the end of the text and sometimes after the first
|
||||
* parenthesis. */
|
||||
|
||||
@@ -170,7 +170,7 @@ void TextInput::setAlignment(float horizontalAlignment, float verticalAlignment)
|
||||
contentView()->setAlignment(horizontalAlignment, verticalAlignment);
|
||||
}
|
||||
|
||||
bool TextInput::insertTextAtLocation(const char * text, const char * location) {
|
||||
bool TextInput::insertTextAtLocation(const char * text, char * location) {
|
||||
if (contentView()->insertTextAtLocation(text, location)) {
|
||||
/* We layout the scrollable view before scrolling to cursor because the
|
||||
* content size might have changed. */
|
||||
|
||||
Reference in New Issue
Block a user