-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
-- local kReject = 0 | ||
local kAccepted = 1 | ||
local kNoop = 2 | ||
|
||
local function processor(key_event, env) | ||
local context = env.engine.context | ||
|
||
if (key_event:repr() ~= 'apostrophe') or key_event:release() then | ||
return kNoop | ||
end | ||
|
||
local composition = context.composition | ||
if composition:empty() then return kNoop end | ||
|
||
local segment = composition:back() | ||
local menu = segment.menu | ||
|
||
if menu:candidate_count() < 3 then | ||
env.engine:process_key(KeyEvent("'")) | ||
return kAccepted | ||
end | ||
|
||
local page_size = env.engine.schema.page_size | ||
local selected_index = segment.selected_index | ||
if selected_index >= page_size then | ||
env.engine:process_key(KeyEvent("3")) | ||
return kAccepted | ||
end | ||
|
||
env.engine:process_key(KeyEvent("3")) | ||
return kAccepted | ||
end | ||
|
||
return processor |