Use ASCII art when the environment is not UTF-8 capable.OB
Based on an initial patch by jasper@, ok jasper@.
This commit is contained in:
parent
7f72d21b63
commit
1471212514
@ -241,10 +241,13 @@ list_xi2(Display *display,
|
||||
dev = &info[i];
|
||||
if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user