From c5965c88d9cbc3d900b9fb78fa6025382523e8ca Mon Sep 17 00:00:00 2001 From: Andrew Shadura Date: Tue, 24 Apr 2018 17:35:40 +0200 Subject: New upstream version 1.2.4 --- sample/mouse.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'sample/mouse.rb') diff --git a/sample/mouse.rb b/sample/mouse.rb index 49d4802..92c2b96 100755 --- a/sample/mouse.rb +++ b/sample/mouse.rb @@ -5,13 +5,13 @@ include Curses def show_message(*msgs) message = msgs.join - width = message.length + 6 - win = Window.new(5, width, - (lines - 5) / 2, (cols - width) / 2) + height, width = 5, message.length + 6 + top, left = (lines - height) / 2, (cols - width) / 2 + win = Window.new(height, width, top, left) win.keypad = true - win.attron(color_pair(COLOR_RED)){ - win.box(?|, ?-, ?+) - } + win.attron(color_pair(COLOR_RED)) do + win.box("|", "-", "+") + end win.setpos(2, 3) win.addstr(message) win.refresh @@ -21,28 +21,28 @@ end init_screen start_color -init_pair(COLOR_BLUE,COLOR_BLUE,COLOR_WHITE) -init_pair(COLOR_RED,COLOR_RED,COLOR_WHITE) +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){ + setpos((lines - 1) / 2, (cols - 5) / 2) + attron(color_pair(COLOR_BLUE)|A_BOLD) do addstr("click") - } + end refresh - while( true ) + loop do 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})") + if m + show_message("getch = #{c.inspect}, ", + "mouse event = #{'0x%x' % m.bstate}, ", + "axis = (#{m.x},#{m.y},#{m.z})") end break end -- cgit v1.2.3