Change default colouring to be compatible on macOS default terminal.
This commit is contained in:
parent
674bf73b32
commit
ae935b6f08
|
@ -1,11 +1,11 @@
|
|||
mod colour_utils;
|
||||
use colour_utils::*;
|
||||
use tui::style::{Color, Style};
|
||||
use tui::style::{Color, Modifier, Style};
|
||||
|
||||
use crate::{constants::*, utils::error};
|
||||
|
||||
const STANDARD_FIRST_COLOUR: Color = Color::Rgb(150, 106, 253);
|
||||
const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;
|
||||
const STANDARD_FIRST_COLOUR: Color = Color::Magenta;
|
||||
const STANDARD_SECOND_COLOUR: Color = Color::Yellow;
|
||||
|
||||
pub struct CanvasColours {
|
||||
pub currently_selected_text_colour: Color,
|
||||
|
@ -30,7 +30,9 @@ impl Default for CanvasColours {
|
|||
currently_selected_text_colour: Color::Black,
|
||||
currently_selected_bg_colour: Color::Cyan,
|
||||
currently_selected_text_style: Style::default().fg(Color::Black).bg(Color::Cyan),
|
||||
table_header_style: Style::default().fg(Color::LightBlue),
|
||||
table_header_style: Style::default()
|
||||
.fg(Color::LightBlue)
|
||||
.modifier(Modifier::BOLD),
|
||||
ram_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||
|
@ -59,7 +61,9 @@ impl CanvasColours {
|
|||
Ok(())
|
||||
}
|
||||
pub fn set_table_header_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||
self.table_header_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||
self.table_header_style = Style::default()
|
||||
.fg(convert_hex_to_color(hex)?)
|
||||
.modifier(Modifier::BOLD);
|
||||
Ok(())
|
||||
}
|
||||
pub fn set_ram_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||
|
|
|
@ -32,15 +32,16 @@ pub fn gen_n_styles(num_to_gen: i32) -> Vec<Style> {
|
|||
|
||||
// Generate colours
|
||||
let mut colour_vec: Vec<Style> = vec![
|
||||
Style::default().fg(Color::Rgb(150, 106, 253)),
|
||||
Style::default().fg(Color::LightYellow),
|
||||
Style::default().fg(Color::LightMagenta),
|
||||
Style::default().fg(Color::LightCyan),
|
||||
Style::default().fg(Color::Magenta),
|
||||
Style::default().fg(Color::Yellow),
|
||||
Style::default().fg(Color::Red),
|
||||
Style::default().fg(Color::Cyan),
|
||||
Style::default().fg(Color::Green),
|
||||
Style::default().fg(Color::Blue),
|
||||
];
|
||||
|
||||
let mut h: f32 = 0.4; // We don't need random colours... right?
|
||||
for _i in 0..(num_to_gen - 5) {
|
||||
for _i in 0..(num_to_gen - 6) {
|
||||
h = gen_hsv(h);
|
||||
let result = hsv_to_rgb(h, 0.5, 0.95);
|
||||
colour_vec.push(Style::default().fg(Color::Rgb(result.0, result.1, result.2)));
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -170,13 +170,11 @@ fn main() -> error::Result<()> {
|
|||
|
||||
// Set up up tui and crossterm
|
||||
let mut stdout_val = stdout();
|
||||
execute!(stdout_val, EnterAlternateScreen, EnableMouseCapture)?;
|
||||
enable_raw_mode()?;
|
||||
execute!(stdout_val, EnterAlternateScreen)?;
|
||||
execute!(stdout_val, EnableMouseCapture)?;
|
||||
|
||||
let mut terminal = Terminal::new(CrosstermBackend::new(stdout_val))?;
|
||||
terminal.hide_cursor()?;
|
||||
terminal.clear()?;
|
||||
|
||||
// Set panic hook
|
||||
panic::set_hook(Box::new(|info| panic_hook(info)));
|
||||
|
@ -656,8 +654,11 @@ fn cleanup_terminal(
|
|||
terminal: &mut tui::terminal::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>,
|
||||
) -> error::Result<()> {
|
||||
disable_raw_mode()?;
|
||||
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
|
||||
execute!(terminal.backend_mut(), DisableMouseCapture)?;
|
||||
execute!(
|
||||
terminal.backend_mut(),
|
||||
DisableMouseCapture,
|
||||
LeaveAlternateScreen
|
||||
)?;
|
||||
terminal.show_cursor()?;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue