forked from enlightenment/enlightenment
E menu: Fix menu abbreviation.
Possibly not the fastest way to do it, but I really don't have the time to do it now. I'm just doing it because it took me less time to fix it than to handle all of Mike's bugging in PM and mails. ;P Something is still broken in here, but I don't have time to deal with it, if there's something broken please let me know or fix it yourself, should be fairly easy. SVN revision: 79189
This commit is contained in:
parent
e79ad1ed13
commit
151e675cf2
|
@ -1361,26 +1361,33 @@ static const char *
|
||||||
_e_int_menus_clients_title_abbrv(const char *title)
|
_e_int_menus_clients_title_abbrv(const char *title)
|
||||||
{
|
{
|
||||||
static char abbv[E_CLIENTLIST_MAX_CAPTION_LEN + 4];
|
static char abbv[E_CLIENTLIST_MAX_CAPTION_LEN + 4];
|
||||||
char *p;
|
char *abbvptr = abbv;
|
||||||
int len, len2, max_len;
|
int str_len, len, len2, max_len;
|
||||||
|
|
||||||
if (!e_config->clientlist_limit_caption_len) return title;
|
if (!e_config->clientlist_limit_caption_len) return title;
|
||||||
|
|
||||||
len = eina_unicode_utf8_get_len(title);
|
|
||||||
max_len = e_config->clientlist_max_caption_len;
|
max_len = e_config->clientlist_max_caption_len;
|
||||||
if (len <= max_len) return title;
|
if (eina_unicode_utf8_get_len(title) <= max_len) return title;
|
||||||
|
|
||||||
abbv[0] = 0;
|
/* Advance to the end of the first half of the string. */
|
||||||
len2 = max_len / 2;
|
len = 0;
|
||||||
p = (char*)title;
|
for (len2 = (max_len / 2) ; len2 ; len2--)
|
||||||
eina_unicode_utf8_get_prev(p, &len2);
|
eina_unicode_utf8_get_next(title, &len);
|
||||||
strncpy(abbv, title, len2);
|
|
||||||
abbv[len2] = '\0';
|
strncat(abbvptr, title, len);
|
||||||
len2 = len - (max_len / 2);
|
abbvptr += len;
|
||||||
p = (char*)title;
|
|
||||||
eina_unicode_utf8_get_next(p, &len2);
|
/* Append the ellipsis char. */
|
||||||
strcat(abbv, "...");
|
strcpy(abbvptr, "\xE2\x80\xA6");
|
||||||
strncat(abbv, title + len2, len - len2);
|
abbvptr += 3;
|
||||||
|
|
||||||
|
/* Advance to the start of the second half of the string */
|
||||||
|
len = str_len = strlen(title);
|
||||||
|
for (len2 = (max_len / 2) ; len2 ; len2--)
|
||||||
|
eina_unicode_utf8_get_prev(title, &len);
|
||||||
|
|
||||||
|
strncpy(abbvptr, title + len, str_len);
|
||||||
|
abbvptr[str_len] = '\0';
|
||||||
|
|
||||||
return abbv;
|
return abbv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue