Add color keybind and fix backspace

This commit is contained in:
Mewrry the Kitty 2026-02-10 14:12:26 -06:00
parent 131fef7866
commit e5e0998e2c

View file

@ -287,7 +287,14 @@ def do_client
socket.puts "#{VERSION[:CLN_CO8]}|#{rand(1..7)}" socket.puts "#{VERSION[:CLN_CO8]}|#{rand(1..7)}"
while (char = STDIN.noecho(&:getch)) while (char = STDIN.noecho(&:getch))
exit if char == "\x04" # ^D 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) char2 = STDIN.noecho(&:getch)
if /[A-D]/.match? (char3 = STDIN.noecho(&:getch).upcase) if /[A-D]/.match? (char3 = STDIN.noecho(&:getch).upcase)
socket.puts "#{VERSION[:CLN_ARO]}|#{char3}" socket.puts "#{VERSION[:CLN_ARO]}|#{char3}"
@ -298,6 +305,8 @@ def do_client
elsif (char == "\x08" || # backspace elsif (char == "\x08" || # backspace
char == "\x7F" ) # delete char == "\x7F" ) # delete
socket.puts "#{VERSION[:CLN_ARO]}|D" socket.puts "#{VERSION[:CLN_ARO]}|D"
socket.puts "#{VERSION[:CLN_TXT]}| "
socket.puts "#{VERSION[:CLN_ARO]}|D"
next next
end end
socket.puts "#{VERSION[:CLN_TXT]}|#{clean_chars(char)}" socket.puts "#{VERSION[:CLN_TXT]}|#{clean_chars(char)}"