Add color keybind and fix backspace
This commit is contained in:
parent
131fef7866
commit
e5e0998e2c
1 changed files with 10 additions and 1 deletions
11
mewny.rb
11
mewny.rb
|
|
@ -287,7 +287,14 @@ def do_client
|
|||
socket.puts "#{VERSION[:CLN_CO8]}|#{rand(1..7)}"
|
||||
while (char = STDIN.noecho(&:getch))
|
||||
exit if char == "\x04" # ^D
|
||||
if char == "\x1b" # Detect arrows
|
||||
if char == "\x0F" # (^O) Color change
|
||||
if /[0-7]/.match? (char2 = STDIN.noecho(&:getch).upcase)
|
||||
socket.puts "#{VERSION[:CLN_CO8]}|#{char2}"
|
||||
next
|
||||
else
|
||||
char << char2
|
||||
end
|
||||
elsif char == "\x1b" # Detect arrows
|
||||
char2 = STDIN.noecho(&:getch)
|
||||
if /[A-D]/.match? (char3 = STDIN.noecho(&:getch).upcase)
|
||||
socket.puts "#{VERSION[:CLN_ARO]}|#{char3}"
|
||||
|
|
@ -298,6 +305,8 @@ def do_client
|
|||
elsif (char == "\x08" || # backspace
|
||||
char == "\x7F" ) # delete
|
||||
socket.puts "#{VERSION[:CLN_ARO]}|D"
|
||||
socket.puts "#{VERSION[:CLN_TXT]}| "
|
||||
socket.puts "#{VERSION[:CLN_ARO]}|D"
|
||||
next
|
||||
end
|
||||
socket.puts "#{VERSION[:CLN_TXT]}|#{clean_chars(char)}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue