Skip to content
Tom Feist edited this page Oct 16, 2011 · 6 revisions

Irssi Keyboard Input

This file is concerned only with the fe-text version of irssi (that is, the standard tty client), and investigates the inner workings of the binding, dispatch and key handling code.

Main files:

Associated Signals:

  • "keyboard created"
  • "keyboard destroyed"
  • "key created"
  • "key destroyed"
  • "keyinfo created"
  • "keyinfo destroyed"
  • "key <keyname>"

Data Structures:

  • KEYBOARD_REC

    char *key_state; /* the ongoing key combo */
    void *gui_data; /* GUI specific data sent in "key pressed" signal */

  • KEYINFO_REC

    char *id;
    char *description;
    GSList *keys, *default_keys;

  • KEY_REC

    KEYINFO_REC *info;
    char *key;
    char *data;

High Level

Setup

Keyboard Creation

gui-readline is responsible for creating and owning the KEYBOARD_REC instance. The keyboard instance is created in gui_readline_init(), setting rec->gui_data to NULL. rec->key_state isn't initialised.

Only a single keyboard instance is ever created. The creation causes the emission of a "keyboard created" signal, but this occurs before the perl script interpreter is loaded, and hence cannot be used in scripts.

Once the keyboard object is created, is it populated with the default bindings, still within the gui_readline_init() function. A simple lock-style function-pair (key_configure_freeze(), key_configure_thaw()) allows the manipulation of large numbers of key entries at once without running the costly key_states_rescan() function each time.

Binding Defaults

void key_bind(const char *id, const char *description, const char *key_default, const char *data, SIGNAL_FUNC func)

is the entry-point for setting up both bindings, and the actions which bindings perform.

Lower level

things.

Clone this wiki locally