summaryrefslogtreecommitdiff
path: root/examples/common.h
diff options
context:
space:
mode:
authorDannyDaemonic <DannyDaemonic@gmail.com>2023-05-08 19:45:48 -0700
committerGitHub <noreply@github.com>2023-05-08 19:45:48 -0700
commit41654efea879bbdf4fd794e13335929d4cf0eb90 (patch)
tree9807bdab964759e8d1bae87930a482194f60216f /examples/common.h
parent56551bc11f46b2716fdf61bb48ac28414889dc0a (diff)
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
Diffstat (limited to 'examples/common.h')
-rw-r--r--examples/common.h23
1 files changed, 18 insertions, 5 deletions
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 <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);