Data Structures | Functions | Variables
ui-keymap.c File Reference

Keymap handling. More...

#include "angband.h"
#include "ui-keymap.h"
#include "ui-term.h"

Data Structures

struct  keymap
 Keymap implementation. More...


const struct keypresskeymap_find (int keymap, struct keypress kc)
 Find a keymap, given a keypress. More...
static struct keypresskeymap_make (const struct keypress *actions)
 Duplicate a given keypress string and return the duplicate. More...
void keymap_add (int keymap, struct keypress trigger, struct keypress *actions, bool user)
 Add a keymap to the mappings table. More...
bool keymap_remove (int keymap, struct keypress trigger)
 Remove a keymap. More...
void keymap_free (void)
 Forget and free all keymaps. More...
void keymap_dump (ang_file *fff)
 Append active keymaps to a given file. More...


static struct keymapkeymaps [KEYMAP_MODE_MAX]
 List of keymaps. More...

Detailed Description

Keymap handling.

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.

Function Documentation

◆ keymap_add()

void keymap_add ( int  keymap,
struct keypress  trigger,
struct keypress actions,
bool  user 

Add a keymap to the mappings table.

Given a keymap mode, a trigger, and an action, store it in the keymap list.

References keymap::actions, keymap::key, keymap_make(), KEYMAP_MODE_MAX, keymap_remove(), mem_zalloc(), keymap::next, and keymap::user.

Referenced by parse_prefs_keymap_input(), and ui_keymap_create().

◆ keymap_dump()

void keymap_dump ( ang_file fff)

Append active keymaps to a given file.

Save keymaps to the specified file.

References keymap::actions, buf, file_putf(), keymap::key, KEYMAP_MODE_ORIG, KEYMAP_MODE_ROGUE, KEYPRESS_NULL, keypress_to_text(), keymap::next, OPT, and keymap::user.

Referenced by ui_keymap_pref_append().

◆ keymap_find()

const struct keypress* keymap_find ( int  keymap,
struct keypress  kc 

Find a keymap, given a keypress.

Given a keymap mode and a keypress, return any attached action.

References keymap::actions, keypress::code, keymap::key, KEYMAP_MODE_MAX, keypress::mods, and keymap::next.

Referenced by target_dir_allow(), textui_get_command(), and ui_keymap_query().

◆ keymap_free()

void keymap_free ( void  )

Forget and free all keymaps.

Free all keymaps.

References keymap::actions, i, mem_free(), N_ELEMENTS, and keymap::next.

Referenced by textui_cleanup().

◆ keymap_make()

static struct keypress* keymap_make ( const struct keypress actions)

Duplicate a given keypress string and return the duplicate.

References EVT_NONE, mem_zalloc(), and type.

Referenced by keymap_add().

◆ keymap_remove()

bool keymap_remove ( int  keymap,
struct keypress  trigger 

Remove a keymap.

Given a keypress, remove any keymap that would trigger on that key.

Return true if one was removed.

References keymap::actions, keypress::code, keymap::key, KEYMAP_MODE_MAX, mem_free(), keypress::mods, keymap::next, and prev.

Referenced by keymap_add(), and ui_keymap_remove().

Variable Documentation

◆ keymaps

struct keymap* keymaps[KEYMAP_MODE_MAX]

List of keymaps.