| 1 | //cxx . . $ `<file>/src/rime/gear/chord_composer.h`/ |
| 2 | // Copyright RIME Developers |
| 3 | // Distributed under the BSD License |
| 4 | // |
| 5 | // 2012-06-05 GONG Chen <[email protected]> |
| 6 | // |
| 7 | #ifndef RIME_CHORD_COMPOSER_H_ |
| 8 | #define RIME_CHORD_COMPOSER_H_cxx . . $ `src/rime/gear/chord_composer.h:8:9`! |
| 9 | |
| 10 | #include <rime/common.h>cxx . . $ `<file>/src/rime/common.h`/ |
| 11 | #include <rime/component.h>cxx . . $ `<file>/src/rime/component.h`/ |
| 12 | #include <rime/key_event.h>cxx . . $ `<file>/src/rime/key_event.h`/ |
| 13 | #include <rime/processor.h>cxx . . $ `<file>/src/rime/processor.h`/ |
| 14 | #include <rime/algo/algebra.h>cxx . . $ `<file>/src/rime/algo/algebra.h`/ |
| 15 | #include <rime/gear/key_binding_processor.h>cxx . . $ `<file>/src/rime/gear/key_binding_processor.h`/ |
| 16 | |
| 17 | namespace rimecxx . . $ rime/ { |
| 18 | |
| 19 | using Chordcxx . . $ rime/Chord# = setcxx . . $ rime/set#<int>; |
| 20 | |
| 21 | struct ChordingStatecxx . . $ rime/ChordingState# { |
| 22 | Chordcxx . . $ rime/Chord# pressed_keyscxx . . $ rime/ChordingState#pressed_keys.; |
| 23 | Chordcxx . . $ rime/Chord# recognized_chordcxx . . $ rime/ChordingState#recognized_chord.; |
| 24 | |
| 25 | bool IsPressedcxx . . $ rime/ChordingState#IsPressed(4a668f6de69bf818).(int ch) const { |
| 26 | return pressed_keyscxx . . $ rime/ChordingState#pressed_keys..findcxx . . $ std/set#find(5d7b472851d10a0f).(ch) !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). pressed_keyscxx . . $ rime/ChordingState#pressed_keys..endcxx . . $ std/set#end(3220b82c0db6d2a1).(); |
| 27 | } |
| 28 | |
| 29 | bool PressKeycxx . . $ rime/ChordingState#PressKey(83c267b20bac841a).(int ch) { return pressed_keyscxx . . $ rime/ChordingState#pressed_keys..insertcxx . . $ std/set#insert(411a10a755068dfe).(ch).secondcxx . . $ std/pair#second.; } |
| 30 | |
| 31 | bool ReleaseKeycxx . . $ rime/ChordingState#ReleaseKey(83c267b20bac841a).(int ch) { return pressed_keyscxx . . $ rime/ChordingState#pressed_keys..erasecxx . . $ std/set#erase(3a53bfe100edb289).(ch) != 0; } |
| 32 | |
| 33 | bool AddKeyToChordcxx . . $ rime/ChordingState#AddKeyToChord(83c267b20bac841a).(int ch) { return recognized_chordcxx . . $ rime/ChordingState#recognized_chord..insertcxx . . $ std/set#insert(411a10a755068dfe).(ch).secondcxx . . $ std/pair#second.; } |
| 34 | |
| 35 | void Clearcxx . . $ rime/ChordingState#Clear(49f6e7a06ebc5aa8).() { |
| 36 | pressed_keyscxx . . $ rime/ChordingState#pressed_keys..clearcxx . . $ std/set#clear(ced63f7c635d850d).(); |
| 37 | recognized_chordcxx . . $ rime/ChordingState#recognized_chord..clearcxx . . $ std/set#clear(ced63f7c635d850d).(); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | class ChordComposercxx . . $ rime/ChordComposer# : public Processorcxx . . $ rime/Processor#, |
| 42 | public KeyBindingProcessorcxx . . $ rime/KeyBindingProcessor#<ChordComposercxx . . $ rime/ChordComposer#> { |
| 43 | public: |
| 44 | ChordComposercxx . . $ rime/ChordComposer#ChordComposer(1b3cee102caa60c1).(const Ticketcxx . . $ rime/Ticket#& ticket); |
| 45 | ~cxx . . $ rime/ChordComposer#`~ChordComposer`(ced63f7c635d850d).ChordComposercxx . . $ rime/ChordComposer#(); |
| 46 | |
| 47 | virtual ProcessResultcxx . . $ rime/ProcessResult# ProcessKeyEventcxx . . $ rime/ChordComposer#ProcessKeyEvent(fb7b9b413336ca09).(const KeyEventcxx . . $ rime/KeyEvent#& key_event); |
| 48 | |
| 49 | Handlercxx . . $ rime/KeyBindingProcessor#Handler# CommitRawInputcxx . . $ rime/ChordComposer#CommitRawInput(ff5bc1b8e13497ec).; |
| 50 | |
| 51 | protected: |
| 52 | bool FinishChordConditionIsMetcxx . . $ rime/ChordComposer#FinishChordConditionIsMet(50ce9a9e25b4a850).() const; |
| 53 | ProcessResultcxx . . $ rime/ProcessResult# ProcessChordingKeycxx . . $ rime/ChordComposer#ProcessChordingKey(fb7b9b413336ca09).(const KeyEventcxx . . $ rime/KeyEvent#& key_event); |
| 54 | ProcessResultcxx . . $ rime/ProcessResult# ProcessFunctionKeycxx . . $ rime/ChordComposer#ProcessFunctionKey(fb7b9b413336ca09).(const KeyEventcxx . . $ rime/KeyEvent#& key_event); |
| 55 | stringcxx . . $ rime/string# SerializeChordcxx . . $ rime/ChordComposer#SerializeChord(2e364e6d070b1dda).(const Chordcxx . . $ rime/Chord#& chord); |
| 56 | void UpdateChordcxx . . $ rime/ChordComposer#UpdateChord(7fdd4ba9c62c643a).(const Chordcxx . . $ rime/Chord#& chord); |
| 57 | void FinishChordcxx . . $ rime/ChordComposer#FinishChord(7fdd4ba9c62c643a).(const Chordcxx . . $ rime/Chord#& chord); |
| 58 | void ClearChordcxx . . $ rime/ChordComposer#ClearChord(49f6e7a06ebc5aa8).(); |
| 59 | bool DeleteLastSyllablecxx . . $ rime/ChordComposer#DeleteLastSyllable(c9857a73d68e59ba).(); |
| 60 | void OnContextUpdatecxx . . $ rime/ChordComposer#OnContextUpdate(7157cea0da45bf75).(Contextcxx . . $ rime/Context#* ctx); |
| 61 | void OnUnhandledKeycxx . . $ rime/ChordComposer#OnUnhandledKey(1b145f2211976797).(Contextcxx . . $ rime/Context#* ctx, const KeyEventcxx . . $ rime/KeyEvent#& key); |
| 62 | |
| 63 | KeySequencecxx . . $ rime/KeySequence# chording_keys_cxx . . $ rime/ChordComposer#chording_keys_.; |
| 64 | stringcxx . . $ rime/string# delimiter_cxx . . $ rime/ChordComposer#delimiter_.; |
| 65 | Projectioncxx . . $ rime/Projection# algebra_cxx . . $ rime/ChordComposer#algebra_.; |
| 66 | Projectioncxx . . $ rime/Projection# output_format_cxx . . $ rime/ChordComposer#output_format_.; |
| 67 | Projectioncxx . . $ rime/Projection# prompt_format_cxx . . $ rime/ChordComposer#prompt_format_.; |
| 68 | bool use_control_cxx . . $ rime/ChordComposer#use_control_. = false; |
| 69 | bool use_alt_cxx . . $ rime/ChordComposer#use_alt_. = false; |
| 70 | bool use_shift_cxx . . $ rime/ChordComposer#use_shift_. = false; |
| 71 | bool use_super_cxx . . $ rime/ChordComposer#use_super_. = false; |
| 72 | bool use_caps_cxx . . $ rime/ChordComposer#use_caps_. = false; |
| 73 | bool finish_chord_on_first_key_release_cxx . . $ rime/ChordComposer#finish_chord_on_first_key_release_. = false; |
| 74 | |
| 75 | ChordingStatecxx . . $ rime/ChordingState# state_cxx . . $ rime/ChordComposer#state_.; |
| 76 | bool editing_chord_cxx . . $ rime/ChordComposer#editing_chord_. = false; |
| 77 | bool sending_chord_cxx . . $ rime/ChordComposer#sending_chord_. = false; |
| 78 | bool composing_cxx . . $ rime/ChordComposer#composing_. = false; |
| 79 | stringcxx . . $ rime/string# raw_sequence_cxx . . $ rime/ChordComposer#raw_sequence_.; |
| 80 | connectioncxx . . $ rime/connection# update_connection_cxx . . $ rime/ChordComposer#update_connection_.; |
| 81 | connectioncxx . . $ rime/connection# unhandled_key_connection_cxx . . $ rime/ChordComposer#unhandled_key_connection_.; |
| 82 | }; |
| 83 | |
| 84 | } // namespace rime |
| 85 | |
| 86 | #endif // RIME_CHORD_COMPOSER_H_ |