Method: Textbringer::TCodeInputMethod#mazegaki_relimit_right

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

#mazegaki_relimit_rightObject



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/textbringer/input_methods/t_code_input_method.rb', line 317

def mazegaki_relimit_right
  with_target_buffer do |buffer|
    start_pos = nil
    yomi = nil
    mazegaki_reset
    buffer.save_excursion do
      pos = buffer.point
      buffer.goto_char(@mazegaki_start_pos)
      if @mazegaki_convert_with_inflection && @mazegaki_yomi &&
          (yomi = mazegaki_lookup_yomi(@mazegaki_yomi, true))
        start_pos = @mazegaki_start_pos
      else
        loop do
          break if buffer.point >= pos
          buffer.forward_char
          s = buffer.substring(buffer.point, pos)
          yomi = mazegaki_lookup_yomi(s, @mazegaki_convert_with_inflection)
          if yomi
            start_pos = buffer.point
            break
          end
        end
      end
    end
    if start_pos.nil?
      if !@mazegaki_convert_with_inflection
        start_pos, yomi = find_mazegaki_start_pos(true)
        if start_pos
          @mazegaki_convert_with_inflection = true
        end
      end
      if start_pos.nil?
        message("Can't relimit right")
        start_pos = @mazegaki_start_pos
        yomi = @mazegaki_yomi
      end
    end
    mazegaki_convert(start_pos, yomi)
    Window.redisplay
  end
end