From 7f41f6527ffedcfccc16f7e4b93a3048f33cf19e Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sun, 19 Feb 2017 21:13:10 +0800 Subject: [PATCH] fix(chord_composer): allow editor to define BackSpace key behavior --- src/rime/gear/chord_composer.cc | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/rime/gear/chord_composer.cc b/src/rime/gear/chord_composer.cc index 9b4623380..042da3fd2 100644 --- a/src/rime/gear/chord_composer.cc +++ b/src/rime/gear/chord_composer.cc @@ -56,14 +56,7 @@ ProcessResult ChordComposer::ProcessFunctionKey(const KeyEvent& key_event) { raw_sequence_.clear(); } ClearChord(); - } else if (ch == XK_BackSpace) { - // invalidate raw sequence - raw_sequence_.clear(); - ClearChord(); - if (DeleteLastSyllable()) { - return kAccepted; - } - } else if (ch == XK_Escape) { + } else if (ch == XK_BackSpace || ch == XK_Escape) { // clear the raw sequence raw_sequence_.clear(); ClearChord(); @@ -195,26 +188,6 @@ void ChordComposer::ClearChord() { } } -bool ChordComposer::DeleteLastSyllable() { - if (!engine_) - return false; - Context* ctx = engine_->context(); - Composition& comp = ctx->composition(); - const string& input(ctx->input()); - size_t start = comp.empty() ? 0 : comp.back().start; - size_t caret_pos = ctx->caret_pos(); - if (input.empty() || caret_pos <= start) - return false; - size_t deleted = 0; - for (; caret_pos > start; --caret_pos, ++deleted) { - if (deleted > 0 && - delimiter_.find(input[caret_pos - 1]) != string::npos) - break; - } - ctx->PopInput(deleted); - return true; -} - void ChordComposer::OnContextUpdate(Context* ctx) { if (ctx->IsComposing() && ctx->input() != kZeroWidthSpace) { composing_ = true;