作者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