Optional colours in the global config file

[?]
Jan 13, 2021, 10:30 PM
5BB266P6HPUGYEVR7QNNOA62EFPYPUYJ3UMLE5J3LLYMSUWXANIQC

Dependencies

  • [2] SEWGHUHQ .pijul/config: simplify remotes and hooks
  • [3] ZRUPLBBT Colours in diff and change: separating concerns and dependencies
  • [4] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [5] 2K7JLB4Z No pager on Windows
  • [6] VIHXB7SG commands: set up pager for diff, change, and credit
  • [7] Q4SVMHAE Removing --channel from the changes command
  • [8] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [*] SLJ3OHD4 unrecord: show list of changes if none were given as arguments

Change contents

  • edit in pijul/src/config.rs at line 11
    [10.822]
    [4.90002]
    pub colors: Option<Choice>,
    pub pager: Option<Choice>,
    }
    #[derive(Debug, Serialize, Deserialize)]
    pub enum Choice {
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "always")]
    Always,
    #[serde(rename = "never")]
    Never,
  • edit in pijul/src/config.rs at line 75
    [2.67]
    [4.91196]
    pub colors: Option<Choice>,
    pub pager: Option<Choice>,
  • replacement in pijul/src/commands/diff.rs at line 90
    [4.175777][3.205:252]()
    let pager_is_colored = super::pager();
    [4.175777]
    [4.175777]
    let colors = is_colored();
  • replacement in pijul/src/commands/diff.rs at line 163
    [3.367][3.367:447]()
    colors: atty::is(atty::Stream::Stdout) || pager_is_colored,
    [3.367]
    [3.447]
    colors,
  • edit in pijul/src/commands/diff.rs at line 244
    [3.2086]
    [3.2086]
    }
    }
    }
    pub fn is_colored() -> bool {
    let mut colors = atty::is(atty::Stream::Stdout);
    if let Ok(global) = crate::config::Global::load() {
    match global.colors {
    Some(crate::config::Choice::Always) => colors = true,
    Some(crate::config::Choice::Never) => colors = false,
    _ => {}
    }
    match global.pager {
    Some(crate::config::Choice::Never) => colors = false,
    _ => {
    super::pager();
    }
  • edit in pijul/src/commands/diff.rs at line 262
    [3.2096]
    [3.2096]
    } else {
    colors |= super::pager();
  • edit in pijul/src/commands/diff.rs at line 265
    [3.2102]
    [4.177744]
    colors
  • replacement in pijul/src/commands/change.rs at line 44
    [4.419][3.2103:2150]()
    let pager_is_colored = super::pager();
    [4.419]
    [3.2150]
    let colors = super::diff::is_colored();
  • replacement in pijul/src/commands/change.rs at line 52
    [3.2378][3.2378:2454]()
    colors: atty::is(atty::Stream::Stdout) || pager_is_colored,
    [3.2378]
    [3.2454]
    colors,