Use io/console to avoid stty error [ci skip]
This commit is contained in:
parent
faee3b9039
commit
0b767d743f
@ -1,6 +1,8 @@
|
|||||||
#! /usr/bin/ruby -Ku
|
#! /usr/bin/ruby -Ku
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
require 'io/console'
|
||||||
|
|
||||||
class Board
|
class Board
|
||||||
def clr
|
def clr
|
||||||
print "\e[2J"
|
print "\e[2J"
|
||||||
@ -143,8 +145,8 @@ class Board
|
|||||||
end
|
end
|
||||||
|
|
||||||
bd=Board.new(10,10,10)
|
bd=Board.new(10,10,10)
|
||||||
system("stty raw -echo")
|
|
||||||
begin
|
IO.console.raw do
|
||||||
loop do
|
loop do
|
||||||
case STDIN.getc
|
case STDIN.getc
|
||||||
when ?n # new game
|
when ?n # new game
|
||||||
@ -170,7 +172,5 @@ begin
|
|||||||
bd.reset
|
bd.reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
system("stty -raw echo")
|
|
||||||
end
|
end
|
||||||
print "\n"
|
print "\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user