libcubescript/tools/edit_fallback.hh

28 lines
607 B
C++
Raw Normal View History

#ifndef CS_REPL_HAS_EDIT
/* use nothing (no line editing support) */
2017-01-30 19:38:11 +01:00
#include <optional>
2021-03-20 08:22:15 +01:00
#include <string>
inline void init_lineedit(cs_state &, std::string_view) {
}
2017-06-19 20:13:54 +02:00
inline std::optional<std::string> read_line(cs_state &, cs_svar *pr) {
2021-03-20 08:22:15 +01:00
std::string lbuf;
char buf[512];
printf("%s", pr->get_value().data());
std::fflush(stdout);
while (fgets(buf, sizeof(buf), stdin)) {
lbuf += static_cast<char const *>(buf);
if (strchr(buf, '\n')) {
break;
}
}
return std::move(lbuf);
}
inline void add_history(cs_state &, std::string_view) {
}
#endif