Debian Codegraph @

terps/tads/tads3/askf_tx.cpp

raw symbols SCIP
1 #ifdef RCSID
2 static char RCSid[] =
3 "$Header$";
4 #endif
5
6 /*
7 * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved.
8 *
9 * Please see the accompanying license file, LICENSE.TXT, for information
10 * on using and copying this software.
11 */
12 /*
13 Name
14 askf_tx.cpp - formatted text implementation of askfile
15 Function
16 Implements file dialog using text prompts.
17 Notes
18 Only one of askf_tx.c or askf_os.c should be included in a given
19 executable. For a text-only version, include askf_tx. For a version
20 where os_askfile() provides a file dialog, use askf_os instead.
21
22 We provide a choice of tio_askfile() implementations in the portable
23 code (rather than only through the OS code) so that we can call
24 the formatted text output routines in this version. An OS-layer
25 implementation could not call the formatted output routines (it would
26 have to call os_printf directly), which would result in poor prompt
27 formatting any time a prompt exceeded a single line of text.
28 Modified
29 09/27/99 MJRoberts - Creation
30 */
31
32
33 #include "os.h"
34 #include "t3std.h"
35 #include "vmglob.h"
36 #include "vmconsol.h"
37
38 /*
39 * formatted text-only file prompt
40 */
41 int CVmConsole::askfile(VMG_ const char *prompt, size_t prompt_len,
42 char *reply, size_t replen,
43 int /*dialog_type*/, os_filetype_t /*file_type*/,
44 int bypass_script)
45 {
46 /* show the prompt */
47 format_text(vmg_ prompt, prompt_len);
48 format_text(vmg_ " >");
49
50 /* ask for the filename */
51 if (read_line(vmg_ reply, replen))
52 return OS_AFE_FAILURE;
53
54 /*
55 * if they entered an empty line, return "cancel"; otherwise, return
56 * success
57 */
58 return (reply[0] == '\0' ? OS_AFE_CANCEL : OS_AFE_SUCCESS);
59 }
60