aboutsummaryrefslogtreecommitdiff
path: root/helix-tui/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-tui/src')
-rw-r--r--helix-tui/src/buffer.rs4
-rw-r--r--helix-tui/src/layout.rs2
-rw-r--r--helix-tui/src/text.rs8
-rw-r--r--helix-tui/src/widgets/block.rs16
-rw-r--r--helix-tui/src/widgets/table.rs6
5 files changed, 14 insertions, 22 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs
index 23ba43f1..5169196a 100644
--- a/helix-tui/src/buffer.rs
+++ b/helix-tui/src/buffer.rs
@@ -6,7 +6,7 @@ use unicode_segmentation::UnicodeSegmentation;
use helix_view::graphics::{Color, Modifier, Rect, Style, UnderlineStyle};
/// A buffer cell
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Cell {
pub symbol: String,
pub fg: Color,
@@ -119,7 +119,7 @@ impl Default for Cell {
/// buf[(5, 0)].set_char('x');
/// assert_eq!(buf[(5, 0)].symbol, "x");
/// ```
-#[derive(Debug, Default, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Buffer {
/// The area represented by this buffer
pub area: Rect,
diff --git a/helix-tui/src/layout.rs b/helix-tui/src/layout.rs
index 7c72a778..1f3ddc6e 100644
--- a/helix-tui/src/layout.rs
+++ b/helix-tui/src/layout.rs
@@ -46,7 +46,7 @@ impl Constraint {
}
}
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Alignment {
Left,
Center,
diff --git a/helix-tui/src/text.rs b/helix-tui/src/text.rs
index 1bfe5ee1..ccdafad5 100644
--- a/helix-tui/src/text.rs
+++ b/helix-tui/src/text.rs
@@ -53,14 +53,14 @@ use std::borrow::Cow;
use unicode_segmentation::UnicodeSegmentation;
/// A grapheme associated to a style.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StyledGrapheme<'a> {
pub symbol: &'a str,
pub style: Style,
}
/// A string where all graphemes have the same style.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Span<'a> {
pub content: Cow<'a, str>,
pub style: Style,
@@ -209,7 +209,7 @@ impl<'a> From<Cow<'a, str>> for Span<'a> {
}
/// A string composed of clusters of graphemes, each with their own style.
-#[derive(Debug, Default, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Spans<'a>(pub Vec<Span<'a>>);
impl<'a> Spans<'a> {
@@ -297,7 +297,7 @@ impl<'a> From<&Spans<'a>> for String {
/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
/// assert_eq!(6, text.height());
/// ```
-#[derive(Debug, Default, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Text<'a> {
pub lines: Vec<Spans<'a>>,
}
diff --git a/helix-tui/src/widgets/block.rs b/helix-tui/src/widgets/block.rs
index bd025a31..98f84abe 100644
--- a/helix-tui/src/widgets/block.rs
+++ b/helix-tui/src/widgets/block.rs
@@ -7,7 +7,7 @@ use crate::{
use helix_view::graphics::{Rect, Style};
/// Border render type. Defaults to [`BorderType::Plain`].
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BorderType {
Plain,
Rounded,
@@ -47,7 +47,7 @@ impl Default for BorderType {
/// .border_type(BorderType::Rounded)
/// .style(Style::default().bg(Color::Black));
/// ```
-#[derive(Debug, Default, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Block<'a> {
/// Optional title place on the upper left of the block
title: Option<Spans<'a>>,
@@ -187,16 +187,8 @@ impl<'a> Widget for Block<'a> {
}
if let Some(title) = self.title {
- let lx = if self.borders.intersects(Borders::LEFT) {
- 1
- } else {
- 0
- };
- let rx = if self.borders.intersects(Borders::RIGHT) {
- 1
- } else {
- 0
- };
+ let lx = u16::from(self.borders.intersects(Borders::LEFT));
+ let rx = u16::from(self.borders.intersects(Borders::RIGHT));
let width = area.width.saturating_sub(lx).saturating_sub(rx);
buf.set_spans(area.left() + lx, area.top(), &title, width);
}
diff --git a/helix-tui/src/widgets/table.rs b/helix-tui/src/widgets/table.rs
index eb03704e..a8f428a7 100644
--- a/helix-tui/src/widgets/table.rs
+++ b/helix-tui/src/widgets/table.rs
@@ -34,7 +34,7 @@ use std::collections::HashMap;
///
/// You can apply a [`Style`] on the entire [`Cell`] using [`Cell::style`] or rely on the styling
/// capabilities of [`Text`].
-#[derive(Debug, Clone, PartialEq, Default)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct Cell<'a> {
pub content: Text<'a>,
style: Style,
@@ -79,7 +79,7 @@ where
/// ```
///
/// By default, a row has a height of 1 but you can change this using [`Row::height`].
-#[derive(Debug, Clone, PartialEq, Default)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct Row<'a> {
pub cells: Vec<Cell<'a>>,
height: u16,
@@ -179,7 +179,7 @@ impl<'a> Row<'a> {
/// // ...and potentially show a symbol in front of the selection.
/// .highlight_symbol(">>");
/// ```
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Table<'a> {
/// A block to wrap the widget in
block: Option<Block<'a>>,