Changeset f95e606
- Timestamp:
- 2016-10-17T04:37:45Z (8 years ago)
- Branches:
- master
- Children:
- b7fec48
- Parents:
- 4466e3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r4466e3e rf95e606 1327 1327 } 1328 1328 1329 /* some arbitrary numbers */ 1330 #define CHAT_TITLE_LEN_MIN 20 1331 #define CHAT_TITLE_LEN_MAX 100 1332 1329 1333 void cmd_chat_list_finish(struct im_connection *ic) 1330 1334 { 1331 1335 account_t *acc = ic->acc; 1332 1336 bee_chat_info_t *ci; 1333 char *hformat, *iformat, *topic ;1337 char *hformat, *iformat, *topic, *padded; 1334 1338 GSList *l; 1335 1339 guint i = 0; 1340 long title_len, new_len; 1336 1341 irc_t *irc = ic->bee->ui_data; 1337 1342 … … 1339 1344 irc_rootmsg(irc, "No existing chatrooms"); 1340 1345 return; 1346 } 1347 1348 /* find a reasonable width for the table */ 1349 title_len = CHAT_TITLE_LEN_MIN; 1350 1351 for (l = ic->chatlist; l; l = l->next) { 1352 ci = l->data; 1353 new_len = g_utf8_strlen(ci->title, -1); 1354 1355 if (new_len >= CHAT_TITLE_LEN_MAX) { 1356 title_len = CHAT_TITLE_LEN_MAX; 1357 break; 1358 } else if (title_len < new_len) { 1359 title_len = new_len; 1360 } 1341 1361 } 1342 1362 … … 1345 1365 iformat = "%u\t%s\t%s"; 1346 1366 } else { 1347 hformat = "%s %-20s %s"; 1348 iformat = "%5u %-20.20s %s"; 1349 } 1350 1351 irc_rootmsg(irc, hformat, "Index", "Title", "Topic"); 1367 hformat = "%s %s %s"; 1368 iformat = "%5u %s %s"; 1369 } 1370 1371 padded = str_pad_and_truncate("Title", title_len, NULL); 1372 irc_rootmsg(irc, hformat, "Index", padded, "Topic"); 1373 g_free(padded); 1352 1374 1353 1375 for (l = ic->chatlist; l; l = l->next) { 1354 1376 ci = l->data; 1355 1377 topic = ci->topic ? ci->topic : ""; 1356 irc_rootmsg(irc, iformat, ++i, ci->title, topic); 1378 1379 padded = str_pad_and_truncate(ci->title, title_len, "[...]"); 1380 irc_rootmsg(irc, iformat, ++i, padded, topic); 1381 g_free(padded); 1357 1382 } 1358 1383
Note: See TracChangeset
for help on using the changeset viewer.