Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run cargo fmt --all
  • Loading branch information
adaschma committed Jun 23, 2024
commit 47aa9f3dd81102460b400c7f40de0facc83adaf6
6 changes: 3 additions & 3 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ impl Drop for Reedline {
}
}


pub struct Theme {
pub visual_selection: Style,
pub use_ansi_coloring: bool,
Expand All @@ -189,13 +188,14 @@ pub struct Theme {
pub prompt_multiline: nu_ansi_term::Color,
pub indicator: Color,
pub prompt_right: Color,

}

impl Default for Theme {
fn default() -> Self {
Self {
visual_selection: Style::new().fg(nu_ansi_term::Color::Black).on(nu_ansi_term::Color::LightGray),
visual_selection: Style::new()
.fg(nu_ansi_term::Color::Black)
.on(nu_ansi_term::Color::LightGray),
use_ansi_coloring: true,
prompt: Color::Green,
prompt_multiline: nu_ansi_term::Color::LightBlue,
Expand Down
20 changes: 7 additions & 13 deletions src/painting/painter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{CursorConfig, PromptEditMode, PromptViMode, engine::Theme};
use crate::{engine::Theme, CursorConfig, PromptEditMode, PromptViMode};

use {
super::utils::{coerce_crlf, line_width},
Expand Down Expand Up @@ -319,24 +319,21 @@ impl Painter {
) -> Result<()> {
// print our prompt with color
if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.prompt))?;
self.stdout.queue(SetForegroundColor(theme.prompt))?;
}

self.stdout
.queue(Print(&coerce_crlf(&lines.prompt_str_left)))?;

if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.indicator))?;
self.stdout.queue(SetForegroundColor(theme.indicator))?;
}

self.stdout
.queue(Print(&coerce_crlf(&lines.prompt_indicator)))?;

if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.prompt_right))?;
self.stdout.queue(SetForegroundColor(theme.prompt_right))?;
}

self.print_right_prompt(lines)?;
Expand Down Expand Up @@ -386,8 +383,7 @@ impl Painter {

// print our prompt with color
if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.prompt))?;
self.stdout.queue(SetForegroundColor(theme.prompt))?;
}

// In case the prompt is made out of multiple lines, the prompt is split by
Expand All @@ -397,8 +393,7 @@ impl Painter {

if extra_rows == 0 {
if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.prompt_right))?;
self.stdout.queue(SetForegroundColor(theme.prompt_right))?;
}

self.print_right_prompt(lines)?;
Expand All @@ -408,8 +403,7 @@ impl Painter {
let extra_rows = extra_rows.saturating_sub(prompt_lines);

if theme.use_ansi_coloring {
self.stdout
.queue(SetForegroundColor(theme.indicator))?;
self.stdout.queue(SetForegroundColor(theme.indicator))?;
}
let indicator_skipped = skip_buffer_lines(&lines.prompt_indicator, extra_rows, None);
self.stdout.queue(Print(&coerce_crlf(indicator_skipped)))?;
Expand Down
2 changes: 1 addition & 1 deletion src/painting/styled_text.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use nu_ansi_term::Style;

use crate::{Prompt, engine::Theme};
use crate::{engine::Theme, Prompt};

use super::utils::strip_ansi;

Expand Down