[escher/layout_field] When pasting, force cursor right of pasted text

Even if the text is inserted code point per code point
This commit is contained in:
Léa Saviot
2020-01-10 10:49:16 +01:00
parent d446d1cb61
commit 8f86769cd1
3 changed files with 4 additions and 4 deletions

View File

@@ -336,7 +336,7 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
if (resultExpression.isUninitialized()) {
// The text is not parsable (for instance, ",") and is added char by char.
KDSize previousLayoutSize = minimalSizeForOptimalDisplay();
m_contentView.cursor()->insertText(text);
m_contentView.cursor()->insertText(text, forceCursorRightOfText);
reload(previousLayoutSize);
return true;
}

View File

@@ -114,7 +114,7 @@ public:
void addEmptyTenPowerLayout();
void addFractionLayoutAndCollapseSiblings();
void addXNTCodePointLayout();
void insertText(const char * text);
void insertText(const char * text, bool forceCursorRightOfText = false);
void addLayoutAndMoveCursor(Layout l);
bool showEmptyLayoutIfNeeded() { return privateShowHideEmptyLayoutIfNeeded(true); }
bool hideEmptyLayoutIfNeeded() { return privateShowHideEmptyLayoutIfNeeded(false); }

View File

@@ -154,7 +154,7 @@ void LayoutCursor::addXNTCodePointLayout() {
m_layout.addSibling(this, CodePointLayout::Builder(m_layout.XNTCodePoint()), true);
}
void LayoutCursor::insertText(const char * text) {
void LayoutCursor::insertText(const char * text, bool forceCursorRightOfText) {
Layout newChild;
Layout pointedChild;
UTF8Decoder decoder(text);
@@ -199,7 +199,7 @@ void LayoutCursor::insertText(const char * text) {
codePoint = decoder.nextCodePoint();
}
}
if (!pointedChild.isUninitialized() && !pointedChild.parent().isUninitialized()) {
if (!forceCursorRightOfText && !pointedChild.isUninitialized() && !pointedChild.parent().isUninitialized()) {
m_layout = pointedChild;
m_position = Position::Right;
}