Bugz Door Project
|
Key and door input routines. More...
#include <iostream>
#include <termios.h>
#include <unistd.h>
#include "door.h"
#include <signal.h>
#include <ctype.h>
Macros | |
#define | CRNL "\r\n" |
used by output routines. More... | |
Functions | |
void | raw (void) |
Enable terminal raw mode. More... | |
void | reset (void) |
Reset the terminal termios to the original values. | |
signed int | getch (void) |
low level getch key read More... | |
void | unget (char c) |
ungets (pushes key back) More... | |
char | get (void) |
get a key from the pushback buffer. More... | |
signed int | getkey (void) |
high level getkey More... | |
Variables | |
struct termios | tio_default |
Original terminal termios defaults. | |
char | buffer [10] |
pushback buffer to store keys we're not ready for yet. | |
int | bpos = 0 |
pushback buffer position | |
Key and door input routines.
#define CRNL "\r\n" |
used by output routines.
Sending "\n" isn't enough.
char get | ( | void | ) |
get a key from the pushback buffer.
signed int getch | ( | void | ) |
low level getch key read
This reads a key with a defined timeout value. This is called by other routines to handle arrow keys, F-keys. returns -1 on timeout (no key), -2 on error (connection closed)
signed int getkey | ( | void | ) |
high level getkey
This returns function keys, arrow keys, see XKEY_* defines. returns -1 (no key avaiable) or -2 (hangup) or XKEY_UNKNOWN (don't know what it is)
void raw | ( | void | ) |
Enable terminal raw mode.
This sets up the linux console so the door library will work correctly in local mode.
void unget | ( | char | c | ) |
ungets (pushes key back)
If we read ahead, and we can't use it, we push it back into the buffer for next time.
c |