class Textbringer::HiraganaInputMethod

Constants

HIRAGANA_PREFIXES
HIRAGANA_TABLE

Public Class Methods

new() click to toggle source
Calls superclass method Textbringer::InputMethod::new
# File lib/textbringer/input_methods/hiragana_input_method.rb, line 30
def initialize
  super
  @input_buffer = +""
end

Public Instance Methods

flush(s) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/textbringer/input_methods/hiragana_input_method.rb, line 35
def status
  "あ"
end