1
/* Copyright (C) 2010~2010 by CSSlayer
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 3 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
#include <sunpinyin.h>
21
* @brief handler called while preedit updated
23
* @param ppd preedit string
26
void FcitxWindowHandler::updatePreedit(const IPreeditString* ppd)
28
char *buf_ = eim->CodeInput;
29
TIConvSrcPtr src = (TIConvSrcPtr) (ppd->string());
30
memset(front_src, 0, BUF_SIZE * sizeof(TWCHAR));
31
memset(end_src, 0, BUF_SIZE * sizeof(TWCHAR));
33
memcpy(front_src, src, ppd->caret() * sizeof(TWCHAR));
34
memcpy(end_src, src + ppd->caret() * sizeof(TWCHAR),
35
(ppd->size() - ppd->caret() + 1) * sizeof(TWCHAR));
37
memset(buf_, 0, MAX_USER_INPUT + 1);
39
WCSTOMBS(buf_, front_src, MAX_USER_INPUT);
40
eim->CaretPos = strlen(buf_);
41
WCSTOMBS(&buf_[strlen(buf_)], end_src, MAX_USER_INPUT);
42
candidate_flag = true;
46
* @brief sunpinyin called this function while updating candidate words
48
* @param pcl candidate list
51
void FcitxWindowHandler::updateCandidates(const ICandidateList* pcl)
54
for (int i = 0, sz = pcl->size(); i < sz; i++) {
55
const TWCHAR* pcand = pcl->candiString(i);
57
TIConvSrcPtr src = (TIConvSrcPtr)(cand_str.c_str());
58
WCSTOMBS(eim->CandTable[i], (const TWCHAR*) src, MAX_CAND_LEN);
61
eim->CandWordCount = pcl->size();
63
candidate_flag = true;
67
* @brief sunpinyin called this function while commit the string
69
* @param str committed string
72
void FcitxWindowHandler::commit(const TWCHAR* str)
74
char *buf_ = eim->StringGet;
75
memset(buf_, 0, MAX_USER_INPUT);
76
WCSTOMBS(buf_, str, MAX_USER_INPUT);