From ce87522f84d80574c5c70f418ee9b976895d2002 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Fri, 13 Apr 2007 21:34:05 +0100 Subject: [PATCH] cmd.exe: Implement a basic 'more'. This implements a basic more, eg 'dir | more' or 'more file.c' but it does not support the flags or keys which can control it. Basically its not worth implementing those, as in some modes we cannot read a single key, we have to wait for anyway. --- programs/cmd/Cs.rc | 4 ++ programs/cmd/De.rc | 4 ++ programs/cmd/En.rc | 4 ++ programs/cmd/Es.rc | 4 ++ programs/cmd/Fr.rc | 4 ++ programs/cmd/Ja.rc | 4 ++ programs/cmd/Ko.rc | 4 ++ programs/cmd/Nl.rc | 4 ++ programs/cmd/No.rc | 4 ++ programs/cmd/Pl.rc | 4 ++ programs/cmd/Pt.rc | 7 +++ programs/cmd/Ru.rc | 4 ++ programs/cmd/Si.rc | 4 ++ programs/cmd/Tr.rc | 4 ++ programs/cmd/builtins.c | 109 +++++++++++++++++++++++++++++++++++++++ programs/cmd/directory.c | 2 +- programs/cmd/wcmd.h | 7 ++- programs/cmd/wcmdmain.c | 14 +++-- 18 files changed, 184 insertions(+), 7 deletions(-) diff --git a/programs/cmd/Cs.rc b/programs/cmd/Cs.rc index 83d01b2373e..7c72f6f7549 100644 --- a/programs/cmd/Cs.rc +++ b/programs/cmd/Cs.rc @@ -199,6 +199,8 @@ P WCMD_VOL, "Npovda k VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT ukon bc sezen a vrt kontrolu\n\ operanmu systmu nebo pkazovmu interpretu,\n\ @@ -217,6 +219,7 @@ DIR\t\tVyp ECHO\t\tVype text na terminl\n\ HELP\t\tZobraz detailn npovdu k tmatu\n\ MD (MKDIR)\tVytvo adres\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tPesune soubor, skupinu soubor nebo adresov strom\n\ PATH\t\tNastav nebo uke prohledvan cesty\n\ PROMPT\t\tZmn vzvu pkazovho dku\n\ @@ -237,4 +240,5 @@ Zadejte HELP

for further information on any of the above commands\n" WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Es.rc b/programs/cmd/Es.rc index 093349674ce..723eef38794 100644 --- a/programs/cmd/Es.rc +++ b/programs/cmd/Es.rc @@ -212,6 +212,8 @@ La bandera de verificaci WCMD_VOL, "Ayuda sobre VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT termina la sesin de comandos actual y regresa al sistema\n\ operativo o intrprete de comandos desde el que invoc cmd.\n" @@ -229,6 +231,7 @@ DIR\t\tListar el contenido de un directorio\n\ ECHO\t\tCopiar texto directamente a la salida de consola\n\ HELP\t\tMostrar detalles breves de ayuda sobre un tema\n\ MD (MKDIR)\tCrear un subdirectorio\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tMover un archivo, conjunto de archivos o rbol de directorio\n\ PATH\t\tAjustar o cambiar la ruta de bsqueda\n\ PROMPT\t\tCambiar el prompt de comandos\n\ @@ -249,4 +252,5 @@ Introduzca HELP para m WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Fr.rc b/programs/cmd/Fr.rc index 6897438b994..51a35b65219 100644 --- a/programs/cmd/Fr.rc +++ b/programs/cmd/Fr.rc @@ -194,6 +194,8 @@ Le flag de verification n'a pas de fonction dans Wine.\n" WCMD_VOL, "\t\tAffiche le nom de volume d'un lecteur de disque\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT termine la session de ligne de commande et retourne\n\ au systme d'exploitation ou au shell o vous avez invoqu cmd.\n" @@ -211,6 +213,7 @@ DIR\t\tListe le contenu d'un r ECHO\t\tAffiche du texte sur la console\n\ HELP\t\tAffiche de brefs dtails sur l'utilisation d'une commande\n\ MD (MKDIR)\tCre un rpertoire\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tDplace un fichier, un groupe de fichiers ou un rpertoire\n\ PATH\t\tRgle ou affiche le chemin de recherche\n\ PROMPT\t\tChange l'invite de commande\n\ @@ -231,4 +234,5 @@ Entrez HELP pour plus d'informations sur les commandes ci-dessus\n" WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Ja.rc b/programs/cmd/Ja.rc index f7435a691f0..fa38df435fd 100644 --- a/programs/cmd/Ja.rc +++ b/programs/cmd/Ja.rc @@ -199,6 +199,8 @@ Wine WCMD_VOL, "VOL̃wv\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT ݂͌̃R}hZbVIcmdĂяoOS܂̓VFɖ߂܂B\n" @@ -215,6 +217,7 @@ DIR\t\t ECHO\t\t𒼐ڃR\[o͂ɃRs[\n\ HELP\t\tgsbN̏ڍׂȃwv\\n\ MD (MKDIR)\tTufBNg쐬\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tt@C܂̓fBNgc[ړ\n\ PATH\t\tpX\͐ݒ\n\ PROMPT\t\tR}hvvgύX\n\ @@ -235,4 +238,5 @@ EXIT\t\tCMD WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Ko.rc b/programs/cmd/Ko.rc index 525ff5998a8..138d93b394e 100644 --- a/programs/cmd/Ko.rc +++ b/programs/cmd/Ko.rc @@ -194,6 +194,8 @@ verify WCMD_POPD, "POPD 丮 PUSH ߴ ٲ۴.\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT ߴܽŰ ü ưų cmd\n\ ȣ ưϴ.\n" @@ -211,6 +213,7 @@ DIR\t\t ECHO\t\tڸ ٷ ȭ \n\ HELP\t\t © ׸ \n\ MD (MKDIR)\t 丮 \n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\t ̳ ,׸ 丮 ̵\n\ PATH\t\tŽ ְų ϱ\n\ POPD\t\tPUSHD ߴ 丮 ư\n\ @@ -233,4 +236,5 @@ HELP < WCMD_NOASSOC, " Ȯ %s Ǯ׸ ϴ. \n" WCMD_NOFTYPE, " '%s'  ɵ ϴ.'\n" WCMD_OVERWRITE, "" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Nl.rc b/programs/cmd/Nl.rc index ef6c7e20a90..8d90b6b2411 100644 --- a/programs/cmd/Nl.rc +++ b/programs/cmd/Nl.rc @@ -197,6 +197,8 @@ De verify-schakelaar heeft geen functie binnen Wine.\n" WCMD_VOL, "Uitleg bij VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT beindigt de lopende sessie en keert terug\n\ naar het besturingssysteem of de schil van waaruit cmd werd gestart.\n" @@ -214,6 +216,7 @@ DIR\t\tToon de inhoud van een directory\n\ ECHO\t\tKopier tekst direct naar het uitvoerapparaat\n\ HELP\t\tToon een korte uitleg over een onderwerp\n\ MD (MKDIR)\tMaak een directory\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tVerplaats een bestand, een verzameling bestanden of een directory\n\ PATH\t\tWijzig of toon het zoekpad\n\ PROMPT\t\tWijzig de prompt\n\ @@ -234,4 +237,5 @@ type HELP voor meer informatie over bovengenoemde opdrachten\n" WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/No.rc b/programs/cmd/No.rc index 87e84d23189..52cc5246488 100644 --- a/programs/cmd/No.rc +++ b/programs/cmd/No.rc @@ -195,6 +195,8 @@ VERIFY Viser ON hvis p WCMD_VOL, "Hjelp til VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT avslutter gjeldende kommandokt og returnerer til operativsystemet\n\ eller skallet CMD ble startet fra.\n" @@ -212,6 +214,7 @@ DIR\t\tViser innholdet i en katalgo\n\ ECHO\t\tKopierer tekst direkte til konsoll-utdataen\n\ HELP\t\tViser en kort hjelpebeskrivelse om et emne\n\ MD (MKDIR)\tLager en underkatalog\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tFlytter en eller flere filer, eller en katalogtre\n\ PATH\t\tEndrer eller viser skestien\n\ PROMPT\t\tEndrer kommando-klartegnet\n\ @@ -232,4 +235,5 @@ Skriv WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Pl.rc b/programs/cmd/Pl.rc index 59afcf0a633..3203c070fec 100644 --- a/programs/cmd/Pl.rc +++ b/programs/cmd/Pl.rc @@ -197,6 +197,8 @@ Ustawienia flagi nic nie zmieniaj WCMD_POPD, "POPD ustala aktualny katalog na ostatni katalog zapamitany przez\n\ PUSHD\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT koczy bierzc sesj cmd i powraca do systemu operacyjnego\n\ lub powoki, w ktrej uruchomiono cmd.\n" @@ -214,6 +216,7 @@ DIR\t\tWy ECHO\t\tKopiuje tekst na wyjcie konsoli\n\ HELP\t\tWywietla dokadniejsz pomoc o komendzie\n\ MD (MKDIR)\tTworzy katalog\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tPrzenosi katalog lub pliki\n\ PATH\t\tUstawia lub wywietla ciek przeszukiwania\n\ POPD\t\tWraca do katalogu zapamitanego przez PUSHD\n\ @@ -236,4 +239,5 @@ Wpisz HELP dla dok WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Pt.rc b/programs/cmd/Pt.rc index 3c9809fce69..af023d324a7 100644 --- a/programs/cmd/Pt.rc +++ b/programs/cmd/Pt.rc @@ -196,6 +196,8 @@ O flag de verifica WCMD_VOL, "Ajuda do comando VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT termina a sesso de comando atual e retorna ao sistema operacional\n\ ou shell que tenha invocado o cmd.\n" @@ -213,6 +215,7 @@ DIR\t\tMostra o conte ECHO\t\tCopia texto diretamente na sada do console\n\ HELP\t\tMostra breves detalhes de um tpico\n\ MD (MKDIR)\tCria um subdiretrio\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tMove um arquivo, conjunto de arquivos ou uma rvore de diretrios\n\ PATH\t\tConfigira o caminho de procura\n\ PROMPT\t\tMuda o 'prompt' de comando\n\ @@ -404,6 +407,8 @@ O flag de verifica WCMD_VOL, "Ajuda do comando VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT termina a sesso de comando actual e retorna ao sistema operacional\n\ ou shell que tenha invocado o cmd.\n" @@ -421,6 +426,7 @@ DIR\t\tMostra o conte ECHO\t\tCopia o texto diretamente na sada da consola\n\ HELP\t\tMostra breves detalhes de um tpico\n\ MD (MKDIR)\tCria um subdirectrio\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tMove um ficheiro, conjunto de ficheiros ou uma rvore de directrios\n\ PATH\t\tConfigura o caminho de procura\n\ PROMPT\t\tMuda a 'prompt' de comando\n\ @@ -441,4 +447,5 @@ Digite HELP para mais informa WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Ru.rc b/programs/cmd/Ru.rc index 781aa26cb68..dfb805546b6 100644 --- a/programs/cmd/Ru.rc +++ b/programs/cmd/Ru.rc @@ -208,6 +208,8 @@ stack, and then changes the current directory to the supplied one.\n" WCMD_POPD, "POPD changes current directory to the last one saved with\n\ PUSHD.\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT \n\ cmd.\n" @@ -225,6 +227,7 @@ DIR\t\t ECHO\t\t \n\ HELP\t\t \n\ MD (MKDIR)\t \n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\t , \n\ PATH\t\t \n\ POPD\t\tRestores the directory to the last one saved with PUSHD\n\ @@ -247,4 +250,5 @@ EXIT\t\t WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Si.rc b/programs/cmd/Si.rc index f70c915e0c9..1c120b45647 100644 --- a/programs/cmd/Si.rc +++ b/programs/cmd/Si.rc @@ -196,6 +196,8 @@ The verify flag has no function in Wine.\n" WCMD_VOL, "Help about VOL\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT terminates the current command session and returns\n\ to the operating system or shell from which you invoked cmd.\n" @@ -213,6 +215,7 @@ DIR\t\tList the contents of a directory\n\ ECHO\t\tCopy text directly to the console output\n\ HELP\t\tShow brief help details on a topic\n\ MD (MKDIR)\tCreate a subdirectory\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tMove a file, set of files or directory tree\n\ PATH\t\tSet or show the search path\n\ PROMPT\t\tChange the command prompt\n\ @@ -233,4 +236,5 @@ Enter HELP for further information on any of the above commands\n" WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/Tr.rc b/programs/cmd/Tr.rc index 8b4820bab01..50a00d0bac7 100644 --- a/programs/cmd/Tr.rc +++ b/programs/cmd/Tr.rc @@ -198,6 +198,8 @@ Do WCMD_VOL, "VOL hakknda yardm\n" + WCMD_MORE, "MORE displays output of files or piped input in pages.\n" + WCMD_EXIT, "EXIT geerli komut oturumunu sonlandrr ve cmd'yi ardnz\n\ yerden iletim sistemine dner.\n" @@ -215,6 +217,7 @@ DIR\t\tDizin i ECHO\t\tMetni dorudan konsol kna kopyala\n\ HELP\t\tBir konu zerinde zet yardm gster\n\ MD (MKDIR)\tAlt dizin olutur\n\ +MORE\t\tDisplay output in pages\n\ MOVE\t\tBir veya daha fazla dosyay ya da dizin aacn ta\n\ PATH\t\tArama yolunu dzenle veya gster\n\ PROMPT\t\tKomut istemini deitir\n\ @@ -235,4 +238,5 @@ Yukar WCMD_NOASSOC, "File association missing for extension %s\n" WCMD_NOFTYPE, "No open command associated with file type '%s'\n" WCMD_OVERWRITE, "Overwrite" + WCMD_MORESTR, "More..." } diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 3d4f034a70f..e7398fd74f9 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1688,6 +1688,115 @@ void WCMD_type (char *command) { } } +/**************************************************************************** + * WCMD_more + * + * Output either a file or stdin to screen in pages + */ + +void WCMD_more (char *command) { + + int argno = 0; + char *argN = command; + BOOL useinput = FALSE; + char moreStr[100]; + char moreStrPage[100]; + char buffer[512]; + DWORD count; + + /* Prefix the NLS more with '-- ', then load the text */ + errorlevel = 0; + strcpy(moreStr, "-- "); + LoadString (hinst, WCMD_MORESTR, &moreStr[3], sizeof(moreStr)-3); + + if (param1[0] == 0x00) { + + /* Wine implements pipes via temporary files, and hence stdin is + effectively reading from the file. This means the prompts for + more are satistied by the next line from the input (file). To + avoid this, ensure stdin is to the console */ + HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE); + HANDLE hConIn = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, 0); + SetStdHandle(STD_INPUT_HANDLE, hConIn); + + /* Warning: No easy way of ending the stream (ctrl+z on windows) so + once you get in this bit unless due to a pipe, its going to end badly... */ + useinput = TRUE; + sprintf(moreStrPage, "%s --\n", moreStr); + + WCMD_enter_paged_mode(moreStrPage); + while (ReadFile (hstdin, buffer, sizeof(buffer)-1, &count, NULL)) { + if (count == 0) break; /* ReadFile reports success on EOF! */ + buffer[count] = 0; + WCMD_output_asis (buffer); + } + WCMD_leave_paged_mode(); + + /* Restore stdin to what it was */ + SetStdHandle(STD_INPUT_HANDLE, hstdin); + CloseHandle(hConIn); + + return; + } else { + BOOL needsPause = FALSE; + + /* Loop through all args */ + WCMD_enter_paged_mode(moreStrPage); + + while (argN) { + char *thisArg = WCMD_parameter (command, argno++, &argN); + HANDLE h; + + if (!argN) break; + + if (needsPause) { + + /* Wait */ + sprintf(moreStrPage, "%s (100%%) --\n", moreStr); + WCMD_leave_paged_mode(); + WCMD_output_asis(moreStrPage); + ReadFile (GetStdHandle(STD_INPUT_HANDLE), buffer, sizeof(buffer), &count, NULL); + WCMD_enter_paged_mode(moreStrPage); + } + + + WINE_TRACE("more: Processing arg '%s'\n", thisArg); + h = CreateFile (thisArg, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) { + WCMD_print_error (); + WCMD_output ("%s :Failed\n", thisArg); + errorlevel = 1; + } else { + ULONG64 curPos = 0; + ULONG64 fileLen = 0; + WIN32_FILE_ATTRIBUTE_DATA fileInfo; + + /* Get the file size */ + GetFileAttributesEx(thisArg, GetFileExInfoStandard, (void*)&fileInfo); + fileLen = (((ULONG64)fileInfo.nFileSizeHigh) << 32) + fileInfo.nFileSizeLow; + + needsPause = TRUE; + while (ReadFile (h, buffer, sizeof(buffer), &count, NULL)) { + if (count == 0) break; /* ReadFile reports success on EOF! */ + buffer[count] = 0; + curPos += count; + + /* Update % count (would be used in WCMD_output_asis as prompt) */ + sprintf(moreStrPage, "%s (%2.2d%%) --\n", moreStr, (int) min(99, (curPos * 100)/fileLen)); + + WCMD_output_asis (buffer); + } + CloseHandle (h); + } + } + + WCMD_leave_paged_mode(); + } +} + /**************************************************************************** * WCMD_verify * diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index ac1e59d5eda..801d59d1205 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -277,7 +277,7 @@ void WCMD_directory (char *cmd) { max_width = 80; } if (paged_mode) { - WCMD_enter_paged_mode(); + WCMD_enter_paged_mode(NULL); } argno = 0; diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 2873ea2c40f..8718dd608a5 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -39,13 +39,14 @@ void WCMD_delete (char *); void WCMD_directory (char *); void WCMD_echo (const char *); void WCMD_endlocal (void); -void WCMD_enter_paged_mode(void); +void WCMD_enter_paged_mode(const char *); void WCMD_exit (void); void WCMD_for (char *); void WCMD_give_help (char *command); void WCMD_goto (void); void WCMD_if (char *); void WCMD_leave_paged_mode(void); +void WCMD_more (char *); void WCMD_move (void); void WCMD_output (const char *format, ...); void WCMD_output_asis (const char *message); @@ -163,9 +164,10 @@ struct env_stack #define WCMD_ASSOC 40 #define WCMD_COLOR 41 #define WCMD_FTYPE 42 +#define WCMD_MORE 43 /* Must be last in list */ -#define WCMD_EXIT 43 +#define WCMD_EXIT 44 /* Some standard messages */ extern const char nyi[]; @@ -180,6 +182,7 @@ extern const char anykey[]; #define WCMD_NOASSOC 1004 #define WCMD_NOFTYPE 1005 #define WCMD_OVERWRITE 1006 +#define WCMD_MORESTR 1007 /* msdn specified max for Win XP */ #define MAXSTRING 8192 diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 5ef6ef65ab1..88a827c4fe1 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -36,7 +36,7 @@ const char * const inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY", "PROMPT", "REM", "REN", "RENAME", "RD", "RMDIR", "SET", "SHIFT", "TIME", "TITLE", "TYPE", "VERIFY", "VER", "VOL", "ENDLOCAL", "SETLOCAL", "PUSHD", "POPD", "ASSOC", "COLOR", "FTYPE", - "EXIT" }; + "MORE", "EXIT" }; HINSTANCE hinst; DWORD errorlevel; @@ -49,6 +49,7 @@ const char anykey[] = "Press Return key to continue: "; char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH]; BATCH_CONTEXT *context = NULL; extern struct env_stack *pushd_directories; +static const char *pagedMessage = NULL; static char *WCMD_expand_envvar(char *start); @@ -714,6 +715,9 @@ void WCMD_process_command (char *command) case WCMD_FTYPE: WCMD_assoc(p, FALSE); break; + case WCMD_MORE: + WCMD_more(p); + break; case WCMD_EXIT: WCMD_exit (); break; @@ -1215,7 +1219,7 @@ static int line_count; static int max_height; static BOOL paged_mode; -void WCMD_enter_paged_mode(void) +void WCMD_enter_paged_mode(const char *msg) { CONSOLE_SCREEN_BUFFER_INFO consoleInfo; @@ -1224,12 +1228,14 @@ void WCMD_enter_paged_mode(void) else max_height = 25; paged_mode = TRUE; - line_count = 5; /* keep 5 lines from previous output */ + line_count = 0; + pagedMessage = (msg==NULL)? anykey : msg; } void WCMD_leave_paged_mode(void) { paged_mode = FALSE; + pagedMessage = NULL; } /******************************************************************* @@ -1250,7 +1256,7 @@ void WCMD_output_asis (const char *message) { if (ptr) { if (++line_count >= max_height - 1) { line_count = 0; - WCMD_output_asis (anykey); + WCMD_output_asis (pagedMessage); ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL); } }