librime: ascii_composer.h Source File

| 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
20 enum AsciiModeSwitchStyle {
21 kAsciiModeSwitchNoop,
22 kAsciiModeSwitchInline,
23 kAsciiModeSwitchCommitText,
24 kAsciiModeSwitchCommitCode,
25 kAsciiModeSwitchClear,
26 kAsciiModeSet,
27 kAsciiModeUnset,
28};
29
30 using AsciiModeSwitchKeyBindings = map<int /* keycode */, AsciiModeSwitchStyle>;
31
32 class AsciiComposer : public Processor {
33 public:
34 AsciiComposer(const Ticket& ticket);
35 ~AsciiComposer();
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
47 AsciiModeSwitchKeyBindings bindings_;
48 AsciiModeSwitchStyle caps_lock_switch_style_ = kAsciiModeSwitchNoop;
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;
57 TimePoint toggle_expired_;
58 connection connection_;
59};
60
61} // namespace rime
62
63#endif // RIME_ASCII_COMPOSER_H_
common.h
component.h
processor.h
rime
Definition algebra.cc:12
rime::AsciiModeSwitchKeyBindings
map< int, AsciiModeSwitchStyle > AsciiModeSwitchKeyBindings
Definition ascii_composer.h:30
rime::AsciiModeSwitchStyle
AsciiModeSwitchStyle
Definition ascii_composer.h:20
rime::kAsciiModeSwitchCommitCode
@ kAsciiModeSwitchCommitCode
Definition ascii_composer.h:24
rime::kAsciiModeSet
@ kAsciiModeSet
Definition ascii_composer.h:26
rime::kAsciiModeSwitchCommitText
@ kAsciiModeSwitchCommitText
Definition ascii_composer.h:23
rime::kAsciiModeUnset
@ kAsciiModeUnset
Definition ascii_composer.h:27
rime::kAsciiModeSwitchNoop
@ kAsciiModeSwitchNoop
Definition ascii_composer.h:21
rime::kAsciiModeSwitchInline
@ kAsciiModeSwitchInline
Definition ascii_composer.h:22
rime::kAsciiModeSwitchClear
@ kAsciiModeSwitchClear
Definition ascii_composer.h:25
rime::ProcessResult
ProcessResult
Definition processor.h:18
rime::Context
Definition context.h:19
rime::AsciiComposer::caps_lock_switch_style_
AsciiModeSwitchStyle caps_lock_switch_style_
Definition ascii_composer.h:48
rime::AsciiComposer::ctrl_key_pressed_
bool ctrl_key_pressed_
Definition ascii_composer.h:53
rime::AsciiComposer::ProcessKeyEvent
virtual ProcessResult ProcessKeyEvent(const KeyEvent &key_event)
Definition ascii_composer.cc:60
rime::AsciiComposer::OnContextUpdate
void OnContextUpdate(Context *ctx)
Definition ascii_composer.cc:271
rime::AsciiComposer::ToggleAsciiModeWithKey
bool ToggleAsciiModeWithKey(int key_code)
Definition ascii_composer.cc:225
rime::AsciiComposer::bindings_
AsciiModeSwitchKeyBindings bindings_
Definition ascii_composer.h:47
rime::AsciiComposer::connection_
connection connection_
Definition ascii_composer.h:58
rime::AsciiComposer::SwitchAsciiMode
void SwitchAsciiMode(bool ascii_mode, AsciiModeSwitchStyle style)
Definition ascii_composer.cc:243
rime::AsciiComposer::shift_key_pressed_
bool shift_key_pressed_
Definition ascii_composer.h:52
rime::AsciiComposer::super_key_pressed_
bool super_key_pressed_
Definition ascii_composer.h:55
rime::AsciiComposer::toggle_with_caps_
bool toggle_with_caps_
Definition ascii_composer.h:51
rime::AsciiComposer::LoadConfig
void LoadConfig(Schema *schema)
Definition ascii_composer.cc:188
rime::AsciiComposer::toggle_expired_
TimePoint toggle_expired_
Definition ascii_composer.h:57
rime::AsciiComposer::good_old_caps_lock_
bool good_old_caps_lock_
Definition ascii_composer.h:49
rime::AsciiComposer::alt_key_pressed_
bool alt_key_pressed_
Definition ascii_composer.h:54
rime::AsciiComposer::AsciiComposer
AsciiComposer(const Ticket &ticket)
Definition ascii_composer.cc:52
rime::AsciiComposer::ProcessCapsLock
ProcessResult ProcessCapsLock(const KeyEvent &key_event)
Definition ascii_composer.cc:143
rime::AsciiComposer::TimePoint
std::chrono::steady_clock::time_point TimePoint
Definition ascii_composer.h:56
rime::KeyEvent
Definition key_event.h:17
rime::Processor::Processor
Processor(const Ticket &ticket)
Definition processor.h:26
rime::Schema
Definition schema.h:15
rime::Ticket
Definition ticket.h:17