Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(spans): remove deprecated Spans type #426

Merged
merged 1 commit into from Sep 19, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 1 addition & 25 deletions src/buffer.rs
Expand Up @@ -6,11 +6,10 @@ use std::{
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;

#[allow(deprecated)]
use crate::{
layout::Rect,
style::{Color, Modifier, Style},
text::{Line, Span, Spans},
text::{Line, Span},
};

/// A buffer cell
Expand Down Expand Up @@ -334,29 +333,6 @@ impl Buffer {
(x_offset as u16, y)
}

#[allow(deprecated)]
#[deprecated(note = "Use `Buffer::set_line` instead")]
pub fn set_spans(&mut self, x: u16, y: u16, spans: &Spans<'_>, width: u16) -> (u16, u16) {
let mut remaining_width = width;
let mut x = x;
for span in &spans.0 {
if remaining_width == 0 {
break;
}
let pos = self.set_stringn(
x,
y,
span.content.as_ref(),
remaining_width as usize,
span.style,
);
let w = pos.0.saturating_sub(x);
x = pos.0;
remaining_width = remaining_width.saturating_sub(w);
}
(x, y)
}

pub fn set_line(&mut self, x: u16, y: u16, line: &Line<'_>, width: u16) -> (u16, u16) {
let mut remaining_width = width;
let mut x = x;
Expand Down
5 changes: 0 additions & 5 deletions src/text.rs
Expand Up @@ -60,11 +60,6 @@ pub use masked::Masked;
mod span;
pub use span::Span;

/// We keep this for backward compatibility.
mod spans;
#[allow(deprecated)]
pub use spans::Spans;

#[allow(clippy::module_inception)]
mod text;
pub use text::Text;
20 changes: 2 additions & 18 deletions src/text/line.rs
@@ -1,7 +1,6 @@
#![allow(deprecated)]
use std::borrow::Cow;

use super::{Span, Spans, Style, StyledGrapheme};
use super::{Span, Style, StyledGrapheme};
use crate::layout::Alignment;

#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
Expand Down Expand Up @@ -180,18 +179,12 @@ impl<'a> From<Line<'a>> for String {
}
}

impl<'a> From<Spans<'a>> for Line<'a> {
fn from(value: Spans<'a>) -> Self {
Self::from(value.0)
}
}

#[cfg(test)]
mod tests {
use crate::{
layout::Alignment,
style::{Color, Modifier, Style},
text::{Line, Span, Spans, StyledGrapheme},
text::{Line, Span, StyledGrapheme},
};

#[test]
Expand Down Expand Up @@ -266,15 +259,6 @@ mod tests {
assert_eq!(vec![span], line.spans);
}

#[test]
fn test_from_spans() {
let spans = vec![
Span::styled("Hello,", Style::default().fg(Color::Red)),
Span::styled(" world!", Style::default().fg(Color::Green)),
];
assert_eq!(Line::from(Spans::from(spans.clone())), Line::from(spans));
}

#[test]
fn test_into_string() {
let line = Line::from(vec![
Expand Down
223 changes: 0 additions & 223 deletions src/text/spans.rs

This file was deleted.