diff --git a/Cargo.lock b/Cargo.lock index f063c58d..98c26439 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,21 +73,9 @@ checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.26", - "quote 1.0.9", - "syn 1.0.68", -] - -[[package]] -name = "derive_more" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "rustc_version", - "syn 0.15.44", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -199,7 +187,6 @@ dependencies = [ "directories-next", "edit", "lazy_static", - "raw_tty", "regex", "shellwords", "strip-ansi-escapes", @@ -234,9 +221,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.26", - "quote 1.0.9", - "syn 1.0.68", + "proc-macro2", + "quote", + "syn", "version_check", ] @@ -246,36 +233,18 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "version_check", ] -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ - "unicode-xid 0.2.1", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", + "unicode-xid", ] [[package]] @@ -284,7 +253,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2", ] [[package]] @@ -327,16 +296,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "raw_tty" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f512d7504049ef0d3f5d48d8aa5129beaea4fccfaf5c500c9b60101394f8b1" -dependencies = [ - "derive_more", - "libc", -] - [[package]] name = "redox_syscall" version = "0.2.5" @@ -391,15 +350,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "same-file" version = "1.0.6" @@ -409,21 +359,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "shellwords" version = "1.1.0" @@ -449,26 +384,15 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - [[package]] name = "syn" version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", - "unicode-xid 0.2.1", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -540,9 +464,9 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", - "syn 1.0.68", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -557,12 +481,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index 12aff3c3..ddf3f466 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ travis-ci = { repository = "denisidoro/navi", branch = "master" } regex = "1.4.3" clap = "3.0.0-beta.2" termion = "1.5.6" -raw_tty = "0.1.0" lazy_static = "1.4.0" directories-next = "2.0.0" terminal_size = "0.1.16" diff --git a/src/display/terminal.rs b/src/display/terminal.rs index 6ec48627..8c956341 100644 --- a/src/display/terminal.rs +++ b/src/display/terminal.rs @@ -2,13 +2,12 @@ use crate::display; use crate::env_vars; use crate::finder; use crate::structures::item::Item; -use crate::terminal_width; +use crate::terminal::{self, color}; use std::cmp::max; use std::collections::HashSet; use std::env; use std::iter; use std::str::FromStr; -use termion::color; // TODO: extract pub fn parse_env_var(varname: &str) -> Option { @@ -146,7 +145,7 @@ fn limit_str(text: &str, length: usize) -> String { } fn get_widths() -> (usize, usize) { - let width = terminal_width::get(); + let width = terminal::width(); let tag_width = max(4, width * *TAG_WIDTH_PERCENTAGE / 100); let comment_width = max(4, width * *COMMENT_WIDTH_PERCENTAGE / 100); (usize::from(tag_width), usize::from(comment_width)) diff --git a/src/lib.rs b/src/lib.rs index 13e3e6b5..0908be2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ mod hash; mod parser; mod shell; mod structures; -mod terminal_width; +mod terminal; mod tldr; mod url; mod welcome; diff --git a/src/terminal_width.rs b/src/terminal.rs similarity index 97% rename from src/terminal_width.rs rename to src/terminal.rs index bb134cf3..8a5b02e0 100644 --- a/src/terminal_width.rs +++ b/src/terminal.rs @@ -1,4 +1,5 @@ use terminal_size::{terminal_size, terminal_size_using_fd, Height, Width}; +pub use termion::color; const FALLBACK_WIDTH: u16 = 80; @@ -57,7 +58,7 @@ fn width_with_fd() -> u16 { } } -pub fn get() -> u16 { +pub fn width() -> u16 { let size = terminal_size(); if let Some((Width(w), Height(_))) = size { w