[2930] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

Re: [PATCH 1/3] Don't precompute UTF-8 encodings of format

daemon@ATHENA.MIT.EDU (Nelson Elhage)
Fri Feb 25 18:08:28 2011

Date: Fri, 25 Feb 2011 18:08:24 -0500
From: Nelson Elhage <nelhage@nelhage.com>
To: David Benjamin <davidben@mit.edu>
Cc: barnowl-dev@mit.edu
In-Reply-To: <1298673382-4273-1-git-send-email-davidben@mit.edu>

All three of these lgtm. If all the parameters to waddstr bug you you could add
a stupid struct owl_fmtext_attributes to wrap them into a single thing, which
would mostly search to tighten up the internal wrapper functions, but I don't
care either way.

- Nelson

On Fri, Feb 25, 2011 at 05:36:20PM -0500, David Benjamin wrote:
> GString can append gunichar just fine.
> ---
>  fmtext.c |   12 ++++++------
>  owl.h    |    4 ----
>  2 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/fmtext.c b/fmtext.c
> index fbeabb6..1fecd9d 100644
> --- a/fmtext.c
> +++ b/fmtext.c
> @@ -49,9 +49,9 @@ void owl_fmtext_append_attr(owl_fmtext *f, const char *text, char attr, short fg
>    g_string_append(f->buff, text);
>  
>    /* Reset attributes */
> -  if (bg) g_string_append(f->buff, OWL_FMTEXT_UTF8_BGDEFAULT);
> -  if (fg) g_string_append(f->buff, OWL_FMTEXT_UTF8_FGDEFAULT);
> -  if (a)  g_string_append(f->buff, OWL_FMTEXT_UTF8_ATTR_NONE);
> +  if (bg) g_string_append_unichar(f->buff, OWL_FMTEXT_UC_BGDEFAULT);
> +  if (fg) g_string_append_unichar(f->buff, OWL_FMTEXT_UC_FGDEFAULT);
> +  if (a)  g_string_append_unichar(f->buff, OWL_FMTEXT_UC_ATTR | OWL_FMTEXT_UC_ATTR);
>  }
>  
>  /* Append normal, uncolored text 'text' to 'f' */
> @@ -179,9 +179,9 @@ static void _owl_fmtext_append_fmtext(owl_fmtext *f, const owl_fmtext *in, int s
>    g_string_append_len(f->buff, in->buff->str+start, stop-start);
>  
>    /* Reset attributes */
> -  g_string_append(f->buff, OWL_FMTEXT_UTF8_BGDEFAULT);
> -  g_string_append(f->buff, OWL_FMTEXT_UTF8_FGDEFAULT);
> -  g_string_append(f->buff, OWL_FMTEXT_UTF8_ATTR_NONE);
> +  g_string_append_unichar(f->buff, OWL_FMTEXT_UC_BGDEFAULT);
> +  g_string_append_unichar(f->buff, OWL_FMTEXT_UC_FGDEFAULT);
> +  g_string_append_unichar(f->buff, OWL_FMTEXT_UC_ATTR | OWL_FMTEXT_UC_ATTR);
>  }
>  
>  /* append fmtext 'in' to 'f' */
> diff --git a/owl.h b/owl.h
> index 0a14243..1d8ee84 100644
> --- a/owl.h
> +++ b/owl.h
> @@ -101,10 +101,6 @@ typedef void HV;
>  #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200)
>  #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4'
>  
> -#define OWL_FMTEXT_UTF8_ATTR_NONE "\xf4\x80\xa0\x80"
> -#define OWL_FMTEXT_UTF8_FGDEFAULT "\xf4\x80\x94\x80"
> -#define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x9C\x80"
> -
>  #define OWL_COLOR_BLACK     0
>  #define OWL_COLOR_RED       1
>  #define OWL_COLOR_GREEN     2
> -- 
> 1.7.3.3.399.g06ddf
> 

home help back first fref pref prev next nref lref last post