@@ -194,46 +194,49 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
194
194
int start_x = (max_x / 2 - MEMBER_INFO_LEFT_ADJ );
195
195
int maxlen = (max_x - start_x );
196
196
197
- wmove (menu , end - start_y + 1 , start_x );
197
+ wmove (menu , end - start_y + 1 , 0 );
198
198
wclrtoeol (menu );
199
- wmove (menu , end - start_y + 2 , start_x );
199
+ wmove (menu , end - start_y + 2 , 0 );
200
200
wclrtoeol (menu );
201
- wmove (menu , end - start_y + 3 , start_x );
201
+ wmove (menu , end - start_y + 3 , 0 );
202
202
wclrtoeol (menu );
203
- wmove (menu , end - start_y + 4 , start_x );
203
+ wmove (menu , end - start_y + 4 , 0 );
204
204
wclrtoeol (menu );
205
- wmove (menu , end - start_y + 5 , start_x );
205
+ wmove (menu , end - start_y + 5 , 0 );
206
206
wclrtoeol (menu );
207
- wmove (menu , end - start_y + 6 , start_x );
207
+ wmove (menu , end - start_y + 6 , 0 );
208
+ wclrtoeol (menu );
209
+ wmove (menu , end - start_y + 7 , 0 );
208
210
wclrtoeol (menu );
209
211
210
212
if (mem -> displayname ) {
211
- int name_len = strlen (mem -> displayname );
213
+ char buf [maxlen + 1 ];
214
+ char * displayname = strdupa (mem -> displayname );
215
+ char * word ;
216
+ int current_line = 1 ;
217
+ int new_line = 1 ;
212
218
219
+ buf [0 ] = '\0' ;
213
220
wmove (menu , end - start_y + 1 , start_x );
214
- if (name_len > maxlen ) {
215
- char * last_space ;
216
- char * line_1 = strdup (mem -> displayname );
217
-
218
- if (line_1 ) {
219
- line_1 [maxlen ] = '\0' ;
220
- last_space = strrchr (line_1 , ' ' );
221
- if (last_space ) {
222
- * last_space = '\0' ;
223
- }
224
- waddstr (menu , line_1 );
225
- wmove (menu , end - start_y + 2 , start_x );
226
- waddstr (menu , & mem -> displayname [last_space - line_1 ]);
227
- free (line_1 );
228
- } else {
229
- waddstr (menu , (char * ) mem -> displayname );
221
+
222
+ while ((word = strsep (& displayname , " " ))) {
223
+ if ((strlen (buf ) + strlen (word ) + 1 ) > maxlen ) {
224
+ waddstr (menu , buf );
225
+ current_line ++ ;
226
+ wmove (menu , end - start_y + current_line , start_x );
227
+ buf [0 ] = '\0' ;
228
+ new_line = 1 ;
230
229
}
231
- } else {
232
- waddstr (menu , (char * ) mem -> displayname );
230
+ sprintf (buf , "%s%*.*s%s" , buf , new_line ? 0 : 1 , new_line ? 0 : 1 , " " , word );
231
+ new_line = 0 ;
232
+ }
233
+ if (strlen (buf )) {
234
+ waddstr (menu , buf );
233
235
}
234
236
}
237
+
235
238
if (!AST_LIST_EMPTY (& mem -> deps )) {
236
- wmove (menu , end - start_y + 3 , start_x );
239
+ wmove (menu , end - start_y + 4 , start_x );
237
240
strcpy (buf , "Depends on: " );
238
241
AST_LIST_TRAVERSE (& mem -> deps , dep , list ) {
239
242
strncat (buf , dep -> displayname , sizeof (buf ) - strlen (buf ) - 1 );
@@ -244,7 +247,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
244
247
waddstr (menu , buf );
245
248
}
246
249
if (!AST_LIST_EMPTY (& mem -> uses )) {
247
- wmove (menu , end - start_y + 4 , start_x );
250
+ wmove (menu , end - start_y + 5 , start_x );
248
251
strcpy (buf , "Can use: " );
249
252
AST_LIST_TRAVERSE (& mem -> uses , use , list ) {
250
253
strncat (buf , use -> displayname , sizeof (buf ) - strlen (buf ) - 1 );
@@ -255,7 +258,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
255
258
waddstr (menu , buf );
256
259
}
257
260
if (!AST_LIST_EMPTY (& mem -> conflicts )) {
258
- wmove (menu , end - start_y + 5 , start_x );
261
+ wmove (menu , end - start_y + 6 , start_x );
259
262
strcpy (buf , "Conflicts with: " );
260
263
AST_LIST_TRAVERSE (& mem -> conflicts , con , list ) {
261
264
strncat (buf , con -> displayname , sizeof (buf ) - strlen (buf ) - 1 );
@@ -268,7 +271,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
268
271
269
272
if (!mem -> is_separator ) { /* Separators lack support levels */
270
273
{ /* support level */
271
- wmove (menu , end - start_y + 6 , start_x );
274
+ wmove (menu , end - start_y + 7 , start_x );
272
275
snprintf (buf , sizeof (buf ), "Support Level: %s" , mem -> support_level );
273
276
if (mem -> replacement && * mem -> replacement ) {
274
277
char buf2 [64 ];
0 commit comments