Keymap module

load_from_memory

procedure2 overloadsSource

Reads bindings from memory into the set. Returns false if any line was invalid; the valid ones still apply.

The text starts with a [1] version line. Each line is [S-][C-][A-]key action, where key is a character or a name such as Space, Enter, F5 or ArrowUp. action is the name of a procedure registered with add_proc, or : followed by a command string passed to command_string_proc. A N- prefix flips whether the binding respects the keymap's ignore_modifier_keys. # starts a comment, and [name] selects the keymap the following lines go to.

Example↗
set: Keymap_Set;
map := add_keymap(*set, "game");
set.default_keymap = map;
add_proc(map, "jump", () { /* ... */ });
assert(load_from_memory(*set, "[1]\nSpace jump\nS-F5 jump\n"));
assert(map.mappings.count == 2);
assert(!load_from_memory(*set, "[1]\nNOT_A_KEY jump"));
reset_keymaps(*set);
load_from_memory :: (
    set: *Keymap_Set,
    memory: string,
    short_name := "unnamed",
    full_path := "(no path)"
) -> bool

Parameters

memory: string
short_name := "unnamed"
full_path := "(no path)"

Returns

bool
load_from_memory :: (
    keymap: *Keymap,
    memory: string,
    short_name: string,
    full_path: string,
    optional := false
) -> bool

Reads bindings from memory into one keymap, ignoring [section] lines. Returns false if any line was invalid.

Parameters

keymap: *Keymap
memory: string
short_name: string
full_path: string
optional := false

Returns

bool

See also