adding preference option for dynamic input blocking

/inpblock is now having subcommands 'timeout' and 'dynamic'
with:

/inpblock timeout <milliseconds>

and

/inpblock dynamic <on|off>

Defaults are:

/inpblock timeout 500
/inpblock dynamic on

To get the old behavior specify:

/inpblock timeout 20
/inpblock dynamic off

The dynamic mode will block incrementally after something
should be written to the window or after a key was pressed. So pressing
a key would set the timeout to 0ms and after 10 timeouts to the next
bigger one.

Example (with dynamic mode on):

"/inpblock timeout 50"

timeout series:

10x 0ms
10x 10ms (0ms + 10 times since last keypress)
10x 30ms (10ms + 20 times since last keypress)
*x50ms until next key was pressed or
This commit is contained in:
Simon Effenberg
2015-01-12 11:32:32 +01:00
parent c7ff3255b8
commit 34148e2101
6 changed files with 62 additions and 14 deletions

View File

@@ -3450,13 +3450,40 @@ cmd_notify(gchar **args, struct cmd_help_t help)
gboolean
cmd_inpblock(gchar **args, struct cmd_help_t help)
{
char *value = args[0];
char *subcmd = args[0];
char *value = args[1];
int intval;
if (_strtoi(value, &intval, 1, 1000) == 0) {
cons_show("Input blocking set to %d milliseconds.", intval);
prefs_set_inpblock(intval);
ui_input_nonblocking(FALSE);
if (strcmp(subcmd, "timeout") == 0) {
if (value == NULL) {
cons_show("Usage: %s", help.usage);
return TRUE;
}
if (_strtoi(value, &intval, 1, 1000) == 0) {
cons_show("Input blocking set to %d milliseconds.", intval);
prefs_set_inpblock(intval);
ui_input_nonblocking(FALSE);
}
return TRUE;
}
if (strcmp(subcmd, "dynamic") == 0) {
if (value == NULL) {
cons_show("Usage: %s", help.usage);
return TRUE;
}
if (strcmp(value, "on") != 0 && strcmp(value, "off") != 0) {
cons_show("Dynamic must be one of 'on' or 'off'");
return TRUE;
}
return _cmd_set_boolean_preference(value, help, "Dynamic input blocking", PREF_INPBLOCK_DYNAMIC);
}
cons_show("Usage: %s", help.usage);
return TRUE;
}