* -> &
This commit is contained in:
parent
fcabe9b8b2
commit
ebf09a1919
3 changed files with 11 additions and 11 deletions
|
@ -267,8 +267,8 @@ std::vector<llama_token> llama_tokenize(struct llama_context * ctx, const std::s
|
|||
}
|
||||
|
||||
/* Keep track of current color of output, and emit ANSI code if it changes. */
|
||||
void set_console_color(console_state* con_st, console_color_t color) {
|
||||
if (con_st->use_color && con_st->color != color) {
|
||||
void set_console_color(console_state & con_st, console_color_t color) {
|
||||
if (con_st.use_color && con_st.color != color) {
|
||||
switch(color) {
|
||||
case CONSOLE_COLOR_DEFAULT:
|
||||
printf(ANSI_COLOR_RESET);
|
||||
|
@ -280,7 +280,7 @@ void set_console_color(console_state* con_st, console_color_t color) {
|
|||
printf(ANSI_BOLD ANSI_COLOR_GREEN);
|
||||
break;
|
||||
}
|
||||
con_st->color = color;
|
||||
con_st.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ struct console_state {
|
|||
console_color_t color = CONSOLE_COLOR_DEFAULT;
|
||||
};
|
||||
|
||||
void set_console_color(console_state* con_st, console_color_t color);
|
||||
void set_console_color(console_state & con_st, console_color_t color);
|
||||
|
||||
#if defined (_WIN32)
|
||||
void win32_console_init(bool enable_color);
|
||||
|
|
|
@ -24,7 +24,7 @@ static bool is_interacting = false;
|
|||
|
||||
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
|
||||
void sigint_handler(int signo) {
|
||||
set_console_color(&con_st, CONSOLE_COLOR_DEFAULT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_DEFAULT);
|
||||
printf("\n"); // this also force flush stdout.
|
||||
if (signo == SIGINT) {
|
||||
if (!is_interacting) {
|
||||
|
@ -235,7 +235,7 @@ int main(int argc, char ** argv) {
|
|||
int n_consumed = 0;
|
||||
|
||||
// the first thing we will do is to output the prompt, so set color accordingly
|
||||
set_console_color(&con_st, CONSOLE_COLOR_PROMPT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_PROMPT);
|
||||
|
||||
std::vector<llama_token> embd;
|
||||
|
||||
|
@ -336,7 +336,7 @@ int main(int argc, char ** argv) {
|
|||
}
|
||||
// reset color to default if we there is no pending user input
|
||||
if (!input_noecho && (int)embd_inp.size() == n_consumed) {
|
||||
set_console_color(&con_st, CONSOLE_COLOR_DEFAULT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_DEFAULT);
|
||||
}
|
||||
|
||||
// in interactive mode, and not currently processing queued inputs;
|
||||
|
@ -356,7 +356,7 @@ int main(int argc, char ** argv) {
|
|||
if (last_output.find(antiprompt.c_str(), last_output.length() - antiprompt.length(), antiprompt.length()) != std::string::npos) {
|
||||
is_interacting = true;
|
||||
is_antiprompt = true;
|
||||
set_console_color(&con_st, CONSOLE_COLOR_USER_INPUT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_USER_INPUT);
|
||||
fflush(stdout);
|
||||
break;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ int main(int argc, char ** argv) {
|
|||
|
||||
if (n_past > 0 && is_interacting) {
|
||||
// potentially set color to indicate we are taking user input
|
||||
set_console_color(&con_st, CONSOLE_COLOR_USER_INPUT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_USER_INPUT);
|
||||
|
||||
if (params.instruct) {
|
||||
printf("\n> ");
|
||||
|
@ -393,7 +393,7 @@ int main(int argc, char ** argv) {
|
|||
} while (another_line);
|
||||
|
||||
// done taking input, reset color
|
||||
set_console_color(&con_st, CONSOLE_COLOR_DEFAULT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_DEFAULT);
|
||||
|
||||
// Add tokens to embd only if the input buffer is non-empty
|
||||
// Entering a empty line lets the user pass control back
|
||||
|
@ -448,7 +448,7 @@ int main(int argc, char ** argv) {
|
|||
llama_print_timings(ctx);
|
||||
llama_free(ctx);
|
||||
|
||||
set_console_color(&con_st, CONSOLE_COLOR_DEFAULT);
|
||||
set_console_color(con_st, CONSOLE_COLOR_DEFAULT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue