[ion/utf8_helper] Put default parameter in RemovePreviousGlyph

This commit is contained in:
Léa Saviot
2019-06-21 14:26:43 +02:00
committed by Émilie Feral
parent b3c9831f66
commit 4f63e4058e
3 changed files with 6 additions and 6 deletions

View File

@@ -149,12 +149,11 @@ bool TextField::ContentView::removePreviousGlyph() {
if (m_horizontalAlignment > 0.0f) {
/* Reload the view. If we do it later, the text beins supposedly shorter, we
* will not clean the first char. */
* will not clean the first char. */
reloadRectFromPosition(m_draftTextBuffer);
}
// Remove the glyph if possible
CodePoint removedCodePoint = 0;
int removedSize = UTF8Helper::RemovePreviousGlyph(m_draftTextBuffer, const_cast<char *>(cursorLocation()), &removedCodePoint);
int removedSize = UTF8Helper::RemovePreviousGlyph(m_draftTextBuffer, const_cast<char *>(cursorLocation()));
if (removedSize == 0) {
assert(cursorLocation() == m_draftTextBuffer);
return false;

View File

@@ -72,7 +72,7 @@ bool CodePointIsUpperCaseLetter(CodePoint c);
bool CodePointIsNumber(CodePoint c);
// Shift the buffer and return the number of bytes removed.
int RemovePreviousGlyph(const char * text, char * location, CodePoint * c);
int RemovePreviousGlyph(const char * text, char * location, CodePoint * c = nullptr);
/* Return the pointer to the (non combining) code point whose glyph is displayed
* at the given position, and vice-versa */

View File

@@ -267,7 +267,6 @@ bool CodePointIsNumber(CodePoint c) {
}
int RemovePreviousGlyph(const char * text, char * location, CodePoint * c) {
assert(c != nullptr);
if (location <= text) {
assert(location == text);
return 0;
@@ -276,7 +275,9 @@ int RemovePreviousGlyph(const char * text, char * location, CodePoint * c) {
// Find the previous glyph
UTF8Decoder decoder(text, location);
const char * previousGlyphPos = decoder.previousGlyphPosition();
*c = decoder.nextCodePoint();
if (c != nullptr) {
*c = decoder.nextCodePoint();
}
// Shift the buffer
int shiftedSize = location - previousGlyphPos;