chore: update to clap v4 & termion v2

This commit is contained in:
graelo 2022-11-07 00:02:27 +01:00
parent 1f79419934
commit 10013a6c6d
9 changed files with 282 additions and 196 deletions

View file

@ -1,20 +1,26 @@
[package]
name = "copyrat"
version = "0.4.1"
authors = ["graelo <graelo@graelo.cc>"]
edition = "2021"
description = "A tmux plugin for copy-pasting within tmux panes."
repository = "https://github.com/graelo/tmux-copyrat"
keywords = ["rust", "tmux", "tmux-plugin", "tmux-copycat"]
readme = "README.md"
license = "MIT"
authors = ["graelo <graelo@graelo.cc>"]
repository = "https://github.com/graelo/tmux-copyrat"
homepage = "https://github.com/graelo/tmux-copyrat"
documentation = "https://docs.rs/tmux-copyrat"
keywords = ["rust", "tmux", "tmux-plugin", "tmux-copycat"]
categories = ["command-line-utilities"]
exclude = ["/.github"]
[dependencies]
thiserror = "1"
termion = "1.5"
regex = "1.5"
clap = { version = "3.1", features = ["derive", "wrap_help"]}
termion = "2"
regex = "1.6"
clap = { version = "4.0", features = ["derive", "wrap_help"]}
sequence_trie = "0.3.6"
duct = "0.13"

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Ferran Basora
Copyright (c) 2022 graelo@grael.cc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,4 +1,6 @@
use clap::{ArgEnum, Parser};
use std::fmt::Display;
use clap::{ArgAction, Parser, ValueEnum};
use crate::{
textbuf::{alphabet, regexes},
@ -18,58 +20,70 @@ pub struct Config {
/// # Examples
///
/// "qwerty", "dvorak-homerow", "azerty-right-hand".
#[clap(short = 'k', long, default_value = "dvorak",
parse(try_from_str = alphabet::parse_alphabet))]
#[arg(
short = 'k',
long,
default_value = "dvorak",
value_parser(alphabet::parse_alphabet)
)]
pub alphabet: alphabet::Alphabet,
/// Use all available regex patterns.
#[clap(short = 'A', long = "--all-patterns")]
#[arg(short = 'A', long = "all-patterns")]
pub use_all_patterns: bool,
/// Pattern names to use ("email", ... see doc).
#[clap(short = 'x', long = "--pattern-name", parse(try_from_str = regexes::parse_pattern_name))]
#[arg(
short = 'x',
long = "pattern-name",
value_parser(regexes::parse_pattern_name)
)]
pub named_patterns: Vec<regexes::NamedPattern>,
/// Additional regex patterns ("(foo.*)bar", etc). Must have a capture
/// group.
#[clap(short = 'X', long = "--custom-pattern")]
#[arg(short = 'X', long)]
pub custom_patterns: Vec<String>,
/// Assign hints starting from the bottom of the screen.
#[clap(short, long)]
#[arg(short, long, action = ArgAction::SetTrue)]
pub reverse: bool,
/// Keep the same hint for identical spans.
#[clap(short, long)]
#[arg(short, long, action = ArgAction::SetTrue)]
pub unique_hint: bool,
/// Move focus back to first/last span.
#[clap(short = 'w', long)]
#[arg(short = 'w', long, action = ArgAction::SetTrue)]
pub focus_wrap_around: bool,
#[clap(flatten)]
#[command(flatten)]
pub colors: ui::colors::UiColors,
/// Align hint with its span.
#[clap(long, arg_enum, default_value = "leading")]
#[arg(long, value_enum, default_value_t = ui::HintAlignment::Leading)]
pub hint_alignment: ui::HintAlignment,
/// Optional hint styling.
///
/// Underline or surround the hint for increased visibility.
/// If not provided, only the hint colors will be used.
#[clap(short = 's', long = "hint-style", arg_enum, rename_all = "lowercase")]
#[arg(short = 's', long = "hint-style", rename_all = "lowercase", value_enum)]
pub hint_style_arg: Option<HintStyleArg>,
/// Chars surrounding each hint, used with `Surround` style.
#[clap(long, default_value = "{}",
parse(try_from_str = try_parse_chars))]
pub hint_surroundings: (char, char),
#[clap(
long,
// default_value_t = HintSurroundingsArg{open: '{', close: '}'},
default_value = "{}",
value_parser(try_parse_chars)
)]
pub hint_surroundings: HintSurroundingsArg,
}
/// Type introduced due to parsing limitation,
/// as we cannot directly parse tuples into ui::HintStyle.
#[derive(Debug, Clone, ArgEnum)]
#[derive(Debug, Clone, ValueEnum)]
pub enum HintStyleArg {
Bold,
Italic,
@ -77,14 +91,29 @@ pub enum HintStyleArg {
Surround,
}
#[derive(Debug, Clone)]
pub struct HintSurroundingsArg {
pub open: char,
pub close: char,
}
impl Display for HintSurroundingsArg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}{}", self.open, self.close)
}
}
/// Try to parse a `&str` into a tuple of `char`s.
fn try_parse_chars(src: &str) -> Result<(char, char)> {
fn try_parse_chars(src: &str) -> Result<HintSurroundingsArg> {
if src.chars().count() != 2 {
return Err(Error::ExpectedSurroundingPair);
}
let chars: Vec<char> = src.chars().collect();
Ok((chars[0], chars[1]))
Ok(HintSurroundingsArg {
open: chars[0],
close: chars[1],
})
}
impl Config {
@ -96,7 +125,7 @@ impl Config {
HintStyleArg::Italic => Some(ui::HintStyle::Italic),
HintStyleArg::Underline => Some(ui::HintStyle::Underline),
HintStyleArg::Surround => {
let (open, close) = self.hint_surroundings;
let HintSurroundingsArg { open, close } = self.hint_surroundings;
Some(ui::HintStyle::Surround(open, close))
}
},

View file

@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::fmt;
use clap::{ArgEnum, Parser};
use clap::{Parser, ValueEnum};
use super::basic;
use crate::{textbuf::alphabet, tmux, ui, Error, Result};
@ -31,7 +31,7 @@ pub struct ConfigExt {
/// Capture visible area or entire pane history.
#[clap(
arg_enum,
value_enum,
long,
rename_all = "kebab-case",
default_value = "visible-area"
@ -113,7 +113,7 @@ impl ConfigExt {
}
/// Specifies which region of the terminal buffer to capture.
#[derive(Debug, Clone, ArgEnum, Parser)]
#[derive(Debug, Clone, ValueEnum, Parser)]
pub enum CaptureRegion {
/// The entire history.
// This will end up sending `-S - -E -` to `tmux capture-pane`.

View file

@ -54,7 +54,7 @@ pub fn parse_alphabet(src: &str) -> Result<Alphabet> {
}
/// Type-safe string alphabet (newtype).
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Alphabet(pub String);
impl Alphabet {

View file

@ -47,7 +47,7 @@ pub(super) const PATTERNS: [(&str, &str); 20] = [
];
/// Type-safe string Pattern Name (newtype).
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct NamedPattern(pub String, pub String);
/// Parse a name string into `NamedPattern`, used during CLI parsing.

View file

@ -1,29 +1,79 @@
use clap::Parser;
use termion::color;
use std::fmt;
use std::str::FromStr;
use clap::Args;
use termion::color as tcolor;
use crate::{Error, Result};
pub fn parse_color(src: &str) -> Result<Box<dyn color::Color>> {
match src {
"black" => Ok(Box::new(color::Black)),
"red" => Ok(Box::new(color::Red)),
"green" => Ok(Box::new(color::Green)),
"yellow" => Ok(Box::new(color::Yellow)),
"blue" => Ok(Box::new(color::Blue)),
"magenta" => Ok(Box::new(color::Magenta)),
"cyan" => Ok(Box::new(color::Cyan)),
"white" => Ok(Box::new(color::White)),
"bright-black" | "brightblack" => Ok(Box::new(color::LightBlack)),
"bright-red" | "brightred" => Ok(Box::new(color::LightRed)),
"bright-green" | "brightgreen" => Ok(Box::new(color::LightGreen)),
"bright-yellow" | "brightyellow" => Ok(Box::new(color::LightYellow)),
"bright-blue" | "brightblue" => Ok(Box::new(color::LightBlue)),
"bright-magenta" | "brightmagenta" => Ok(Box::new(color::LightMagenta)),
"bright-cyan" | "brightcyan" => Ok(Box::new(color::LightCyan)),
"bright-white" | "brightwhite" => Ok(Box::new(color::LightWhite)),
"none" => Ok(Box::new(color::Reset)),
_ => Err(Error::UnknownColor),
#[derive(Debug, Clone, Copy)]
pub struct Color(Option<u8>);
impl tcolor::Color for Color {
#[inline]
fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
Some(value) => write!(f, "\x1B[38;5;{}m", value),
None => write!(f, "\x1B[39m"),
}
}
#[inline]
fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
Some(value) => write!(f, "\x1B[48;5;{}m", value),
None => write!(f, "\x1B[49m"),
}
}
}
pub(crate) static BLACK: Color = Color(Some(0));
pub(crate) static RED: Color = Color(Some(1));
pub(crate) static GREEN: Color = Color(Some(2));
pub(crate) static YELLOW: Color = Color(Some(3));
pub(crate) static BLUE: Color = Color(Some(4));
pub(crate) static MAGENTA: Color = Color(Some(5));
pub(crate) static CYAN: Color = Color(Some(6));
pub(crate) static WHITE: Color = Color(Some(7));
pub(crate) static BRIGHTBLACK: Color = Color(Some(8));
pub(crate) static BRIGHTRED: Color = Color(Some(9));
pub(crate) static BRIGHTGREEN: Color = Color(Some(10));
pub(crate) static BRIGHTYELLOW: Color = Color(Some(11));
pub(crate) static BRIGHTBLUE: Color = Color(Some(12));
pub(crate) static BRIGHTMAGENTA: Color = Color(Some(13));
pub(crate) static BRIGHTCYAN: Color = Color(Some(14));
pub(crate) static BRIGHTWHITE: Color = Color(Some(15));
pub(crate) static RESET: Color = Color(None);
impl FromStr for Color {
type Err = Error;
fn from_str(src: &str) -> std::result::Result<Self, Self::Err> {
match src {
"black" => Ok(BLACK),
"red" => Ok(RED),
"green" => Ok(GREEN),
"yellow" => Ok(YELLOW),
"blue" => Ok(BLUE),
"magenta" => Ok(MAGENTA),
"cyan" => Ok(CYAN),
"white" => Ok(WHITE),
"bright-black" | "brightblack" => Ok(BRIGHTBLACK),
"bright-red" | "brightred" => Ok(BRIGHTRED),
"bright-green" | "brightgreen" => Ok(BRIGHTGREEN),
"bright-yellow" | "brightyellow" => Ok(BRIGHTYELLOW),
"bright-blue" | "brightblue" => Ok(BRIGHTBLUE),
"bright-magenta" | "brightmagenta" => Ok(BRIGHTMAGENTA),
"bright-cyan" | "brightcyan" => Ok(BRIGHTCYAN),
"bright-white" | "brightwhite" => Ok(BRIGHTWHITE),
"none" => Ok(RESET),
_ => Err(Error::UnknownColor),
}
}
}
pub fn parse_color(src: &str) -> Result<Color> {
Color::from_str(src)
}
#[cfg(test)]
@ -31,20 +81,27 @@ mod tests {
use super::*;
#[test]
fn span_color() {
let text1 = format!(
"{}{}",
color::Fg(parse_color("green").unwrap().as_ref()),
"foo"
);
let text2 = format!("{}{}", color::Fg(color::Green), "foo");
fn span_color_fg() {
let actual = format!("{}{}", tcolor::Fg(Color::from_str("green").unwrap()), "foo");
let expected = format!("{}{}", tcolor::Fg(tcolor::Green), "foo");
assert_eq!(text1, text2);
assert_eq!(actual, expected);
}
#[test]
fn span_color_bg() {
let actual = format!("{}{}", tcolor::Bg(Color::from_str("green").unwrap()), "foo");
let expected = format!("{}{}", tcolor::Bg(tcolor::Green), "foo");
assert_eq!(actual, expected);
}
#[test]
fn no_span_color() {
assert!(parse_color("wat").is_err(), "this color should not exist");
assert!(
Color::from_str("wat").is_err(),
"this color should not exist"
);
}
}
@ -53,44 +110,38 @@ mod tests {
/// - `focus_*` colors are used to render the currently focused text span.
/// - `normal_*` colors are used to render other text spans.
/// - `hint_*` colors are used to render the hints.
#[derive(Parser, Debug)]
#[clap(about)] // Needed to avoid this doc comment to be used as overall `about`.
#[derive(Args, Debug)]
// #[clap(about)] // Needed to avoid this doc comment to be used as overall `about`.
pub struct UiColors {
/// Foreground color for base text.
#[clap(long, default_value = "bright-cyan", parse(try_from_str = parse_color))]
pub text_fg: Box<dyn color::Color>,
#[arg(long, default_value = "bright-cyan", value_parser(parse_color))]
pub text_fg: Color,
/// Background color for base text.
#[clap(long, default_value = "none", parse(try_from_str = parse_color))]
pub text_bg: Box<dyn color::Color>,
#[clap(long, default_value = "none", value_parser(parse_color))]
pub text_bg: Color,
/// Foreground color for spans.
#[clap(long, default_value = "blue",
parse(try_from_str = parse_color))]
pub span_fg: Box<dyn color::Color>,
#[clap(long, default_value = "blue", value_parser(parse_color))]
pub span_fg: Color,
/// Background color for spans.
#[clap(long, default_value = "none",
parse(try_from_str = parse_color))]
pub span_bg: Box<dyn color::Color>,
#[clap(long, default_value = "none", value_parser(parse_color))]
pub span_bg: Color,
/// Foreground color for the focused span.
#[clap(long, default_value = "magenta",
parse(try_from_str = parse_color))]
pub focused_fg: Box<dyn color::Color>,
#[clap(long, default_value = "magenta", value_parser(parse_color))]
pub focused_fg: Color,
/// Background color for the focused span.
#[clap(long, default_value = "none",
parse(try_from_str = parse_color))]
pub focused_bg: Box<dyn color::Color>,
#[clap(long, default_value = "none", value_parser(parse_color))]
pub focused_bg: Color,
/// Foreground color for hints.
#[clap(long, default_value = "yellow",
parse(try_from_str = parse_color))]
pub hint_fg: Box<dyn color::Color>,
#[clap(long, default_value = "yellow", value_parser(parse_color))]
pub hint_fg: Color,
/// Background color for hints.
#[clap(long, default_value = "none",
parse(try_from_str = parse_color))]
pub hint_bg: Box<dyn color::Color>,
#[clap(long, default_value = "none", value_parser(parse_color))]
pub hint_bg: Color,
}

