Skip to content

Commit

Permalink
feat(context): allow composing with zero input
Browse files Browse the repository at this point in the history
let IsComposing = either input or composition is non-empty.
  • Loading branch information
lotem committed Dec 6, 2021
1 parent dd6af3d commit 8e2826a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/rime/composition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ bool Composition::HasFinishedComposition() const {
Preedit Composition::GetPreedit(const string& full_input, size_t caret_pos,
const string& caret) const {
Preedit preedit;
if (empty()) {
return preedit;
}
preedit.caret_pos = string::npos;
size_t start = 0;
size_t end = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/rime/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ string Context::GetScriptText() const {
return composition_.GetScriptText();
}

static const string kCaretSymbol("\xe2\x80\xb8");
static const string kCaretSymbol("\xe2\x80\xb8"); // U+2038 ‸ CARET

string Context::GetSoftCursor() const {
return get_option("soft_cursor") ? kCaretSymbol : string();
Expand All @@ -43,7 +43,7 @@ Preedit Context::GetPreedit() const {
}

bool Context::IsComposing() const {
return !input_.empty();
return !input_.empty() || !composition_.empty();
}

bool Context::HasMenu() const {
Expand Down
21 changes: 11 additions & 10 deletions src/rime/switcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ void Switcher::HighlightNextSchema() {
```yaml
schema_list:
- case: [mode/wubi, mode/wubi_pinyin]
schema: wubi_pinyin
schema: wubi_pinyin
- case: [mode/wubi]
schema: wubi86
- case: [mode/default]
schema: pinyin
schema: wubi86
- case: [mode/default]
schema: pinyin
mode:
wubi: false
wubi_pinyin: false
default: true
```
mode:
wubi: false
wubi_pinyin: false
default: true
```
*/

static an<ConfigValue> ParseSchemaListEntry(Config* config,
Expand Down Expand Up @@ -224,7 +224,8 @@ void Switcher::OnSelect(Context* ctx) {
void Switcher::RefreshMenu() {
Composition& comp = context_->composition();
if (comp.empty()) {
context_->set_input(" "); // make context_->IsComposing() == true
// no longer need this to make context_->IsComposing() == true
// context_->set_input(" ");
Segment seg(0, 0); // empty range
seg.prompt = caption_;
comp.AddSegment(seg);
Expand Down

0 comments on commit 8e2826a

Please sign in to comment.