{"action":"created","issue":{"url":"https://api.github.com/repos/rime/librime/issues/38","labels_url":"https://api.github.com/repos/rime/librime/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/rime/librime/issues/38/comments","events_url":"https://api.github.com/repos/rime/librime/issues/38/events","html_url":"https://github.com/rime/librime/issues/38","id":85027429,"number":38,"title":"select_candidate只取了首頁，是否要修正爲當前頁？","user":{"login":"osfans","id":7677088,"avatar_url":"https://avatars.githubusercontent.com/u/7677088?v=3","gravatar_id":"","url":"https://api.github.com/users/osfans","html_url":"https://github.com/osfans","followers_url":"https://api.github.com/users/osfans/followers","following_url":"https://api.github.com/users/osfans/following{/other_user}","gists_url":"https://api.github.com/users/osfans/gists{/gist_id}","starred_url":"https://api.github.com/users/osfans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osfans/subscriptions","organizations_url":"https://api.github.com/users/osfans/orgs","repos_url":"https://api.github.com/users/osfans/repos","events_url":"https://api.github.com/users/osfans/events{/privacy}","received_events_url":"https://api.github.com/users/osfans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-04T10:23:48Z","updated_at":"2015-06-05T02:15:52Z","closed_at":null,"body":"這個API在觸屏上很有用，哈哈。\r\n如果不改也不錯，可以從所有候選中選擇。\r\n\r\n```C  \r\n//! select a candidate from current page\r\n  Bool (*select_candidate)(RimeSessionId session_id, size_t index);\r\n\r\nBool RimeSelectCandidate(RimeSessionId session_id, size_t index) {\r\n  rime::shared_ptr<rime::Session> session(rime::Service::instance().GetSession(session_id));\r\n  if (!session)\r\n    return False;\r\n  rime::Context *ctx = session->context();\r\n  if (!ctx)\r\n    return False;\r\n  return Bool(ctx->Select(index));\r\n}\r\n```\r\n\r\n```C\r\nbool Selector::SelectCandidateAt(Context* ctx, int index) {\r\n  Composition& comp = ctx->composition();\r\n  if (comp.empty())\r\n    return false;\r\n  int page_size = engine_->schema()->page_size();\r\n  if (index >= page_size)\r\n    return false;\r\n  int selected_index = comp.back().selected_index;\r\n  int page_start = (selected_index / page_size) * page_size;\r\n  return ctx->Select(page_start + index);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/rime/librime/issues/comments/109131569","html_url":"https://github.com/rime/librime/issues/38#issuecomment-109131569","issue_url":"https://api.github.com/repos/rime/librime/issues/38","id":109131569,"user":{"login":"lotem","id":151157,"avatar_url":"https://avatars.githubusercontent.com/u/151157?v=3","gravatar_id":"","url":"https://api.github.com/users/lotem","html_url":"https://github.com/lotem","followers_url":"https://api.github.com/users/lotem/followers","following_url":"https://api.github.com/users/lotem/following{/other_user}","gists_url":"https://api.github.com/users/lotem/gists{/gist_id}","starred_url":"https://api.github.com/users/lotem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lotem/subscriptions","organizations_url":"https://api.github.com/users/lotem/orgs","repos_url":"https://api.github.com/users/lotem/repos","events_url":"https://api.github.com/users/lotem/events{/privacy}","received_events_url":"https://api.github.com/users/lotem/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T02:15:52Z","updated_at":"2015-06-05T02:15:52Z","body":"大發現。\r\n正好缺少不分頁取得候選的 API（迭代器式的）。那就改成兩組取詞、選詞的 API 好了。"}}