1 // 2 // Copyright RIME Developers 3 // Distributed under the BSD License 4 // 5 // 2011-10-23 GONG Chen <chen.sst@gmail.com> 6 // 7 #ifndef RIME_EDITOR_H_ 8 #define RIME_EDITOR_H_ 9 10 #include <rime/common.h> 11 #include <rime/component.h> 12 #include <rime/key_event.h> 13 #include <rime/processor.h> 14 #include <rime/gear/key_binding_processor.h> 15 16 namespace rime { 17 18 class Context; 19 20 class Editor : public Processor, public KeyBindingProcessor<Editor> { 21 public: 22 typedef ProcessResult CharHandler(Context* ctx, int ch); 23 using CharHandlerPtr = ProcessResult (Editor::*)(Context* ctx, int ch); 24 25 Editor(const Ticket& ticket, bool auto_commit); 26 ProcessResult ProcessKeyEvent(const KeyEvent& key_event); 27 28 Handler Confirm; 29 Handler ToggleSelection; 30 Handler CommitComment; 31 Handler CommitScriptText; 32 Handler CommitRawInput; 33 Handler CommitComposition; 34 Handler RevertLastEdit; 35 Handler BackToPreviousInput; 36 Handler BackToPreviousSyllable; 37 Handler DeleteCandidate; 38 Handler DeleteChar; 39 Handler CancelComposition; 40 41 CharHandler DirectCommit; 42 CharHandler AddToInput; 43 44 protected: 45 void LoadConfig(); 46 47 CharHandlerPtr char_handler_ = nullptr; 48 }; 49 50 class FluidEditor : public Editor { 51 public: 52 FluidEditor(const Ticket& ticket); 53 }; 54 55 class ExpressEditor : public Editor { 56 public: 57 ExpressEditor(const Ticket& ticket); 58 }; 59 60 } // namespace rime 61 62 #endif // RIME_EDITOR_H_ 63