Add a command to clear specific IMTs.

in_clear <imt>... where each argument to in_clear is an imt identifier. If
any identifiers are incorrect, the incorrect ones will be displayed and no
tables will be cleared. All or nothing.
This commit is contained in:
Bill Currie 2013-01-13 18:05:41 +09:00
parent 0c81364da8
commit b1ddae927b
1 changed files with 28 additions and 0 deletions

View File

@ -649,6 +649,32 @@ Key_Unbindall_f (void)
Key_SetBinding (j, i, NULL);
}
static void
Key_In_Clear (void)
{
int err = 0;
int imt;
int i, j;
if (Cmd_Argc () == 1) {
Sys_Printf ("in_clear <imt> ...\n");
return;
}
for (i = 1; i < Cmd_Argc (); i++) {
if (Key_StringToIMTnum (Cmd_Argv (i)) == -1) {
Sys_Printf ("\"%s\" isn't a valid imt\n", Cmd_Argv (i));
err = 1;
}
}
if (err)
return;
for (i = 1; i < Cmd_Argc (); i++) {
imt = Key_StringToIMTnum (Cmd_Argv (i));
for (j = 0; j < QFK_LAST; j++)
Key_SetBinding (imt, j, NULL);
}
}
static void
Key_In_Bind (const char *imt, const char *key, const char *cmd)
{
@ -946,6 +972,8 @@ Key_Init (cbuf_t *cb)
"Remove the bind from the the selected key");
Cmd_AddCommand ("unbindall", Key_Unbindall_f,
"Remove all binds (USE CAUTIOUSLY!!!)");
Cmd_AddCommand ("in_clear", Key_In_Clear,
"Remove all binds from the specified imts");
Cmd_AddCommand ("imt", Key_InputMappingTable_f, "");
Cmd_AddCommand ("bind", Key_Bind_f, "wrapper for in_bind that uses "
"in_bind_imt for the imt parameter");