Ruby/Gtk2 でソフトウェアキーボードを作ってみた。キー入力を選択したウィンドウに送る方法が分からないので、出力は端末にしかできないが、結構快適に入力できる。Rubyでプログラムを書いても十分実用的に使える可能性がある。 ファイル名:softkey.rb (freeware) #!/usr/bin/ruby require 'gtk2' class Button @@repeat = -1 def initialize(id, label, chars) @id = id @label = label @chars = chars @n = chars.length @i = 0 @button = Gtk::Button.new(label) @button.signal_connect("clicked") do if @@repeat == id print "\b", @chars[@i] else @i = 0 print @chars[@i] end @i = (@i + 1) % @n @@repeat = id STDOUT.flush end end attr_reader :button end window = Gtk::Window.new window.signal_connect("delete_event") do Gtk.main_quit end table = Gtk::Table.new(4, 4, true) window.add(table) button0 = Button.new(0," A J ", ['a','j']) button1 = Button.new(1," T K ", ['t','k']) button2 = Button.new(2," S Z ", ['s','z']) button3 = Button.new(3," F V", ['f','v']) button4 = Button.new(4," E X ", ['e','x']) button5 = Button.new(5," M N ", ['m','n']) button6 = Button.new(6," R L ", ['r','l']) button7 = Button.new(7," - ' \" ", ['-',"'",'"']) button8 = Button.new(8," I Y ", ['i','y']) button9 = Button.new(9," H B ", ['h','b']) button10 = Button.new(10," D G ", ['d','g']) button11 = Button.new(11," , . ?", [',','.','?']) button12 = Button.new(12," O P ", ['o','p']) button13 = Button.new(13," U W ", ['u','w']) button14 = Button.new(14," C Q ", ['c','q']) button15 = Button.new(15,';:/\\', [';',':','/','\\']) button16 = Button.new(16," -> ", ['']) button17 = Button.new(17," BS ", ["\b"]) button18 = Button.new(18,"Enter", ["\n"]) button19 = Button.new(19,"Space", [' ']) table.attach_defaults(button0.button,0,1,0,1) table.attach_defaults(button1.button,1,2,0,1) table.attach_defaults(button2.button,2,3,0,1) table.attach_defaults(button3.button,3,4,0,1) table.attach_defaults(button4.button,0,1,1,2) table.attach_defaults(button5.button,1,2,1,2) table.attach_defaults(button6.button,2,3,1,2) table.attach_defaults(button7.button,3,4,1,2) table.attach_defaults(button8.button,0,1,2,3) table.attach_defaults(button9.button,1,2,2,3) table.attach_defaults(button10.button,2,3,2,3) table.attach_defaults(button11.button,3,4,2,3) table.attach_defaults(button12.button,0,1,3,4) table.attach_defaults(button13.button,1,2,3,4) table.attach_defaults(button14.button,2,3,3,4) table.attach_defaults(button15.button,3,4,3,4) table.attach_defaults(button16.button,0,1,4,5) table.attach_defaults(button17.button,1,2,4,5) table.attach_defaults(button18.button,2,3,4,5) table.attach_defaults(button19.button,3,4,4,5) window.show_all Gtk.main
by tnomura9
| 2009-12-19 07:28
| NetWalker
|
Comments(0)
|
カテゴリ
新型コロナウイルス 主インデックス Haskell 記事リスト 圏論記事リスト 考えるということのリスト 考えるということ ラッセルのパラドックス Haskell Prelude Ocaml ボーカロイド 圏論 jQuery デモ HTML Python ツールボックス XAMPP Ruby ubuntu WordPress 脳の話 話のネタ リンク 幸福論 キリスト教 心の話 メモ 電子カルテ Dojo JavaScript C# NetWalker ed と sed HTML Raspberry Pi C 言語 命題論理 以前の記事
最新のトラックバック
最新のコメント
ファン
記事ランキング
ブログジャンル
画像一覧
|
ファン申請 |
||