1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#!/usr/bin/env ruby
$KCODE= 'e'
require '../src/suikyo'
class TestSuikyo
def initialize ()
@suikyo = SuikyoComposer.new()
@suikyo.set_table("romaji", "../../conv-table/")
@suikyo.set_reverse_table("romaji_reverse", "../../conv-table/")
end
def edit (string)
if string.index("^") == 0 then
string[1..-1].split(//).each { | command |
case ( command )
when "b" then
@suikyo.cursor_left()
when "a" then
@suikyo.cursor_left_edge()
when "f" then
@suikyo.cursor_right()
when "e" then
@suikyo.cursor_right_edge()
when "h" then
@suikyo.edit_backspace()
when "d" then
@suikyo.edit_delete()
when "1" then
@suikyo.set_mode_default()
when "6" then # F6
@suikyo.set_mode_hiragana()
when "7" then # F7
@suikyo.set_mode_katakana()
when "8" then # F8
@suikyo.set_mode_half_katakana()
when "9" then # F9
@suikyo.set_mode_wide_ascii()
when "0" then # F10
@suikyo.set_mode_raw()
when "-" then
@suikyo.edit_erase()
when "!" then
p @suikyo.edit_get_expansion()
when "=" then
p @suikyo.edit_get_preediting_string()
when "?" then
p @suikyo.edit_get_query_string()
end
}
else
@suikyo.edit_insert(string)
end
@suikyo.edit_display()
end
def main ()
loop {
print "> "
line = $stdin.gets
line.chomp!
edit(line)
}
end
end
test = TestSuikyo.new()
test.main()
|