Nimbin2git.christianimmanuel.de / Tools / typing_10_fingers / test_input.c

typing_10_fingers git · main

git clone https://git.christianimmanuel.de/tools/typing_10_fingers.gitwget https://git.christianimmanuel.de/tools/typing_10_fingers/archive/typing_10_fingers.tar.gz
test_input.c 1.1 KB · 63 lines raw
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include <sys/ioctl.h> // window size
#include <string.h>
#include <time.h>
#include <locale.h>
#include <wchar.h>

wchar_t readChar() {
    struct termios old_settings, new_settings;

    wchar_t c = L'\0';

    tcgetattr(STDIN_FILENO, &old_settings);
    new_settings = old_settings;

    new_settings.c_lflag &= ~(ICANON | ECHO);
    tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);

    c = fgetwc(stdin);
    wprintf(L"\033[1;1H%lc", c);

    tcsetattr(STDIN_FILENO, TCSANOW, &old_settings);

    return c;
}


int main() {
    struct termios old_settings, new_settings;
    setlocale(LC_ALL, "");


    wchar_t c = L'\0';
    /*
    setlocale(LC_ALL, "");

    tcgetattr(STDIN_FILENO, &old_settings);
    new_settings = old_settings;

    new_settings.c_lflag &= ~(ICANON | ECHO);
    tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);

    c = fgetwc(stdin);

    tcsetattr(STDIN_FILENO, TCSANOW, &old_settings);
    
    wprintf(L"|%lc|", c);
    */
    wprintf(L"|%lc|", readChar());
    
    return 1;





    printf("|%c|", c);

    return 0;
}