Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add IO#raw! and IO#cooked! to io/console.rb
- Loading branch information
Showing
4 changed files
with
89 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
class IO | ||
# Indexes for termios list. | ||
IFLAG = 0 | ||
OFLAG = 1 | ||
CFLAG = 2 | ||
LFLAG = 3 | ||
ISPEED = 4 | ||
OSPEED = 5 | ||
CC = 6 | ||
include Topaz::TermIOConstants | ||
|
||
# def raw | ||
# end | ||
|
||
def raw!(&block) | ||
mode = Topaz.tcgetattr(fileno) | ||
mode[IFLAG] = mode[IFLAG] & ~(IGNBRK | BRKINT | PARMRK | ISTRIP | ICRNL | | ||
IXON) | ||
mode[OFLAG] = mode[OFLAG] & ~(OPOST) | ||
mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB) | ||
mode[CFLAG] = mode[CFLAG] | CS8 | ||
mode[LFLAG] = mode[LFLAG] & ~(ECHO | ECHOE | ECHOK | ECHONL | ICANON | ISIG | | ||
IEXTEN) | ||
Topaz.tcsetattr(fileno, TCSANOW, mode) | ||
if block | ||
begin | ||
block[] | ||
ensure | ||
cooked! | ||
end | ||
end | ||
end | ||
|
||
# def cooked | ||
# end | ||
|
||
def cooked! | ||
mode = Topaz.tcgetattr(fileno) | ||
mode[IFLAG] = mode[IFLAG] | (BRKINT | ISTRIP | ICRNL | IXON) | ||
mode[OFLAG] = mode[OFLAG] | OPOST | ||
mode[LFLAG] = mode[LFLAG] | (ECHO | ECHOE | ECHOK | ECHONL | ICANON | ISIG | | ||
IEXTEN) | ||
Topaz.tcsetattr(fileno, TCSANOW, mode) | ||
end | ||
|
||
# def getch | ||
# end | ||
|
||
# def echo= | ||
# end | ||
|
||
# def echo | ||
# end | ||
|
||
# def echo? | ||
# end | ||
|
||
# def noecho | ||
# end | ||
|
||
# def winsize | ||
# end | ||
|
||
# def winsize= | ||
# end | ||
|
||
# def iflush | ||
# end | ||
|
||
# def oflush | ||
# end | ||
|
||
# def ioflush | ||
# end | ||
|
||
# def self.console | ||
# end | ||
|
||
# module Readable | ||
# alias getch getc | ||
# end | ||
end |
Empty file.
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
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