@@ -82,17 +82,21 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
8282 assert (w <= INT_MAX - MAXIMUM (0 , x ));
8383
8484 // Draw the caption
85- int captionLen = 3 ;
85+ const int captionWidth = 3 ;
8686 const char * caption = Meter_getCaption (this );
87- if (w >= captionLen ) {
87+ if (w >= captionWidth ) {
8888 attrset (CRT_colors [METER_TEXT ]);
89- mvaddnstr (y , x , caption , captionLen );
89+
90+ const char * ptr = caption ;
91+ int nCols = String_mbswidth (& ptr , 256 , captionWidth );
92+ int len = (int )(ptr - caption );
93+ mvprintw (y , x , "%-*.*s" , len + captionWidth - nCols , len , caption );
9094 }
91- w -= captionLen ;
95+ w -= captionWidth ;
9296
9397 // Draw the bar borders
9498 if (w >= 1 ) {
95- x += captionLen ;
99+ x += captionWidth ;
96100 attrset (CRT_colors [BAR_BORDER ]);
97101 mvaddch (y , x , '[' );
98102 w -- ;
@@ -206,13 +210,17 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
206210 assert (w <= INT_MAX - MAXIMUM (0 , x ));
207211
208212 // Draw the caption
209- const int captionLen = 3 ;
213+ const int captionWidth = 3 ;
210214 const char * caption = Meter_getCaption (this );
211- if (w >= captionLen ) {
215+ if (w >= captionWidth ) {
212216 attrset (CRT_colors [METER_TEXT ]);
213- mvaddnstr (y , x , caption , captionLen );
217+
218+ const char * ptr = caption ;
219+ int nCols = String_mbswidth (& ptr , 256 , captionWidth );
220+ int len = (int )(ptr - caption );
221+ mvprintw (y , x , "%-*.*s" , len + captionWidth - nCols , len , caption );
214222 }
215- w -= captionLen ;
223+ w -= captionWidth ;
216224
217225 GraphData * data = & this -> drawData ;
218226
@@ -250,7 +258,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
250258 if (w < 1 ) {
251259 goto end ;
252260 }
253- x += captionLen ;
261+ x += captionWidth ;
254262
255263 // Graph drawing style (character set, etc.)
256264 const char * const * GraphMeterMode_dots ;
0 commit comments