ELinks 0.18.0
kbd.h File Reference
#include "intl/charsets.h"
Include dependency graph for kbd.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  term_event_keyboard
 A key received from a terminal, with modifiers. More...
 Like struct term_event_keyboard but used in the interlink protocol between ELinks processes. More...

Macros

#define MAX_TERM_LEN   32 /* this must be multiple of 8! (alignment problems) */
#define MAX_CWD_LEN   256 /* this must be multiple of 8! (alignment problems) */
#define number_to_kbd_fkey(num)
#define kbd_fkey_to_number(key)
#define is_kbd_character(key)
 Check whether key is a character or a special key.
#define kbd_get_key(kbd_)
#define kbd_key_is(kbd_, key)
#define kbd_get_modifier(kbd_)
#define kbd_modifier_is(kbd_, mod)
#define kbd_set(kbd_, key_, modifier_)

Typedefs

typedef unicode_val_T term_event_char_T
 A character received from a terminal.
typedef int32_t term_event_key_T
 A key received from a terminal, without modifiers.
typedef unsigned char term_event_modifier_T

Enumerations

enum  term_event_modifier {
  KBD_MOD_NONE = 0 , KBD_MOD_SHIFT = 1 , KBD_MOD_CTRL = 2 , KBD_MOD_ALT = 4 ,
  KBD_MOD_PASTE = 8
}
 Values for term_event_keyboard.modifier and interlink_event_keyboard.modifier. More...
enum  term_event_special_key {
  KBD_UNDEF = -1 , KBD_ENTER = -0x100 , KBD_BS = -0x101 , KBD_TAB = -0x102 ,
  KBD_ESC = -0x103 , KBD_LEFT = -0x104 , KBD_RIGHT = -0x105 , KBD_UP = -0x106 ,
  KBD_DOWN = -0x107 , KBD_INS = -0x108 , KBD_DEL = -0x109 , KBD_HOME = -0x10a ,
  KBD_END = -0x10b , KBD_PAGE_UP = -0x10c , KBD_PAGE_DOWN = -0x10d , KBD_F1 = -0x120 ,
  KBD_F2 = -0x121 , KBD_F3 = -0x122 , KBD_F4 = -0x123 , KBD_F5 = -0x124 ,
  KBD_F6 = -0x125 , KBD_F7 = -0x126 , KBD_F8 = -0x127 , KBD_F9 = -0x128 ,
  KBD_F10 = -0x129 , KBD_F11 = -0x12a , KBD_F12 = -0x12b , KBD_CTRL_C = -0x200
}
 Codes of special keys, for use in term_event_key_T. More...

Functions

static int is_kbd_fkey (term_event_key_T key)
void handle_trm (int std_in, int std_out, int sock_in, int sock_out, int ctl_in, void *init_string, int init_len, int remote)
 Construct the struct itrm of this process, make ditrm point to it, set up select() handlers, and send the initial interlink packet.
void itrm_queue_event (struct itrm *itrm, char *data, int len)
void block_itrm (void)
int unblock_itrm (void)
void free_all_itrms (void)
void resize_terminal (void)
void dispatch_special (const char *)
void kbd_ctrl_c (void)
int is_blocked (void)
void get_terminal_name (char[MAX_TERM_LEN])

Macro Definition Documentation

◆ is_kbd_character

#define is_kbd_character ( key)
Value:
((key) >= 0)

Check whether key is a character or a special key.

int32_t term_event_key_T
A key received from a terminal, without modifiers.
Definition kbd.h:36
#define is_kbd_character(key)
Check whether key is a character or a special key.
Definition kbd.h:131

Return true if key is a character from term_event_char_T. (The character is not necessarily printable.) Return false if key is a special key from enum term_event_special_key.

◆ kbd_fkey_to_number

#define kbd_fkey_to_number ( key)
Value:
(KBD_F1 - (key) + 1)
@ KBD_F1
Definition kbd.h:106

◆ kbd_get_key

#define kbd_get_key ( kbd_)
Value:
((kbd_)->key)

◆ kbd_get_modifier

#define kbd_get_modifier ( kbd_)
Value:
((kbd_)->modifier)

◆ kbd_key_is

#define kbd_key_is ( kbd_,
key )
Value:
(kbd_get_key(kbd_) == (key))
#define kbd_get_key(kbd_)
Definition kbd.h:147

◆ kbd_modifier_is

#define kbd_modifier_is ( kbd_,
mod )
Value:
(kbd_get_modifier(kbd_) == (mod))
#define kbd_get_modifier(kbd_)
Definition kbd.h:150

◆ kbd_set

#define kbd_set ( kbd_,
key_,
modifier_ )
Value:
do { \
(kbd_)->key = (key_); \
(kbd_)->modifier = (modifier_); \
} while (0)

◆ MAX_CWD_LEN

#define MAX_CWD_LEN   256 /* this must be multiple of 8! (alignment problems) */

◆ MAX_TERM_LEN

#define MAX_TERM_LEN   32 /* this must be multiple of 8! (alignment problems) */

◆ number_to_kbd_fkey

#define number_to_kbd_fkey ( num)
Value:
(KBD_F1 - (num) + 1)
@ num
Definition gettextP.h:52

Typedef Documentation

◆ term_event_char_T

A character received from a terminal.

◆ term_event_key_T

typedef int32_t term_event_key_T

A key received from a terminal, without modifiers.

The value is either from term_event_char_T or from enum term_event_special_key. To check which one it is, use is_kbd_character().

  • Values <= -0x100 are special; from enum term_event_special_key.
  • Values between -0xFF and -2 are not used yet; treat as special.
  • Value == -1 is KBD_UNDEF; not sent via socket.
  • Values >= 0 are characters; from term_event_char_T.

Any at least 32-bit signed integer type would work here; using an exact-width type hurts portability in principle, but some other parts of ELinks already require the existence of uint32_t.

◆ term_event_modifier_T

typedef unsigned char term_event_modifier_T

Enumeration Type Documentation

◆ term_event_modifier

Values for term_event_keyboard.modifier and interlink_event_keyboard.modifier.

Enumerator
KBD_MOD_NONE 
KBD_MOD_SHIFT 
KBD_MOD_CTRL 
KBD_MOD_ALT 
KBD_MOD_PASTE 

The character is part of a string being pasted from the terminal.

parse_keystroke() does not support this flag, so keystrokes that include it cannot be bound to any actions, and ELinks will instead insert the characters if possible.

◆ term_event_special_key

Codes of special keys, for use in term_event_key_T.

The enum has a tag mainly to let you cast numbers to it in GDB and see their names. ELinks doesn't use this enum type as term_event_key_T, because it might be 16-bit and Unicode characters wouldn't then fit.

Enumerator
KBD_UNDEF 
KBD_ENTER 
KBD_BS 
KBD_TAB 
KBD_ESC 
KBD_LEFT 
KBD_RIGHT 
KBD_UP 
KBD_DOWN 
KBD_INS 
KBD_DEL 
KBD_HOME 
KBD_END 
KBD_PAGE_UP 
KBD_PAGE_DOWN 
KBD_F1 
KBD_F2 
KBD_F3 
KBD_F4 
KBD_F5 
KBD_F6 
KBD_F7 
KBD_F8 
KBD_F9 
KBD_F10 
KBD_F11 
KBD_F12 
KBD_CTRL_C 

Function Documentation

◆ block_itrm()

void block_itrm ( void )

◆ dispatch_special()

void dispatch_special ( const char * text)

◆ free_all_itrms()

void free_all_itrms ( void )

◆ get_terminal_name()

void get_terminal_name ( char name[MAX_TERM_LEN])

◆ handle_trm()

void handle_trm ( int std_in,
int std_out,
int sock_in,
int sock_out,
int ctl_in,
void * init_string,
int init_len,
int remote )

Construct the struct itrm of this process, make ditrm point to it, set up select() handlers, and send the initial interlink packet.

The first five parameters are file descriptors that this function saves in submembers of struct itrm, and for which this function may set select() handlers. Please see the definitions of struct itrm_in and struct itrm_out for further explanations.

Parameters
std_initrm_in.std: read tty device (or pipe)
std_outitrm_out.std: write tty device (or pipe)
sock_initrm_in.sock
  • If master: == std_out (masterhood flag)
  • If slave: read socket from master
sock_outitrm_out.sock
  • If master: write pipe to same process
  • If slave: write socket to master
ctl_initrm_in.ctl: control tty device

The remaining three parameters control the initial interlink packet.

Parameters
init_stringA string to be passed to the master process. Need not be null-terminated. If remote == 0, this is a URI. Otherwise, this is a remote command.
init_lenThe length of init_string, in bytes.
remote= 0 if asking the master to start a new session and display it via this process. Otherwise, enum remote_session_flags.

◆ is_blocked()

int is_blocked ( void )

◆ is_kbd_fkey()

int is_kbd_fkey ( term_event_key_T key)
inlinestatic

◆ itrm_queue_event()

void itrm_queue_event ( struct itrm * itrm,
char * data,
int len )

◆ kbd_ctrl_c()

void kbd_ctrl_c ( void )

◆ resize_terminal()

void resize_terminal ( void )

◆ unblock_itrm()

int unblock_itrm ( void )