Sha256: e2696d155c120a249c4e261e5ab02416533a8eff024c793879cecadf0fd16534
Contents?: true
Size: 1011 Bytes
Versions: 3
Compression:
Stored size: 1011 Bytes
Contents
#!/usr/local/bin/ruby require "curses" include Curses def show_message(*msgs) message = msgs.join width = message.length + 6 win = Window.new(5, width, (lines - 5) / 2, (cols - width) / 2) win.keypad = true win.attron(color_pair(COLOR_RED)){ win.box(?|, ?-, ?+) } win.setpos(2, 3) win.addstr(message) win.refresh win.getch win.close end init_screen start_color init_pair(COLOR_BLUE,COLOR_BLUE,COLOR_WHITE) init_pair(COLOR_RED,COLOR_RED,COLOR_WHITE) crmode noecho stdscr.keypad(true) begin mousemask(BUTTON1_CLICKED|BUTTON2_CLICKED|BUTTON3_CLICKED|BUTTON4_CLICKED) setpos((lines - 5) / 2, (cols - 10) / 2) attron(color_pair(COLOR_BLUE)|A_BOLD){ addstr("click") } refresh while( true ) c = getch case c when KEY_MOUSE m = getmouse if( m ) show_message("getch = #{c.inspect}, ", "mouse event = #{'0x%x' % m.bstate}, ", "axis = (#{m.x},#{m.y},#{m.z})") end break end end refresh ensure close_screen end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
curses-1.0.1 | sample/mouse.rb |
rubysl-curses-1.0.0 | lib/curses/mouse.rb |
curses-1.0.0 | sample/mouse.rb |