diff options
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/qlineedit.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/qtextedit.cpp | 16 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/widgets/qlineedit.cpp b/src/widgets/qlineedit.cpp index bcf9b2d0d..eba3f6b20 100644 --- a/src/widgets/qlineedit.cpp +++ b/src/widgets/qlineedit.cpp @@ -877,10 +877,18 @@ void TQLineEdit::backspace() if ( d->hasSelectedText() ) { d->removeSelectedText(); } else if ( d->cursor ) { + --d->cursor; + if ( d->maskData ) { + d->cursor = d->prevMaskBlank( d->cursor ); + } + // second half of a surrogate, check if we have the first half as well, + // if yes delete both at once + if (d->cursor > 0 && d->text.at(d->cursor).isLowSurrogate() && + d->text.at(d->cursor - 1).isHighSurrogate()) { + d->del(true); --d->cursor; - if ( d->maskData ) - d->cursor = d->prevMaskBlank( d->cursor ); - d->del( TRUE ); + } + d->del(true); } d->finishChange( priorState ); } diff --git a/src/widgets/qtextedit.cpp b/src/widgets/qtextedit.cpp index bac58af15..73e800be8 100644 --- a/src/widgets/qtextedit.cpp +++ b/src/widgets/qtextedit.cpp @@ -1783,8 +1783,20 @@ void TQTextEdit::doKeyboardAction( KeyboardAction action ) undoRedoInfo.index = cursor->index(); undoRedoInfo.d->text = TQString::null; } - undoRedoInfo.d->text.insert( 0, cursor->paragraph()->at( cursor->index()-1 ), TRUE ); - undoRedoInfo.index = cursor->index()-1; + int cur_idx = cursor->index(); + const TQTextParagraph *para = cursor->paragraph(); + if (para->at(cur_idx - 1)->c.isLowSurrogate() && cur_idx > 1 && + para->at(cur_idx - 2)->c.isHighSurrogate()) + { + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 1), TRUE ); + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 2), TRUE ); + undoRedoInfo.index = cursor->index() - 2; + } + else + { + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 1), TRUE ); + undoRedoInfo.index = cursor->index() - 1; + } } cursor->removePreviousChar(); lastFormatted = cursor->paragraph(); |
