librime: commit_history.h Source File

| librime 1.2 Rime Input Method Engine, the core library

commit_history.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2012-04-27 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_COMMIT_HISTORY_H_
8#define RIME_COMMIT_HISTORY_H_
9
10#include <rime/common.h>
11
12namespace rime {
13
14 struct CommitRecord {
15 string type;
16 string text;
17 CommitRecord(const string& a_type, const string& a_text)
18 : type(a_type), text(a_text) {}
19 CommitRecord(int keycode) : type("thru"), text(1, keycode) {}
20};
21
22class KeyEvent;
23class Composition;
24
25 class CommitHistory : public list<CommitRecord> {
26 public:
27 static const size_t kMaxRecords = 20;
28 void Push(const CommitRecord& record);
29 void Push(const KeyEvent& key_event);
30 void Push(const Composition& composition, const string& input);
31 string repr() const;
32 string latest_text() const { return empty() ? string() : back().text; }
33};
34
35} // Namespace rime
36
37#endif // RIME_COMMIT_HISTORY_H_
common.h
rime
Definition algebra.cc:12
rime::CommitRecord
Definition commit_history.h:14
rime::CommitRecord::text
string text
Definition commit_history.h:16
rime::CommitRecord::CommitRecord
CommitRecord(int keycode)
Definition commit_history.h:19
rime::CommitRecord::type
string type
Definition commit_history.h:15
rime::CommitRecord::CommitRecord
CommitRecord(const string &a_type, const string &a_text)
Definition commit_history.h:17
rime::CommitHistory
Definition commit_history.h:25
rime::CommitHistory::Push
void Push(const CommitRecord &record)
Definition commit_history.cc:14
rime::CommitHistory::kMaxRecords
static const size_t kMaxRecords
Definition commit_history.h:27
rime::CommitHistory::repr
string repr() const
Definition commit_history.cc:61
rime::CommitHistory::latest_text
string latest_text() const
Definition commit_history.h:32
rime::Composition
Definition composition.h:21
rime::KeyEvent
Definition key_event.h:17