libcubescript/tools/edit_fallback.hh

28 lines
612 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>
2021-03-23 23:29:32 +01:00
inline void init_lineedit(cs::state &, std::string_view) {
}
inline std::optional<std::string> read_line(cs::state &, cs::string_var &pr) {
2021-03-20 08:22:15 +01:00
std::string lbuf;
char buf[512];
printf("%s", pr.value().data());
2021-03-20 08:22:15 +01:00
std::fflush(stdout);
while (fgets(buf, sizeof(buf), stdin)) {
lbuf += static_cast<char const *>(buf);
if (strchr(buf, '\n')) {
break;
}
}
return std::move(lbuf);
}
2021-03-23 23:29:32 +01:00
inline void add_history(cs::state &, std::string_view) {
}
#endif