diff options
Diffstat (limited to 'examples/common.h')
-rw-r--r-- | examples/common.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/examples/common.h b/examples/common.h index 842e151..43f1cc9 100644 --- a/examples/common.h +++ b/examples/common.h @@ -10,6 +10,11 @@ #include <thread> #include <unordered_map> +#if !defined (_WIN32) +#include <stdio.h> +#include <termios.h> +#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); |