window: support early exit from the readline prompt with Ctrl-{C,G}

This commit is contained in:
Andrzej Rybczak
2014-10-30 23:47:31 +01:00
parent 1d0cfce646
commit 6dd7c742c6
3 changed files with 35 additions and 1 deletions

View File

@@ -112,6 +112,20 @@
/// wrappers over original curses library
namespace NC {//
/// Thrown if Ctrl-G is pressed during the call to Window::getString().
/// @see Window::getString()
struct PromptAborted : std::exception
{
template <typename ArgT>
PromptAborted(ArgT &&prompt)
: m_prompt(std::forward<ArgT>(prompt)) { }
virtual const char *what() const noexcept OVERRIDE { return m_prompt.c_str(); }
private:
std::string m_prompt;
};
/// Colors used by NCurses
enum class Color { Default, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, End };