Newer
Older
Ruby / cursor.rb
@DOMON Yuki DOMON Yuki on 16 Jan 2022 956 bytes 2022-01-16 21:08:17
#!usr/bin/env ruby
# -*- coding: utf-8 -*-

def hyouzi(x,y,z)
  setpos(x,y)
  addstr (z)
  refresh
end

require 'curses'
include Curses
require 'io/console'

init_screen
cbreak
noecho

begin
  choice = 1
  while true
    hyouzi(2,5,"予定表")
    hyouzi(4,5,"日記")
    if choice == 1
      hyouzi(2,2,"→")
    elsif choice == 2
      hyouzi(4,2,"→")
    end
    while true
      cursor_key1 = STDIN.getch
      if cursor_key1 == "\e"
        cursor_key2 = STDIN.getch
        if cursor_key2 == "["
          cursor_key3 = STDIN.getch
          if cursor_key3 == "A"
            choice = 1
          end
        end
        break
      elsif cursor_key1 = STDIN.getch
        if cursor_key1 == "\e"
          cursor_key2 = STDIN.getch
          if cursor_key2 == "["
            cursor_key3 = STDIN.getch
            if cursor_key3 == "A"
              choice = 2
            end
          end
        end
        break
      end
    end
  end
end