mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
less colors more contrast
This commit is contained in:
parent
ec93892c6b
commit
c6b5e2f8c3
4 changed files with 19 additions and 28 deletions
|
@ -6,7 +6,7 @@ use const_format::concatcp;
|
||||||
use roc_load::MonomorphizedModule;
|
use roc_load::MonomorphizedModule;
|
||||||
use roc_mono::ir::OptLevel;
|
use roc_mono::ir::OptLevel;
|
||||||
use roc_repl_eval::gen::Problems;
|
use roc_repl_eval::gen::Problems;
|
||||||
use roc_repl_ui::colors::{BLUE, END_COL, PINK};
|
use roc_repl_ui::colors::{CYAN, END_COL, GREEN};
|
||||||
use roc_repl_ui::repl_state::{ReplAction, ReplState};
|
use roc_repl_ui::repl_state::{ReplAction, ReplState};
|
||||||
use roc_repl_ui::{format_output, is_incomplete, CONT_PROMPT, PROMPT, SHORT_INSTRUCTIONS, TIPS};
|
use roc_repl_ui::{format_output, is_incomplete, CONT_PROMPT, PROMPT, SHORT_INSTRUCTIONS, TIPS};
|
||||||
use roc_reporting::report::{ANSI_STYLE_CODES, DEFAULT_PALETTE};
|
use roc_reporting::report::{ANSI_STYLE_CODES, DEFAULT_PALETTE};
|
||||||
|
@ -21,11 +21,11 @@ use crate::cli_gen::eval_llvm;
|
||||||
|
|
||||||
pub const WELCOME_MESSAGE: &str = concatcp!(
|
pub const WELCOME_MESSAGE: &str = concatcp!(
|
||||||
"\n The rockin' ",
|
"\n The rockin' ",
|
||||||
BLUE,
|
CYAN,
|
||||||
"roc repl",
|
"roc repl",
|
||||||
END_COL,
|
END_COL,
|
||||||
"\n",
|
"\n",
|
||||||
PINK,
|
GREEN,
|
||||||
"────────────────────────",
|
"────────────────────────",
|
||||||
END_COL,
|
END_COL,
|
||||||
"\n\n"
|
"\n\n"
|
||||||
|
|
|
@ -6,7 +6,6 @@ const STYLE_CODES: StyleCodes = if cfg!(target_family = "wasm") {
|
||||||
ANSI_STYLE_CODES
|
ANSI_STYLE_CODES
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BLUE: &str = STYLE_CODES.blue;
|
|
||||||
pub const PINK: &str = STYLE_CODES.magenta;
|
|
||||||
pub const GREEN: &str = STYLE_CODES.green;
|
pub const GREEN: &str = STYLE_CODES.green;
|
||||||
|
pub const CYAN: &str = STYLE_CODES.green;
|
||||||
pub const END_COL: &str = STYLE_CODES.reset;
|
pub const END_COL: &str = STYLE_CODES.reset;
|
||||||
|
|
|
@ -4,19 +4,17 @@ pub mod colors;
|
||||||
pub mod repl_state;
|
pub mod repl_state;
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use colors::{BLUE, END_COL, PINK};
|
use colors::{CYAN, GREEN, END_COL};
|
||||||
use const_format::concatcp;
|
use const_format::concatcp;
|
||||||
use repl_state::{parse_src, ParseOutcome};
|
use repl_state::{parse_src, ParseOutcome};
|
||||||
use roc_parse::ast::{Expr, ValueDef};
|
use roc_parse::ast::{Expr, ValueDef};
|
||||||
use roc_repl_eval::gen::{Problems, ReplOutput};
|
use roc_repl_eval::gen::{Problems, ReplOutput};
|
||||||
use roc_reporting::report::StyleCodes;
|
use roc_reporting::report::StyleCodes;
|
||||||
|
|
||||||
use crate::colors::GREEN;
|
|
||||||
|
|
||||||
// TODO add link to repl tutorial (does not yet exist).
|
// TODO add link to repl tutorial (does not yet exist).
|
||||||
pub const TIPS: &str = concatcp!(
|
pub const TIPS: &str = concatcp!(
|
||||||
"\nEnter an expression to evaluate, or a definition (like ",
|
"\nEnter an expression to evaluate, or a definition (like ",
|
||||||
BLUE,
|
CYAN,
|
||||||
"x = 1",
|
"x = 1",
|
||||||
END_COL,
|
END_COL,
|
||||||
") to use later.\n\n",
|
") to use later.\n\n",
|
||||||
|
@ -25,25 +23,25 @@ pub const TIPS: &str = concatcp!(
|
||||||
} else {
|
} else {
|
||||||
// We use ctrl-v + ctrl-j for newlines because on Unix, terminals cannot distinguish between Shift-Enter and Enter
|
// We use ctrl-v + ctrl-j for newlines because on Unix, terminals cannot distinguish between Shift-Enter and Enter
|
||||||
concatcp!(
|
concatcp!(
|
||||||
BLUE,
|
CYAN,
|
||||||
" - ",
|
" - ",
|
||||||
END_COL,
|
END_COL,
|
||||||
PINK,
|
GREEN,
|
||||||
"ctrl-v",
|
"ctrl-v",
|
||||||
END_COL,
|
END_COL,
|
||||||
" + ",
|
" + ",
|
||||||
PINK,
|
GREEN,
|
||||||
"ctrl-j",
|
"ctrl-j",
|
||||||
END_COL,
|
END_COL,
|
||||||
" makes a newline\n",
|
" makes a newline\n",
|
||||||
BLUE,
|
CYAN,
|
||||||
" - ",
|
" - ",
|
||||||
END_COL,
|
END_COL,
|
||||||
GREEN,
|
GREEN,
|
||||||
":q",
|
":q",
|
||||||
END_COL,
|
END_COL,
|
||||||
" quits\n",
|
" quits\n",
|
||||||
BLUE,
|
CYAN,
|
||||||
" - ",
|
" - ",
|
||||||
END_COL,
|
END_COL,
|
||||||
GREEN,
|
GREEN,
|
||||||
|
@ -57,8 +55,8 @@ pub const TIPS: &str = concatcp!(
|
||||||
// For when nothing is entered in the repl
|
// For when nothing is entered in the repl
|
||||||
// TODO add link to repl tutorial(does not yet exist).
|
// TODO add link to repl tutorial(does not yet exist).
|
||||||
pub const SHORT_INSTRUCTIONS: &str = "Enter an expression, or :help, or :q to quit.\n\n";
|
pub const SHORT_INSTRUCTIONS: &str = "Enter an expression, or :help, or :q to quit.\n\n";
|
||||||
pub const PROMPT: &str = concatcp!(BLUE, "»", END_COL, " ");
|
pub const PROMPT: &str = concatcp!(CYAN, "»", END_COL, " ");
|
||||||
pub const CONT_PROMPT: &str = concatcp!(BLUE, "…", END_COL, " ");
|
pub const CONT_PROMPT: &str = concatcp!(CYAN, "…", END_COL, " ");
|
||||||
|
|
||||||
pub fn is_incomplete(input: &str) -> bool {
|
pub fn is_incomplete(input: &str) -> bool {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
|
@ -116,7 +114,7 @@ pub fn format_output(
|
||||||
{
|
{
|
||||||
buf.push('\n');
|
buf.push('\n');
|
||||||
buf.push_str(&expr);
|
buf.push_str(&expr);
|
||||||
buf.push_str(style_codes.magenta); // Color for the type separator
|
buf.push_str(style_codes.green); // Color for the type separator
|
||||||
buf.push_str(EXPR_TYPE_SEPARATOR);
|
buf.push_str(EXPR_TYPE_SEPARATOR);
|
||||||
buf.push_str(style_codes.reset);
|
buf.push_str(style_codes.reset);
|
||||||
buf.push_str(&expr_type);
|
buf.push_str(&expr_type);
|
||||||
|
|
|
@ -219,7 +219,7 @@ const fn default_palette_from_style_codes(codes: StyleCodes) -> Palette {
|
||||||
code_block: codes.white,
|
code_block: codes.white,
|
||||||
keyword: codes.green,
|
keyword: codes.green,
|
||||||
ellipsis: codes.green,
|
ellipsis: codes.green,
|
||||||
variable: codes.blue,
|
variable: codes.cyan,
|
||||||
type_variable: codes.yellow,
|
type_variable: codes.yellow,
|
||||||
structure: codes.green,
|
structure: codes.green,
|
||||||
alias: codes.yellow,
|
alias: codes.yellow,
|
||||||
|
@ -249,8 +249,6 @@ pub struct StyleCodes {
|
||||||
pub red: &'static str,
|
pub red: &'static str,
|
||||||
pub green: &'static str,
|
pub green: &'static str,
|
||||||
pub yellow: &'static str,
|
pub yellow: &'static str,
|
||||||
pub blue: &'static str,
|
|
||||||
pub magenta: &'static str,
|
|
||||||
pub cyan: &'static str,
|
pub cyan: &'static str,
|
||||||
pub white: &'static str,
|
pub white: &'static str,
|
||||||
pub bold: &'static str,
|
pub bold: &'static str,
|
||||||
|
@ -260,12 +258,10 @@ pub struct StyleCodes {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ANSI_STYLE_CODES: StyleCodes = StyleCodes {
|
pub const ANSI_STYLE_CODES: StyleCodes = StyleCodes {
|
||||||
red: "\u{001b}[31m",
|
red: "\u{001b}[1;31m",
|
||||||
green: "\u{001b}[32m",
|
green: "\u{001b}[1;32m",
|
||||||
yellow: "\u{001b}[33m",
|
yellow: "\u{001b}[1;33m",
|
||||||
blue: "\u{001b}[34m",
|
cyan: "\u{001b}[1;36m",
|
||||||
magenta: "\u{001b}[35m",
|
|
||||||
cyan: "\u{001b}[36m",
|
|
||||||
white: "\u{001b}[37m",
|
white: "\u{001b}[37m",
|
||||||
bold: "\u{001b}[1m",
|
bold: "\u{001b}[1m",
|
||||||
underline: "\u{001b}[4m",
|
underline: "\u{001b}[4m",
|
||||||
|
@ -283,8 +279,6 @@ pub const HTML_STYLE_CODES: StyleCodes = StyleCodes {
|
||||||
red: html_color!("red"),
|
red: html_color!("red"),
|
||||||
green: html_color!("green"),
|
green: html_color!("green"),
|
||||||
yellow: html_color!("yellow"),
|
yellow: html_color!("yellow"),
|
||||||
blue: html_color!("blue"),
|
|
||||||
magenta: html_color!("magenta"),
|
|
||||||
cyan: html_color!("cyan"),
|
cyan: html_color!("cyan"),
|
||||||
white: html_color!("white"),
|
white: html_color!("white"),
|
||||||
bold: "<span class='bold'>",
|
bold: "<span class='bold'>",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue