@@ -1150,36 +1150,7 @@ std::string display::colorized_bodypart_status_legend_text( const Character &u,
1150
1150
}
1151
1151
}
1152
1152
}
1153
- // Split legend keys into X lines, where X = height.
1154
- // Lines use the provided width.
1155
- // This effectively limits the text to a 'width'x'height' box.
1156
- std::string ret;
1157
- height = 0 ;
1158
- const int h_max = max_height == 0 ? INT_MAX : max_height;
1159
- const int nsize = keys.size ();
1160
- for ( int row = 0 , nidx = 0 ; row < h_max && nidx < nsize; row++ ) {
1161
- int wavail = width;
1162
- int nwidth = utf8_width ( keys[nidx], true );
1163
- bool startofline = true ;
1164
- while ( nidx < nsize && ( wavail > nwidth || startofline ) ) {
1165
- startofline = false ;
1166
- wavail -= nwidth;
1167
- ret += keys[nidx];
1168
- nidx++;
1169
- if ( nidx < nsize ) {
1170
- nwidth = utf8_width ( keys[nidx], true );
1171
- if ( wavail > nwidth ) {
1172
- ret += " " ;
1173
- wavail -= 2 ;
1174
- }
1175
- }
1176
- }
1177
- if ( row < h_max - 1 ) {
1178
- ret += " \n " ;
1179
- }
1180
- height++;
1181
- }
1182
- return ret;
1153
+ return format_widget_multiline ( keys, max_height, width, height );
1183
1154
}
1184
1155
1185
1156
std::string display::colorized_bodypart_outer_armor ( const Character &u, const bodypart_id &bp )
@@ -1586,36 +1557,7 @@ std::string display::colorized_compass_legend_text( int width, int max_height, i
1586
1557
name = string_format ( " %s %s" , colorize ( m.first ->sym , m.first ->color ), colorize ( name, danger ) );
1587
1558
names.emplace_back ( name );
1588
1559
}
1589
- // Split names into X lines, where X = height.
1590
- // Lines use the provided width.
1591
- // This effectively limits the text to a 'width'x'height' box.
1592
- std::string ret;
1593
- height = 0 ;
1594
- const int h_max = max_height == 0 ? INT_MAX : max_height;
1595
- const int nsize = names.size ();
1596
- for ( int row = 0 , nidx = 0 ; row < h_max && nidx < nsize; row++ ) {
1597
- int wavail = width;
1598
- int nwidth = utf8_width ( names[nidx], true );
1599
- bool startofline = true ;
1600
- while ( nidx < nsize && ( wavail > nwidth || startofline ) ) {
1601
- startofline = false ;
1602
- wavail -= nwidth;
1603
- ret += names[nidx];
1604
- nidx++;
1605
- if ( nidx < nsize ) {
1606
- nwidth = utf8_width ( names[nidx], true );
1607
- if ( wavail > nwidth ) {
1608
- ret += " " ;
1609
- wavail -= 2 ;
1610
- }
1611
- }
1612
- }
1613
- if ( row < h_max - 1 ) {
1614
- ret += " \n " ;
1615
- }
1616
- height++;
1617
- }
1618
- return ret;
1560
+ return format_widget_multiline ( names, max_height, width, height );
1619
1561
}
1620
1562
1621
1563
// Print monster info to the given window
0 commit comments