Bump deps and touchup (#2066)

This commit is contained in:
Jonathan Turner
2020-06-27 19:54:31 +12:00
committed by GitHub
parent 4e2a4236f8
commit 7fed9992c9
18 changed files with 258 additions and 227 deletions

View File

@ -106,6 +106,7 @@ pub async fn autoview(context: RunnableContext) -> Result<OutputStream, ShellErr
};
let (mut input_stream, context) = RunnableContextWithoutInput::convert(context);
let term_width = context.host.lock().width();
if let Some(x) = input_stream.next().await {
match input_stream.next().await {
@ -263,7 +264,7 @@ pub async fn autoview(context: RunnableContext) -> Result<OutputStream, ShellErr
.iter()
.fold(0usize, |acc, len| acc + len.len())
+ row.entries.iter().count() * 2)
> textwrap::termwidth()) =>
> term_width) =>
{
let mut entries = vec![];
for (key, value) in row.entries.iter() {
@ -286,7 +287,7 @@ pub async fn autoview(context: RunnableContext) -> Result<OutputStream, ShellErr
let table =
nu_table::Table::new(vec![], entries, nu_table::Theme::compact());
nu_table::draw_table(&table, textwrap::termwidth());
nu_table::draw_table(&table, term_width);
}
Value {

View File

@ -241,7 +241,7 @@ async fn table(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
let mut delay_slot = None;
let termwidth = std::cmp::max(textwrap::termwidth(), 20);
let term_width = args.host.lock().width();
while !finished {
let mut new_input: VecDeque<Value> = VecDeque::new();
@ -294,7 +294,7 @@ async fn table(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
if !input.is_empty() {
let t = from_list(&input, start_number);
draw_table(&t, termwidth);
draw_table(&t, term_width);
}
start_number += input.len();

View File

@ -120,7 +120,9 @@ impl Host for BasicHost {
}
fn width(&self) -> usize {
std::cmp::max(textwrap::termwidth(), 20)
let (mut term_width, _) = term_size::dimensions().unwrap_or_else(|| (20, 20));
term_width -= 1;
std::cmp::max(term_width, 20)
}
}