Re: Make "old esc mode" key timeout configurable



Hi Denis,

On Sun, 2006-07-30 at 14:45 +0200, Denis Vlasenko wrote:
> I patched mc to look at KEYBOARD_KEY_TIMEOUT_US environment variable 
> so that delay is configurable (instead of hardcoded 0.5 second one).

Patch is easily understandable but I'd like to see some changes to it.

> diff -urp mc-4.6.0.orig/src/key.c mc-4.6.0/src/key.c

> -#define ESCMODE_TIMEOUT 1000000
> +#define ESCMODE_TIMEOUT keyboard_key_timeout

Why do you keep this define around if it is substituted for a global
variable? Just get rid of that define and substitute it with the
variable.

> +    char *kt = (char *)getenv("KEYBOARD_KEY_TIMEOUT_US");

Please conform to the used coding style. I agree the extra spaces are
ugly but its even uglier mixing styles.

> +    if (kt != NULL)
> +       keyboard_key_timeout = atoi(kt);

What about a multiplier (1000) so the environment variable is in ms? And
should there be a sanity check here for invalid input (= 0) and/or too
small (10ms?) and too large (10s?) values?

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]