summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-05-11 22:04:01 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-05-11 22:04:01 +0300
commit55cac6f2e54b6b620f6c1e6dcf0056fe8ad7c888 (patch)
treef79ec86e8a2145627ee1f4629e5a845f99b30647
parent099d41f3b53f9b8dfb5ec966a3a6e057b1810cdd (diff)
mu-server: disable readline support for now
Seems to be causing problem in non-interactive mode
-rw-r--r--mu/mu-cmd-server.cc91
1 files changed, 3 insertions, 88 deletions
diff --git a/mu/mu-cmd-server.cc b/mu/mu-cmd-server.cc
index d6261d6..11811d0 100644
--- a/mu/mu-cmd-server.cc
+++ b/mu/mu-cmd-server.cc
@@ -20,7 +20,6 @@
#include "config.h"
#include "mu-cmd.h"
-
#include <iostream>
#include <string>
#include <algorithm>
@@ -29,33 +28,6 @@
#include <glib.h>
#include <glib/gprintf.h>
-#ifdef HAVE_LIBREADLINE
-# if defined(HAVE_READLINE_READLINE_H)
-# include <readline/readline.h>
-# elif defined(HAVE_READLINE_H)
-# include <readline.h>
-# else /* !defined(HAVE_READLINE_H) */
-extern char *readline ();
-# endif /* !defined(HAVE_READLINE_H) */
-char *cmdline = NULL;
-#else /* !defined(HAVE_READLINE_READLINE_H) */
- /* no readline */
-#endif /* HAVE_LIBREADLINE */
-
-#ifdef HAVE_READLINE_HISTORY
-# if defined(HAVE_READLINE_HISTORY_H)
-# include <readline/history.h>
-# elif defined(HAVE_HISTORY_H)
-# include <history.h>
-# else /* !defined(HAVE_HISTORY_H) */
-extern void add_history ();
-extern int write_history ();
-extern int read_history ();
-# endif /* defined(HAVE_READLINE_HISTORY_H) */
- /* no history */
-#endif /* HAVE_READLINE_HISTORY */
-
-
#include "mu-runtime.h"
#include "mu-cmd.h"
#include "mu-maildir.h"
@@ -1299,59 +1271,8 @@ make_command_map (Context& context)
}
-struct Readline {
- Readline (const std::string& histpath, size_t max_lines);
- ~Readline();
- std::string read_line(bool& do_quit);
- void save_line(const std::string& line);
- std::string histpath_;
- size_t max_lines_{0};
-};
-
-/// Wrapper around readline (if available) or nothing otherwise.
-#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_HISTORY)
-Readline::Readline (const std::string& histpath, size_t max_lines):
- histpath_{histpath}, max_lines_{max_lines}
-{
- rl_bind_key('\t', rl_insert); // default (filenames) is not useful
- using_history();
- read_history (histpath_.c_str());
-
- if (max_lines_ > 0)
- stifle_history(max_lines_);
-}
-
-Readline::~Readline () {
- write_history(histpath_.c_str());
- if (max_lines_ > 0)
- history_truncate_file (histpath_.c_str(), max_lines_);
-}
-
-std::string
-Readline::read_line(bool& do_quit)
-{
- auto buf = readline(";; mu% ");
- if (!buf) {
- do_quit = true;
- return {};
- }
- std::string line{buf};
- ::free (buf);
- return line;
-}
-
-void
-Readline::save_line(const std::string& line)
-{
- add_history(line.c_str());
-}
-#else
-Readline::Readline (const std::string& histpath, size_t max_lines) {}
-Readline::~Readline() {}
-void Readline::save_line(const std::string& line) {}
-
-std::string
-Readline::read_line(bool& do_quit)
+static std::string
+read_line(bool& do_quit)
{
std::string line;
std::cout << ";; mu> ";
@@ -1359,8 +1280,6 @@ Readline::read_line(bool& do_quit)
do_quit = true;
return line;
}
-#endif // ! defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_HISTORY)
-
MuError
mu_cmd_server (MuConfig *opts, GError **err) try
@@ -1381,9 +1300,6 @@ mu_cmd_server (MuConfig *opts, GError **err) try
return MU_OK;
}
- const auto histpath{std::string{mu_runtime_path(MU_RUNTIME_PATH_CACHE)} + "/history"};
- Readline 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";
@@ -1392,12 +1308,11 @@ mu_cmd_server (MuConfig *opts, GError **err) try
std::string line;
try {
- line = readline.read_line(context.do_quit);
+ line = read_line(context.do_quit);
if (line.find_first_not_of(" \t") == std::string::npos)
continue; // skip whitespace-only lines
auto call{Sexp::parse(line)};
- readline.save_line(line);
invoke(context.command_map, call);