mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-15 15:50:38 +08:00
I learned that there is an implementation of a pager in `crates/radicle-term/src/pager.rs`. It does not make sense to me to maintain a pager in `heartwood`, this is too far from the core of what we are trying to achieve and adds unnecessary maintenance burden. We can allow ourselves to defer to the paging done by `git` or just call the user's `$PAGER`. Even though falling back to unpaged output might not be the nicest thing, I still prefer that over maintaining the pager. It also was frustrating to me that the pager does not support things like search (like `less` does). This also significantly decreases our dependence on `termion`. The pager was originally implemented by cloudhead in40f4383bbcand integrated into `rad diff` in6dd52c94fbThis commit restores the behaviour introduced in84a95848b0(before there was a custom pager implementation).
83 lines
1.6 KiB
Rust
83 lines
1.6 KiB
Rust
pub mod ansi;
|
|
pub mod cell;
|
|
pub mod colors;
|
|
pub mod command;
|
|
pub mod editor;
|
|
pub mod element;
|
|
pub mod format;
|
|
pub mod hstack;
|
|
pub mod io;
|
|
pub mod label;
|
|
pub mod spinner;
|
|
pub mod table;
|
|
pub mod textarea;
|
|
pub mod vstack;
|
|
|
|
use std::fmt;
|
|
use std::io::IsTerminal;
|
|
|
|
pub use ansi::Color;
|
|
pub use ansi::{paint, Filled, Paint, Style};
|
|
pub use editor::Editor;
|
|
pub use element::{Constraint, Element, Line, Size};
|
|
pub use hstack::HStack;
|
|
pub use inquire::ui::Styled;
|
|
pub use io::*;
|
|
pub use label::{label, Label};
|
|
pub use spinner::{spinner, spinner_to, Spinner};
|
|
pub use table::{Table, TableOptions};
|
|
pub use textarea::{textarea, TextArea};
|
|
pub use vstack::{VStack, VStackOptions};
|
|
|
|
#[derive(Debug, PartialEq, Eq, Copy, Clone, Default)]
|
|
pub enum Interactive {
|
|
Yes,
|
|
#[default]
|
|
No,
|
|
}
|
|
|
|
impl Interactive {
|
|
pub fn new(term: impl IsTerminal) -> Self {
|
|
Self::from(term.is_terminal())
|
|
}
|
|
|
|
pub fn yes(&self) -> bool {
|
|
(*self).into()
|
|
}
|
|
|
|
pub fn no(&self) -> bool {
|
|
!self.yes()
|
|
}
|
|
|
|
pub fn confirm(&self, prompt: impl fmt::Display) -> bool {
|
|
if self.yes() {
|
|
confirm(prompt)
|
|
} else {
|
|
true
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<Interactive> for bool {
|
|
fn from(c: Interactive) -> Self {
|
|
match c {
|
|
Interactive::Yes => true,
|
|
Interactive::No => false,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<bool> for Interactive {
|
|
fn from(b: bool) -> Self {
|
|
if b {
|
|
Interactive::Yes
|
|
} else {
|
|
Interactive::No
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn style<T>(item: T) -> Paint<T> {
|
|
paint(item)
|
|
}
|