Crossfire Client, Branch
R11627
|
Functions | |
void | bind_key (char *params) |
Implements the "bind" command when entered as a text command. | |
static void | configure_keys (uint32 keysym) |
void | draw_keybindings (GtkWidget *keylist) |
Output the current list of keybindings to the message pane. | |
void | draw_prompt (const char *str) |
Draws a prompt. | |
static char * | get_key_info (Key_Entry *key, int save_mode) |
void | gtk_command_history (int direction) |
Deals with command history. | |
void | gtk_complete_command (void) |
Executes when the TAB key is pressed while the command input box has focus to give hints on what commands begin with the text already entered to this point. | |
static void | init_default_keybindings (void) |
Initialize the standard keybindings as specified in the def-keys.h file. | |
static void | insert_key (uint32 keysym, int flags, const char *command) |
Updates the keys array with the keybinding that is passed. | |
void | keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK Callback function used to handle client key press events. | |
void | keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK callback function used to handle client key release events. | |
void | keys_init (GtkWidget *window_root) |
Reads in the keybindings, and initializes special values. | |
void | on_entry_commands_activate (GtkEntry *entry, gpointer user_data) |
Used to process keyboard input whenever the player types commands into the command entry box. | |
static void | parse_key (char key, uint32 keysym) |
Parses a keypress. | |
static void | parse_key_release (uint32 ks) |
The only things we actually care about is the run and fire keys. | |
static void | parse_keybind_line (char *buf, int line, int standard) |
This function is common to both gdk and x11 client. | |
static void | save_individual_key (FILE *fp, Key_Entry *key, KeyCode kc) |
A recursive function that saves all the entries for a particular entry. | |
static void | save_keys (void) |
Saves the keybindings into the user's .crossfire/keys file. | |
static void | show_keys (int allbindings) |
Shows all the keybindings. | |
void | unbind_key (const char *params) |
static void | unbind_usage (void) |
Show help for the unbind command in the message pane. | |
void | x_set_echo (void) |
void bind_key | ( | char * | params | ) |
Implements the "bind" command when entered as a text command.
It parses the command options, records the command to bind, then prompts the user to press a key to bind. It also shows help for the bind command if the player types bind with no parameters.
params | If null, show bind command help in the message pane. |
Definition at line 878 of file keys.c.
References altkeysym, bind_buf, bind_flags, bind_keysym, commandkeysym, completekeysym, Configure_Keys, cpl, draw_info(), firekeysym, Player_Struct::input_state, KEYF_ALT, KEYF_EDIT, KEYF_FIRE, KEYF_META, KEYF_MODIFIERS, KEYF_NORMAL, KEYF_RUN, MAX_BUF, metakeysym, NDI_BLACK, NDI_RED, nextkeysym, prevkeysym, and runkeysym.
static void configure_keys | ( | uint32 | keysym | ) | [static] |
keysym |
Definition at line 1150 of file keys.c.
References Player_Struct::alt_on, altkeysym, bind_buf, bind_flags, bind_keysym, Keys::command, cpl, draw_info(), draw_message_window(), Player_Struct::fire_on, firekeysym, Keys::flags, Player_Struct::input_state, insert_key(), KEYF_ALT, KEYF_FIRE, KEYF_META, KEYF_MODIFIERS, KEYF_RUN, KEYHASH, Keys::keysym, MAX_BUF, Player_Struct::meta_on, metakeysym, NDI_BLACK, NDI_RED, Keys::next, Playing, Player_Struct::run_on, runkeysym, and save_keys().
void draw_keybindings | ( | GtkWidget * | keylist | ) |
Output the current list of keybindings to the message pane.
keylist |
Definition at line 1496 of file keys.c.
References buffers, Keys::command, Keys::flags, KEYF_ALT, KEYF_EDIT, KEYF_FIRE, KEYF_META, KEYF_MODIFIERS, KEYF_NORMAL, KEYF_RUN, KEYF_STANDARD, KEYHASH, Keys::keysym, MAX_BUF, and Keys::next.
Referenced by bind_callback(), ckeyunbind(), and configdialog().
void draw_prompt | ( | const char * | str | ) |
Draws a prompt.
Don't deal with popups for the time being.
str |
Definition at line 1565 of file keys.c.
References draw_info(), entry_commands, and NDI_WHITE.
static char* get_key_info | ( | Key_Entry * | key, |
int | save_mode | ||
) | [static] |
key | |
save_mode | If true, it means that the format used for saving the information is used, instead of the usual format for displaying the information in a friendly manner. |
Definition at line 754 of file keys.c.
References bind_buf, Keys::command, Keys::flags, KEYF_ALT, KEYF_EDIT, KEYF_FIRE, KEYF_META, KEYF_MODIFIERS, KEYF_NORMAL, KEYF_RUN, KEYF_STANDARD, Keys::keysym, and MAX_BUF.
Referenced by save_individual_key(), show_keys(), and unbind_key().
void gtk_command_history | ( | int | direction | ) |
Deals with command history.
direction | If 0, we are going backwards, if 1, we are moving forward. |
Definition at line 1576 of file keys.c.
References Command_Mode, cpl, cur_history_position, entry_commands, entrytext, history, Player_Struct::input_state, MAX_HISTORY, and scroll_history_position.
Referenced by keyfunc().
void gtk_complete_command | ( | void | ) |
Executes when the TAB key is pressed while the command input box has focus to give hints on what commands begin with the text already entered to this point.
It is almost like tab completion, except for the completion. The TAB key is also known by GDK_Tab, completekey, or completekeysym.
Definition at line 1616 of file keys.c.
References complete_command(), entry_commands, and entrytext.
Referenced by keyfunc().
static void init_default_keybindings | ( | void | ) | [static] |
Initialize the standard keybindings as specified in the def-keys.h file.
This code is common to both x11 and gdk client
Definition at line 378 of file keys.c.
References def_keys, MAX_BUF, and parse_keybind_line().
Referenced by keys_init().
static void insert_key | ( | uint32 | keysym, |
int | flags, | ||
const char * | command | ||
) | [static] |
Updates the keys array with the keybinding that is passed.
It allocates memory for the array entry, then uses strdup_local() to allocate memory for the command being bound. This function is common to both gdk and x11 client.
keysym | A key to bind. |
flags | State that the keyboard is in. |
command | A command to bind to the key specified in keysym. |
Definition at line 176 of file keys.c.
References Keys::command, Keys::direction, directions, Keys::flags, KEYHASH, Keys::keysym, Keys::next, and strdup_local().
Referenced by configure_keys(), on_keybinding_button_bind_clicked(), and parse_keybind_line().
void keyfunc | ( | GtkWidget * | widget, |
GdkEventKey * | event, | ||
GtkWidget * | window | ||
) |
GTK Callback function used to handle client key press events.
widget | |
event | GDK Key Press Event |
window |
Definition at line 1350 of file keys.c.
References cancelkeysym, Command_Mode, completekeysym, CONFIG_POPUPS, Configure_Keys, configure_keys(), cpl, csocket, csocket_fd, disconnect(), entry_commands, entrytext, ClientSocket::fd, fire_label, Player_Struct::fire_on, gtk_command_history(), gtk_complete_command(), Player_Struct::input_state, LOG(), LOG_ERROR, Metaserver_Select, nextkeysym, parse_key(), Playing, prevkeysym, Reply_Many, Reply_One, reset_map(), run_label, Player_Struct::run_on, send_reply(), stop_fire(), stop_run(), text, updatelock, and use_config.
Referenced by create_windows(), and main().
void keyrelfunc | ( | GtkWidget * | widget, |
GdkEventKey * | event, | ||
GtkWidget * | window | ||
) |
GTK callback function used to handle client key release events.
widget | |
event | GDK Key Release Event |
window |
Definition at line 1335 of file keys.c.
References entry_commands, entrytext, parse_key_release(), and updatelock.
Referenced by create_windows(), and main().
void keys_init | ( | GtkWidget * | window_root | ) |
Reads in the keybindings, and initializes special values.
It is called from main() as part of the client start up. The function is common to both the x11 and gdk clients.
window_root | The client's main window. |
Definition at line 398 of file keys.c.
References altkeysym, BIG_BUF, cancelkeysym, client_libdir, commandkeysym, completekeysym, cpl, dialog_xml, entry_commands, FALSE, fire_label, firekeysym, history, init_default_keybindings(), keybinding_button_bind, keybinding_button_remove, keybinding_button_update, keybinding_checkbutton_alt, keybinding_checkbutton_control, keybinding_checkbutton_edit, keybinding_checkbutton_meta, keybinding_checkbutton_shift, keybinding_entry_command, keybinding_entry_key, keybinding_selection, keybinding_selection_func(), keybinding_store, keybinding_treeview, keybinding_window, KEYHASH, KLIST_COMMAND, KLIST_EDIT, KLIST_KEY, KLIST_MODS, LOG(), LOG_INFO, MAX_HISTORY, metakeysym, Player_Struct::name, nextkeysym, on_entry_commands_activate(), on_keybinding_button_bind_clicked(), on_keybinding_button_clear_clicked(), on_keybinding_button_close_clicked(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), on_keybinding_entry_key_key_press_event(), parse_keybind_line(), prevkeysym, run_label, runkeysym, and spinbutton_count.
Referenced by main().
void on_entry_commands_activate | ( | GtkEntry * | entry, |
gpointer | user_data | ||
) |
Used to process keyboard input whenever the player types commands into the command entry box.
entry | |
user_data |
Definition at line 1639 of file keys.c.
References CONFIG_POPUPS, cpl, cur_history_position, extended_command(), history, Player_Struct::input_state, Player_Struct::input_text, MAX_COMMAND_LEN, MAX_HISTORY, Metaserver_Select, Playing, Reply_Many, Reply_One, scroll_history_position, send_reply(), treeview_look, TRUE, and use_config.
Referenced by keys_init().
Parses a keypress.
It should only be called when in Playing mode.
key | |
keysym |
Definition at line 638 of file keys.c.
References Player_Struct::alt_on, altkeysym, Keys::command, Command_Mode, commandkeysym, CONFIG_ECHO, Player_Struct::count, cpl, Keys::direction, draw_info(), entry_commands, extended_command(), FALSE, fire_dir(), fire_label, Player_Struct::fire_on, firekeysym, Keys::flags, Player_Struct::input_state, Player_Struct::input_text, KEYF_ALT, KEYF_EDIT, KEYF_FIRE, KEYF_META, KEYF_MODIFIERS, KEYF_NORMAL, KEYF_RUN, KEYHASH, Keys::keysym, MAX_BUF, Player_Struct::meta_on, metakeysym, NDI_BLACK, Keys::next, Player_Struct::no_echo, run_dir(), run_label, Player_Struct::run_on, runkeysym, spinbutton_count, and use_config.
static void parse_key_release | ( | uint32 | ks | ) | [static] |
The only things we actually care about is the run and fire keys.
Other key releases are not important. If it is the release of a run or fire key, we tell the client to stop firing or running. In some cases, it is possible that we actually are not running or firing, and in such cases, the server will just ignore the command.
This code is used by gdk and x11 client, but has a fair number of ifdefs to get the right behavior.
ks |
Definition at line 599 of file keys.c.
References Player_Struct::alt_on, altkeysym, clear_fire(), clear_run(), CONFIG_ECHO, cpl, draw_info(), fire_label, Player_Struct::fire_on, firekeysym, Player_Struct::meta_on, metakeysym, NDI_BLACK, run_label, Player_Struct::run_on, runkeysym, and use_config.
static void parse_keybind_line | ( | char * | buf, |
int | line, | ||
int | standard | ||
) | [static] |
This function is common to both gdk and x11 client.
buf | |
line | |
standard | Set (1) or clear (0) the KEYF_STANDARD flag for the binding. |
Definition at line 218 of file keys.c.
References altkeysym, bind_buf, commandkeysym, completekeysym, firekeysym, Keys::flags, insert_key(), KEYF_ALT, KEYF_EDIT, KEYF_FIRE, KEYF_META, KEYF_NORMAL, KEYF_RUN, KEYF_STANDARD, Keys::keysym, LOG(), LOG_WARNING, metakeysym, nextkeysym, prevkeysym, and runkeysym.
static void save_individual_key | ( | FILE * | fp, |
Key_Entry * | key, | ||
KeyCode | kc | ||
) | [static] |
A recursive function that saves all the entries for a particular entry.
We save the first element first, and then go through and save the rest of the elements. In this way, the ordering of the key entries in the file remains the same.
fp | Pointer to an open file for writing key bind settings into. |
key | Pointer of a key hash record to save to the key bind file. During recursion, key takes the value key->next, and then returns when it becomes a NULL pointer. |
kc |
Definition at line 1039 of file keys.c.
References get_key_info(), and Keys::next.
Referenced by save_keys().
static void save_keys | ( | void | ) | [static] |
Saves the keybindings into the user's .crossfire/keys file.
The output file is opened, then the special shift/modifier keys are written first. Next, the entire key hash is traversed and the contents of each slot is dumped to the file, and the output file is closed. Success or failure is reported to the message pane.
Definition at line 1055 of file keys.c.
References altkeysym, commandkeysym, completekeysym, cpl, draw_info(), firekeysym, KEYHASH, LOG(), LOG_WARNING, make_path_to_file(), MAX_BUF, metakeysym, Player_Struct::name, NDI_BLACK, nextkeysym, prevkeysym, runkeysym, and save_individual_key().
Referenced by configure_keys(), on_keybinding_button_bind_clicked(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), and unbind_key().
static void show_keys | ( | int | allbindings | ) | [static] |
Shows all the keybindings.
allbindings | Also shows the standard (default) keybindings. |
Definition at line 814 of file keys.c.
References altkeysym, commandkeysym, completekeysym, draw_info(), firekeysym, Keys::flags, get_key_info(), KEYF_STANDARD, KEYHASH, MAX_BUF, metakeysym, NDI_BLACK, Keys::next, nextkeysym, prevkeysym, and runkeysym.
Referenced by unbind_key().
void unbind_key | ( | const char * | params | ) |
params |
Definition at line 1255 of file keys.c.
References Keys::command, draw_info(), Keys::flags, get_key_info(), KEYF_STANDARD, KEYHASH, LOG(), LOG_ERROR, MAX_BUF, NDI_BLACK, Keys::next, save_keys(), show_keys(), and unbind_usage().
static void unbind_usage | ( | void | ) | [static] |
Show help for the unbind command in the message pane.
Definition at line 1243 of file keys.c.
References draw_info(), and NDI_BLACK.
Referenced by unbind_key().
void x_set_echo | ( | void | ) |
Definition at line 1555 of file keys.c.
References cpl, entry_commands, and Player_Struct::no_echo.