require 'nyle'

class Screen < Nyle::Screen
  def initialize
    super(400, 200, {bgcolor: :IVORY})
  end

  def draw
    stat  = ""
    stat += "[space]"     if Nyle.key_down?(:SPACE)
    stat += "[backspace]" if Nyle.key_down?(:BACKSPACE)
    stat += "[tab]"       if Nyle.key_down?(:TAB)
    stat += "[enter]"     if Nyle.key_down?(:RETURN)
    stat += "[escape]"    if Nyle.key_down?(:ESCAPE)
    stat += "[left]"      if Nyle.key_down?(:LEFT)
    stat += "[up]"        if Nyle.key_down?(:UP)
    stat += "[down]"      if Nyle.key_down?(:DOWN)
    stat += "[right]"     if Nyle.key_down?(:RIGHT)
    stat += "[pageup]"    if Nyle.key_down?(:PAGEUP)
    stat += "[pagedown]"  if Nyle.key_down?(:PAGEDOWN)
    stat += "[insert]"    if Nyle.key_down?(:INSERT)
    stat += "[delete]"    if Nyle.key_down?(:DELETE)
    stat += "[home]"      if Nyle.key_down?(:HOME)
    stat += "[end]"       if Nyle.key_down?(:END)
    stat += "[f1]"        if Nyle.key_down?(:F1)
    stat += "[f2]"        if Nyle.key_down?(:F2)
    stat += "[f3]"        if Nyle.key_down?(:F3)
    stat += "[f4]"        if Nyle.key_down?(:F4)
    stat += "[f5]"        if Nyle.key_down?(:F5)
    stat += "[f6]"        if Nyle.key_down?(:F6)
    stat += "[f7]"        if Nyle.key_down?(:F7)
    stat += "[f8]"        if Nyle.key_down?(:F8)
    stat += "[f9]"        if Nyle.key_down?(:F9)
    stat += "[f10]"       if Nyle.key_down?(:F10)
    stat += "[f11]"       if Nyle.key_down?(:F11)
    stat += "[f12]"       if Nyle.key_down?(:F12)
    stat += "[shift]"     if Nyle.key_down?(:SHIFT)
    stat += "[ctrl]"      if Nyle.key_down?(:CONTROL)
    stat += "[meta]"      if Nyle.key_down?(:META)
    stat += "[alt]"       if Nyle.key_down?(:ALT)
    stat += "[0]"         if Nyle.key_down?(:_0)
    stat += "[1]"         if Nyle.key_down?(:_1)
    stat += "[2]"         if Nyle.key_down?(:_2)
    stat += "[3]"         if Nyle.key_down?(:_3)
    stat += "[4]"         if Nyle.key_down?(:_4)
    stat += "[5]"         if Nyle.key_down?(:_5)
    stat += "[6]"         if Nyle.key_down?(:_6)
    stat += "[7]"         if Nyle.key_down?(:_7)
    stat += "[8]"         if Nyle.key_down?(:_8)
    stat += "[9]"         if Nyle.key_down?(:_9)
    stat += "[a/A]"       if Nyle.key_down?(:A)
    stat += "[b/B]"       if Nyle.key_down?(:B)
    stat += "[c/C]"       if Nyle.key_down?(:C)
    stat += "[d/D]"       if Nyle.key_down?(:D)
    stat += "[e/E]"       if Nyle.key_down?(:E)
    stat += "[f/F]"       if Nyle.key_down?(:F)
    stat += "[g/G]"       if Nyle.key_down?(:G)
    stat += "[h/H]"       if Nyle.key_down?(:H)
    stat += "[i/I]"       if Nyle.key_down?(:I)
    stat += "[j/J]"       if Nyle.key_down?(:J)
    stat += "[k/K]"       if Nyle.key_down?(:K)
    stat += "[l/L]"       if Nyle.key_down?(:L)
    stat += "[m/M]"       if Nyle.key_down?(:M)
    stat += "[n/N]"       if Nyle.key_down?(:N)
    stat += "[o/O]"       if Nyle.key_down?(:O)
    stat += "[p/P]"       if Nyle.key_down?(:P)
    stat += "[q/Q]"       if Nyle.key_down?(:Q)
    stat += "[r/R]"       if Nyle.key_down?(:R)
    stat += "[s/S]"       if Nyle.key_down?(:S)
    stat += "[t/T]"       if Nyle.key_down?(:T)
    stat += "[u/U]"       if Nyle.key_down?(:U)
    stat += "[v/V]"       if Nyle.key_down?(:V)
    stat += "[w/W]"       if Nyle.key_down?(:W)
    stat += "[x/X]"       if Nyle.key_down?(:X)
    stat += "[y/Y]"       if Nyle.key_down?(:Y)
    stat += "[z/Z]"       if Nyle.key_down?(:Z)

    stat += "(shift_l)"   if Nyle.key_down?(KEY_Shift_L)
    stat += "(shift_r)"   if Nyle.key_down?(KEY_Shift_R)
    stat += "(ctrl_l)"    if Nyle.key_down?(KEY_Control_L)
    stat += "(ctrl_r)"    if Nyle.key_down?(KEY_Control_R)
    stat += "(meta_l)"    if Nyle.key_down?(KEY_Meta_L)
    stat += "(meta_r)"    if Nyle.key_down?(KEY_Meta_R)
    stat += "(alt_l)"     if Nyle.key_down?(KEY_Alt_L)
    stat += "(alt_r)"     if Nyle.key_down?(KEY_Alt_R)

    stat += "(A)"         if Nyle.key_down?(KEY_A)
    stat += "(B)"         if Nyle.key_down?(KEY_B)
    stat += "(C)"         if Nyle.key_down?(KEY_C)
    stat += "(D)"         if Nyle.key_down?(KEY_D)
    stat += "(E)"         if Nyle.key_down?(KEY_E)
    stat += "(F)"         if Nyle.key_down?(KEY_F)
    stat += "(G)"         if Nyle.key_down?(KEY_G)
    stat += "(H)"         if Nyle.key_down?(KEY_H)
    stat += "(I)"         if Nyle.key_down?(KEY_I)
    stat += "(J)"         if Nyle.key_down?(KEY_J)
    stat += "(K)"         if Nyle.key_down?(KEY_K)
    stat += "(L)"         if Nyle.key_down?(KEY_L)
    stat += "(M)"         if Nyle.key_down?(KEY_M)
    stat += "(N)"         if Nyle.key_down?(KEY_N)
    stat += "(O)"         if Nyle.key_down?(KEY_O)
    stat += "(P)"         if Nyle.key_down?(KEY_P)
    stat += "(Q)"         if Nyle.key_down?(KEY_Q)
    stat += "(R)"         if Nyle.key_down?(KEY_R)
    stat += "(S)"         if Nyle.key_down?(KEY_S)
    stat += "(T)"         if Nyle.key_down?(KEY_T)
    stat += "(U)"         if Nyle.key_down?(KEY_U)
    stat += "(V)"         if Nyle.key_down?(KEY_V)
    stat += "(W)"         if Nyle.key_down?(KEY_W)
    stat += "(X)"         if Nyle.key_down?(KEY_X)
    stat += "(Y)"         if Nyle.key_down?(KEY_Y)
    stat += "(Z)"         if Nyle.key_down?(KEY_Z)

    stat += "(a)"         if Nyle.key_down?(KEY_a)
    stat += "(b)"         if Nyle.key_down?(KEY_b)
    stat += "(c)"         if Nyle.key_down?(KEY_c)
    stat += "(d)"         if Nyle.key_down?(KEY_d)
    stat += "(e)"         if Nyle.key_down?(KEY_e)
    stat += "(f)"         if Nyle.key_down?(KEY_f)
    stat += "(g)"         if Nyle.key_down?(KEY_g)
    stat += "(h)"         if Nyle.key_down?(KEY_h)
    stat += "(i)"         if Nyle.key_down?(KEY_i)
    stat += "(j)"         if Nyle.key_down?(KEY_j)
    stat += "(k)"         if Nyle.key_down?(KEY_k)
    stat += "(l)"         if Nyle.key_down?(KEY_l)
    stat += "(m)"         if Nyle.key_down?(KEY_m)
    stat += "(n)"         if Nyle.key_down?(KEY_n)
    stat += "(o)"         if Nyle.key_down?(KEY_o)
    stat += "(p)"         if Nyle.key_down?(KEY_p)
    stat += "(q)"         if Nyle.key_down?(KEY_q)
    stat += "(r)"         if Nyle.key_down?(KEY_r)
    stat += "(s)"         if Nyle.key_down?(KEY_s)
    stat += "(t)"         if Nyle.key_down?(KEY_t)
    stat += "(u)"         if Nyle.key_down?(KEY_u)
    stat += "(v)"         if Nyle.key_down?(KEY_v)
    stat += "(w)"         if Nyle.key_down?(KEY_w)
    stat += "(x)"         if Nyle.key_down?(KEY_x)
    stat += "(y)"         if Nyle.key_down?(KEY_y)
    stat += "(z)"         if Nyle.key_down?(KEY_z)

    Nyle.draw_text(10,  60, "Press any key!" , {size: 24})
    Nyle.draw_text(30, 100, stat, {size: 24, color: :FOREST_GREEN})

    Nyle.quit if Nyle.mouse_press?(:R)
  end
end


Screen.new.show_all
Nyle.main

