module BBS::Telnet::LineInput
Line input of a telnet line: readline echoes what the caller types, with Backspace, on an ANSI terminal and a Commodore 64 alike.
Constants
- ERASE
-
Takes back the last character on the callerโs screen: back, space, back.
- MAX_LINE
-
The most bytes
readlinekeeps in a line; further characters are dropped.
Public Instance Methods
Source
# File lib/bbs/telnet/line_input.rb, line 22 def readline(mask: nil) line = +''.b loop do raw = @client.read(1) or return nil byte = telnet_data(raw.ord) or next done = edit_line(line, line_key(byte), mask) return done if done end end
Reads a line typed by the caller, echoing it back, and returns it as a UTF-8 String without the line end (invalid bytes removed), or nil on hangup. Backspace deletes the last character; control characters and bytes beyond MAX_LINE are ignored. ENTER writes a CRLF.
- mask
-
when given, echoed in place of each character (for passwords, e.g.
'*');nilechoes the characters themselves