Fix UTF-8 handling (including colors) (#79)

This commit is contained in:
Val Kharitonov 2023-03-13 12:24:18 -04:00 committed by GitHub
parent d1f224712d
commit 2a20f48efa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 11 deletions

View file

@ -939,6 +939,11 @@ int main(int argc, char ** argv) {
break;
}
}
// reset color to default if we there is no pending user input
if (!input_noecho && params.use_color && embd_inp.size() == input_consumed) {
printf(ANSI_COLOR_RESET);
}
}
// display text
@ -946,10 +951,6 @@ int main(int argc, char ** argv) {
for (auto id : embd) {
printf("%s", vocab.id_to_token[id].c_str());
}
// reset color to default if we there is no pending user input
if (params.use_color && embd_inp.size() <= input_consumed) {
printf(ANSI_COLOR_RESET);
}
fflush(stdout);
}