parent
aa43cbb764
commit
bd17ccf1d8
1 changed files with 10 additions and 1 deletions
|
@ -186,7 +186,16 @@ bool NixRepl::getLine(string & input, const std::string &prompt)
|
||||||
{
|
{
|
||||||
char * s = linenoise(prompt.c_str());
|
char * s = linenoise(prompt.c_str());
|
||||||
Finally doFree([&]() { free(s); });
|
Finally doFree([&]() { free(s); });
|
||||||
if (!s) return false;
|
if (!s) {
|
||||||
|
switch (auto type = linenoiseKeyType()) {
|
||||||
|
case 1: // ctrl-C
|
||||||
|
return true;
|
||||||
|
case 2: // ctrl-D
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
throw Error(format("Unexpected linenoise keytype: %1%") % type);
|
||||||
|
}
|
||||||
|
}
|
||||||
input += s;
|
input += s;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue