Angband
Macros | Functions | Variables
ui-event.c File Reference

Utility functions relating to UI events. More...

#include "angband.h"
#include "ui-event.h"

Macros

#define STORE(buffer, pos, mod, cod)
 

Functions

keycode_t keycode_find_code (const char *str, size_t len)
 Given a string, try and find it in "mappings". More...
 
const char * keycode_find_desc (keycode_t kc)
 Given a keycode, return its textual mapping. More...
 
static int dehex (char c)
 Convert a hexidecimal-digit into a decimal. More...
 
void keypress_from_text (struct keypress *buf, size_t len, const char *str)
 Convert an encoding of a set of keypresses into actual keypresses. More...
 
void keypress_to_text (char *buf, size_t len, const struct keypress *src, bool expand_backslash)
 Convert a string of keypresses into their textual equivalent. More...
 
void keypress_to_readable (char *buf, size_t len, struct keypress src)
 Convert a keypress into something readable. More...
 
bool char_matches_key (wchar_t c, keycode_t key)
 Return whether the given display char matches an entered symbol. More...
 

Variables

struct {
   keycode_t   code
 
   const char *   desc
 
mappings []
 Map keycodes to their textual equivalent. More...
 

Detailed Description

Utility functions relating to UI events.

Copyright (c) 2011 Andi Sidwell

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation

#define STORE (   buffer,
  pos,
  mod,
  cod 
)
Value:
{ \
int p = (pos); \
keycode_t c = (cod); \
byte m = (mod); \
\
if ((m & KC_MOD_CONTROL) && ENCODE_KTRL(c)) { \
m &= ~KC_MOD_CONTROL; \
c = KTRL(c); \
} \
buffer[p].mods = m; \
buffer[p].code = c; \
}
typedef int
Definition: libpng12/png.h:1135
uint8_t byte
Definition: h-basic.h:167
static byte * buffer
Definition: savefile.c:157
#define KC_MOD_CONTROL
Key modifiers.
Definition: ui-event.h:46
const char ** p[]
Definition: name.c:40
#define ENCODE_KTRL(v)
If keycode you're trying to apply control to is between 0x40-0x5F inclusive, then you should take 0x4...
Definition: ui-event.h:87
#define KTRL(X)
Given a character X, turn it into a control character.
Definition: ui-event.h:94
u32b keycode_t
Type capable of holding any input key we might want to use.
Definition: ui-event.h:156

Referenced by keypress_from_text().

Function Documentation

bool char_matches_key ( wchar_t  c,
keycode_t  key 
)

Return whether the given display char matches an entered symbol.

Horrible hack. TODO UTF-8 find some way of entering mb chars

References text_mbstowcs().

Referenced by do_cmd_query_symbol(), and lookup_symbol().

static int dehex ( char  c)
static

Convert a hexidecimal-digit into a decimal.

References A2I, and D2I.

Referenced by keypress_from_text().

keycode_t keycode_find_code ( const char *  str,
size_t  len 
)

Given a string, try and find it in "mappings".

Given a string (and that string's length), return the corresponding keycode.

References code, desc, i, mappings, and N_ELEMENTS.

Referenced by keypress_from_text().

const char* keycode_find_desc ( keycode_t  kc)

Given a keycode, return its textual mapping.

Given a keycode, return its description.

References code, i, mappings, N_ELEMENTS, and NULL.

Referenced by keypress_to_readable(), and keypress_to_text().

void keypress_from_text ( struct keypress buf,
size_t  len,
const char *  str 
)

Convert an encoding of a set of keypresses into actual keypresses.

Convert a textual representation of keypresses into actual keypresses.

References dehex(), EVT_KBRD, EVT_NONE, KC_MOD_ALT, KC_MOD_CONTROL, KC_MOD_KEYPAD, KC_MOD_META, KC_MOD_SHIFT, keycode_find_code(), MIN, and STORE.

Referenced by parse_prefs_keymap_action(), and parse_prefs_keymap_input().

void keypress_to_readable ( char *  buf,
size_t  len,
struct keypress  src 
)

Convert a keypress into something readable.

Convert a keypress into something the user can read (not designed to be used internally.

References keypress::code, desc, i, KC_MOD_ALT, KC_MOD_CONTROL, KC_MOD_KEYPAD, KC_MOD_META, KC_MOD_SHIFT, keycode_find_desc(), keypress::mods, strnfcat(), and UN_KTRL.

Referenced by cmd_sub_entry().

void keypress_to_text ( char *  buf,
size_t  len,
const struct keypress src,
bool  expand_backslash 
)

Convert a string of keypresses into their textual equivalent.

Convert a string of keypresses into their textual representation.

References keypress::code, desc, EVT_KBRD, i, KC_MOD_ALT, KC_MOD_CONTROL, KC_MOD_KEYPAD, KC_MOD_META, KC_MOD_SHIFT, keycode_find_desc(), keypress::mods, strnfcat(), type, and UN_KTRL.

Referenced by do_cmd_keylog(), keymap_browse_hook(), keymap_dump(), keymap_get_trigger(), ui_keymap_create(), and ui_keymap_query().

Variable Documentation

keycode_t code
const char* desc
const { ... } mappings[]

Map keycodes to their textual equivalent.

Referenced by keycode_find_code(), and keycode_find_desc().