Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1026:fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Backport of changesets 023891f99732 and 553b8ecf901f.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Thu, 16 Nov 2006 19:30:12 +0100 |
parents | d9acb7f2a3d1 |
children | f7ef8003fc35 |
comparison
equal
deleted
inserted
replaced
1025:804aebb39028 | 1026:fc6060707022 |
---|---|
1086 update_panels(); | 1086 update_panels(); |
1087 curs_set(cursor_backup); | 1087 curs_set(cursor_backup); |
1088 return; | 1088 return; |
1089 } | 1089 } |
1090 | 1090 |
1091 name = g_new0(char, Roster_Width); | |
1092 | |
1093 // Update offset if necessary | 1091 // Update offset if necessary |
1094 // a) Try to show as many buddylist items as possible | 1092 // a) Try to show as many buddylist items as possible |
1095 i = g_list_length(buddylist) - maxy; | 1093 i = g_list_length(buddylist) - maxy; |
1096 if (i < 0) | 1094 if (i < 0) |
1097 i = 0; | 1095 i = 0; |
1099 offset = i; | 1097 offset = i; |
1100 // b) Make sure the current_buddy is visible | 1098 // b) Make sure the current_buddy is visible |
1101 i = g_list_position(buddylist, current_buddy); | 1099 i = g_list_position(buddylist, current_buddy); |
1102 if (i == -1) { // This is bad | 1100 if (i == -1) { // This is bad |
1103 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); | 1101 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
1104 g_free(name); | |
1105 curs_set(cursor_backup); | 1102 curs_set(cursor_backup); |
1106 return; | 1103 return; |
1107 } else if (i < offset) { | 1104 } else if (i < offset) { |
1108 offset = i; | 1105 offset = i; |
1109 } else if (i+1 > offset + maxy) { | 1106 } else if (i+1 > offset + maxy) { |
1110 offset = i + 1 - maxy; | 1107 offset = i + 1 - maxy; |
1111 } | 1108 } |
1112 | 1109 |
1113 rline = g_new0(char, Roster_Width+1); | 1110 name = g_new0(char, 4*Roster_Width); |
1111 rline = g_new0(char, 4*Roster_Width+1); | |
1114 | 1112 |
1115 buddy = buddylist; | 1113 buddy = buddylist; |
1116 rOffset = offset; | 1114 rOffset = offset; |
1117 | 1115 |
1118 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { | 1116 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
1168 else | 1166 else |
1169 wattrset(rosterWnd, get_color(COLOR_ROSTER)); | 1167 wattrset(rosterWnd, get_color(COLOR_ROSTER)); |
1170 } | 1168 } |
1171 | 1169 |
1172 if (Roster_Width > 7) | 1170 if (Roster_Width > 7) |
1173 strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); | 1171 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); |
1174 else | 1172 else |
1175 name[0] = 0; | 1173 name[0] = 0; |
1176 | 1174 |
1177 if (isgrp) { | 1175 if (isgrp) { |
1178 char *sep; | 1176 char *sep; |
1194 sepleft = '{'; | 1192 sepleft = '{'; |
1195 sepright = '}'; | 1193 sepright = '}'; |
1196 } | 1194 } |
1197 } | 1195 } |
1198 | 1196 |
1199 snprintf(rline, Roster_Width, | 1197 snprintf(rline, 4*Roster_Width, |
1200 " %c%c%c%c %s", pending, sepleft, status, sepright, name); | 1198 " %c%c%c%c %s", pending, sepleft, status, sepright, name); |
1201 } | 1199 } |
1202 | 1200 |
1203 rline_locale = from_utf8(rline); | 1201 rline_locale = from_utf8(rline); |
1204 mvwprintw(rosterWnd, i, 0, "%s", rline_locale); | 1202 mvwprintw(rosterWnd, i, 0, "%s", rline_locale); |