福祉支援サービス コミル
コミルは障害をお持ちの方の生活をモノの工夫によって豊かにすることをお手伝いします。
コミルは障害をお持ちの方の生活をモノの工夫によって豊かにすることをお手伝いします。
#!/usr/bin/ruby # # 言ノ葉 ver.0.11 2005/12/01 # (c) H.Mabuchi@comil # require "tk" require "prime/prime" root = TkRoot.new $scanspeed = 10 # スキャンスピード (x0.1秒) $initconvword = %w(吸引 トイレ 痛い かゆい ベッド上 ベッド下) # 未変換時に変換エリアに表示する単文 $sex = 'male' $panelframes = Hash.new # 各文字盤を収めるフレーム $panelorder = Hash.new # 各文字盤のスキャン順 scanlevelmax = 3 scanlevel = 0 # スキャンの深さ 0:待機 1:グループ(例) 2:列(例) 3:行(例) l1_counter = -1 # 各スキャンの深さ毎のスキャン位置 l2_counter = -1 l3_counter = -1 $convmodelist = ['out', 'in'] # 変換モード in/out $convmode = $convmodelist.shift $convstartpos = '1.0' # カーソル位置 $scanordertbl = [] # 文字盤スキャン順の保管テーブル $scanordertbl[0] = [] $prime = Prime.new # 予測変換機能の保持 # 各フレーム内のフォント定義 $editareafont = TkFont.new(['gothic', 40, []]) $convareafont = TkFont.new(['gothic', 40, []]) $panelfont = TkFont.new(['gothic', 40, []]) # 編集画面フレーム editframe = TkFrame.new(root) TkGrid.rowconfigure(editframe, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(editframe, 0, 'weight'=>1, 'minsize'=>0) $editarea = TkText.new(editframe, 'wrap'=>'char', 'font'=>$editareafont, 'width'=>'41', 'height'=>'7' ) yscr = TkScrollbar.new(editframe) Tk.grid($editarea, yscr, 'sticky'=>'news') $editarea.yscrollbar(yscr) # 変換画面フレーム convframe = TkFrame.new(root) $convarea = TkText.new(convframe, 'wrap'=>'word', 'font'=>$convareafont, 'width'=>'41', 'height'=>'3' ).pack('fill'=>'x') # 文字盤画面フレーム panelframe = TkFrame.new(root) # 文字ボタン class KthCharButton < TkButton def initialize(frame, order, scanorder, char) @button = TkButton.new( frame, 'text'=>char, 'font'=>$panelfont, 'background'=>'gray', 'command'=>proc{ if $convmode == 'out' $convstartpos = $editarea.index( 'insert') $convmodelist.push( $convmode) $convmode = $convmodelist.shift end srcwordtag = TkTextTag.new($editarea, "background"=>"green") $editarea.insert( 'insert', char, srcwordtag) $scanordertbl[0]=[] $convarea.delete( '1.0', 'end') $prime.lookup_hybrid( $editarea.get( $convstartpos, 'insert')).each {|x| destbutton = TkButton.new( $convarea, 'text'=>x.to_text_literal, 'command'=>proc{ $editarea.delete( $convstartpos, 'insert') if $convmode == 'in' $convstartpos = 'insert' $convmodelist.push( $convmode) $convmode = $convmodelist.shift end $editarea.insert( 'insert', x.to_text_literal) $prime.learn_word( x.values[0], x.values[1], x.values[2]) $prime.update # $scanordertbl[0] = [] # $convarea.delete( '1.0', 'end') displaymsg }, 'font'=>$convareafont, 'background'=>'yellow' ) $scanordertbl[0] << destbutton TkTextWindow.new( $convarea, 'insert', 'window'=>destbutton) $convarea.insert( 'end', ' ') } } ) # スキャン順の設定 l1, l2, l3 = scanorder l1 -= 1 l2 -= 1 l3 -= 1 if order[l1].nil? then tl2 = [] tl3 = [] tl3[l3] = self tl2[l2] = tl3 order[l1] = tl2 elsif order[l1][l2].nil? then tl3 = [] tl3[l3] = self order[l1][l2] = tl3 else order[l1][l2][l3] = self end @path = @button.path end end class KthSpcCharButton < TkButton SpcCharTbl = { 'daku' => { 'か'=>'が', 'き'=>'ぎ', 'く'=>'ぐ', 'け'=>'げ', 'こ'=>'ご', 'が'=>'か', 'ぎ'=>'き', 'ぐ'=>'く', 'げ'=>'け', 'ご'=>'こ', 'さ'=>'ざ', 'し'=>'じ', 'す'=>'ず', 'せ'=>'ぜ', 'そ'=>'ぞ', 'ざ'=>'さ', 'じ'=>'し', 'ず'=>'す', 'ぜ'=>'せ', 'ぞ'=>'そ', 'た'=>'だ', 'ち'=>'ぢ', 'つ'=>'づ', 'て'=>'で', 'と'=>'ど', 'だ'=>'た', 'ぢ'=>'ち', 'づ'=>'つ', 'で'=>'て', 'ど'=>'と', 'は'=>'ば', 'ひ'=>'び', 'ふ'=>'ぶ', 'へ'=>'べ', 'ほ'=>'ぼ', 'ば'=>'ぱ', 'び'=>'ぴ', 'ぶ'=>'ぷ', 'べ'=>'ぺ', 'ぼ'=>'ぽ', 'ぱ'=>'は', 'ぴ'=>'ひ', 'ぷ'=>'ふ', 'ぺ'=>'へ', 'ぽ'=>'ほ' }, 'handaku' => { 'は'=>'ぱ', 'ひ'=>'ぴ', 'ふ'=>'ぷ', 'へ'=>'ぺ', 'ほ'=>'ぽ', 'ぱ'=>'は', 'ぴ'=>'ひ', 'ぷ'=>'ふ', 'ぺ'=>'へ', 'ぽ'=>'ほ' }, 'sokuyou' => { 'つ'=>'っ', 'や'=>'ゃ', 'ゆ'=>'ゅ', 'よ'=>'ょ', 'っ'=>'つ', 'ゃ'=>'や', 'ゅ'=>'ゆ', 'ょ'=>'よ', 'あ'=>'ぁ', 'い'=>'ぃ', 'う'=>'ぅ', 'え'=>'ぇ', 'お'=>'ぉ', 'ぁ'=>'あ', 'ぃ'=>'い', 'ぅ'=>'う', 'ぇ'=>'え', 'ぉ'=>'お' } } def initialize(f, order, scanorder, char, func) @button = TkButton.new( f, 'text'=>char, 'font'=>$panelfont, 'background'=>'gray', 'command'=>proc{ if $convmode == 'out' $convstartpos = $editarea.index( 'insert') $convmodelist.push( $convmode) $convmode = $convmodelist.shift end sourcechar = $editarea.get('insert - 1 chars') $editarea.delete('insert - 1 chars') srcwordtag = TkTextTag.new($editarea, "background"=>"green") $editarea.insert('insert', SpcCharTbl[func][sourcechar], srcwordtag) $scanordertbl[0]=[] $convarea.delete( '1.0', 'end') $prime.lookup_hybrid( $editarea.get( $convstartpos, 'insert')).each {|x| destbutton = TkButton.new( $convarea, 'text'=>x.to_text_literal, 'command'=>proc{ $editarea.delete( $convstartpos, 'insert') if $convmode == 'in' $convstartpos = 'insert' $convmodelist.push( $convmode) $convmode = $convmodelist.shift end $editarea.insert( 'insert', x.to_text_literal) $prime.learn_word( x.values[0], x.values[1], x.values[2]) $prime.update # $scanordertbl[0]=[] # $convarea.delete( '1.0', 'end') displaymsg }, 'font'=>$convareafont, 'background'=>'yellow' ) $scanordertbl[0] << destbutton TkTextWindow.new( $convarea, 'insert', 'window'=>destbutton) $convarea.insert( 'end', ' ') } } ) # スキャン順の設定 l1, l2, l3 = scanorder l1 -= 1 l2 -= 1 l3 -= 1 if order[l1].nil? then tl2 = [] tl3 = [] tl3[l3] = self tl2[l2] = tl3 order[l1] = tl2 elsif order[l1][l2].nil? then tl3 = [] tl3[l3] = self order[l1][l2] = tl3 else order[l1][l2][l3] = self end @path = @button.path end end class KthFuncButton < TkButton def initialize(f, order, scanorder, char, func) @button = TkButton.new( f, 'text'=>char, 'font'=>$panelfont, 'background'=>'gray', 'command'=>proc{eval(func)} ) # スキャン順の設定 l1, l2, l3 = scanorder l1 -= 1 l2 -= 1 l3 -= 1 if order[l1].nil? then tl2 = [] tl3 = [] tl3[l3] = self tl2[l2] = tl3 order[l1] = tl2 elsif order[l1][l2].nil? then tl3 = [] tl3[l3] = self order[l1][l2] = tl3 else order[l1][l2][l3] = self end @path = @button.path end end class KthChgPnlButton < TkButton def initialize(f, order, scanorder, char, panel) @button = TkButton.new( f, 'text'=>char, 'font'=>$panelfont, 'background'=>'gray', 'command'=>proc{ $panelframes[ panel].raise $scanordertbl = $panelorder[ panel] displaymsg } ) # スキャン順の設定 l1, l2, l3 = scanorder l1 -= 1 l2 -= 1 l3 -= 1 if order[l1].nil? then tl2 = [] tl3 = [] tl3[l3] = self tl2[l2] = tl3 order[l1] = tl2 elsif order[l1][l2].nil? then tl3 = [] tl3[l3] = self order[l1][l2] = tl3 else order[l1][l2][l3] = self end @path = @button.path end end # 音声合成出力 def talk( str) open("| ~/Desktop/koto/galatea-v3.0/SSM/gtalk -C ~/Desktop/koto/galatea-v3.0/SSM/ssm.conf","w") {|io| io.print "set Speaker = #{$sex}01\n" io.print "set Text = #{str}\n" io.print "set Speak = NOW\n" io.print "set Run = EXIT\n" } end # 編集画面の文字列削除 def editareadelete( range) $editarea.delete( range) if $editarea.value.empty? then displaymsg end end # ひらがな文字盤定義 $panelframes['kana'] = TkFrame.new(panelframe) $panelorder['kana'] = [] kanabord = [ [ KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 1, 1], '呼', ''), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 1, 2], '声', 'talk( $editarea.value)'), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 1, 3], '印', ''), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 1, 4], 'テ', ''), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 1, 5], '消', '$editarea.delete(\'1.0\', \'end\');displaymsg') ],[ KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 2, 1], '削', 'editareadelete(\'insert - 1 chars\')'), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 2, 2], '頁', ''), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 2, 3], '改', '$editarea.insert( \'insert\', \'\n\')'), KthChgPnlButton.new($panelframes['kana'], $panelorder['kana'], [2, 2, 4], '英', 'alpha'), KthFuncButton.new($panelframes['kana'], $panelorder['kana'], [2, 2, 5], '終', 'exit') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 3, 1], '1'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 3, 2], '2'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 3, 3], '3'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 3, 4], '4'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 3, 5], '5') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 4, 1], '6'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 4, 2], '7'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 4, 3], '8'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 4, 4], '9'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [2, 4, 5], '0') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 1, 1], 'あ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 1, 2], 'い'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 1, 3], 'う'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 1, 4], 'え'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 1, 5], 'お') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 2, 1], 'か'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 2, 2], 'き'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 2, 3], 'く'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 2, 4], 'け'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 2, 5], 'こ') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 3, 1], 'さ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 3, 2], 'し'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 3, 3], 'す'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 3, 4], 'せ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 3, 5], 'そ') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 4, 1], 'た'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 4, 2], 'ち'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 4, 3], 'つ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 4, 4], 'て'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 4, 5], 'と') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 5, 1], 'な'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 5, 2], 'に'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 5, 3], 'ぬ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 5, 4], 'ね'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [3, 5, 5], 'の') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 1, 1], 'は'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 1, 2], 'ひ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 1, 3], 'ふ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 1, 4], 'へ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 1, 5], 'ほ') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 2, 1], 'ま'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 2, 2], 'み'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 2, 3], 'む'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 2, 4], 'め'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 2, 5], 'も') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 3, 1], 'や'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 3, 2], 'ゆ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 3, 3], 'よ'), KthSpcCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 3, 4], '゛', 'daku'), KthSpcCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 3, 5], '小', 'sokuyou') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 4, 1], 'ら'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 4, 2], 'り'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 4, 3], 'る'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 4, 4], 'れ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 4, 5], 'ろ') ],[ KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 5, 1], 'わ'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 5, 2], 'を'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 5, 3], 'ん'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 5, 4], '、'), KthCharButton.new($panelframes['kana'], $panelorder['kana'], [4, 5, 5], 'ー') ] ] # 英字記号文字盤定義 $panelframes['alpha'] = TkFrame.new(panelframe) $panelorder['alpha'] = [] alphabord = [ [ KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 1, 1], '呼', ''), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 1, 2], '声', 'talk( $editarea.value)'), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 1, 3], '印', ''), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 1, 4], 'テ', ''), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 1, 5], '消', '$editarea.delete(\'1.0\', \'end\');displaymsg') ],[ KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 2, 1], '削', 'editareadelete(\'insert - 1 chars\')'), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 2, 2], '頁', ''), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 2, 3], '改', '$editarea.insert( \'insert\', \'\n\')'), KthChgPnlButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 2, 4], 'ひ', 'kana'), KthFuncButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 2, 5], '終', 'exit') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 3, 1], '1'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 3, 2], '2'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 3, 3], '3'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 3, 4], '4'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 3, 5], '5') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 4, 1], '6'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 4, 2], '7'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 4, 3], '8'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 4, 4], '9'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [2, 4, 5], '0') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 1, 1], '+'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 1, 2], '‐'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 1, 3], '×'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 1, 4], '='), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 1, 5], '*') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 2, 1], '¥'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 2, 2], '%'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 2, 3], '$'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 2, 4], '#'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 2, 5], '~') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 3, 1], '?'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 3, 2], '@'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 3, 3], ':'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 3, 4], ';'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 3, 5], '/') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 4, 1], '('), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 4, 2], ')'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 4, 3], ','), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 4, 4], '.'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 4, 5], ' ') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 5, 1], 'A'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 5, 2], 'B'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 5, 3], 'C'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 5, 4], 'D'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [3, 5, 5], 'E') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 1, 1], 'F'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 1, 2], 'G'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 1, 3], 'H'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 1, 4], 'I'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 1, 5], 'J') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 2, 1], 'K'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 2, 2], 'L'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 2, 3], 'M'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 2, 4], 'N'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 2, 5], 'O') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 3, 1], 'P'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 3, 2], 'Q'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 3, 3], 'R'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 3, 4], 'S'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 3, 5], 'T') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 4, 1], 'U'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 4, 2], 'V'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 4, 3], 'W'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 4, 4], 'X'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 4, 5], 'Y') ],[ KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 5, 1], 'Z'), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 5, 2], ' '), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 5, 3], ' '), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 5, 4], ' '), KthCharButton.new($panelframes['alpha'], $panelorder['alpha'], [4, 5, 5], ' ') ] ] # 各文字盤ボタンの配置 kanabord.each_with_index do |x, i| x.each_with_index do |y, j| y.grid('row'=>j, 'column'=>i) end end alphabord.each_with_index do |x, i| x.each_with_index do |y, j| y.grid('row'=>j, 'column'=>i) end end $scanordertbl = $panelorder[ 'kana'] # 変換エリアに初期表示する単文の表示 def displaymsg $convarea.delete( '1.0', 'end') # $editarea.delete('1.0', 'end') $scanordertbl[0] = [] $initconvword.each {|x| msgbutton = TkButton.new( $convarea, 'text'=>x, 'command'=>proc{ # $editarea.delete( $convstartpos, 'insert') $editarea.insert( 'insert', x) # $scanordertbl[0] = [] # $convarea.delete( '1.0', 'end') displaymsg }, 'font'=>$convareafont, 'background'=>'yellow' ) $scanordertbl[0] << msgbutton TkTextWindow.new( $convarea, 'insert', 'window'=>msgbutton) $convarea.insert( 'end', ' ') } end displaymsg # 各フレームの表示 editframe.pack('fill'=>'both') convframe.pack('fill'=>'x') $panelframes['kana'].pack $panelframes['alpha'].place( 'anchor' => 'nw').lower panelframe.pack # 右クリック(スイッチ入力)の処理 #ev_PushSw = TkVirtualEvent.new( 'ButtonPush-3', 'KeyPush-F11') ev_RelSw = TkVirtualEvent.new( 'ButtonRelease-3', 'KeyRelease-F11') root.bind( ev_RelSw, proc{ case scanlevel when 1 if l1_counter == 0 then $scanordertbl[0].each {|x| x.background('yellow') } elsif not $scanordertbl[l1_counter].nil? then $scanordertbl[l1_counter].each {|x| x.each {|y| y.background('gray') } } end l2_counter = -1 l3_counter = -1 when 2 if l1_counter == 0 then $scanordertbl[0][l2_counter].invoke scanlevel += 1 elsif not $scanordertbl[l1_counter][l2_counter].nil? then $scanordertbl[l1_counter][l2_counter].each {|x| x.background('gray') } end l3_counter = -1 when 3 button = $scanordertbl[l1_counter][l2_counter][l3_counter] if not button.nil? button.flash button.invoke button.background('gray') end l1_counter = -1 l2_counter = -1 l3_counter = -1 end scanlevel += 1 scanlevel = 0 if scanlevel == scanlevelmax + 1 }) root.title('Kotonoha') root.geometry('1024x740+0+0') # スキャン scanproc = TkAfter.new( $scanspeed * 100 , -1, proc{ case scanlevel when 1 if l1_counter == 0 then $scanordertbl[0].each {|x| x.background('yellow') } elsif not $scanordertbl[l1_counter].nil? then $scanordertbl[l1_counter].each {|x| x.each {|y| y.background('gray') } } end l1_counter += 1 l1_counter = 0 if l1_counter == $scanordertbl.size if l1_counter == 0 then $scanordertbl[0].each {|x| x.background('green') } elsif not $scanordertbl[l1_counter].nil? then $scanordertbl[l1_counter].each {|x| x.each {|y| y.background('red') } } end when 2 if l1_counter == 0 then $scanordertbl[0][l2_counter].background('yellow') elsif not $scanordertbl[l1_counter][l2_counter].nil? then $scanordertbl[l1_counter][l2_counter].each {|x| x.background('gray') } end l2_counter += 1 l2_counter = 0 if l2_counter == $scanordertbl[l1_counter].size if l1_counter == 0 then $scanordertbl[0][l2_counter].background('green') elsif not $scanordertbl[l1_counter][l2_counter].nil? then $scanordertbl[l1_counter][l2_counter].each {|x| x.background('red') } end when 3 if not (l1_counter ==0 || $scanordertbl[l1_counter][l2_counter][l3_counter].nil?) then $scanordertbl[l1_counter][l2_counter][l3_counter].background('gray') end l3_counter += 1 l3_counter = 0 if l3_counter == $scanordertbl[l1_counter][l2_counter].size if not (l1_counter ==0 || $scanordertbl[l1_counter][l2_counter][l3_counter].nil?) then $scanordertbl[l1_counter][l2_counter][l3_counter].background('red') end end } ).start # # 設定変更画面 # configsex = TkVariable.new( $sex) configspeed = TkVariable.new( $scanspeed.to_s) configwindow = TkToplevel.new( 'title'=>'Kotonoha Configure') TkLabel.new( configwindow, 'text' => '言ノ葉 設定変更').pack TkLabel.new( configwindow, 'text' => '').pack TkLabel.new( configwindow, 'text' => '読み上げ音声').pack TkRadioButton.new( configwindow, 'text' => '男性', 'value' => 'male', 'variable' => configsex).pack TkRadioButton.new( configwindow, 'text' => '女性', 'value' => 'female', 'variable' => configsex).pack TkLabel.new( configwindow, 'text' => '').pack TkLabel.new( configwindow, 'text' => 'スキャン速度 (×0.1秒)').pack TkScale.new( configwindow, # 'label' => '', 'orient' => 'h', 'from' => '2', 'to' =>'70', 'variable' => configspeed ).pack TkButton.new( configwindow, 'text'=>'適用', 'command'=>proc{ $sex = configsex.value scanproc.stop $scanspeed = configspeed.value.to_i scanproc = TkAfter.new( $scanspeed * 100 , -1, proc{ case scanlevel when 1 if l1_counter == 0 then $scanordertbl[0].each {|x| x.background('yellow') } elsif not $scanordertbl[l1_counter].nil? then $scanordertbl[l1_counter].each {|x| x.each {|y| y.background('gray') } } end l1_counter += 1 l1_counter = 0 if l1_counter == $scanordertbl.size if l1_counter == 0 then $scanordertbl[0].each {|x| x.background('green') } elsif not $scanordertbl[l1_counter].nil? then $scanordertbl[l1_counter].each {|x| x.each {|y| y.background('red') } } end when 2 if l1_counter == 0 then $scanordertbl[0][l2_counter].background('yellow') elsif not $scanordertbl[l1_counter][l2_counter].nil? then $scanordertbl[l1_counter][l2_counter].each {|x| x.background('gray') } end l2_counter += 1 l2_counter = 0 if l2_counter == $scanordertbl[l1_counter].size if l1_counter == 0 then $scanordertbl[0][l2_counter].background('green') elsif not $scanordertbl[l1_counter][l2_counter].nil? then $scanordertbl[l1_counter][l2_counter].each {|x| x.background('red') } end when 3 if not (l1_counter ==0 || $scanordertbl[l1_counter][l2_counter][l3_counter].nil?) then $scanordertbl[l1_counter][l2_counter][l3_counter].background('gray') end l3_counter += 1 l3_counter = 0 if l3_counter == $scanordertbl[l1_counter][l2_counter].size if not (l1_counter ==0 || $scanordertbl[l1_counter][l2_counter][l3_counter].nil?) then $scanordertbl[l1_counter][l2_counter][l3_counter].background('red') end end } ).start }).pack # # スイッチ入力の検出 # # ゲームポート、パラレルポート入力 swpushed = false Thread.start{ open("/dev/js0","r") {|joy| loop { joybutton = joy.read(8) if joybutton[4] == 1 # pushed swpushed = true else # released if swpushed == true Tk.event_generate( root, ev_RelSw) end swpushed = false end } } } # 伝の心形式シリアルポート入力 Tk.mainloop