Class: Textbringer::HiraganaInputMethod
- Inherits:
-
InputMethod
- Object
- InputMethod
- Textbringer::HiraganaInputMethod
- Defined in:
- lib/textbringer/input_methods/hiragana_input_method.rb
Constant Summary collapse
- HIRAGANA_TABLE =
{ "a" => "あ", "i" => "い", "u" => "う", "e" => "え", "o" => "お", "ka" => "か", "ki" => "き", "ku" => "く", "ke" => "け", "ko" => "こ", "ga" => "が", "gi" => "ぎ", "gu" => "ぐ", "ge" => "げ", "go" => "ご", "sa" => "さ", "si" => "し", "su" => "す", "se" => "せ", "so" => "そ", "za" => "ざ", "zi" => "じ", "zu" => "ず", "ze" => "ぜ", "zo" => "ぞ", "sha" => "しゃ", "shi" => "し", "shu" => "しゅ", "she" => "しぇ", "sho" => "しょ", "ja" => "じゃ", "ji" => "じ", "ju" => "じゅ", "je" => "じぇ", "jo" => "じょ", "ta" => "た", "ti" => "ち", "tu" => "つ", "te" => "て", "to" => "と", "da" => "だ", "di" => "ぢ", "du" => "づ", "de" => "で", "do" => "ど", "cha" => "ちゃ", "chi" => "ち", "chu" => "ちゅ", "che" => "ちぇ", "cho" => "ちょ", "na" => "な", "ni" => "に", "nu" => "ぬ", "ne" => "ね", "no" => "の", "ha" => "は", "hi" => "ひ", "hu" => "ふ", "he" => "へ", "ho" => "ほ", "ba" => "ば", "bi" => "び", "bu" => "ぶ", "be" => "べ", "bo" => "ぼ", "pa" => "ぱ", "pi" => "ぴ", "pu" => "ぷ", "pe" => "ぺ", "po" => "ぽ", "ma" => "ま", "mi" => "み", "mu" => "む", "me" => "め", "mo" => "も", "ya" => "や", "yi" => "い", "yu" => "ゆ", "ye" => "いぇ", "yo" => "よ", "ra" => "ら", "ri" => "り", "ru" => "る", "re" => "れ", "ro" => "ろ", "wa" => "わ", "wi" => "ゐ", "wu" => "う", "we" => "ゑ", "wo" => "を", "nn" => "ん" }
- HIRAGANA_PREFIXES =
HIRAGANA_TABLE.keys.flat_map { |s| (s.size - 1).times.map { |i| s[0, i + 1] } }.uniq
Constants included from Commands
Commands::CLIPBOARD_AVAILABLE, Commands::CTAGS, Commands::HELP_RING, Commands::ISEARCH_STATUS, Commands::KEYBOARD_MACROS, Commands::REGISTERS, Commands::RE_SEARCH_STATUS
Constants included from Utils
Utils::COMPLETION, Utils::HOOKS
Instance Method Summary collapse
- #flush(s) ⇒ Object
- #handle_event(event) ⇒ Object
-
#initialize ⇒ HiraganaInputMethod
constructor
A new instance of HiraganaInputMethod.
- #status ⇒ Object
Methods inherited from InputMethod
#disable, #enabled?, #filter_event, find, inherited, list, #toggle
Methods included from Commands
[], #command_help, command_table, #current_prefix_arg, define_command, #execute_keyboard_macro, #get_tags, #isearch_done, #isearch_mode, #isearch_mode?, #isearch_pre_command_hook, #isearch_prompt, #isearch_repeat, #isearch_repeat_backward, #isearch_repeat_forward, #isearch_search, #keymap_bindings, list, #match_beginning, #match_end, #match_string, #number_prefix_arg, #prefix_numeric_value, #read_input_method_name, #read_keyboard_macro, #read_register, #replace_match, undefine_command, #universal_argument_mode
Methods included from Utils
add_hook, background, complete_for_minibuffer, foreground, foreground!, message, read_buffer, read_char, read_command_name, read_encoding, read_event, read_expression, read_file_name, read_from_minibuffer, read_key_sequence, read_object, read_single_char, received_keyboard_quit?, remove_hook, ruby_install_name, run_hooks, self_insert_and_exit_minibuffer, set_transient_map, show_exception, sit_for, sleep_for, y_or_n?, yes_or_no?
Constructor Details
#initialize ⇒ HiraganaInputMethod
Returns a new instance of HiraganaInputMethod.
30 31 32 33 |
# File 'lib/textbringer/input_methods/hiragana_input_method.rb', line 30 def initialize super @input_buffer = +"" end |
Instance Method Details
#flush(s) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/textbringer/input_methods/hiragana_input_method.rb', line 57 def flush(s) if !@input_buffer.empty? @input_buffer = +"" end if s.size == 1 s else Buffer.current.insert(s) Window.redisplay nil end end |
#handle_event(event) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/textbringer/input_methods/hiragana_input_method.rb', line 39 def handle_event(event) if !event.is_a?(String) if !@input_buffer.empty? @input_buffer = +"" end return event end @input_buffer << event s = HIRAGANA_TABLE[@input_buffer] if s return flush(s) end if HIRAGANA_PREFIXES.include?(@input_buffer) return nil end flush(@input_buffer) end |
#status ⇒ Object
35 36 37 |
# File 'lib/textbringer/input_methods/hiragana_input_method.rb', line 35 def status "あ" end |