1 // 2 // Copyright RIME Developers 3 // Distributed under the BSD License 4 // 5 // 2011-06-19 GONG Chen <chen.sst@gmail.com> 6 // 7 #ifndef RIME_COMPOSITION_H_ 8 #define RIME_COMPOSITION_H_ 9 10 #include <rime/segmentation.h> 11 12 namespace rime { 13 14 struct Preedit { 15 string text; 16 size_t caret_pos = 0; 17 size_t sel_start = 0; 18 size_t sel_end = 0; 19 }; 20 21 class Composition : public Segmentation { 22 public: 23 Composition() = default; 24 25 bool HasFinishedComposition() const; 26 Preedit GetPreedit(const string& full_input, size_t caret_pos, 27 const string& caret) const; 28 string GetPrompt() const; 29 string GetCommitText() const; 30 string GetScriptText() const; 31 string GetDebugText() const; 32 // Returns text of the last segment before the given position. 33 string GetTextBefore(size_t pos) const; 34 }; 35 36 } // namespace rime 37 38 #endif // RIME_COMPOSITION_H_ 39