From cfb6ce6958751da5e13683ea07f42a5dbc4eae01 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 11 Mar 2023 18:53:36 +0800 Subject: 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 --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main.rs') 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 }; -- cgit v1.2.3