Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes: > COL_MODE_COLUMN and COL_MODE_ROW fill column by column (or row by row > respectively), given the terminal width and how many space between > columns. > > Strings are supposed to be in UTF-8. If strings contain ANSI escape > strings, COL_ANSI must be specified for correct length calculation. Hrm, is it too heavyweight to autodetect and relieve the caller from the burden of passing COL_ANSI? Perhaps if you update utf8_strwidth() so that it takes <ptr, len> input not NUL terminated string, you can do item_length like this, no? cp = s; width = 0; while (1) { ep = strstr(cp, "\033["); if (!ep) { width += utf8_strwidth(cp); break; } utf8_strwidth_counted(cp, ep - cp); ... scan ep to skip the "\033[...;X" cp = ep; } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html