Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
doy committed Aug 7, 2023
1 parent 7a3b74c commit 1e4014a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Attrs {
other: &Self,
) {
if self != other && self == &Self::default() {
crate::term::ClearAttrs::default().write_buf(contents);
crate::term::ClearAttrs.write_buf(contents);
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ impl Grid {
&self,
contents: &mut Vec<u8>,
) -> crate::attrs::Attrs {
crate::term::ClearAttrs::default().write_buf(contents);
crate::term::ClearScreen::default().write_buf(contents);
crate::term::ClearAttrs.write_buf(contents);
crate::term::ClearScreen.write_buf(contents);

let mut prev_attrs = crate::attrs::Attrs::default();
let mut prev_pos = Pos::default();
Expand Down Expand Up @@ -418,10 +418,10 @@ impl Grid {
end_cell
.attrs()
.write_escape_code_diff(contents, &prev_attrs);
crate::term::SaveCursor::default().write_buf(contents);
crate::term::Backspace::default().write_buf(contents);
crate::term::SaveCursor.write_buf(contents);
crate::term::Backspace.write_buf(contents);
crate::term::EraseChar::new(1).write_buf(contents);
crate::term::RestoreCursor::default().write_buf(contents);
crate::term::RestoreCursor.write_buf(contents);
prev_attrs
.write_escape_code_diff(contents, end_cell.attrs());
}
Expand Down
20 changes: 9 additions & 11 deletions src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Row {
prev_attrs = *default_attrs;
}
contents.push(b' ');
crate::term::Backspace::default().write_buf(contents);
crate::term::Backspace.write_buf(contents);
crate::term::EraseChar::new(1).write_buf(contents);
prev_pos = crate::grid::Pos { row, col: 0 };
}
Expand Down Expand Up @@ -203,8 +203,7 @@ impl Row {
);
} else {
contents.extend(b" ");
crate::term::Backspace::default()
.write_buf(contents);
crate::term::Backspace.write_buf(contents);
}
} else {
crate::term::MoveFromTo::new(prev_pos, new_pos)
Expand Down Expand Up @@ -262,7 +261,7 @@ impl Row {
);
} else {
contents.extend(b" ");
crate::term::Backspace::default().write_buf(contents);
crate::term::Backspace.write_buf(contents);
}
} else {
crate::term::MoveFromTo::new(prev_pos, new_pos)
Expand All @@ -273,7 +272,7 @@ impl Row {
attrs.write_escape_code_diff(contents, &prev_attrs);
prev_attrs = *attrs;
}
crate::term::ClearRowForward::default().write_buf(contents);
crate::term::ClearRowForward.write_buf(contents);
}

(prev_pos, prev_attrs)
Expand Down Expand Up @@ -319,9 +318,9 @@ impl Row {
false
};
contents.extend(cell_contents.as_bytes());
crate::term::Backspace::default().write_buf(contents);
crate::term::Backspace.write_buf(contents);
if prev_first_cell.is_wide() {
crate::term::Backspace::default().write_buf(contents);
crate::term::Backspace.write_buf(contents);
}
if need_erase {
crate::term::EraseChar::new(1).write_buf(contents);
Expand Down Expand Up @@ -361,8 +360,7 @@ impl Row {
);
} else {
contents.extend(b" ");
crate::term::Backspace::default()
.write_buf(contents);
crate::term::Backspace.write_buf(contents);
}
} else {
crate::term::MoveFromTo::new(prev_pos, new_pos)
Expand Down Expand Up @@ -419,7 +417,7 @@ impl Row {
);
} else {
contents.extend(b" ");
crate::term::Backspace::default().write_buf(contents);
crate::term::Backspace.write_buf(contents);
}
} else {
crate::term::MoveFromTo::new(prev_pos, new_pos)
Expand All @@ -430,7 +428,7 @@ impl Row {
attrs.write_escape_code_diff(contents, &prev_attrs);
prev_attrs = *attrs;
}
crate::term::ClearRowForward::default().write_buf(contents);
crate::term::ClearRowForward.write_buf(contents);
}

// if this row is going from wrapped to not wrapped, we need to erase
Expand Down
2 changes: 1 addition & 1 deletion src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl Screen {
}

fn write_attributes_formatted(&self, contents: &mut Vec<u8>) {
crate::term::ClearAttrs::default().write_buf(contents);
crate::term::ClearAttrs.write_buf(contents);
self.attrs.write_escape_code_diff(
contents,
&crate::attrs::Attrs::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl MoveFromTo {
impl BufWrite for MoveFromTo {
fn write_buf(&self, buf: &mut Vec<u8>) {
if self.to.row == self.from.row + 1 && self.to.col == 0 {
crate::term::Crlf::default().write_buf(buf);
crate::term::Crlf.write_buf(buf);
} else if self.from.row == self.to.row && self.from.col < self.to.col
{
crate::term::MoveRight::new(self.to.col - self.from.col)
Expand Down

0 comments on commit 1e4014a

Please sign in to comment.