@@ -177,13 +177,27 @@ void TFilePane::draw() {
177177 for (i=0 ;i<size.y ;i++) {
178178 dBuf.moveChar (0 , ' ' , getColor (0x0101 ), (short )size.x );
179179 if ((fileCount==0 )&&(i==0 ))
180- dBuf.moveCStr ( 2 , " <no files>" , getColor (0x0101 ) );
180+ dBuf.moveStr ( 2 , " <no files>" , getColor (0x0101 ) );
181181 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 );
183183 writeLine ( 0 , i, (short )size.x , 1 , dBuf );
184184 }
185185 }
186186
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+
187201void TFilePane::newDir ( const char *path ) {
188202 char searchPath[128 ] = {0 };
189203 find_t searchRec;
@@ -208,7 +222,8 @@ void TFilePane::newDir( const char *path ) {
208222 i=0 ;
209223 while (result==0 ) {
210224 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 ,
212227 ((searchRec.wr_date & 0x01E0 ) >> 5 ),
213228 (searchRec.wr_date & 0x001F ),
214229 ((searchRec.wr_date >> 9 )+1980 )%100 ,
@@ -218,14 +233,15 @@ void TFilePane::newDir( const char *path ) {
218233 searchRec.attrib & FA_RDONLY ? ' r' : ' \xFA ' ,
219234 searchRec.attrib & FA_SYSTEM ? ' s' : ' \xFA ' ,
220235 searchRec.attrib & FA_HIDDEN ? ' h' : ' \xFA ' );
236+ insertTextWidth (searchPath, searchRec.name , 18 , sizeof (searchPath));
221237 files[i++] = newStr (searchPath);
222238 }
223239 result=_dos_findnext ( &searchRec );
224240 }
225241 if (fileCount==0 )
226242 setLimit ( 1 , 1 );
227243 else
228- setLimit ( strlen (files[0 ]), fileCount );
244+ setLimit ( strwidth (files[0 ]), fileCount );
229245 drawView ();
230246 }
231247
0 commit comments