| 1 |
#ifndef _FCITX5_VARNAM_STATE_H |
| 2 |
#define _FCITX5_VARNAM_STATE_H |
| 3 |
|
| 4 |
#include "varnam_candidate.h" |
| 5 |
|
| 6 |
#include <fcitx/inputcontext.h> |
| 7 |
#include <fcitx/text.h> |
| 8 |
|
| 9 |
extern "C" { |
| 10 |
#include <libgovarnam/libgovarnam.h> |
| 11 |
} |
| 12 |
|
| 13 |
namespace fcitx { |
| 14 |
|
| 15 |
class VarnamEngine; |
| 16 |
|
| 17 |
class VarnamState : public InputContextProperty { |
| 18 |
|
| 19 |
private: |
| 20 |
// Private Variables |
| 21 |
unsigned int cursor; |
| 22 |
char candidateSelected; |
| 23 |
bool lastTypedCharIsDigit; |
| 24 |
|
| 25 |
InputContext *ic_; |
| 26 |
VarnamEngine *engine_; |
| 27 |
Text preedit_; |
| 28 |
|
| 29 |
std::vector<char> buffer_; |
| 30 |
varray *result_; |
| 31 |
|
| 32 |
// Private Methods |
| 33 |
|
| 34 |
// convert buffer to std::string |
| 35 |
std::string bufferToString(); |
| 36 |
|
| 37 |
// generate Varnam Result |
| 38 |
bool getVarnamResult(); |
| 39 |
|
| 40 |
// update Preedit Cursor Position |
| 41 |
void updatePreeditCursor(); |
| 42 |
|
| 43 |
public: |
| 44 |
VarnamState(VarnamEngine *, InputContext &); |
| 45 |
|
| 46 |
~VarnamState(); |
| 47 |
|
| 48 |
// Handle KeyEvents |
| 49 |
void processKeyEvent(KeyEvent &); |
| 50 |
|
| 51 |
// Commit Selected Candidate to text |
| 52 |
void commitText(const FcitxKeySym &key = FcitxKey_None); |
| 53 |
|
| 54 |
// Generate Candidate List/Lookup tables |
| 55 |
void setLookupTable(); |
| 56 |
|
| 57 |
// Update Lookup table entries |
| 58 |
void updateLookupTable(const PageAction &); |
| 59 |
|
| 60 |
// Select Candidate from Candidate List/Lookup Table |
| 61 |
void selectCandidate(int); |
| 62 |
|
| 63 |
// Update Input panel |
| 64 |
void updateUI(); |
| 65 |
|
| 66 |
// Reset context properties |
| 67 |
void reset(); |
| 68 |
}; |
| 69 |
|
| 70 |
} // namespace fcitx |
| 71 |
#endif // end of _FCITX5_VARNAM_STATE_H |