additional termimad config

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-17 00:19:17 +00:00
parent 1ccdba8921
commit 8affdc43a6

View file

@ -27,24 +27,12 @@ const HISTORY_LIMIT: usize = 48;
impl Console { impl Console {
#[must_use] #[must_use]
pub fn new() -> Arc<Self> { pub fn new() -> Arc<Self> {
use termimad::{crossterm::style::Color, Alignment, CompoundStyle, LineStyle};
let mut output = MadSkin::default_dark();
let code_style = CompoundStyle::with_fgbg(Color::AnsiValue(40), Color::AnsiValue(234));
output.inline_code = code_style.clone();
output.code_block = LineStyle {
left_margin: 0,
right_margin: 0,
align: Alignment::Left,
compound_style: code_style,
};
Arc::new(Self { Arc::new(Self {
worker_join: None.into(), worker_join: None.into(),
input_abort: None.into(), input_abort: None.into(),
command_abort: None.into(), command_abort: None.into(),
history: VecDeque::with_capacity(HISTORY_LIMIT).into(), history: VecDeque::with_capacity(HISTORY_LIMIT).into(),
output, output: configure_output(MadSkin::default_dark()),
}) })
} }
@ -175,8 +163,7 @@ impl Console {
} }
async fn output(self: Arc<Self>, output_content: RoomMessageEventContent) { async fn output(self: Arc<Self>, output_content: RoomMessageEventContent) {
let output = self.output.term_text(output_content.body()); self.output.print_text(output_content.body());
println!("{output}");
} }
fn set_history(&self, readline: &mut Readline) { fn set_history(&self, readline: &mut Readline) {
@ -192,3 +179,26 @@ impl Console {
history.truncate(HISTORY_LIMIT); history.truncate(HISTORY_LIMIT);
} }
} }
fn configure_output(mut output: MadSkin) -> MadSkin {
use termimad::{crossterm::style::Color, Alignment, CompoundStyle, LineStyle};
let code_style = CompoundStyle::with_fgbg(Color::AnsiValue(40), Color::AnsiValue(234));
output.inline_code = code_style.clone();
output.code_block = LineStyle {
left_margin: 0,
right_margin: 0,
align: Alignment::Left,
compound_style: code_style,
};
let table_style = CompoundStyle::default();
output.table = LineStyle {
left_margin: 1,
right_margin: 1,
align: Alignment::Left,
compound_style: table_style,
};
output
}