| 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 |
/* |
| 23 |
* The original code is scim_uim_imengine.cpp in scim-uim-0.1.3. |
| 24 |
* Copyright (C) 2004 James Su <[email protected]> |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef __FCITX_ANTHY_IMENGINE_H__ |
| 28 |
#define __FCITX_ANTHY_IMENGINE_H__ |
| 29 |
|
| 30 |
#include <map> |
| 31 |
#include <anthy/anthy.h> |
| 32 |
#include "preedit.h" |
| 33 |
#include "key2kana_table.h" |
| 34 |
#include "factory.h" |
| 35 |
|
| 36 |
|
| 37 |
struct AnthyStatus { |
| 38 |
const char* icon; |
| 39 |
const char* label; |
| 40 |
const char* description; |
| 41 |
}; |
| 42 |
|
| 43 |
class AnthyInstance |
| 44 |
{ |
| 45 |
public: |
| 46 |
AnthyInstance (FcitxInstance* instance); |
| 47 |
~AnthyInstance (); |
| 48 |
bool load_config(); |
| 49 |
void save_config(); |
| 50 |
|
| 51 |
void configure(); |
| 52 |
|
| 53 |
bool process_key_event (const KeyEvent& key); |
| 54 |
void move_preedit_caret (unsigned int pos); |
| 55 |
void select_candidate (unsigned int item); |
| 56 |
void update_lookup_table_page_size(unsigned int page_size); |
| 57 |
void reset_im (void); |
| 58 |
void reset (void); |
| 59 |
void init (void); |
| 60 |
|
| 61 |
public: |
| 62 |
/* actions */ |
| 63 |
bool action_convert (void); |
| 64 |
bool action_predict (void); |
| 65 |
bool action_revert (void); |
| 66 |
bool action_cancel_all (void); |
| 67 |
bool action_commit_follow_preference (void); |
| 68 |
bool action_commit_reverse_preference (void); |
| 69 |
bool action_commit_first_segment (void); |
| 70 |
bool action_commit_selected_segment (void); |
| 71 |
bool action_commit_first_segment_reverse_preference |
| 72 |
(void); |
| 73 |
bool action_commit_selected_segment_reverse_preference |
| 74 |
(void); |
| 75 |
bool action_back (void); |
| 76 |
bool action_delete (void); |
| 77 |
bool action_insert_space (void); |
| 78 |
bool action_insert_alternative_space (void); |
| 79 |
bool action_insert_half_space (void); |
| 80 |
bool action_insert_wide_space (void); |
| 81 |
|
| 82 |
bool action_move_caret_backward (void); |
| 83 |
bool action_move_caret_forward (void); |
| 84 |
bool action_move_caret_first (void); |
| 85 |
bool action_move_caret_last (void); |
| 86 |
|
| 87 |
bool action_select_prev_segment (void); |
| 88 |
bool action_select_next_segment (void); |
| 89 |
bool action_select_first_segment (void); |
| 90 |
bool action_select_last_segment (void); |
| 91 |
bool action_shrink_segment (void); |
| 92 |
bool action_expand_segment (void); |
| 93 |
|
| 94 |
bool action_select_first_candidate (void); |
| 95 |
bool action_select_last_candidate (void); |
| 96 |
bool action_select_next_candidate (void); |
| 97 |
bool action_select_prev_candidate (void); |
| 98 |
bool action_candidates_page_up (void); |
| 99 |
bool action_candidates_page_down (void); |
| 100 |
|
| 101 |
bool action_convert_to_hiragana (void); |
| 102 |
bool action_convert_to_katakana (void); |
| 103 |
bool action_circle_latin_hiragana_mode (void); |
| 104 |
bool action_convert_to_half (void); |
| 105 |
bool action_convert_to_half_katakana (void); |
| 106 |
bool action_convert_to_latin (void); |
| 107 |
bool action_convert_to_wide_latin (void); |
| 108 |
bool action_convert_char_type_forward (void); |
| 109 |
bool action_convert_char_type_backward (void); |
| 110 |
bool action_reconvert (void); |
| 111 |
|
| 112 |
bool action_circle_input_mode (void); |
| 113 |
bool action_circle_kana_mode (void); |
| 114 |
bool action_circle_typing_method (void); |
| 115 |
|
| 116 |
bool action_latin_mode (void); |
| 117 |
bool action_wide_latin_mode (void); |
| 118 |
bool action_hiragana_mode (void); |
| 119 |
bool action_katakana_mode (void); |
| 120 |
bool action_half_katakana_mode (void); |
| 121 |
bool action_cancel_pseudo_ascii_mode (void); |
| 122 |
|
| 123 |
bool action_add_word (void); |
| 124 |
bool action_launch_dict_admin_tool (void); |
| 125 |
/* |
| 126 |
void actoin_register_word (void); |
| 127 |
*/ |
| 128 |
|
| 129 |
public: |
| 130 |
TypingMethod |
| 131 |
get_typing_method (void); |
| 132 |
InputMode |
| 133 |
get_input_mode (void); |
| 134 |
ConversionMode |
| 135 |
get_conversion_mode (void) { return m_config.m_conversion_mode; } |
| 136 |
PeriodCommaStyle |
| 137 |
get_period_style (void) { return m_config.m_period_comma_style; } |
| 138 |
SymbolStyle |
| 139 |
get_symbol_style (void) { return m_config.m_symbol_style; } |
| 140 |
void set_input_mode (InputMode mode); |
| 141 |
void set_conversion_mode (ConversionMode mode); |
| 142 |
void set_typing_method (TypingMethod method); |
| 143 |
void set_period_style (PeriodCommaStyle period); |
| 144 |
void set_symbol_style (SymbolStyle symbol); |
| 145 |
void update_ui (void); |
| 146 |
|
| 147 |
int get_pseudo_ascii_mode (void); |
| 148 |
FcitxAnthyConfig* get_config() { return &m_config; } |
| 149 |
FcitxInstance* get_owner() { return m_owner; } |
| 150 |
FcitxMessages* get_preedit() { return m_preedit_msg; } |
| 151 |
FcitxMessages* get_client_preedit() { return m_client_preedit_msg; } |
| 152 |
FcitxInputState* get_input() { return m_input; } |
| 153 |
FcitxProfile* get_profile() { return m_profile; } |
| 154 |
bool support_client_preedit(); |
| 155 |
|
| 156 |
const char* get_input_mode_icon(); |
| 157 |
const char* get_typing_method_icon(); |
| 158 |
const char* get_conversion_mode_icon(); |
| 159 |
const char* get_period_style_icon(); |
| 160 |
const char* get_symbol_style_icon(); |
| 161 |
|
| 162 |
const char* get_input_mode_name(); |
| 163 |
|
| 164 |
bool action_select_candidate (unsigned int i); |
| 165 |
void reset_cursor(int cursor); |
| 166 |
void auto_commit(FcitxIMCloseEventType type); |
| 167 |
private: |
| 168 |
/* processing key event */ |
| 169 |
bool process_key_event_input (const KeyEvent &key); |
| 170 |
bool process_key_event_lookup_keybind (const KeyEvent &key); |
| 171 |
bool process_key_event_latin_mode (const KeyEvent &key); |
| 172 |
bool process_key_event_wide_latin_mode (const KeyEvent &key); |
| 173 |
|
| 174 |
/* utility */ |
| 175 |
void set_preedition (void); |
| 176 |
void set_aux_string (void); |
| 177 |
int set_lookup_table (void); |
| 178 |
void unset_lookup_table (void); |
| 179 |
void install_properties (void); |
| 180 |
void set_period_style (PeriodStyle period, |
| 181 |
CommaStyle comma); |
| 182 |
void set_symbol_style (BracketStyle bracket, |
| 183 |
SlashStyle slash); |
| 184 |
bool is_selecting_candidates (void); |
| 185 |
void select_candidate_no_direct (unsigned int item); |
| 186 |
bool convert_kana (CandidateType type); |
| 187 |
|
| 188 |
bool action_commit (bool learn, bool do_real_commit = true); |
| 189 |
|
| 190 |
bool is_single_segment (void); |
| 191 |
bool is_realtime_conversion (void); |
| 192 |
char* get_file_name(const std::string& name); |
| 193 |
|
| 194 |
private: // FIXME! |
| 195 |
bool is_nicola_thumb_shift_key (const KeyEvent &key); |
| 196 |
void commit_string(std::string str); |
| 197 |
void update_aux_string(const std::string& str); |
| 198 |
std::string get_key_profile(); |
| 199 |
std::string get_romaji_table(); |
| 200 |
std::string get_kana_table(); |
| 201 |
std::string get_nicola_table(); |
| 202 |
|
| 203 |
private: |
| 204 |
FcitxInstance* m_owner; |
| 205 |
|
| 206 |
/* for preedit */ |
| 207 |
Preedit m_preedit; |
| 208 |
bool m_preedit_string_visible; |
| 209 |
|
| 210 |
FcitxInputState* m_input; |
| 211 |
|
| 212 |
/* for candidates window */ |
| 213 |
FcitxCandidateWordList* m_lookup_table; |
| 214 |
bool m_lookup_table_visible; |
| 215 |
unsigned int m_n_conv_key_pressed; |
| 216 |
|
| 217 |
/* for toggling latin and wide latin */ |
| 218 |
InputMode m_prev_input_mode; |
| 219 |
|
| 220 |
/* for action */ |
| 221 |
KeyEvent m_last_key; |
| 222 |
|
| 223 |
FcitxAnthyConfig m_config; |
| 224 |
FcitxMessages* m_aux_up; |
| 225 |
FcitxMessages* m_aux_down; |
| 226 |
|
| 227 |
int m_cursor_pos; |
| 228 |
FcitxMessages* m_client_preedit_msg; |
| 229 |
FcitxMessages* m_preedit_msg; |
| 230 |
|
| 231 |
std::map<std::string, Action> m_actions; |
| 232 |
FcitxProfile* m_profile; |
| 233 |
bool m_status_installed; |
| 234 |
|
| 235 |
FcitxUIMenu m_input_mode_menu; |
| 236 |
FcitxUIMenu m_typing_method_menu; |
| 237 |
FcitxUIMenu m_conversion_mode_menu; |
| 238 |
FcitxUIMenu m_period_style_menu; |
| 239 |
FcitxUIMenu m_symbol_style_menu; |
| 240 |
int m_ui_update; |
| 241 |
}; |
| 242 |
#endif /* __FCITX_ANTHY_IMENGINE_H__ */ |
| 243 |
/* |
| 244 |
vi:ts=4:nowrap:ai:expandtab |
| 245 |
*/ |