mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
#140: Ctrl-C handling via linenoise-ng
This commit is contained in:
parent
8b0b447e6a
commit
3b007bec3b
1 changed files with 16 additions and 9 deletions
|
@ -39,17 +39,24 @@ static ret_value entry(program& prog)
|
|||
|
||||
// get user entry
|
||||
entry = linenoise(PROMPT);
|
||||
if (entry != NULL)
|
||||
{
|
||||
// parse it
|
||||
ret = parse(entry, prog);
|
||||
|
||||
// keep history
|
||||
if (entry[0] != 0)
|
||||
linenoiseHistoryAdd(entry);
|
||||
}
|
||||
// Ctrl-C
|
||||
if (linenoiseKeyType() == 1)
|
||||
ret = ret_good_bye;
|
||||
else
|
||||
ret = ret_internal;
|
||||
{
|
||||
if (entry != NULL)
|
||||
{
|
||||
// parse it
|
||||
ret = parse(entry, prog);
|
||||
|
||||
// keep history
|
||||
if (entry[0] != 0)
|
||||
linenoiseHistoryAdd(entry);
|
||||
}
|
||||
else
|
||||
ret = ret_internal;
|
||||
}
|
||||
|
||||
free(entry);
|
||||
|
||||
|
|
Loading…
Reference in a new issue