takano32 #6983(2008/08/05 01:08 GMT) [ Ruby ] Rating0/0=0.00
see: curses - Rubyリファレンスマニュアル
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
#!/usr/bin/env ruby require 'curses' lines = ARGF.readlines index = 0 LINES = 10 Curses::init_screen def update(index, lines) (index..index+LINES).each do |l| Curses::stdscr.setpos(l - index, 0) Curses::addstr lines[l] end end def search(index, lines) word = '' while (ch = Curses::getch) != 0x0A do word += ch.chr end (index..(lines.size)).each do |l| if lines[l].match(word) then return l end end return nil end update(index, lines) while ch = Curses::getch do case ch when ?j index += 1 if index < lines.length - LINES when ?k index -= 1 if 0 < index when ?/ index = search(index, lines) || index when ?q break end update(index, lines) end
Rating0/0=0.00-0+
[ reply ]
takano32
#6983()
[
Ruby
]
Rating0/0=0.00
Gentoo Linuxで動作確認してます。
% ruby -v
ruby 1.8.6 (2008-06-20 patchlevel 230) [i686-linux]
less準拠でjk/qが使えます。
see: curses - Rubyリファレンスマニュアル
Rating0/0=0.00-0+
[ reply ]