ietf

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f6a584ac28ebf13425cfdfd686db433b90a40850
parent 9d0be962a119fc598e93e1e1a4d39c2aaf77ff5c
Author: cy6erlion <dev@merely.tech>
Date:   Sun,  7 Feb 2021 10:59:44 +0200

feat: Revert back to using normal pager for IETF reading

Diffstat:
MCargo.lock | 38++++++++++++++++++++++++++++++++++++++
MCargo.toml | 4++++
Msrc/main.rs | 28+++++++++++++++++-----------
3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -250,12 +250,39 @@ dependencies = [ ] [[package]] +name = "errno" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +dependencies = [ + "gcc", + "libc", +] + +[[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + +[[package]] name = "getrandom" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -300,6 +327,7 @@ dependencies = [ "cursive", "dirs-next", "minreq", + "pager", ] [[package]] @@ -440,6 +468,16 @@ dependencies = [ ] [[package]] +name = "pager" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c7d08cf0d0b55c4f0ffedb5e06569ea212e85d622975071370393970491968" +dependencies = [ + "errno", + "libc", +] + +[[package]] name = "pkg-config" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -27,3 +27,6 @@ dirs-next = "2.0.0" # Terminal User Interface cursive = "0.16" + +# Pager for reading the RFCs +pager = "0.16.0" +\ No newline at end of file diff --git a/src/main.rs b/src/main.rs @@ -1,10 +1,12 @@ +extern crate pager; use clap::{App, Arg, SubCommand}; use cursive::align::HAlign; use cursive::event::EventResult; use cursive::traits::With; use cursive::traits::*; -use cursive::views::{Dialog, OnEventView, SelectView, TextView}; +use cursive::views::{Dialog, OnEventView, SelectView}; use cursive::Cursive; +use pager::Pager; mod fetch; mod storage; @@ -38,13 +40,6 @@ fn main() -> Result<(), std::io::Error> { .get_matches(); let storage = storage::Storage::new(); - let mut siv = cursive::default(); - siv.set_theme(cursive::theme::Theme::default().with(|theme| { - use cursive::theme::{BaseColor::*, Color::*, PaletteColor::*}; - theme.palette[Background] = TerminalDefault; - theme.palette[Primary] = Dark(Black); - theme.palette[Secondary] = Rgb(255, 12, 42); - })); // Read RFC by rfcnumber if let Some(n) = matches.value_of("Number") { @@ -70,8 +65,8 @@ fn main() -> Result<(), std::io::Error> { .read_to_string(&mut rfc_data) .expect("Unable to read RFC"); - siv.add_layer(TextView::new(rfc_data).with_name("text").scrollable()); - siv.run(); + Pager::with_pager("less -r").setup(); + println!("{}", rfc_data); return Ok(()); } @@ -97,6 +92,14 @@ fn main() -> Result<(), std::io::Error> { } // ---------- Display RFC list view ------------ + let mut siv = cursive::default(); + siv.set_theme(cursive::theme::Theme::default().with(|theme| { + use cursive::theme::{BaseColor::*, Color::*, PaletteColor::*}; + theme.palette[Background] = TerminalDefault; + theme.palette[Primary] = Dark(Black); + theme.palette[Secondary] = Rgb(255, 12, 42); + })); + let mut index_data = String::new(); let index_file = File::open(&storage.index_file_path).expect("Unable to open file"); let mut buffer_reader = BufReader::new(index_file); @@ -130,7 +133,10 @@ fn main() -> Result<(), std::io::Error> { .read_to_string(&mut rfc_data) .expect("Unable to read RFC"); - siv.add_layer(TextView::new(rfc_data).with_name("text").scrollable()); + siv.dump(); + Pager::with_pager("less -r").setup(); + println!("{}", rfc_data); + siv.quit(); }; buffer_reader