summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-11 18:53:36 +0800
committerGitHub <noreply@github.com>2023-03-11 18:53:36 +0800
commitcfb6ce6958751da5e13683ea07f42a5dbc4eae01 (patch)
treec7ec60ba7c1d2e37225ae6b1476057a18e2eb987 /src/main.rs
parentdc09cb38d480342c9fe781a19fe72d2bb892b70c (diff)
downloadaichat-cfb6ce6958751da5e13683ea07f42a5dbc4eae01.tar.gz
feat: support light theme (#65)
There are two ways to enable the light theme: - add `light_theme: true` to config.yaml - use `AICHAT_LIGHT_THEME=true` env var
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 5bcdf11..fa0e64e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -75,10 +75,11 @@ fn start_directive(
no_stream: bool,
) -> Result<()> {
let highlight = config.lock().highlight && stdout().is_terminal();
+ let light_theme = config.lock().light_theme;
let output = if no_stream {
let output = client.send_message(input)?;
if highlight {
- let mut markdown_render = MarkdownRender::new();
+ let mut markdown_render = MarkdownRender::new(light_theme);
println!("{}", markdown_render.render(&output).trim());
} else {
println!("{}", output.trim());
@@ -92,7 +93,15 @@ fn start_directive(
abort_clone.set_ctrlc();
})
.expect("Error setting Ctrl-C handler");
- let output = render_stream(input, &client, highlight, false, abort, wg.clone())?;
+ let output = render_stream(
+ input,
+ &client,
+ highlight,
+ light_theme,
+ false,
+ abort,
+ wg.clone(),
+ )?;
wg.wait();
output
};