Mercurial > hg > forks > yadex
changeset 114:3287e1b7c77c
Add function for two prompts.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Oct 2014 15:47:56 +0300 |
parents | 275ec0b8c4cd |
children | 8fdb848549d0 |
files | src/wads2.cc |
diffstat | 1 files changed, 24 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- 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; } }