質問 1:OFILL
フラグは何にtermios_p->c_oflag
使用されますか?
ドキュメントの内容は次のとおりです。
時間遅延を使用するのではなく、遅延のために充填文字を送信します。
これをいじるために、この小さなテスト プログラムを作成しました。
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <termios.h>
int main(int argc, char *argv[])
{
char c;
int res;
struct termios termios_old, termios_new;
res = tcgetattr(0, &termios_old);
assert(res == 0);
termios_new = termios_old;
// Setup the terminal in raw mode
termios_new.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
INLCR | IGNCR | ICRNL | IXON);
termios_new.c_oflag &= ~OPOST;
termios_new.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
termios_new.c_cflag &= ~(CSIZE | PARENB);
termios_new.c_cflag |= CS8;
// Add the flag I'm trying to understand
termios_new.c_oflag |= OFILL; // What is this flag used for?
res = tcsetattr(0, TCSANOW, &termios_new);
assert(res == 0);
while (1) {
read(0, &c, 1);
printf("0x%x %d\r\n", (int)c, (int)c);
if (c == 'q')
break;
}
tcsetattr(0, TCSANOW, &termios_old);
return 0;
}
ESC
プログラムを実行すると、フラグが設定されているかどうかにかかわらず、違いは見られません...このフラグにより、キーが押されたかどうかを検出しやすくなることを望んでいました。
上記のプログラムでは、 を押したLeft-Arrow-key
場合とシーケンス : を押した場合、まったく同じ出力が表示されますESC
[
D
。
質問 2: ユーザーがボタンを押したESC
かどうか、およびユーザーが「左矢印ボタン」を押したかどうかをどのように検出する必要がありますか
これはターミナル IO システムがどのように機能するかを学習する演習であるため、ライブラリは使用したくありません。