Skip to content

Commit dad4761

Browse files
fxliangWindyValley
authored andcommitted
feat: clear composition with a abortcomposition notification (rime#1054)
1 parent 54bf793 commit dad4761

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/rime/context.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ void Context::Clear() {
110110
update_notifier_(this);
111111
}
112112

113+
void Context::AbortComposition() {
114+
Clear();
115+
abort_notifier_(this);
116+
}
117+
113118
bool Context::Select(size_t index) {
114119
if (composition_.empty())
115120
return false;

src/rime/context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class RIME_DLL Context {
4141
bool PopInput(size_t len = 1);
4242
bool DeleteInput(size_t len = 1);
4343
void Clear();
44+
// Clear and notify abort
45+
void AbortComposition();
4446

4547
// return false if there is no candidate at index
4648
bool Select(size_t index);
@@ -84,6 +86,7 @@ class RIME_DLL Context {
8486
Notifier& select_notifier() { return select_notifier_; }
8587
Notifier& update_notifier() { return update_notifier_; }
8688
Notifier& delete_notifier() { return delete_notifier_; }
89+
Notifier& abort_notifier() { return abort_notifier_; }
8790
OptionUpdateNotifier& option_update_notifier() {
8891
return option_update_notifier_;
8992
}
@@ -106,6 +109,7 @@ class RIME_DLL Context {
106109
Notifier select_notifier_;
107110
Notifier update_notifier_;
108111
Notifier delete_notifier_;
112+
Notifier abort_notifier_;
109113
OptionUpdateNotifier option_update_notifier_;
110114
PropertyUpdateNotifier property_update_notifier_;
111115
KeyEventNotifier unhandled_key_notifier_;

src/rime/service.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool Session::CommitComposition() {
4545
void Session::ClearComposition() {
4646
if (!engine_)
4747
return;
48-
engine_->context()->Clear();
48+
engine_->context()->AbortComposition();
4949
}
5050

5151
void Session::ApplySchema(Schema* schema) {

0 commit comments

Comments
 (0)