mu-server: restore readline-support

Restore readline support for `mu server' (but _only_ when readline is
found and when in tty mode)
This commit is contained in:
Dirk-Jan C. Binnema
2020-05-25 18:32:10 +03:00
parent 57d38aa707
commit b60cfc7df2
5 changed files with 196 additions and 11 deletions

View File

@ -40,6 +40,7 @@
#include "utils/mu-str.h"
#include "utils/mu-utils.hh"
#include "utils/mu-command-parser.hh"
#include "utils/mu-readline.hh"
using namespace Mu;
using namespace Command;
@ -1270,17 +1271,6 @@ make_command_map (Context& context)
return cmap;
}
static std::string
read_line(bool& do_quit)
{
std::string line;
std::cout << ";; mu> ";
if (!std::getline(std::cin, line))
do_quit = true;
return line;
}
MuError
mu_cmd_server (MuConfig *opts, GError **err) try
{
@ -1300,6 +1290,10 @@ mu_cmd_server (MuConfig *opts, GError **err) try
return MU_OK;
}
const auto histpath{std::string{mu_runtime_path(MU_RUNTIME_PATH_CACHE)} + "/history"};
setup_readline(histpath, 50);
install_sig_handler();
std::cout << ";; Welcome to the " << PACKAGE_STRING << " command-server\n"
<< ";; Use (help) to get a list of commands, (quit) to quit.\n";
@ -1322,6 +1316,7 @@ mu_cmd_server (MuConfig *opts, GError **err) try
er.what(), line.c_str());
}
}
shutdown_readline();
return MU_OK;