Debian Codegraph @

src/nicola.h

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Copyright (C) 2004 Hiroyuki Ikezoe
4 * Copyright (C) 2004 Takuro Ashie
5 * Copyright (C) 2012 CSSlayer
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22 #ifndef __FCITX_ANTHY_NICOLA_H__
23 #define __FCITX_ANTHY_NICOLA_H__
24
25 #include <sys/time.h>
26 #include <stdint.h>
27
28 #include "key2kana_base.h"
29 #include "key2kana_table.h"
30
31 class AnthyInstance;
32
33 typedef enum {
34 FCITX_ANTHY_NICOLA_SHIFT_NONE,
35 FCITX_ANTHY_NICOLA_SHIFT_LEFT,
36 FCITX_ANTHY_NICOLA_SHIFT_RIGHT,
37 } NicolaShiftType;
38
39 class NicolaConvertor : public Key2KanaConvertorBase
40 {
41 public:
42 NicolaConvertor (AnthyInstance & anthy,
43 Key2KanaTableSet & tables);
44 virtual ~NicolaConvertor ();
45
46 bool can_append (const KeyEvent& key,
47 bool ignore_space = false);
48 bool append (const KeyEvent& key,
49 std::string & result,
50 std::string & pending,
51 std::string & raw);
52 bool append (const std::string & raw,
53 std::string & result,
54 std::string & pending);
55 void clear (void);
56
57 bool is_pending (void);
58 std::string get_pending (void);
59 std::string flush_pending (void);
60 void reset_pending (const std::string & result,
61 const std::string & raw);
62
63 public:
64 void process_timeout (void);
65
66 private:
67 void search (const KeyEvent& key,
68 NicolaShiftType shift_type,
69 std::string & result,
70 std::string & raw);
71 bool handle_voiced_consonant (std::string & result,
72 std::string & pending);
73 bool is_char_key (const KeyEvent& key);
74 bool is_thumb_key (const KeyEvent& key);
75 bool is_left_thumb_key (const KeyEvent& key);
76 bool is_right_thumb_key (const KeyEvent& key);
77 NicolaShiftType
78 get_thumb_key_type (const KeyEvent& key);
79 bool emit_key_event (const KeyEvent& key);
80 void set_alarm (int time_msec);
81 bool stop();
82 int thumb_key ( const KeyEvent& key);
83
84 private:
85 Key2KanaTableSet &m_tables;
86
87 AnthyInstance &m_anthy;
88
89 // state
90 KeyEvent m_prev_char_key;
91
92 KeyEvent m_repeat_char_key;
93
94 uint32_t m_timer_id;
95 bool m_processing_timeout;
96
97 std::string m_pending;
98 KeyEvent m_through_key_event;
99 KeyEvent m_repeat_thumb_key;
100 KeyEvent m_prev_thumb_key;
101 };
102
103 #endif /* __FCITX_ANTHY_NICOLA_H__ */
104 /*
105 vi:ts=4:nowrap:ai:expandtab
106 */