| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2005 Takuro Ashie |
| 4 |
* Copyright (C) 2012 CSSlayer |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2, or (at your option) |
| 9 |
* any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef __FCITX_ANTHY_KEY2KANA_TABLE_H__ |
| 22 |
#define __FCITX_ANTHY_KEY2KANA_TABLE_H__ |
| 23 |
|
| 24 |
#include <vector> |
| 25 |
#include <string> |
| 26 |
#include "default_tables.h" |
| 27 |
#include "factory.h" |
| 28 |
|
| 29 |
typedef enum { |
| 30 |
FCITX_ANTHY_PERIOD_JAPANESE, |
| 31 |
FCITX_ANTHY_PERIOD_WIDE, |
| 32 |
FCITX_ANTHY_PERIOD_HALF, |
| 33 |
} PeriodStyle; |
| 34 |
|
| 35 |
typedef enum { |
| 36 |
FCITX_ANTHY_COMMA_JAPANESE, |
| 37 |
FCITX_ANTHY_COMMA_WIDE, |
| 38 |
FCITX_ANTHY_COMMA_HALF, |
| 39 |
} CommaStyle; |
| 40 |
|
| 41 |
typedef enum { |
| 42 |
FCITX_ANTHY_BRACKET_JAPANESE, |
| 43 |
FCITX_ANTHY_BRACKET_WIDE, |
| 44 |
} BracketStyle; |
| 45 |
|
| 46 |
typedef enum { |
| 47 |
FCITX_ANTHY_SLASH_JAPANESE, |
| 48 |
FCITX_ANTHY_SLASH_WIDE, |
| 49 |
} SlashStyle; |
| 50 |
|
| 51 |
|
| 52 |
class Key2KanaRule; |
| 53 |
class Key2KanaTable; |
| 54 |
class Key2KanaTableSet; |
| 55 |
|
| 56 |
typedef std::vector<Key2KanaRule> Key2KanaRules; |
| 57 |
|
| 58 |
|
| 59 |
class Key2KanaRule |
| 60 |
{ |
| 61 |
public: |
| 62 |
Key2KanaRule (); |
| 63 |
Key2KanaRule (std::string sequence, |
| 64 |
const std::vector<std::string> &result); |
| 65 |
virtual ~Key2KanaRule (); |
| 66 |
|
| 67 |
std::string get_sequence (void); |
| 68 |
std::string get_result (unsigned int idx); |
| 69 |
|
| 70 |
void clear (void); |
| 71 |
|
| 72 |
bool is_empty (void); |
| 73 |
|
| 74 |
private: |
| 75 |
std::string m_sequence; |
| 76 |
std::vector<std::string> m_result; |
| 77 |
}; |
| 78 |
|
| 79 |
|
| 80 |
class Key2KanaTable |
| 81 |
{ |
| 82 |
public: |
| 83 |
Key2KanaTable (std::string name); |
| 84 |
Key2KanaTable (std::string name, |
| 85 |
ConvRule *table); |
| 86 |
Key2KanaTable (std::string name, |
| 87 |
NicolaRule *table); |
| 88 |
virtual ~Key2KanaTable (); |
| 89 |
|
| 90 |
Key2KanaRules & get_table (void) { return m_rules; } |
| 91 |
|
| 92 |
void append_rule (std::string sequence, |
| 93 |
const std::vector<std::string> &result); |
| 94 |
void append_rule (std::string sequence, |
| 95 |
std::string result, |
| 96 |
std::string cont); |
| 97 |
void append_rule (std::string sequence, |
| 98 |
std::string normal, |
| 99 |
std::string left_shift, |
| 100 |
std::string right_shift); |
| 101 |
void clear (void); |
| 102 |
|
| 103 |
private: |
| 104 |
std::string m_name; |
| 105 |
Key2KanaRules m_rules; |
| 106 |
}; |
| 107 |
|
| 108 |
|
| 109 |
class Key2KanaTableSet |
| 110 |
{ |
| 111 |
public: |
| 112 |
Key2KanaTableSet (); |
| 113 |
virtual ~Key2KanaTableSet (); |
| 114 |
|
| 115 |
std::vector<Key2KanaTable*> & |
| 116 |
get_tables (void) { return m_all_tables; }; |
| 117 |
|
| 118 |
void set_typing_method (TypingMethod method, |
| 119 |
Key2KanaTable *fundamental_table = NULL); |
| 120 |
void set_symbol_width (bool half); |
| 121 |
void set_number_width (bool half); |
| 122 |
void set_period_style (PeriodStyle style); |
| 123 |
void set_comma_style (CommaStyle style); |
| 124 |
void set_bracket_style (BracketStyle style); |
| 125 |
void set_slash_style (SlashStyle style); |
| 126 |
|
| 127 |
TypingMethod |
| 128 |
get_typing_method (void) { return m_typing_method; } |
| 129 |
bool symbol_is_half (void) { return m_use_half_symbol; } |
| 130 |
bool number_is_half (void) { return m_use_half_number;} |
| 131 |
PeriodStyle |
| 132 |
get_period_style (void) { return m_period_style; } |
| 133 |
CommaStyle |
| 134 |
get_comma_style (void) { return m_comma_style; } |
| 135 |
BracketStyle |
| 136 |
get_bracket_style (void) { return m_bracket_style; } |
| 137 |
SlashStyle |
| 138 |
get_slash_style (void) { return m_slash_style; } |
| 139 |
|
| 140 |
#if 0 |
| 141 |
void set_use_consonant_table (bool use); |
| 142 |
void set_use_symbol_table (bool use); |
| 143 |
void set_use_number_table (bool use); |
| 144 |
void set_use_period_table (bool use); |
| 145 |
void set_use_comma_table (bool use); |
| 146 |
|
| 147 |
bool get_use_consonant_table (void); |
| 148 |
bool get_use_symbol_table (void); |
| 149 |
bool get_use_number_table (void); |
| 150 |
bool get_use_period_table (void); |
| 151 |
bool get_use_comma_table (void); |
| 152 |
#endif |
| 153 |
|
| 154 |
private: |
| 155 |
void reset_tables (void); |
| 156 |
|
| 157 |
private: |
| 158 |
std::string m_name; |
| 159 |
|
| 160 |
// tables |
| 161 |
Key2KanaTable *m_fundamental_table; |
| 162 |
Key2KanaTable m_voiced_consonant_table; |
| 163 |
std::vector<Key2KanaTable*> *m_additional_table; |
| 164 |
std::vector<Key2KanaTable*> m_all_tables; |
| 165 |
|
| 166 |
// flags |
| 167 |
TypingMethod m_typing_method; |
| 168 |
PeriodStyle m_period_style; |
| 169 |
CommaStyle m_comma_style; |
| 170 |
BracketStyle m_bracket_style; |
| 171 |
SlashStyle m_slash_style; |
| 172 |
bool m_use_half_symbol; |
| 173 |
bool m_use_half_number; |
| 174 |
}; |
| 175 |
|
| 176 |
#endif /* __FCITX_ANTHY_KEY2KANA_TABLE_H__ */ |
| 177 |
/* |
| 178 |
vi:ts=4:nowrap:ai:expandtab |
| 179 |
*/ |