diff options
author | Neil Moore <neil@s-z.org> | 2013-08-24 03:20:38 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-08-24 03:56:01 -0400 |
commit | f8c068ad83a84cf057d4f422c23b716d86a5db47 (patch) | |
tree | 86cff845e990b496f87eee2c112c71ac6e70853e /crawl-ref/source/cio.cc | |
parent | d1430c45d1c8454ff1b2807c1a96363b44deddc1 (diff) | |
download | crawl-ref-f8c068ad83a84cf057d4f422c23b716d86a5db47.tar.gz crawl-ref-f8c068ad83a84cf057d4f422c23b716d86a5db47.zip |
Allow specifying pre-filled text for {msgwin,cancelable}_get_line.
Also remove an unused parameter.
Diffstat (limited to 'crawl-ref/source/cio.cc')
-rw-r--r-- | crawl-ref/source/cio.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index 076c8eea86..7d36610079 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -157,7 +157,7 @@ static void wrapcprintf(int wrapcol, const char *s, ...) } int cancelable_get_line(char *buf, int len, input_history *mh, - int (*keyproc)(int &ch)) + int (*keyproc)(int &ch), const string &fill) { flush_prev_message(); @@ -166,7 +166,7 @@ int cancelable_get_line(char *buf, int len, input_history *mh, reader.set_input_history(mh); reader.set_keyproc(keyproc); - return reader.read_line(); + return reader.read_line(fill); } @@ -290,6 +290,14 @@ static void _webtiles_abort_get_line() } #endif +int line_reader::read_line(const string &prefill) +{ + strncpy(buffer, prefill.c_str(), bufsz); + // Just in case it was too long. + buffer[bufsz - 1] = '\0'; + return read_line(false); +} + int line_reader::read_line(bool clear_previous) { if (bufsz <= 0) |