On Wed, Dec 08, 2010 at 10:31:37PM +0100, Matthieu Herrb wrote: > > Based on an initial patch by Jasper Lievisse Adriaanse. > > Signed-off-by: Matthieu Herrb <[email protected]> > --- > src/list.c | 37 ++++++++++++++++++++++++++++++++----- > 1 files changed, 32 insertions(+), 5 deletions(-) > > diff --git a/src/list.c b/src/list.c > index 8633c62..7f882ab 100644 > --- a/src/list.c > +++ b/src/list.c > @@ -241,10 +241,13 @@ list_xi2(Display *display, > dev = &info[i]; > if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard) > { > - if (dev->use == XIMasterPointer) > - printf("⎡ "); > - else > - printf("⎣ "); > + if (have_utf8()) > + if (dev->use == XIMasterPointer) > + printf("⎡ "); > + else > + printf("⎣ "); > + else > + printf("+ "); > > print_info_xi2(display, dev, shortformat); > for (j = 0; j < ndevices; j++) > @@ -254,7 +257,10 @@ list_xi2(Display *display, > if ((sd->use == XISlavePointer || sd->use == > XISlaveKeyboard) && > (sd->attachment == dev->deviceid)) > { > - printf("%s ↳ ", dev->use == XIMasterPointer ? "⎜" : " > "); > + if (have_utf8()) > + printf("%s ↳ ", dev->use == XIMasterPointer ? "⎜" > : " "); > + else > + printf("%s + ", dev->use == XIMasterPointer ? "|" : " > "); > print_info_xi2(display, sd, shortformat); > } > } > @@ -324,4 +330,25 @@ list(Display *display, > } > } > > +Bool > +have_utf8(void){ > + char *t; > + > + /* > + * There is no standard way to detect UTF-8 capabilities of a > + * given terminal, but this gets pretty close as a good heuristic. > + */ > + if ((t = getenv("LC_ALL")) == NULL) { > + if ((t = getenv("LC_CTYPE")) == NULL) { > + t = getenv("LANG"); > + } > + } > + > + if (t != NULL && (strcasestr(t, "UTF-8") != NULL || > + strcasestr(t, "UTF8") != NULL)) > + return True; > + > + return False; > +} > + > /* end of list.c */ > -- > 1.7.3.2
urgh, no. I'd rather change the output ASCII only than have if/else conditions for the output. we could probably use /|\ instead of ⎡⎜⎣ and simple -> or just - instead of ↳. Cheers, Peter _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
