tui: add nmt_newt_text_width()
We were using g_utf8_strlen() to measure strings for layout, but that counts combining marks too, and also fails to deal with "fullwidth" (ie, double-width) CJK characters. Add a new utility function to do a better job of this (based on code from vte), and use it everywhere.
This commit is contained in:
@@ -436,7 +436,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list)
|
||||
for (citer = nmtdev->conns; citer; citer = citer->next) {
|
||||
nmtconn = citer->data;
|
||||
|
||||
max_width = MAX (max_width, g_utf8_strlen (nmtconn->name, -1));
|
||||
max_width = MAX (max_width, nmt_newt_text_width (nmtconn->name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list)
|
||||
row = g_strdup_printf ("%c %s%-*s%s",
|
||||
active_col,
|
||||
nmtconn->name,
|
||||
(int)(max_width - g_utf8_strlen (nmtconn->name, -1)), "",
|
||||
(int)(max_width - nmt_newt_text_width (nmtconn->name)), "",
|
||||
strength_col);
|
||||
|
||||
nmt_newt_listbox_append (listbox, row, nmtconn);
|
||||
|
Reference in New Issue
Block a user