mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-12-01 14:36:27 +03:00
4362b3cb1c
This commit adds getTtyEraseChar. This function queries the kernel for the current terminal's settings to obtain the character assigned by the "stty erase" command. The "erase" character indicates which input character the terminal should interpret to mean "backspace" when the terminal is in canonical input mode. Vty applications run with canonical mode disabled, but even in those cases some users may want their "stty erase" setting honored by Vty's input-handling so that incoming erase characters (according to stty) result in "KBS" key events being delivered to the application.
19 lines
412 B
C
19 lines
412 B
C
#include <termios.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
|
|
// Given a file descriptor for a terminal, get the ERASE character for
|
|
// the terminal. If the terminal info cannot be obtained, this returns
|
|
// zero.
|
|
char vty_get_tty_erase(int fd)
|
|
{
|
|
struct termios trm;
|
|
|
|
if (0 == tcgetattr(fd, &trm)) {
|
|
return (char) trm.c_cc[VERASE];
|
|
} else {
|
|
return (char) 0;
|
|
}
|
|
}
|