代码
while (1)
{
keycode = key_hook();
if (keycode == SPACE || keycode == BKSPACE)
{
render_again = 1;
}
if (keycode == ESC)
break;
if (render_again)
{
render_again = 0;
render(all);
}
dprintf(1, ""); //I have no idea why this prevents the program from freezing
}
int key_hook()
{
char buffer[4];
read(0, buffer, 4);
return (*(unsigned int *)buffer);
}
好的,所以这段代码处理屏幕上文本的重绘。某些文本行使用 加下划线或突出显示termcaps (tputs(tgetstr("us, NULL")......)
。一切都打印得很好,但是在第一次重绘文本之后,while 显然会冻结,除非 adprintf/printf
存在。该函数只是从 中key_hook
读取并将它们转换为.4 bytes
stdin
int