12a9127af8
- /names #channel to list users - Ctrl-P/Ctrl-N for page up/down in scrollback - Charset logger (irc.log) with hex dump and detection - chartest.c utility for inspecting key codes - Fix window redraw to align lines at bottom - Fix terminal cleanup via atexit (no more broken terminal) - Green prompt
33 lines
747 B
C
33 lines
747 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <termios.h>
|
|
|
|
int main(void)
|
|
{
|
|
struct termios orig, raw;
|
|
tcgetattr(STDIN_FILENO, &orig);
|
|
raw = orig;
|
|
raw.c_lflag &= ~(ICANON | ECHO);
|
|
raw.c_cc[VMIN] = 1;
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &raw);
|
|
|
|
printf("Press keys (Ctrl-D to quit):\n");
|
|
for (;;) {
|
|
unsigned char c;
|
|
if (read(STDIN_FILENO, &c, 1) <= 0 || c == 0x04)
|
|
break;
|
|
printf(" dec=%3d hex=0x%02X oct=%03o", c, c, c);
|
|
if (c >= 32 && c < 127)
|
|
printf(" char='%c'", c);
|
|
else if (c >= 0xC0)
|
|
printf(" (UTF-8 lead byte, %d-byte seq)",
|
|
c < 0xE0 ? 2 : c < 0xF0 ? 3 : 4);
|
|
else if ((c & 0xC0) == 0x80)
|
|
printf(" (UTF-8 continuation)");
|
|
printf("\n");
|
|
}
|
|
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &orig);
|
|
return 0;
|
|
}
|