mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 09:04:18 +01:00
moved grid
to it's own crate named nu-term-grid
This commit is contained in:
parent
7697f7bdce
commit
58d73d4c23
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -294,6 +294,7 @@ dependencies = [
|
||||
"nu-path",
|
||||
"nu-protocol",
|
||||
"nu-table",
|
||||
"nu-term-grid",
|
||||
"pretty_assertions",
|
||||
"reedline",
|
||||
"tempfile",
|
||||
@ -523,10 +524,10 @@ dependencies = [
|
||||
"nu-path",
|
||||
"nu-protocol",
|
||||
"nu-table",
|
||||
"nu-term-grid",
|
||||
"sysinfo",
|
||||
"terminal_size",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -589,6 +590,13 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-term-grid"
|
||||
version = "0.36.0"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
|
@ -19,6 +19,7 @@ nu-parser = { path="./crates/nu-parser" }
|
||||
nu-path = { path="./crates/nu-path" }
|
||||
nu-protocol = { path = "./crates/nu-protocol" }
|
||||
nu-table = { path = "./crates/nu-table" }
|
||||
nu-term-grid = { path = "./crates/nu-term-grid" }
|
||||
miette = "3.0.0"
|
||||
# mimalloc = { version = "*", default-features = false }
|
||||
|
||||
|
@ -11,11 +11,11 @@ nu-json = { path = "../nu-json" }
|
||||
nu-path = { path = "../nu-path" }
|
||||
nu-protocol = { path = "../nu-protocol" }
|
||||
nu-table = { path = "../nu-table" }
|
||||
nu-term-grid = { path = "../nu-term-grid" }
|
||||
|
||||
# Potential dependencies for extras
|
||||
glob = "0.3.0"
|
||||
thiserror = "1.0.29"
|
||||
sysinfo = "0.20.4"
|
||||
chrono = { version="0.4.19", features=["serde"] }
|
||||
unicode-width = "0.1.9"
|
||||
terminal_size = "0.1.17"
|
||||
|
@ -1,10 +1,10 @@
|
||||
use super::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions};
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
ast::{Call, PathMember},
|
||||
engine::{Command, EvaluationContext},
|
||||
Signature, Span, SyntaxShape, Value,
|
||||
};
|
||||
use nu_term_grid::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions};
|
||||
use terminal_size::{Height, Width}; //{Alignment, Cell, Direction, Filling, Grid, GridOptions};
|
||||
|
||||
pub struct Griddle;
|
||||
|
@ -1,7 +1,5 @@
|
||||
pub mod grid;
|
||||
mod griddle;
|
||||
mod table;
|
||||
|
||||
pub use grid::Grid;
|
||||
pub use griddle::Griddle;
|
||||
pub use table::Table;
|
||||
|
22
crates/nu-term-grid/.gitignore
vendored
Normal file
22
crates/nu-term-grid/.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/target
|
||||
/scratch
|
||||
**/*.rs.bk
|
||||
history.txt
|
||||
tests/fixtures/nuplayground
|
||||
crates/*/target
|
||||
|
||||
# Debian/Ubuntu
|
||||
debian/.debhelper/
|
||||
debian/debhelper-build-stamp
|
||||
debian/files
|
||||
debian/nu.substvars
|
||||
debian/nu/
|
||||
|
||||
# macOS junk
|
||||
.DS_Store
|
||||
|
||||
# JetBrains' IDE items
|
||||
.idea/*
|
||||
|
||||
# VSCode's IDE items
|
||||
.vscode/*
|
15
crates/nu-term-grid/Cargo.toml
Normal file
15
crates/nu-term-grid/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
authors = ["The Nu Project Contributors"]
|
||||
description = "Nushell grid printing"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
name = "nu-term-grid"
|
||||
version = "0.36.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[[bin]]
|
||||
name = "grid"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
unicode-width = "0.1.9"
|
@ -13,7 +13,7 @@
|
||||
//! needed. For example:
|
||||
//!
|
||||
//! ```rust
|
||||
//! use nu_command::grid::{Grid, GridOptions, Direction, Filling, Cell};
|
||||
//! use nu_term_grid::grid::{Grid, GridOptions, Direction, Filling, Cell};
|
||||
//!
|
||||
//! let mut grid = Grid::new(GridOptions {
|
||||
//! filling: Filling::Spaces(1),
|
3
crates/nu-term-grid/src/lib.rs
Normal file
3
crates/nu-term-grid/src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod grid;
|
||||
|
||||
pub use grid::Grid;
|
30
crates/nu-term-grid/src/main.rs
Normal file
30
crates/nu-term-grid/src/main.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use nu_term_grid::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions};
|
||||
|
||||
// This produces:
|
||||
//
|
||||
// 1 | 128 | 16384 | 2097152 | 268435456 | 34359738368 | 4398046511104
|
||||
// 2 | 256 | 32768 | 4194304 | 536870912 | 68719476736 | 8796093022208
|
||||
// 4 | 512 | 65536 | 8388608 | 1073741824 | 137438953472 | 17592186044416
|
||||
// 8 | 1024 | 131072 | 16777216 | 2147483648 | 274877906944 | 35184372088832
|
||||
// 16 | 2048 | 262144 | 33554432 | 4294967296 | 549755813888 | 70368744177664
|
||||
// 32 | 4096 | 524288 | 67108864 | 8589934592 | 1099511627776 | 140737488355328
|
||||
// 64 | 8192 | 1048576 | 134217728 | 17179869184 | 2199023255552 |
|
||||
|
||||
fn main() {
|
||||
let mut grid = Grid::new(GridOptions {
|
||||
direction: Direction::TopToBottom,
|
||||
filling: Filling::Text(" | ".into()),
|
||||
});
|
||||
|
||||
for i in 0..48 {
|
||||
let mut cell = Cell::from(format!("{}", 2_isize.pow(i)));
|
||||
cell.alignment = Alignment::Right;
|
||||
grid.add(cell)
|
||||
}
|
||||
|
||||
if let Some(grid_display) = grid.fit_into_width(80) {
|
||||
println!("{}", grid_display);
|
||||
} else {
|
||||
println!("Couldn't fit grid into 80 columns!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user