From 41654efea879bbdf4fd794e13335929d4cf0eb90 Mon Sep 17 00:00:00 2001 From: DannyDaemonic Date: Mon, 8 May 2023 19:45:48 -0700 Subject: Interface improvements and `--multiline-input` (previously `--author-mode`) (#1040) * Interface improvements * Multiline input * Track character width * Works with all characters and control codes + Windows console fixes --- examples/common.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'examples/common.h') diff --git a/examples/common.h b/examples/common.h index 842e1516..43f1cc9e 100644 --- a/examples/common.h +++ b/examples/common.h @@ -10,6 +10,11 @@ #include #include +#if !defined (_WIN32) +#include +#include +#endif + // // CLI argument parsing // @@ -56,6 +61,7 @@ struct gpt_params { bool embedding = false; // get only sentence embedding bool interactive_first = false; // wait for user input immediately + bool multiline_input = false; // reverse the usage of `\` bool instruct = false; // instruction mode (used for Alpaca models) bool penalize_nl = true; // consider newlines as a repeatable token @@ -104,13 +110,20 @@ enum console_color_t { }; struct console_state { + bool multiline_input = false; bool use_color = false; console_color_t color = CONSOLE_COLOR_DEFAULT; -}; - -void set_console_color(console_state & con_st, console_color_t color); + FILE* out = stdout; #if defined (_WIN32) -void win32_console_init(bool enable_color); -void win32_utf8_encode(const std::wstring & wstr, std::string & str); + void* hConsole; +#else + FILE* tty = nullptr; + termios prev_state; #endif +}; + +void console_init(console_state & con_st); +void console_cleanup(console_state & con_st); +void console_set_color(console_state & con_st, console_color_t color); +bool console_readline(console_state & con_st, std::string & line); -- cgit v1.2.3