librime: navigator.h Source File

| librime 1.2 Rime Input Method Engine, the core library

navigator.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-11-20 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_NAVIGATOR_H_
8#define RIME_NAVIGATOR_H_
9
10#include <rime/common.h>
11#include <rime/component.h>
12#include <rime/processor.h>
13#include <rime/gear/key_binding_processor.h>
14#include <rime/gear/translator_commons.h>
15
16namespace rime {
17
18 class Navigator : public Processor, public KeyBindingProcessor<Navigator, 2> {
19 public:
20 enum TextOrientation {
21 Horizontal = 0,
22 Vertical = 1,
23 };
24 enum SyllableJumpPosition {
25 AfterDelimiter = 0,
26 BeforeDelimiter = 1,
27 };
28
29 explicit Navigator(const Ticket& ticket);
30 virtual ~Navigator();
31
32 ProcessResult ProcessKeyEvent(const KeyEvent& key_event) override;
33
34 Handler Rewind;
35 Handler Forward;
36 Handler LeftByChar;
37 Handler RightByChar;
38 Handler LeftBySyllable;
39 Handler RightBySyllable;
40 Handler Home;
41 Handler End;
42 Handler LeftByCharNoLoop;
43 Handler RightByCharNoLoop;
44 Handler LeftBySyllableNoLoop;
45 Handler RightBySyllableNoLoop;
46
47 private:
48 void BeginMove(Context* ctx);
49 bool JumpLeft(Context* ctx, size_t start_pos = 0, bool loop = false);
50 bool JumpRight(Context* ctx, size_t start_pos = 0, bool loop = false);
51 bool MoveLeft(Context* ctx);
52 bool MoveRight(Context* ctx);
53 bool GoHome(Context* ctx);
54 bool GoToEnd(Context* ctx);
55 void OnSelect(Context*);
56
57 string input_;
58 Spans spans_;
59
60 connection select_connection_;
61
62 private:
63 string delimiters_;
64 SyllableJumpPosition syllable_jump_position_ = AfterDelimiter;
65 size_t ToSpanStart(size_t pos);
66 size_t ToSpanEnd(size_t pos);
67 size_t ToSyllableStart(size_t pos);
68 size_t ToSyllableEnd(size_t pos);
69 size_t SkipDelimiterBackward(size_t pos);
70 size_t SkipDelimiterForward(size_t pos);
71};
72
73} // namespace rime
74
75#endif // RIME_NAVIGATOR_H_
common.h
component.h
processor.h
key_binding_processor.h
translator_commons.h
rime
Definition algebra.cc:12
rime::ProcessResult
ProcessResult
Definition processor.h:18
rime::Context
Definition context.h:19
rime::KeyBindingProcessor< Navigator, 2 >::KeyBindingProcessor
KeyBindingProcessor(ActionDef *action_definitions)
Definition key_binding_processor.h:36
rime::KeyBindingProcessor< Navigator, 2 >::Handler
bool Handler(Context *ctx)
Definition key_binding_processor.h:19
rime::Navigator
Definition navigator.h:18
rime::Navigator::RightByChar
Handler RightByChar
Definition navigator.h:37
rime::Navigator::RightBySyllableNoLoop
Handler RightBySyllableNoLoop
Definition navigator.h:45
rime::Navigator::Navigator
Navigator(const Ticket &ticket)
Definition navigator.cc:36
rime::Navigator::RightByCharNoLoop
Handler RightByCharNoLoop
Definition navigator.h:43
rime::Navigator::RightBySyllable
Handler RightBySyllable
Definition navigator.h:39
rime::Navigator::End
Handler End
Definition navigator.h:41
rime::Navigator::LeftByChar
Handler LeftByChar
Definition navigator.h:36
rime::Navigator::Home
Handler Home
Definition navigator.h:40
rime::Navigator::LeftBySyllable
Handler LeftBySyllable
Definition navigator.h:38
rime::Navigator::SyllableJumpPosition
SyllableJumpPosition
Definition navigator.h:24
rime::Navigator::BeforeDelimiter
@ BeforeDelimiter
Definition navigator.h:26
rime::Navigator::AfterDelimiter
@ AfterDelimiter
Definition navigator.h:25
rime::Navigator::TextOrientation
TextOrientation
Definition navigator.h:20
rime::Navigator::Vertical
@ Vertical
Definition navigator.h:22
rime::Navigator::Horizontal
@ Horizontal
Definition navigator.h:21
rime::Navigator::LeftByCharNoLoop
Handler LeftByCharNoLoop
Definition navigator.h:42
rime::Navigator::ProcessKeyEvent
ProcessResult ProcessKeyEvent(const KeyEvent &key_event) override
Definition navigator.cc:88
rime::Navigator::Forward
Handler Forward
Definition navigator.h:35
rime::Navigator::Rewind
Handler Rewind
Definition navigator.h:34
rime::Navigator::LeftBySyllableNoLoop
Handler LeftBySyllableNoLoop
Definition navigator.h:44
rime::Spans
Definition translator_commons.h:30
rime::KeyEvent
Definition key_event.h:17
rime::Processor::Processor
Processor(const Ticket &ticket)
Definition processor.h:26
rime::Ticket
Definition ticket.h:17