Skip to content

Add Highlight::reverse #545

@zhiburt

Description

@zhiburt

Nowadays Hightlight works from top to bottom and left to right, but it would be helpful if we could reverse it.

See.

use tabled::{
    builder::Builder,
    settings::{object::{Columns, Object, Rows}, themes::BorderCorrection, Border, Highlight, Span, Style}, Table,
};

fn main() {
    let mut builder: Builder = Builder::new();
    builder.push_record(vec!["", "a", "b", "c"]);
    builder.push_record(vec!["1", "", "", ""]);
    builder.push_record(vec!["2", "", "x", ""]);
    builder.push_record(vec!["3", "", "", ""]);

    let mut table = builder.build();
    table.with(Style::modern());
    table.modify((2, 2), (Span::column(2), Span::row(2)));
    table.with(BorderCorrection::span());
    table.with(Highlight::new(Columns::new(2..).intersect(Rows::new(2..))).border(Border::inherit(Style::modern())));

    println!("{table}");
}
┌───┬───┬───┬───┐
│   │ a │ b │ c │
├───┼───┼───┼───┤
│ 1 │   │   │   │
├───┼───┌───────┐
│ 2 │   │ x     │
├───┼───│       │
│ 3 │   │       │
└───┴───└───────┘

Reverse logic would do

┌───┬───┬───┬───┐
│   │ a │ b │ c │
├───┼───┼───┼───┤
│ 1 │   │   │   │
├───┼───┼───┴───┘
│ 2 │   │ x     │
├───┼───┤       │
│ 3 │   │       │
└───┴───┘───────┘

ref: #544

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions