Fix output formatting of 'dir' command
Adapt to 'pause' command working correctly (assuming the terminal height is 25, this will need further adjustments for supporting 80x50 and different modes). Adjust "intro" by 1 space to make formatting the same as MS-DOS 'dir' command - this makes intro not "merge" visually with the files listed. Adjust placing of files and directories counters, to make it resemble most 'dir' implementations. Count intro lines for purpose of correct pagination with 'dir /p'. Skip counting not printed lines with 'dir /b /p'. Output of 'dir /w /p' is still broken, but fixing it will require more invasive changes. Fixes: #75
This commit is contained in:
parent
e68a64aade
commit
3eaabb41c1
2 changed files with 19 additions and 9 deletions
|
@ -581,9 +581,9 @@ void SHELL_Init() {
|
|||
MSG_Add("SHELL_CMD_GOTO_LABEL_NOT_FOUND","GOTO: Label %s not found.\n");
|
||||
MSG_Add("SHELL_CMD_FILE_NOT_FOUND","File %s not found.\n");
|
||||
MSG_Add("SHELL_CMD_FILE_EXISTS","File %s already exists.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_INTRO","Directory of %s.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_USED","%5d File(s) %17s Bytes.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_FREE","%5d Dir(s) %17s Bytes free.\n");
|
||||
MSG_Add("SHELL_CMD_DIR_INTRO"," Directory of %s\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_USED","%16d file(s) %17s bytes\n");
|
||||
MSG_Add("SHELL_CMD_DIR_BYTES_FREE","%16d dir(s) %17s bytes free\n");
|
||||
MSG_Add("SHELL_EXECUTE_DRIVE_NOT_FOUND","Drive %c does not exist!\nYou must \033[31mmount\033[0m it first. Type \033[1;33mintro\033[0m or \033[1;33mintro mount\033[0m for more information.\n");
|
||||
MSG_Add("SHELL_EXECUTE_ILLEGAL_COMMAND","Illegal command: %s.\n");
|
||||
MSG_Add("SHELL_CMD_PAUSE","Press any key to continue...");
|
||||
|
|
|
@ -489,11 +489,9 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem);
|
||||
return;
|
||||
}
|
||||
Bit32u byte_count,file_count,dir_count;
|
||||
Bitu w_count=0;
|
||||
Bitu p_count=0;
|
||||
Bitu w_count = 0;
|
||||
Bitu p_count = 0;
|
||||
Bitu w_size = optW?5:1;
|
||||
byte_count=file_count=dir_count=0;
|
||||
|
||||
char buffer[CROSS_LEN];
|
||||
args = trim(args);
|
||||
|
@ -529,7 +527,11 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
return;
|
||||
}
|
||||
*(strrchr(path,'\\')+1)=0;
|
||||
if (!optB) WriteOut(MSG_Get("SHELL_CMD_DIR_INTRO"),path);
|
||||
if (!optB) {
|
||||
WriteOut(MSG_Get("SHELL_CMD_DIR_INTRO"), path);
|
||||
WriteOut_NoParsing("\n");
|
||||
p_count += 2;
|
||||
}
|
||||
|
||||
/* Command uses dta so set it to our internal dta */
|
||||
RealPt save_dta=dos.dta();
|
||||
|
@ -573,6 +575,10 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
std::reverse(results.begin(), results.end());
|
||||
}
|
||||
|
||||
uint32_t byte_count = 0;
|
||||
uint32_t file_count = 0;
|
||||
uint32_t dir_count = 0;
|
||||
|
||||
for (std::vector<DtaResult>::iterator iter = results.begin(); iter != results.end(); iter++) {
|
||||
|
||||
char * name = iter->name;
|
||||
|
@ -586,6 +592,10 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
// this overrides pretty much everything
|
||||
if (strcmp(".",name) && strcmp("..",name)) {
|
||||
WriteOut("%s\n",name);
|
||||
} else {
|
||||
// skip to the next file, otherwise this file
|
||||
// will be counted as printed for pause cmd
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
char * ext = empty_string;
|
||||
|
@ -625,7 +635,7 @@ void DOS_Shell::CMD_DIR(char * args) {
|
|||
w_count++;
|
||||
}
|
||||
}
|
||||
if (optP && !(++p_count%(22*w_size))) {
|
||||
if (optP && !(++p_count % (24 * w_size))) {
|
||||
CMD_PAUSE(empty_string);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue