Skip to content

Commit

Permalink
Run cargo fmt --all
Browse files Browse the repository at this point in the history
  • Loading branch information
adaschma committed Jun 23, 2024
1 parent 681d056 commit 47aa9f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
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

0 comments on commit 47aa9f3

Please sign in to comment.