| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef _TABLE_CONTEXT_H_ |
| 8 |
#define _TABLE_CONTEXT_H_ |
| 9 |
|
| 10 |
#include "ime.h" |
| 11 |
#include <fcitx/text.h> |
| 12 |
#include <libime/core/prediction.h> |
| 13 |
#include <libime/table/tablecontext.h> |
| 14 |
#include <memory> |
| 15 |
#include <string> |
| 16 |
|
| 17 |
namespace fcitx { |
| 18 |
|
| 19 |
class TableContext : public libime::TableContext { |
| 20 |
public: |
| 21 |
TableContext(libime::TableBasedDictionary &dict, const TableConfig &config, |
| 22 |
libime::UserLanguageModel &model); |
| 23 |
|
| 24 |
const TableConfig &config() { return config_; } |
| 25 |
std::string customHint(const std::string &code) const { |
| 26 |
if (*config_.displayCustomHint) { |
| 27 |
return dict().hint(code); |
| 28 |
} |
| 29 |
return code; |
| 30 |
} |
| 31 |
|
| 32 |
Text preeditText(bool hint, bool clientPreedit) const; |
| 33 |
|
| 34 |
libime::Prediction *prediction() const { |
| 35 |
if (!model().languageModelFile()) { |
| 36 |
return nullptr; |
| 37 |
} |
| 38 |
return prediction_.get(); |
| 39 |
} |
| 40 |
|
| 41 |
private: |
| 42 |
const TableConfig &config_; |
| 43 |
std::unique_ptr<libime::Prediction> prediction_; |
| 44 |
}; |
| 45 |
} |
| 46 |
|
| 47 |
#endif |