summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Kuehl <cipkuehl@gmail.com>2018-05-08 12:01:56 -0700
committerDavid Peter <sharkdp@users.noreply.github.com>2018-05-08 22:57:29 +0200
commite5e47716b0ca22fd2ee0e3538d9a6d22359c4056 (patch)
tree4c79cd5ebda5123b4db5f02ff2c054dc8dba8a76
parentb4f8cd3bae4fb7988ad238579714efb646a85efa (diff)
Add term_width to options struct, move getting term_width to run()
-rw-r--r--src/main.rs4
-rw-r--r--src/printer.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 201b9ff0..4f457068 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -67,6 +67,7 @@ pub struct Options<'a> {
pub language: Option<&'a str>,
pub colored_output: bool,
pub paging: bool,
+ pub term_width: usize,
}
enum OutputType {
@@ -552,6 +553,7 @@ fn run() -> Result<()> {
interactive_terminal
},
},
+ term_width: console::Term::stdout().size().1 as usize,
};
let assets =
@@ -580,7 +582,7 @@ fn run() -> Result<()> {
print!("{:width$}{}", lang.name, separator, width = longest);
// Line-wrapping for the possible file extension overflow.
- let desired_width = 90 - longest;
+ let desired_width = options.term_width - longest;
// Number of characters on this line so far, wrap before `desired_width`
let mut num_chars = 0;
diff --git a/src/printer.rs b/src/printer.rs
index 06502afc..6f112ccc 100644
--- a/src/printer.rs
+++ b/src/printer.rs
@@ -1,5 +1,4 @@
use ansi_term::Style;
-use console::Term;
use errors::*;
use std::io::Write;
use syntect::highlighting;
@@ -18,8 +17,7 @@ pub struct Printer<'a> {
impl<'a> Printer<'a> {
pub fn new(handle: &'a mut Write, options: &'a Options) -> Self {
- let (_, term_width) = Term::stdout().size();
- let term_width = term_width as usize;
+ let term_width = options.term_width;
let colors = if options.colored_output {
Colors::colored()