Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod prompt;
pub mod status;

/// `Component` is a trait that represents a visual and interactive element of the user interface.
/// Implementors of this trait can be registered with the main application loop and will be able to receive events,
/// Implementers of this trait can be registered with the main application loop and will be able to receive events,
/// update state, and be rendered on the screen.
pub trait Component {
/// Register an action handler that can send actions for processing if necessary.
Expand Down
16 changes: 8 additions & 8 deletions src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use similar::{ChangeTag, TextDiff};

use crate::termtext::Text;

pub fn diff_and_mark(current: &str, pervious: &str, text: &mut Text) {
pub fn diff_and_mark(current: &str, previous: &str, text: &mut Text) {
let style = anstyle::Style::new()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Black)))
.bg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Green)));

let chunks = diff(pervious, current);
let chunks = diff(previous, current);

let mut cursor = 0;
for chunk in chunks.into_iter() {
Expand All @@ -30,12 +30,12 @@ pub fn diff_and_mark(current: &str, pervious: &str, text: &mut Text) {
}
}

pub fn diff_and_mark_delete(current: &str, pervious: &str, text: &mut Text) {
pub fn diff_and_mark_delete(current: &str, previous: &str, text: &mut Text) {
let style = anstyle::Style::new()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Black)))
.bg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red)));

let chunks = diff(pervious, current);
let chunks = diff(previous, current);

let mut cursor = 0;
for chunk in chunks {
Expand Down Expand Up @@ -66,28 +66,28 @@ mod test {
#[test]
fn test_diff_and_mark() {
let current = "hello world!";
let pervious = "hello world";
let previous = "hello world";
let mut text = Text::new(current);
let style = anstyle::Style::new()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Black)))
.bg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Green)));

super::diff_and_mark(current, pervious, &mut text);
super::diff_and_mark(current, previous, &mut text);

assert_eq!(text[10].style, Style::new());
assert_eq!(text[11].style, style);
}

#[test]
fn test_diff_and_mark_new_line() {
let pervious = "hello world";
let previous = "hello world";
let current = "hello world\nnew world";
let mut text = Text::new(current);
let style = anstyle::Style::new()
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Black)))
.bg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Green)));

super::diff_and_mark(current, pervious, &mut text);
super::diff_and_mark(current, previous, &mut text);

assert_eq!(text[11].style, Style::new());
for i in 12..=14 {
Expand Down
Loading