作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] struct termios
时间Tue Oct 20 09:08:06 2009
: 查了一下网路上的资料...
:
: c_lflag &= (~ECHO) 这个应该是 bit splitting 的运算吧?
yes, 就像是我们在 enum 讲义上所说的用法
:
: 然後不要 ECHO 是叫 terminal 不要把输入的字元直接显示出来
: 留待之後的 insertChar 来完成
: --
:
: tcgetattr(...) 和 tcsetattr(...) 是用来读取和设置 terminal 的函式吧?
yes.
: 不过看完之後还是不太懂 ICANON (canonical mode) 是什麽东西
From termios programmer's manual:
ICANON
Enable canonical mode. This enables the special characters EOF, EOL,
EOL2, ERASE, KILL, LNEXT, REPRINT, STATUS, and WERASE, and buffers by lines.
你可以不用管 "enables...." 在说什麽, 重点是 "buffers by lines".
By default ICANON is on, so the input will be buffered by lines.
You can comment that line out and you will see what happens.
: --
:
: 还有是不是那个 c_cc[VMIN]=1 让 cin 在接收到一个 char 之前先 hold 住,
:
: 等到接到一个 char 後就马上存进 operator>> 之後接的变数里?
VMIN
Minimum number of characters for non-canonical read.
Since it is now non-canonical mode, this VMIN defines the minimum number
of characters the buffer will hold before it send to your program.
Yes, c_cc[VMIN]=1 set this minimum to 1.
: --
:
: 还有啊...
:
: charDef.cpp 中的第 25 行
:
: tcgetattr(0,&stored_settings);
:
: 是不是多打了啊?和第 20 行重复且中间看起来好像 stored_settings 也没被改过
啊... 应该是 copy and paste 时弄错了, 可以删掉
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.224.42.151
1F:推 herbert570:实在太感谢 ric 了!!!! 10/20 14:26