#!usr/bin/env ruby
# -*- coding: utf-8 -*-


require "curses"
include Curses

init_screen

begin
  x = y = 0
  curs_set(0)
  noecho
  stdscr.keypad(true)
  while 1
    setpos(y,x)
    addch("↓")
    refresh
    c = getch
    setpos(y,x)
    delch
    case c
    when Curses::KEY_UP
      if y > 0
        y -= 1
      end
    when Curses::KEY_DOWN
      if y < lines - 1
        y += 1
      end
    when Curses::KEY_RIGHT
      if x < cols - 1
        x += 1
      end
    when Curses::KEY_LEFT
      if x > 0
        x -= 1
      end
    else
      break
    end
  end
ensure
  close_screen
end
