@@ -177,13 +177,27 @@ void TFilePane::draw() {
177
177
for (i=0 ;i<size.y ;i++) {
178
178
dBuf.moveChar (0 , ' ' , getColor (0x0101 ), (short )size.x );
179
179
if ((fileCount==0 )&&(i==0 ))
180
- dBuf.moveCStr ( 2 , " <no files>" , getColor (0x0101 ) );
180
+ dBuf.moveStr ( 2 , " <no files>" , getColor (0x0101 ) );
181
181
if ((i+delta.y )<fileCount)
182
- dBuf.moveCStr ( 2 , & files[i+delta.y ][delta. x ] , getColor (0x0101 ) );
182
+ dBuf.moveStr ( 2 , files[i+delta.y ], getColor (0x0101 ), ( ushort ) - 1U , delta. x );
183
183
writeLine ( 0 , i, (short )size.x , 1 , dBuf );
184
184
}
185
185
}
186
186
187
+ static void insertTextWidth (char *dst, TStringView src, int width, size_t dstSize)
188
+ // Inserts 'width' columns of text from 'src' into 'dst'. If not enough characters
189
+ // can be extracted from 'src', remaining columns are filled with spaces.
190
+ {
191
+ size_t srcLen = TText::wseek (src, 18 , False);
192
+ size_t emptyLen = 18 - strwidth (TStringView (&src[0 ], srcLen));
193
+ size_t moveLen = srcLen + emptyLen;
194
+ size_t textLen = min (strlen (dst), dstSize-1 -moveLen);
195
+ memmove (&dst[moveLen] , dst, textLen);
196
+ memcpy (dst, &src[0 ], srcLen);
197
+ for (size_t j = 0 ; j < emptyLen; ++j)
198
+ dst[srcLen + j] = ' ' ;
199
+ }
200
+
187
201
void TFilePane::newDir ( const char *path ) {
188
202
char searchPath[128 ] = {0 };
189
203
find_t searchRec;
@@ -208,7 +222,8 @@ void TFilePane::newDir( const char *path ) {
208
222
i=0 ;
209
223
while (result==0 ) {
210
224
if (!(searchRec.attrib & FA_DIREC)) {
211
- sprintf (searchPath," %-18.18s %8ld %2d-%02d-%02d %2d:%02d %c%c%c%c" ,searchRec.name ,searchRec.size ,
225
+ sprintf (searchPath," %8ld %2d-%02d-%02d %2d:%02d %c%c%c%c" ,
226
+ searchRec.size ,
212
227
((searchRec.wr_date & 0x01E0 ) >> 5 ),
213
228
(searchRec.wr_date & 0x001F ),
214
229
((searchRec.wr_date >> 9 )+1980 )%100 ,
@@ -218,14 +233,15 @@ void TFilePane::newDir( const char *path ) {
218
233
searchRec.attrib & FA_RDONLY ? ' r' : ' \xFA ' ,
219
234
searchRec.attrib & FA_SYSTEM ? ' s' : ' \xFA ' ,
220
235
searchRec.attrib & FA_HIDDEN ? ' h' : ' \xFA ' );
236
+ insertTextWidth (searchPath, searchRec.name , 18 , sizeof (searchPath));
221
237
files[i++] = newStr (searchPath);
222
238
}
223
239
result=_dos_findnext ( &searchRec );
224
240
}
225
241
if (fileCount==0 )
226
242
setLimit ( 1 , 1 );
227
243
else
228
- setLimit ( strlen (files[0 ]), fileCount );
244
+ setLimit ( strwidth (files[0 ]), fileCount );
229
245
drawView ();
230
246
}
231
247
0 commit comments