delete key의 인식에 대한 질문입니다.
글쓴이: study / 작성시간: 목, 2017/09/21 - 12:32오후
아래와 같은 code를 인터넷 어딘가에서 구해서 시험을 해보고 있었는데요.
Teraterm (VT100)으로 접속해서, 프로그램을 수행하면 delete key를 누를 때 아래의 출력예 1과 같이 7f값이 찍히는데요 .
직접 Console에서 프로그램을 수행하면 delete key를 누를 때 아래의 출력예 2와 같이 1b 5b 33과 같이 escape 문자열이 찍히는 것 같아 보이네요.
이건 왜 이런지, 어떻게 하면 console에서도 7f가 찍히도록 할 수 있는지 몰라서요.
조언 부탁드립니다 !!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
static struct termios tin;
static void terminal_set(void)
{
// save terminal configuration
tcgetattr(STDIN_FILENO, &tin);
static struct termios tlocal;
memcpy(&tlocal, &tin, sizeof(tin));
cfmakeraw(&tlocal);
tcsetattr(STDIN_FILENO,TCSANOW,&tlocal);
}
static void terminal_reset(void)
{
// restore terminal upon exit
tcsetattr(STDIN_FILENO,TCSANOW,&tin);
}
int main(void)
{
unsigned char buf[10];
terminal_set();
atexit(terminal_reset);
while (1)
{
buf[0] = fgetc(stdin);
printf("buf[0] = %x", buf[0]);
if (buf[0] == 0x61)
break;
}
return 0;
}<출력예 1>
$ ./a.out
buf[0] = dbuf[0] = dbuf[0] = 7fbuf[0] = dbuf[0] = 3buf[0] = dbuf[0] = 61
<출력예 2>
$ ./a.out
buf[0] = dbuf[0] = dbuf[0] = dbuf[0] = dbuf[0] = 1bbuf[0] = 5bbuf[0] = 33buf[0] = 7ebuf[0] = 1bbuf[0] = 5bbuf[0] = 33buf[0] = 7e
Forums:


댓글 달기