|
|
@ -152,14 +152,12 @@ static int process_input()
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_line(char* line)
|
|
|
|
static void handle_line(char* line)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(last_line == "exit" || last_line == "q")
|
|
|
|
// This function never gets called now as we are trapping newlines.
|
|
|
|
{
|
|
|
|
// However, it still needs to be present for readline to know we are
|
|
|
|
|
|
|
|
// manually handling lines.
|
|
|
|
|
|
|
|
rl_done = 1;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::lock_guard<std::mutex> lock(sync_mutex);
|
|
|
|
|
|
|
|
rl_set_prompt(last_prompt.c_str());
|
|
|
|
|
|
|
|
rl_already_prompted = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int handle_enter(int x, int y)
|
|
|
|
static int handle_enter(int x, int y)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -167,30 +165,42 @@ static int handle_enter(int x, int y)
|
|
|
|
char* line = NULL;
|
|
|
|
char* line = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
line = rl_copy_text(0, rl_end);
|
|
|
|
line = rl_copy_text(0, rl_end);
|
|
|
|
|
|
|
|
std::string test_line = line;
|
|
|
|
|
|
|
|
boost::trim_right(test_line);
|
|
|
|
|
|
|
|
|
|
|
|
rl_crlf();
|
|
|
|
rl_crlf();
|
|
|
|
rl_on_new_line();
|
|
|
|
rl_on_new_line();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(test_line.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
last_line = "";
|
|
|
|
|
|
|
|
rl_set_prompt(last_prompt.c_str());
|
|
|
|
|
|
|
|
rl_replace_line("", 1);
|
|
|
|
|
|
|
|
rl_redisplay();
|
|
|
|
|
|
|
|
have_line.notify_one();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rl_set_prompt("");
|
|
|
|
rl_set_prompt("");
|
|
|
|
rl_replace_line("", 1);
|
|
|
|
rl_replace_line("", 1);
|
|
|
|
rl_redisplay();
|
|
|
|
rl_redisplay();
|
|
|
|
|
|
|
|
|
|
|
|
std::string test_line = line;
|
|
|
|
if (!test_line.empty())
|
|
|
|
boost::trim_right(test_line);
|
|
|
|
|
|
|
|
if (test_line.length() > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
last_line = test_line;
|
|
|
|
last_line = test_line;
|
|
|
|
add_history(test_line.c_str());
|
|
|
|
add_history(test_line.c_str());
|
|
|
|
have_line.notify_one();
|
|
|
|
history_set_pos(history_length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(line);
|
|
|
|
free(line);
|
|
|
|
|
|
|
|
|
|
|
|
if(last_line != "exit" && last_line != "q")
|
|
|
|
if(last_line != "exit" && last_line != "q")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rl_set_prompt(last_prompt.c_str());
|
|
|
|
rl_set_prompt(last_prompt.c_str());
|
|
|
|
rl_on_new_line_with_prompt();
|
|
|
|
rl_replace_line("", 1);
|
|
|
|
rl_redisplay();
|
|
|
|
rl_redisplay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rl_done = 1;
|
|
|
|
have_line.notify_one();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -236,6 +246,7 @@ static void install_line_handler()
|
|
|
|
rl_startup_hook = startup_hook;
|
|
|
|
rl_startup_hook = startup_hook;
|
|
|
|
rl_attempted_completion_function = attempted_completion;
|
|
|
|
rl_attempted_completion_function = attempted_completion;
|
|
|
|
rl_callback_handler_install("", handle_line);
|
|
|
|
rl_callback_handler_install("", handle_line);
|
|
|
|
|
|
|
|
stifle_history(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void remove_line_handler()
|
|
|
|
static void remove_line_handler()
|
|
|
|