FreeBASIC  0.91.0
io_inkey.c File Reference
#include "../fb.h"
#include "fb_private_console.h"
#include <termcap.h>
Include dependency graph for io_inkey.c:

Go to the source code of this file.

Data Structures

struct  NODE
 
struct  KEY_DATA
 

Macros

#define KEY_BUFFER_LEN   256
 
#define KEY_MOUSE   0x200
 

Typedefs

typedef struct NODE NODE
 
typedef struct KEY_DATA KEY_DATA
 

Functions

static void add_key (NODE **node, char *key, short code)
 
static void init_keys ()
 
static int get_input ()
 
void fb_hAddCh (int k)
 
int fb_hGetCh (int remove)
 
FBSTRINGfb_ConsoleInkey (void)
 
int fb_ConsoleGetkey (void)
 
int fb_ConsoleKeyHit (void)
 

Variables

static const KEY_DATA key_data []
 
static int key_buffer [KEY_BUFFER_LEN]
 
static int key_head = 0
 
static int key_tail = 0
 
static NODEroot_node = NULL
 

Macro Definition Documentation

#define KEY_BUFFER_LEN   256

Definition at line 12 of file io_inkey.c.

#define KEY_MOUSE   0x200

Definition at line 14 of file io_inkey.c.

Typedef Documentation

typedef struct KEY_DATA KEY_DATA
typedef struct NODE NODE

Function Documentation

static void add_key ( NODE **  node,
char *  key,
short  code 
)
static

This builds a simple tree that allows fairly easy lookup of the terminal escape sequences (keys) that were added. For example:

after adding these key sequences:

    [a1, [a2, [b1, [b2

the tree looks like:  (| = child, - = sibling)

    root -> <[>
             |
            <b>-----------<a>
             |             |
            <2>----<1>    <2>----<1>

Definition at line 59 of file io_inkey.c.

Here is the caller graph for this function:

int fb_ConsoleGetkey ( void  )

Definition at line 244 of file io_inkey.c.

Here is the call graph for this function:

FBSTRING* fb_ConsoleInkey ( void  )

Definition at line 227 of file io_inkey.c.

Here is the call graph for this function:

int fb_ConsoleKeyHit ( void  )

Definition at line 257 of file io_inkey.c.

Here is the call graph for this function:

void fb_hAddCh ( int  k)

Definition at line 195 of file io_inkey.c.

Here is the caller graph for this function:

int fb_hGetCh ( int  remove)

Definition at line 208 of file io_inkey.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_input ( )
static

Definition at line 144 of file io_inkey.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_keys ( )
static

Lookup the terminal escape sequences (termcap database entries) corresponding to the id strings defined in the key_data table above (only key presses here).

For example, the id string "kh" corresponds to the HOME key, and tgetstr("kh", NULL) returns the escape sequence that the terminal will send when the HOME key was pressed.

These typically vary from terminal to terminal (for example TERM=xterm vs. TERM=linux) and perhaps depend on other factors aswell.

Definition at line 99 of file io_inkey.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int key_buffer[KEY_BUFFER_LEN]
static

Definition at line 56 of file io_inkey.c.

const KEY_DATA key_data[]
static
Initial value:
= {
{ "kb", KEY_BACKSPACE },
{ "kT", KEY_TAB },
{ "k1", KEY_F1 },
{ "k2", KEY_F2 },
{ "k3", KEY_F3 },
{ "k4", KEY_F4 },
{ "k5", KEY_F5 },
{ "k6", KEY_F6 },
{ "k7", KEY_F7 },
{ "k8", KEY_F8 },
{ "k9", KEY_F9 },
{ "k;", KEY_F10 },
{ "kh", KEY_HOME },
{ "ku", KEY_UP },
{ "kP", KEY_PAGE_UP },
{ "kl", KEY_LEFT },
{ "kr", KEY_RIGHT },
{ "@7", KEY_END },
{ "kd", KEY_DOWN },
{ "kN", KEY_PAGE_DOWN },
{ "kI", KEY_INS },
{ "kD", KEY_DEL },
{ NULL, 0 }
}

Definition at line 30 of file io_inkey.c.

int key_head = 0
static

Definition at line 56 of file io_inkey.c.

int key_tail = 0
static

Definition at line 56 of file io_inkey.c.

NODE* root_node = NULL
static

Definition at line 57 of file io_inkey.c.