View file

@ -1,8 +1,8 @@
use clap::{ArgEnum, Parser};
use clap::{Parser, ValueEnum};
/// Describes if, during rendering, a hint should aligned to the leading edge of
/// the matched text, or to its trailing edge.
#[derive(Debug, Clone, ArgEnum, Parser)]
#[derive(Debug, Clone, ValueEnum, Parser)]
pub enum HintAlignment {
Leading,
Trailing,

View file

@ -1,8 +1,9 @@
use std::char;
use std::cmp;
use std::io;
use std::io::Write;
use termion::{self, color, cursor, event, style};
use termion::{self, color, cursor, event, screen::IntoAlternateScreen, style};
use super::colors::UiColors;
use super::Selection;
@ -63,7 +64,7 @@ impl<'a> ViewController<'a> {
};
let (term_width, _) = termion::terminal_size().unwrap_or((80u16, 30u16)); // .expect("Cannot read the terminal size.");
let wrapped_lines = compute_wrapped_lines(&model.lines, term_width);
let wrapped_lines = compute_wrapped_lines(model.lines, term_width);
ViewController {
model,
@ -177,8 +178,8 @@ impl<'a> ViewController<'a> {
write!(
stdout,
"{bg_color}{fg_color}",
fg_color = color::Fg(colors.text_fg.as_ref()),
bg_color = color::Bg(colors.text_bg.as_ref()),
fg_color = color::Fg(colors.text_fg),
bg_color = color::Bg(colors.text_bg),
)
.unwrap();
@ -233,8 +234,8 @@ impl<'a> ViewController<'a> {
stdout,
"{goto}{bg_color}{fg_color}{text}{fg_reset}{bg_reset}",
goto = cursor::Goto(pos.0 as u16 + 1, pos.1 as u16 + 1),
fg_color = color::Fg(fg_color.as_ref()),
bg_color = color::Bg(bg_color.as_ref()),
fg_color = color::Fg(*fg_color),
bg_color = color::Bg(*bg_color),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
text = &text,
@ -260,8 +261,8 @@ impl<'a> ViewController<'a> {
colors: &UiColors,
hint_style: &Option<HintStyle>,
) {
let fg_color = color::Fg(colors.hint_fg.as_ref());
let bg_color = color::Bg(colors.hint_bg.as_ref());
let fg_color = color::Fg(colors.hint_fg);
let bg_color = color::Bg(colors.hint_bg);
let fg_reset = color::Fg(color::Reset);
let bg_reset = color::Bg(color::Reset);
let goto = cursor::Goto(pos.0 as u16 + 1, pos.1 as u16 + 1);
@ -358,7 +359,7 @@ impl<'a> ViewController<'a> {
text,
focused,
(pos_x, pos_y),
&self.rendering_colors,
self.rendering_colors,
);
if !focused {
@ -374,7 +375,7 @@ impl<'a> ViewController<'a> {
stdout,
&span.hint,
(pos_x + offset, pos_y),
&self.rendering_colors,
self.rendering_colors,
&self.hint_style,
);
}
@ -399,9 +400,9 @@ impl<'a> ViewController<'a> {
// 1. Trim all lines and render non-empty ones.
ViewController::render_base_text(
stdout,
&self.model.lines,
self.model.lines,
&self.wrapped_lines,
&self.rendering_colors,
self.rendering_colors,
);
for (index, span) in self.model.spans.iter().enumerate() {
@ -598,17 +599,16 @@ impl<'a> ViewController<'a> {
/// - Setup steps: switch to alternate screen, switch to raw mode, hide the cursor.
/// - Teardown steps: show cursor, back to main screen.
pub fn present(&mut self) -> Option<Selection> {
use std::io::Write;
use termion::raw::IntoRawMode;
use termion::screen::AlternateScreen;
let mut stdin = termion::async_stdin();
let mut stdout = AlternateScreen::from(
io::stdout()
.into_raw_mode()
.expect("Cannot access alternate screen."),
);
let mut stdout = io::stdout()
.into_alternate_screen()
.expect("Cannot access alternate screen.")
.into_raw_mode()
.expect("Cannot access alternate screen.");
// stdout.write(cursor::Hide.into()).unwrap();
write!(stdout, "{}", cursor::Hide).unwrap();
let selection = match self.listen(&mut stdin, &mut stdout) {
@ -663,7 +663,7 @@ enum Event {
#[cfg(test)]
mod tests {
use super::*;
use crate::textbuf::alphabet;
use crate::{textbuf::alphabet, ui::colors};
#[test]
fn test_render_all_lines() {
@ -684,14 +684,14 @@ path: /usr/local/bin/cargo";
];
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let mut writer = vec![];
@ -706,8 +706,8 @@ path: /usr/local/bin/cargo";
format!(
"{bg}{fg}{g1}some text{g2}* e006b06 - (12 days ago) swapper: Make quotes{g3}path: /usr/local/bin/git{g6}path: /usr/local/bin/cargo{fg_reset}{bg_reset}",
g1 = goto1, g2 = goto2, g3 = goto3, g6 = goto6,
fg = color::Fg(colors.text_fg.as_ref()),
bg = color::Bg(colors.text_bg.as_ref()),
fg = color::Fg(colors.text_fg),
bg = color::Bg(colors.text_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
)
@ -722,14 +722,14 @@ path: /usr/local/bin/cargo";
let focused = true;
let position: (usize, usize) = (3, 1);
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
ViewController::render_span_text(&mut writer, text, focused, position, &colors);
@ -739,8 +739,8 @@ path: /usr/local/bin/cargo";
format!(
"{goto}{bg}{fg}{text}{fg_reset}{bg_reset}",
goto = cursor::Goto(4, 2),
fg = color::Fg(colors.focused_fg.as_ref()),
bg = color::Bg(colors.focused_bg.as_ref()),
fg = color::Fg(colors.focused_fg),
bg = color::Bg(colors.focused_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
text = &text,
@ -756,14 +756,14 @@ path: /usr/local/bin/cargo";
let focused = false;
let position: (usize, usize) = (3, 1);
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
ViewController::render_span_text(&mut writer, text, focused, position, &colors);
@ -773,8 +773,8 @@ path: /usr/local/bin/cargo";
format!(
"{goto}{bg}{fg}{text}{fg_reset}{bg_reset}",
goto = cursor::Goto(4, 2),
fg = color::Fg(colors.span_fg.as_ref()),
bg = color::Bg(colors.span_bg.as_ref()),
fg = color::Fg(colors.span_fg),
bg = color::Bg(colors.span_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
text = &text,
@ -789,14 +789,14 @@ path: /usr/local/bin/cargo";
let hint_text = "eo";
let position: (usize, usize) = (3, 1);
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let offset = 0;
@ -815,8 +815,8 @@ path: /usr/local/bin/cargo";
format!(
"{goto}{bg}{fg}{text}{fg_reset}{bg_reset}",
goto = cursor::Goto(4, 2),
fg = color::Fg(colors.hint_fg.as_ref()),
bg = color::Bg(colors.hint_bg.as_ref()),
fg = color::Fg(colors.hint_fg),
bg = color::Bg(colors.hint_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
text = "eo",
@ -831,14 +831,14 @@ path: /usr/local/bin/cargo";
let hint_text = "eo";
let position: (usize, usize) = (3, 1);
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let offset = 0;
@ -857,8 +857,8 @@ path: /usr/local/bin/cargo";
format!(
"{goto}{bg}{fg}{sty}{text}{sty_reset}{fg_reset}{bg_reset}",
goto = cursor::Goto(4, 2),
fg = color::Fg(colors.hint_fg.as_ref()),
bg = color::Bg(colors.hint_bg.as_ref()),
fg = color::Fg(colors.hint_fg),
bg = color::Bg(colors.hint_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
sty = style::Underline,
@ -875,14 +875,14 @@ path: /usr/local/bin/cargo";
let hint_text = "eo";
let position: (usize, usize) = (3, 1);
let colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let offset = 0;
@ -901,8 +901,8 @@ path: /usr/local/bin/cargo";
format!(
"{goto}{bg}{fg}{bra}{text}{bra_close}{fg_reset}{bg_reset}",
goto = cursor::Goto(4, 2),
fg = color::Fg(colors.hint_fg.as_ref()),
bg = color::Bg(colors.hint_bg.as_ref()),
fg = color::Fg(colors.hint_fg),
bg = color::Bg(colors.hint_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
bra = '{',
@ -937,16 +937,16 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
unique_hint,
);
let term_width: u16 = 80;
let wrapped_lines = compute_wrapped_lines(&model.lines, term_width);
let wrapped_lines = compute_wrapped_lines(model.lines, term_width);
let rendering_colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let hint_alignment = HintAlignment::Leading;
@ -974,8 +974,8 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
{goto3}Barcelona https://en.wikipedia.org/wiki/Barcelona -{fg_reset}{bg_reset}",
goto1 = goto1,
goto3 = goto3,
fg = color::Fg(rendering_colors.text_fg.as_ref()),
bg = color::Bg(rendering_colors.text_bg.as_ref()),
fg = color::Fg(rendering_colors.text_fg),
bg = color::Bg(rendering_colors.text_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset),
);
@ -1013,14 +1013,14 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
let default_output_destination = OutputDestination::Tmux;
let rendering_colors = UiColors {
text_fg: Box::new(color::Black),
text_bg: Box::new(color::White),
focused_fg: Box::new(color::Red),
focused_bg: Box::new(color::Blue),
span_fg: Box::new(color::Green),
span_bg: Box::new(color::Magenta),
hint_fg: Box::new(color::Yellow),
hint_bg: Box::new(color::Cyan),
text_fg: colors::BLACK,
text_bg: colors::WHITE,
focused_fg: colors::RED,
focused_bg: colors::BLUE,
span_fg: colors::GREEN,
span_bg: colors::MAGENTA,
hint_fg: colors::YELLOW,
hint_bg: colors::CYAN,
};
let hint_alignment = HintAlignment::Leading;
let hint_style = None;
@ -1046,8 +1046,8 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
{goto3}Barcelona https://en.wikipedia.org/wiki/Barcelona -{fg_reset}{bg_reset}",
goto1 = goto1,
goto3 = goto3,
fg = color::Fg(rendering_colors.text_fg.as_ref()),
bg = color::Bg(rendering_colors.text_bg.as_ref()),
fg = color::Fg(rendering_colors.text_fg),
bg = color::Bg(rendering_colors.text_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset)
)
@ -1058,8 +1058,8 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
format!(
"{goto7_1}{span_bg}{span_fg}127.0.0.1{fg_reset}{bg_reset}",
goto7_1 = goto7_1,
span_fg = color::Fg(rendering_colors.span_fg.as_ref()),
span_bg = color::Bg(rendering_colors.span_bg.as_ref()),
span_fg = color::Fg(rendering_colors.span_fg),
span_bg = color::Bg(rendering_colors.span_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset)
)
@ -1071,8 +1071,8 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
format!(
"{goto7_1}{hint_bg}{hint_fg}b{fg_reset}{bg_reset}",
goto7_1 = goto7_1,
hint_fg = color::Fg(rendering_colors.hint_fg.as_ref()),
hint_bg = color::Bg(rendering_colors.hint_bg.as_ref()),
hint_fg = color::Fg(rendering_colors.hint_fg),
hint_bg = color::Bg(rendering_colors.hint_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset)
)
@ -1083,8 +1083,8 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
format!(
"{goto11_3}{focus_bg}{focus_fg}https://en.wikipedia.org/wiki/Barcelona{fg_reset}{bg_reset}",
goto11_3 = goto11_3,
focus_fg = color::Fg(rendering_colors.focused_fg.as_ref()),
focus_bg = color::Bg(rendering_colors.focused_bg.as_ref()),
focus_fg = color::Fg(rendering_colors.focused_fg),
focus_bg = color::Bg(rendering_colors.focused_bg),
fg_reset = color::Fg(color::Reset),
bg_reset = color::Bg(color::Reset)
)