crazyfuturamanoob
July 4th, 2010, 10:49 AM
I want to be able to type faster, so I have used typespeed for practicing before. But I want to make a better typing program, with full unicode support.
I have piece of code to read key presses without waiting for carriage return (got the code from http://groups.google.com/group/comp.os.linux.development/browse_thread/thread/d3d0b4ff5a40dec7):
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
...
static wchar_t get_key()
{
struct termios argin, argout;
wchar_t ch = 0;
tcgetattr( 0,&argin );
argout = argin;
argout.c_lflag &= ~(ICANON);
argout.c_iflag &= ~(ICRNL);
argout.c_oflag &= ~(OPOST);
argout.c_cc[VMIN] = 1;
argout.c_cc[VTIME] = 0;
tcsetattr( 0,TCSADRAIN,&argout );
read( 0, &ch, sizeof(ch) );
tcsetattr( 0,TCSADRAIN,&argin );
return ch;
}
(I don't usually copy-paste-modify code from the internet but I couldn't figure that out myself.)
I have a finnish keyboard, which has keys for ä and ö.
It's not possible to get ä nor ö with the function above (they show up as 뛃 and ꓃).
How to read unicode characters (without waiting for carriage return)?
I have piece of code to read key presses without waiting for carriage return (got the code from http://groups.google.com/group/comp.os.linux.development/browse_thread/thread/d3d0b4ff5a40dec7):
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
...
static wchar_t get_key()
{
struct termios argin, argout;
wchar_t ch = 0;
tcgetattr( 0,&argin );
argout = argin;
argout.c_lflag &= ~(ICANON);
argout.c_iflag &= ~(ICRNL);
argout.c_oflag &= ~(OPOST);
argout.c_cc[VMIN] = 1;
argout.c_cc[VTIME] = 0;
tcsetattr( 0,TCSADRAIN,&argout );
read( 0, &ch, sizeof(ch) );
tcsetattr( 0,TCSADRAIN,&argin );
return ch;
}
(I don't usually copy-paste-modify code from the internet but I couldn't figure that out myself.)
I have a finnish keyboard, which has keys for ä and ö.
It's not possible to get ä nor ö with the function above (they show up as 뛃 and ꓃).
How to read unicode characters (without waiting for carriage return)?