grub-devel
[Top][All Lists]
Advanced

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

Re: [rfc] User definable terminfo support


From: Marco Gerards
Subject: Re: [rfc] User definable terminfo support
Date: Wed, 04 Jan 2006 00:09:12 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Omniflux <address@hidden> writes:

Hi,

> This code is incomplete, but I want to get some feedback from you,
> Marco, to ensure I am going down the correct path.

Hopefully my understanding of the code is correct so the comments are
sane :)

> -/* Free *PTR and set *PTR to NULL, to prevent double-free.  */
> +/* Set terminfo definition.  */
>  static void
> -grub_terminfo_free (char **ptr)
> +set_definition (const char *name, const char *definition)
> +{
> +  unset_definition ();
> +
> +  /* terminfo definition variable set to "".  */
> +  if (grub_strcmp (definition, "") == 0 )
> +      return;
> +
> +  /* Parse new definition and save as terminal_definition.  */
> +  /* FIXME: Write a parser. :)  */
> +  terminfo_definition->name = grub_strdup (name);
> +}
> +
> +/* Write hook for the terminfo environment variable.  */
> +static char *
> +set_definition_hook (struct grub_env_var *var, const char *val)
>  {
> -  grub_free (*ptr);
> -  *ptr = 0;
> +  set_definition (var->name, val);
> +  return grub_strdup (val);
>  }

Why do you have a hook for variables?

For example, when I do:

set vt100=...  

It's ok that is does not take effect until you change TERM, IMO.

So what happens is:

1)  VT100 is set
2)  TERM is set
2a) The hook is executed
2b) VT100 is read by the hook.
2c) The contents of VT100 is read and parsed.
2d) From this point of the VT100 stuff can be used and the hook
    returns.

Does this make sense and does it fit well in the design of the
terminfo code?

> +/* Write hook for the environment variable "TERM".  */
> +static char *
> +select_definition_hook (struct grub_env_var *var __attribute__ ((unused)),
> +                        const char *val)
> +{
> +  select_definition (val);
> +  return grub_strdup (val);
> +}

Perhaps you can even return 0 when the definition was not valid.  In
that case TERM is set to 0, IIRC?

Thanks,
Marco





reply via email to

[Prev in Thread] Current Thread [Next in Thread]