Method: Textbringer::TCodeInputMethod#find_mazegaki_start_pos

Defined in:
lib/textbringer/input_methods/t_code_input_method.rb

#find_mazegaki_start_pos(with_inflection) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/textbringer/input_methods/t_code_input_method.rb', line 180

def find_mazegaki_start_pos(with_inflection)
  with_target_buffer do |buffer|
    buffer.save_excursion do
      pos = buffer.point
      start_pos = nil
      yomi = nil
      MAZEGAKI_MAX_WORD_LEN.times do
        break if buffer.beginning_of_buffer?
        buffer.backward_char
        s = buffer.substring(buffer.point, pos)
        y = mazegaki_lookup_yomi(s, with_inflection)
        if y
          start_pos = buffer.point
          yomi = y
        end
      end
      return start_pos, yomi
    end
  end
end