mirror of
https://github.com/atuinsh/atuin.git
synced 2025-02-21 12:52:23 +01:00
change back to no extra crate
This commit is contained in:
parent
f6ee8fcd2e
commit
2dbb178603
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -82,7 +82,6 @@ dependencies = [
|
|||||||
"atuin-client",
|
"atuin-client",
|
||||||
"atuin-common",
|
"atuin-common",
|
||||||
"atuin-server",
|
"atuin-server",
|
||||||
"atuin-syntect",
|
|
||||||
"base64 0.20.0",
|
"base64 0.20.0",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
@ -101,11 +100,13 @@ dependencies = [
|
|||||||
"interim",
|
"interim",
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
|
"once_cell",
|
||||||
"rpassword",
|
"rpassword",
|
||||||
"runtime-format",
|
"runtime-format",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"syntect",
|
||||||
"tiny-bip39",
|
"tiny-bip39",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
@ -189,14 +190,6 @@ dependencies = [
|
|||||||
"whoami",
|
"whoami",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atuin-syntect"
|
|
||||||
version = "14.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"once_cell",
|
|
||||||
"syntect",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -32,7 +32,7 @@ buildflags = ["--release"]
|
|||||||
atuin = { path = "/usr/bin/atuin" }
|
atuin = { path = "/usr/bin/atuin" }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["./atuin-client", "./atuin-server", "./atuin-common", "./atuin-syntect"]
|
members = ["./atuin-client", "./atuin-server", "./atuin-common"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# TODO(conradludgate)
|
# TODO(conradludgate)
|
||||||
@ -47,7 +47,6 @@ server = ["atuin-server", "tracing-subscriber"]
|
|||||||
atuin-server = { path = "atuin-server", version = "14.0.0", optional = true }
|
atuin-server = { path = "atuin-server", version = "14.0.0", optional = true }
|
||||||
atuin-client = { path = "atuin-client", version = "14.0.0", optional = true, default-features = false }
|
atuin-client = { path = "atuin-client", version = "14.0.0", optional = true, default-features = false }
|
||||||
atuin-common = { path = "atuin-common", version = "14.0.0" }
|
atuin-common = { path = "atuin-common", version = "14.0.0" }
|
||||||
atuin-syntect = { path = "atuin-syntect", version = "14.0.0" }
|
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
@ -76,6 +75,9 @@ futures-util = "0.3"
|
|||||||
fuzzy-matcher = "0.3.7"
|
fuzzy-matcher = "0.3.7"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
|
|
||||||
|
syntect = { version = "5.0.0", default-features = false, features = ["dump-load", "parsing", "regex-fancy"] }
|
||||||
|
once_cell = "1"
|
||||||
|
|
||||||
# ratatui
|
# ratatui
|
||||||
bitflags = "1.3"
|
bitflags = "1.3"
|
||||||
cassowary = "0.3"
|
cassowary = "0.3"
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "atuin-syntect"
|
|
||||||
version = "14.0.0"
|
|
||||||
authors = ["Ellie Huxtable <ellie@elliehuxtable.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
license = "MIT"
|
|
||||||
description = "common library for atuin"
|
|
||||||
homepage = "https://atuin.sh"
|
|
||||||
repository = "https://github.com/ellie/atuin"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
syntect = { version = "5.0.0", default-features = false, features = ["dump-load", "parsing", "regex-fancy"] }
|
|
||||||
once_cell = "1"
|
|
@ -1,61 +0,0 @@
|
|||||||
//! `style` contains the primitives used to control how your user interface will look.
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub enum Color {
|
|
||||||
Black,
|
|
||||||
Red,
|
|
||||||
Green,
|
|
||||||
Yellow,
|
|
||||||
Blue,
|
|
||||||
Magenta,
|
|
||||||
Cyan,
|
|
||||||
Gray,
|
|
||||||
DarkGray,
|
|
||||||
LightRed,
|
|
||||||
LightGreen,
|
|
||||||
LightYellow,
|
|
||||||
LightBlue,
|
|
||||||
LightMagenta,
|
|
||||||
LightCyan,
|
|
||||||
White,
|
|
||||||
Rgb(u8, u8, u8),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
||||||
pub struct Style {
|
|
||||||
pub fg: Option<Color>,
|
|
||||||
pub bg: Option<Color>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Style {
|
|
||||||
/// Changes the foreground color.
|
|
||||||
///
|
|
||||||
/// ## Examples
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// # use ratatui::style::{Color, Style};
|
|
||||||
/// let style = Style::default().fg(Color::Blue);
|
|
||||||
/// let diff = Style::default().fg(Color::Red);
|
|
||||||
/// assert_eq!(style.patch(diff), Style::default().fg(Color::Red));
|
|
||||||
/// ```
|
|
||||||
pub fn fg(mut self, color: Color) -> Style {
|
|
||||||
self.fg = Some(color);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Changes the background color.
|
|
||||||
///
|
|
||||||
/// ## Examples
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// # use ratatui::style::{Color, Style};
|
|
||||||
/// let style = Style::default().bg(Color::Blue);
|
|
||||||
/// let diff = Style::default().bg(Color::Red);
|
|
||||||
/// assert_eq!(style.patch(diff), Style::default().bg(Color::Red));
|
|
||||||
/// ```
|
|
||||||
pub fn bg(mut self, color: Color) -> Style {
|
|
||||||
self.bg = Some(color);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,6 +16,7 @@ mod duration;
|
|||||||
mod engines;
|
mod engines;
|
||||||
mod history_list;
|
mod history_list;
|
||||||
mod interactive;
|
mod interactive;
|
||||||
|
mod search_syntect;
|
||||||
pub use duration::{format_duration, format_duration_into};
|
pub use duration::{format_duration, format_duration_into};
|
||||||
|
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashMap, time::Duration};
|
use std::{collections::HashMap, time::Duration};
|
||||||
|
|
||||||
|
use super::search_syntect::{ParsedSyntax, Theme};
|
||||||
use crate::ratatui::{
|
use crate::ratatui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
@ -7,7 +8,6 @@ use crate::ratatui::{
|
|||||||
widgets::{Block, StatefulWidget, Widget},
|
widgets::{Block, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
use atuin_client::history::History;
|
use atuin_client::history::History;
|
||||||
use atuin_syntect::{ParsedSyntax, Theme};
|
|
||||||
|
|
||||||
use super::format_duration;
|
use super::format_duration;
|
||||||
|
|
||||||
@ -172,9 +172,7 @@ impl DrawState<'_> {
|
|||||||
let selected = self.y as usize + self.state.offset == self.state.selected;
|
let selected = self.y as usize + self.state.offset == self.state.selected;
|
||||||
let with_select = move |style: Style| {
|
let with_select = move |style: Style| {
|
||||||
if selected {
|
if selected {
|
||||||
style
|
style.bg(theme.selection).add_modifier(Modifier::BOLD)
|
||||||
.bg(map_color(theme.selection))
|
|
||||||
.add_modifier(Modifier::BOLD)
|
|
||||||
} else {
|
} else {
|
||||||
style
|
style
|
||||||
}
|
}
|
||||||
@ -185,7 +183,7 @@ impl DrawState<'_> {
|
|||||||
if t.is_empty() {
|
if t.is_empty() {
|
||||||
self.x += 1;
|
self.x += 1;
|
||||||
} else {
|
} else {
|
||||||
self.draw(t, with_select(map_style(style)));
|
self.draw(t, with_select(style));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -209,34 +207,3 @@ impl DrawState<'_> {
|
|||||||
self.x += self.buf.set_stringn(cx, cy, s, w, style).0 - cx;
|
self.x += self.buf.set_stringn(cx, cy, s, w, style).0 - cx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_color(c: atuin_syntect::Color) -> Color {
|
|
||||||
match c {
|
|
||||||
atuin_syntect::Color::Black => Color::Black,
|
|
||||||
atuin_syntect::Color::Red => Color::Red,
|
|
||||||
atuin_syntect::Color::Green => Color::Green,
|
|
||||||
atuin_syntect::Color::Yellow => Color::Yellow,
|
|
||||||
atuin_syntect::Color::Blue => Color::Blue,
|
|
||||||
atuin_syntect::Color::Magenta => Color::Magenta,
|
|
||||||
atuin_syntect::Color::Cyan => Color::Cyan,
|
|
||||||
atuin_syntect::Color::Gray => Color::Gray,
|
|
||||||
atuin_syntect::Color::DarkGray => Color::DarkGray,
|
|
||||||
atuin_syntect::Color::LightRed => Color::LightRed,
|
|
||||||
atuin_syntect::Color::LightGreen => Color::LightGreen,
|
|
||||||
atuin_syntect::Color::LightYellow => Color::LightYellow,
|
|
||||||
atuin_syntect::Color::LightBlue => Color::LightBlue,
|
|
||||||
atuin_syntect::Color::LightMagenta => Color::LightMagenta,
|
|
||||||
atuin_syntect::Color::LightCyan => Color::LightCyan,
|
|
||||||
atuin_syntect::Color::White => Color::White,
|
|
||||||
atuin_syntect::Color::Rgb(r, g, b) => Color::Rgb(r, g, b),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn map_style(c: atuin_syntect::Style) -> Style {
|
|
||||||
Style {
|
|
||||||
fg: c.fg.map(map_color),
|
|
||||||
bg: c.bg.map(map_color),
|
|
||||||
add_modifier: Modifier::empty(),
|
|
||||||
sub_modifier: Modifier::empty(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use atuin_syntect::{ParsedSyntax, Theme, ShellSyntax, get_syntax, get_theme};
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
|
event::{self, Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
|
||||||
execute, terminal,
|
execute, terminal,
|
||||||
@ -12,10 +11,6 @@ use crossterm::{
|
|||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
// use syntect::{
|
|
||||||
// dumps::from_uncompressed_data,
|
|
||||||
// parsing::{ScopeStackOp, SyntaxReference, SyntaxSet},
|
|
||||||
// };
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use atuin_client::{
|
use atuin_client::{
|
||||||
@ -28,23 +23,21 @@ use super::{
|
|||||||
cursor::Cursor,
|
cursor::Cursor,
|
||||||
engines::{SearchEngine, SearchState},
|
engines::{SearchEngine, SearchState},
|
||||||
history_list::{HistoryList, ListState, PREFIX_LENGTH},
|
history_list::{HistoryList, ListState, PREFIX_LENGTH},
|
||||||
|
search_syntect::{get_syntax, get_theme, ParsedSyntax, ShellSyntax, Theme},
|
||||||
|
};
|
||||||
|
use crate::ratatui::{
|
||||||
|
backend::{Backend, CrosstermBackend},
|
||||||
|
layout::{Alignment, Constraint, Direction, Layout},
|
||||||
|
style::{Color, Modifier, Style},
|
||||||
|
text::{Span, Spans, Text},
|
||||||
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
|
Frame, Terminal, TerminalOptions, Viewport,
|
||||||
};
|
};
|
||||||
use crate::{command::client::search::engines, VERSION};
|
use crate::{command::client::search::engines, VERSION};
|
||||||
use crate::{
|
|
||||||
ratatui::{
|
|
||||||
backend::{Backend, CrosstermBackend},
|
|
||||||
layout::{Alignment, Constraint, Direction, Layout},
|
|
||||||
style::{Color, Modifier, Style},
|
|
||||||
text::{Span, Spans, Text},
|
|
||||||
widgets::{Block, BorderType, Borders, Paragraph},
|
|
||||||
Frame, Terminal, TerminalOptions, Viewport,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const RETURN_ORIGINAL: usize = usize::MAX;
|
const RETURN_ORIGINAL: usize = usize::MAX;
|
||||||
const RETURN_QUERY: usize = usize::MAX - 1;
|
const RETURN_QUERY: usize = usize::MAX - 1;
|
||||||
|
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
history_count: i64,
|
history_count: i64,
|
||||||
update_needed: Option<Version>,
|
update_needed: Option<Version>,
|
||||||
@ -621,4 +614,3 @@ pub async fn history(
|
|||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ use syntect::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod style;
|
use crate::ratatui::style::{Color, Style};
|
||||||
pub use style::*;
|
|
||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
// this is a manual/simpler implementation of
|
// this is a manual/simpler implementation of
|
Loading…
Reference in New Issue
Block a user