For example, on vim
, when you scroll, it knows to move the cursor up and down, but so far, following this tutorial, scrolling will take you off the page of the editor.
For example, you can note that the following code is unable to catch the scroll action, and the terminal simply scrolls:
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
struct termios orig_termios;
void
disable_raw_mode (void)
{
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void
enable_raw_mode (void)
{
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disable_raw_mode);
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | INPCK | PARMRK | INLCR | IGNCR | ISTRIP | ICRNL | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
raw.c_cflag &= ~(CSIZE | PARENB);
raw.c_cflag |= (CS8);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int
main (void)
{
enable_raw_mode();
char c;
while ( read(STDIN_FILENO, &c, 1) == 1 )
{
if (iscntrl(c))
printf("%d\n", c);
else
printf("%d ('%c')\n", c, c);
}
return 0;
}