void display_Ls( int cnt ){
int wordLenMax = 0;//the LenMax word
int wordRowNum = 0;//the amount of one row
int wordColNum = 0;//the amount of one col
int i , j;
for( i=0;i<cnt;i++ ){
if( i==0 ) wordLenMax = strlen( Output[ i ].FileName );
else wordLenMax = wordLenMax>strlen( Output[ i ].FileName )?wordLenMax:strlen( Output[ i ].FileName );
}
wordLenMax +=2;
wordRowNum = terminalWidth / wordLenMax;
if( cnt%wordRowNum==0 ) wordColNum = cnt / wordRowNum;
else wordColNum = cnt / wordRowNum + 1;
for( i=0;i<wordColNum;i++ ){
j = i;
while( j<cnt ){
getcolor( Output[ j ].FileName );
printf("\033[%d;%d;%dm%-15s\033[0m ",colormode,foreground,background,Output[ j ].FileName);
j += wordColNum;
}
printf("\n");
}
return ;
}
/**********************************************************
ls的分栏输出
***********************************************************/
void display_Ls_a( int cntPoint,int cnt ){
int CNT = 0;
int wordLenMax = 0;//the LenMax word
int wordRowNum = 0;//the amount of one row
int wordColNum = 0;//the amount of one col
int i , j;
for( i=0;i<cntPoint;i++ ){
strcpy( Temp[ CNT ].FileName,OutputPoint[ i ].FileName );
Temp[ CNT ].file_type = OutputPoint[ i ].file_type;
Temp[ CNT ].modify_time = OutputPoint[ i ].modify_time;
CNT ++;
wordLenMax = wordLenMax>strlen( OutputPoint[ i ].FileName )?wordLenMax:strlen( OutputPoint[ i ].FileName );
}
for( i=0;i<cnt;i++ ){
strcpy( Temp[ CNT ].FileName,Output[ i ].FileName );
Temp[ CNT ].file_type = Output[ i ].file_type;
Temp[ CNT ].modify_time = Output[ i ].modify_time;
CNT ++;
wordLenMax = wordLenMax>strlen( Output[ i ].FileName )?wordLenMax:strlen( Output[ i ].FileName );
}
wordLenMax += 2;
wordRowNum = terminalWidth / wordLenMax;
if( CNT%wordRowNum==0 ) wordColNum = CNT / wordRowNum;
else wordColNum = CNT / wordRowNum + 1;
for( i=0;i<wordColNum;i++ ){
j = i;
while( j<CNT ){
getcolor( Temp[ j ].FileName );
printf("\033[%d;%d;%dm%-15s\033[0m ",colormode,foreground,background,Temp[ j ].FileName);
j += wordColNum;
}
printf("\n");
}
return ;
}
/**********************************************************
ls -a 的分栏输出
***********************************************************/