librime 1.2
Rime Input Method Engine, the core library
ascii_composer.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-12-18 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_ASCII_COMPOSER_H_
8#define RIME_ASCII_COMPOSER_H_
9
10#include <chrono>
11#include <rime/common.h>
12#include <rime/component.h>
13#include <rime/processor.h>
14
15namespace rime {
16
17class Context;
18class Schema;
19
28};
29
30using AsciiModeSwitchKeyBindings = map<int /* keycode */, AsciiModeSwitchStyle>;
31
32class AsciiComposer : public Processor {
33 public:
34 AsciiComposer(const Ticket& ticket);
36
37 virtual ProcessResult ProcessKeyEvent(const KeyEvent& key_event);
38
39 protected:
40 ProcessResult ProcessCapsLock(const KeyEvent& key_event);
41 void LoadConfig(Schema* schema);
42 bool ToggleAsciiModeWithKey(int key_code);
43 void SwitchAsciiMode(bool ascii_mode, AsciiModeSwitchStyle style);
44 void OnContextUpdate(Context* ctx);
45
46 // config options
49 bool good_old_caps_lock_ = false;
50 // state
51 bool toggle_with_caps_ = false;
52 bool shift_key_pressed_ = false;
53 bool ctrl_key_pressed_ = false;
54 bool alt_key_pressed_ = false;
55 bool super_key_pressed_ = false;
56 using TimePoint = std::chrono::steady_clock::time_point;
58 connection connection_;
59};
60
61} // namespace rime
62
63#endif // RIME_ASCII_COMPOSER_H_
Definition algebra.cc:12
map< int, AsciiModeSwitchStyle > AsciiModeSwitchKeyBindings
Definition ascii_composer.h:30
AsciiModeSwitchStyle
Definition ascii_composer.h:20
@ kAsciiModeSwitchCommitCode
Definition ascii_composer.h:24
@ kAsciiModeSet
Definition ascii_composer.h:26
@ kAsciiModeSwitchCommitText
Definition ascii_composer.h:23
@ kAsciiModeUnset
Definition ascii_composer.h:27
@ kAsciiModeSwitchNoop
Definition ascii_composer.h:21
@ kAsciiModeSwitchInline
Definition ascii_composer.h:22
@ kAsciiModeSwitchClear
Definition ascii_composer.h:25
ProcessResult
Definition processor.h:18
Definition context.h:19
AsciiModeSwitchStyle caps_lock_switch_style_
Definition ascii_composer.h:48
bool ctrl_key_pressed_
Definition ascii_composer.h:53
virtual ProcessResult ProcessKeyEvent(const KeyEvent &key_event)
Definition ascii_composer.cc:60
void OnContextUpdate(Context *ctx)
Definition ascii_composer.cc:271
bool ToggleAsciiModeWithKey(int key_code)
Definition ascii_composer.cc:225
AsciiModeSwitchKeyBindings bindings_
Definition ascii_composer.h:47
connection connection_
Definition ascii_composer.h:58
void SwitchAsciiMode(bool ascii_mode, AsciiModeSwitchStyle style)
Definition ascii_composer.cc:243
bool shift_key_pressed_
Definition ascii_composer.h:52
bool super_key_pressed_
Definition ascii_composer.h:55
bool toggle_with_caps_
Definition ascii_composer.h:51
void LoadConfig(Schema *schema)
Definition ascii_composer.cc:188
TimePoint toggle_expired_
Definition ascii_composer.h:57
bool good_old_caps_lock_
Definition ascii_composer.h:49
bool alt_key_pressed_
Definition ascii_composer.h:54
AsciiComposer(const Ticket &ticket)
Definition ascii_composer.cc:52
ProcessResult ProcessCapsLock(const KeyEvent &key_event)
Definition ascii_composer.cc:143
std::chrono::steady_clock::time_point TimePoint
Definition ascii_composer.h:56
Definition key_event.h:17
Processor(const Ticket &ticket)
Definition processor.h:26
Definition schema.h:15
Definition ticket.h:17