Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/commands.c @ 1761:61f0482d3993
Limit = alignment to 1/3 of screen in option list
* Add scr_gettextwidth()
* Use it to limit alignment of equal sign in option list
to one third of available message width
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Sat, 13 Mar 2010 18:12:47 +0200 |
parents | 106bbf7e97da |
children | c450d1e66c2e |
comparison
equal
deleted
inserted
replaced
1760:106bbf7e97da | 1761:61f0482d3993 |
---|---|
2101 GSList *list = NULL; | 2101 GSList *list = NULL; |
2102 // Get sorted list of keys | 2102 // Get sorted list of keys |
2103 settings_foreach(SETTINGS_TYPE_OPTION, list_option_cb, &list); | 2103 settings_foreach(SETTINGS_TYPE_OPTION, list_option_cb, &list); |
2104 if (list) { | 2104 if (list) { |
2105 gsize max = 0; | 2105 gsize max = 0; |
2106 gsize maxmax = scr_gettextwidth() / 3; | |
2106 GSList *lel; | 2107 GSList *lel; |
2107 gchar *format; | 2108 gchar *format; |
2108 // Find out maximum key length | 2109 // Find out maximum key length |
2109 for (lel = list; lel; lel = lel->next) { | 2110 for (lel = list; lel; lel = lel->next) { |
2110 const gchar *key = lel->data; | 2111 const gchar *key = lel->data; |
2111 gsize len = strlen(key); | 2112 gsize len = strlen(key); |
2112 if (len > max) | 2113 if (len > max) { |
2113 max = len; | 2114 max = len; |
2115 if (max > maxmax) { | |
2116 max = maxmax; | |
2117 break; | |
2118 } | |
2119 } | |
2114 } | 2120 } |
2115 // Print out list of options | 2121 // Print out list of options |
2116 format = g_strdup_printf("%%-%us = [%%s]", max); | 2122 format = g_strdup_printf("%%-%us = [%%s]", max); |
2117 for (lel = list; lel; lel = lel->next) { | 2123 for (lel = list; lel; lel = lel->next) { |
2118 const gchar *key = lel->data; | 2124 const gchar *key = lel->data; |