Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up structure of io/console and avoid stty on Windows.
Fixes #3989. * Restructure the different impls of console into their own files. * Always use stubbed version on Windows. * Cascade from native to stty to stubbed on other platforms.
- Loading branch information
Showing
7 changed files
with
342 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Methods common to all backend impls | ||
class IO | ||
def getch(*) | ||
raw do | ||
getc | ||
end | ||
end | ||
|
||
def getpass(prompt = nil) | ||
wio = self == $stdin ? $stderr : self | ||
wio.write(prompt) if prompt | ||
begin | ||
str = nil | ||
noecho do | ||
str = gets | ||
end | ||
ensure | ||
puts($/) | ||
end | ||
str.chomp | ||
end | ||
|
||
module GenericReadable | ||
def getch(*) | ||
getc | ||
end | ||
|
||
def getpass(prompt = nil) | ||
write(prompt) if prompt | ||
str = gets.chomp | ||
puts($/) | ||
str | ||
end | ||
end | ||
end |
File renamed without changes.
Oops, something went wrong.