| 1136 | | } |
|---|
| 1137 | | if( w > 0 ) |
|---|
| 1138 | | { |
|---|
| 1139 | | if( ( i_len = strlen( p_buf ) ) > w ) |
|---|
| 1140 | | { |
|---|
| 1141 | | char *psz_local; |
|---|
| 1142 | | int i_cut = i_len - w; |
|---|
| 1143 | | int x1 = i_len/2 - i_cut/2; |
|---|
| 1144 | | int x2 = x1 + i_cut; |
|---|
| 1145 | | |
|---|
| 1146 | | if( i_len > x2 ) |
|---|
| 1147 | | { |
|---|
| 1148 | | memmove( &p_buf[x1], &p_buf[x2], i_len - x2 ); |
|---|
| 1149 | | } |
|---|
| 1150 | | p_buf[w] = '\0'; |
|---|
| 1151 | | if( w > 7 ) |
|---|
| 1152 | | { |
|---|
| 1153 | | p_buf[w/2-1] = '.'; |
|---|
| 1154 | | p_buf[w/2 ] = '.'; |
|---|
| 1155 | | p_buf[w/2+1] = '.'; |
|---|
| 1156 | | } |
|---|
| 1157 | | psz_local = ToLocale( p_buf ); |
|---|
| 1158 | | mvprintw( y, x, "%s", psz_local ); |
|---|
| 1159 | | LocaleFree( p_buf ); |
|---|
| 1160 | | } |
|---|
| 1161 | | else |
|---|
| 1162 | | { |
|---|
| 1163 | | char *psz_local = ToLocale( p_buf ); |
|---|
| 1164 | | mvprintw( y, x, "%s", psz_local ); |
|---|
| 1165 | | LocaleFree( p_buf ); |
|---|
| 1166 | | mvhline( y, x + i_len, ' ', w - i_len ); |
|---|
| 1167 | | } |
|---|
| | 1138 | |
|---|
| | 1139 | i_len = strlen( p_buf ); |
|---|
| | 1140 | psz_wide = (wchar_t *) malloc( sizeof( wchar_t ) * ( i_len + 1 ) ); |
|---|
| | 1141 | |
|---|
| | 1142 | i_char_len = mbstowcs( psz_wide, p_buf, i_len ); |
|---|
| | 1143 | |
|---|
| | 1144 | if( i_char_len == -1 ) /* an invalid character was encountered */ |
|---|
| | 1145 | i_width = i_len; |
|---|
| | 1146 | else |
|---|
| | 1147 | { |
|---|
| | 1148 | i_width = wcswidth( psz_wide, i_char_len ); |
|---|
| | 1149 | if( i_width == -1 ) /* a non printable character was encountered */ |
|---|
| | 1150 | i_width = i_len; |
|---|
| | 1151 | } |
|---|
| | 1152 | |
|---|
| | 1153 | if( i_width > w ) |
|---|
| | 1154 | { /* FIXME: ellipsize psz_wide while keeping the width in mind */ |
|---|
| | 1155 | char *psz_local; |
|---|
| | 1156 | int i_cut = i_len - w; |
|---|
| | 1157 | int x1 = i_len/2 - i_cut/2; |
|---|
| | 1158 | int x2 = x1 + i_cut; |
|---|
| | 1159 | |
|---|
| | 1160 | if( i_len > x2 ) |
|---|
| | 1161 | { |
|---|
| | 1162 | memmove( &p_buf[x1], &p_buf[x2], i_len - x2 ); |
|---|
| | 1163 | } |
|---|
| | 1164 | p_buf[w] = '\0'; |
|---|
| | 1165 | if( w > 7 ) |
|---|
| | 1166 | { |
|---|
| | 1167 | p_buf[w/2-1] = '.'; |
|---|
| | 1168 | p_buf[w/2 ] = '.'; |
|---|
| | 1169 | p_buf[w/2+1] = '.'; |
|---|
| | 1170 | } |
|---|
| | 1171 | psz_local = ToLocale( p_buf ); |
|---|
| | 1172 | mvprintw( y, x, "%s", psz_local ); |
|---|
| | 1173 | LocaleFree( p_buf ); |
|---|
| | 1174 | } |
|---|
| | 1175 | else |
|---|
| | 1176 | { |
|---|
| | 1177 | char *psz_local = ToLocale( p_buf ); |
|---|
| | 1178 | mvprintw( y, x, "%s", psz_local ); |
|---|
| | 1179 | LocaleFree( p_buf ); |
|---|
| | 1180 | mvhline( y, x + i_width, ' ', w - i_width ); |
|---|