Skip to content

Commit

Permalink
Merge pull request #439 from zhiburt/patch/tabled-line-text-impl-for-…
Browse files Browse the repository at this point in the history
…last-row-offset

tabled/ line text impl for last row offset
  • Loading branch information
zhiburt authored Nov 13, 2024
2 parents 4273113 + 658b464 commit 10e15af
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use crate::{
grid::{
ansi::ANSIBuf,
config::{self, ColoredConfig, SpannedConfig},
config::{self, ColoredConfig, Entity, SpannedConfig},
dimension::{Dimension, Estimate},
records::{ExactRecords, Records},
},
settings::{
object::{Column, FirstColumn, FirstRow, LastColumn, LastRow, Row},
object::{
Column, FirstColumn, FirstRow, LastColumn, LastColumnOffset, LastRow, LastRowOffset,
Object, Row,
},
Color, TableOption,
},
};
Expand Down Expand Up @@ -112,8 +115,25 @@ where
D: Dimension,
{
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D) {
let line = records.count_rows();
change_horizontal_chars(records, dims, cfg, line, self.text, self.offset, self.color)
let line = self.line.cells(records).next();
if let Some(Entity::Row(line)) = line {
change_horizontal_chars(records, dims, cfg, line, self.text, self.offset, self.color)
}
}
}

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRowOffset>
where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig>,
D: Dimension,
{
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D) {
let line = self.line.cells(records).next();
if let Some(Entity::Row(line)) = line {
change_horizontal_chars(records, dims, cfg, line, self.text, self.offset, self.color)
}
}
}

Expand Down Expand Up @@ -155,6 +175,21 @@ where
}
}

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumnOffset>
where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig>,
D: Dimension,
{
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D) {
let line = self.line.cells(records).next();
if let Some(Entity::Column(line)) = line {
change_vertical_chars(records, dims, cfg, line, self.text, self.offset, self.color)
}
}
}

fn set_horizontal_chars<D: Dimension>(
cfg: &mut SpannedConfig,
dims: &D,
Expand Down
4 changes: 2 additions & 2 deletions tabled/src/settings/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod vertical_line;
#[cfg(feature = "std")]
mod border_color;
#[cfg(feature = "std")]
mod border_text;
mod line_text;
#[cfg(feature = "std")]
mod line_char;
#[cfg(feature = "std")]
Expand All @@ -114,7 +114,7 @@ mod span_border_correction;
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub use self::{
border_color::BorderColor, border_text::LineText, line_char::LineChar,
border_color::BorderColor, line_text::LineText, line_char::LineChar,
span_border_correction::BorderSpanCorrection,
};

Expand Down

0 comments on commit 10e15af

Please sign in to comment.