-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Minimal repro case (mac OSX):
#include "cpp-terminal/exception.hpp"
#include "cpp-terminal/key.hpp"
#include "cpp-terminal/prompt.hpp"
#include "cpp-terminal/terminal.hpp"
#include "cpp-terminal/tty.hpp"
#include <cpp-terminal/terminal_initializer.hpp>
#include <iostream>
bool determine_completeness(const std::string& command)
{
// Determine if the statement is complete
if (command.size() > 1 && command.substr(command.size() - 2, 1) == "\\")
return false;
return true;
}
int main()
{
try
{
Term::terminal.setOptions(Term::Option::NoClearScreen,
Term::Option::SignalKeys,
Term::Option::NoCursor,
Term::Option::Raw);
if (!Term::is_stdin_a_tty())
{
throw Term::Exception("The terminal is not attached to a TTY and therefore can't "
"catch user input. Exiting...");
}
Term::cout << "Interactive prompt.\n"
<< " * Use Ctrl-D to exit.\n"
<< " * Use Enter to submit.\n"
<< " * Features:\n"
<< " - Editing (Keys: Left, Right, Home, End, Backspace)\n"
<< " - History (Keys: Up, Down)" << std::endl;
std::vector<std::string> history;
std::function<bool(std::string)> iscomplete = determine_completeness;
std::string input = Term::prompt_multiline("Query> ", history, iscomplete);
return 0;
}
catch (const Term::Exception& re)
{
std::cerr << "cpp-terminal error: " << re.what() << std::endl;
return 2;
}
return 0;
}
Then clear the terminal and run.
I think I see what the issue is, I'll post a PR.
Metadata
Metadata
Assignees
Labels
No labels