# HG changeset patch # User Matti Hamalainen # Date 1412599676 -10800 # Node ID 3287e1b7c77c9076646caf9d57282884044cfdb2 # Parent 275ec0b8c4cd2fd18e2cabccfbcac1328ff66b64 Add function for two prompts. diff -r 275ec0b8c4cd -r 3287e1b7c77c src/wads2.cc --- a/src/wads2.cc Mon Oct 06 15:47:29 2014 +0300 +++ b/src/wads2.cc Mon Oct 06 15:47:56 2014 +0300 @@ -41,6 +41,24 @@ static int level_name_order(const void *p1, const void *p2); +static bool ShowContinuePrompt(FILE *file, int *lines) +{ + if (file == stdout && (*lines)++ > cfg.screen_lines - 4) + { + lines = 0; + printf("['Q' followed by Return to abort, Return only to continue]"); + char key = getchar(); + printf("\r%57s\r", ""); + if (key == 'Q' || key == 'q') + { + getchar(); // Read the '\n' + return false; + } + } + + return true; +} + /* * OpenMainWad - open the iwad * @@ -513,7 +531,6 @@ { char dataname[WAD_NAME + 1]; MDirPtr dir; - char key; int lines = 3; dataname[WAD_NAME] = '\0'; @@ -528,19 +545,9 @@ fprintf(file, "%-*s %-50s %6ld x%08lx\n", WAD_NAME, dataname, dir->wadfile->pathname(), dir->dir.size, dir->dir.start); - if (file == stdout && lines++ > cfg.screen_lines - 4) - { - lines = 0; - printf - ("['Q' followed by Return to abort, Return only to continue]"); - key = getchar(); - printf("\r%57s\r", ""); - if (key == 'Q' || key == 'q') - { - getchar(); // Read the '\n' - break; - } - } + + if (!ShowContinuePrompt(file, &lines)) + break; } } @@ -550,7 +557,6 @@ */ void ListFileDirectory(FILE * file, const Wad_file * wad) { - char key; char dataname[WAD_NAME + 1] = ""; int lines = 5; long n; @@ -567,19 +573,9 @@ wad->directory[n].size, wad->directory[n].start, wad->directory[n].size + wad->directory[n].start - 1); - if (file == stdout && lines++ > cfg.screen_lines - 4) - { - lines = 0; - printf - ("['Q' followed by Return to abort, Return only to continue]"); - key = getchar(); - printf("\r%57s\r", ""); - if (key == 'Q' || key == 'q') - { - getchar(); // Read the '\n' - break; - } - } + + if (!ShowContinuePrompt(file, &lines)) + break; } }