change back to no extra crate

This commit is contained in:
Conrad Ludgate 2023-04-10 23:16:32 +01:00
parent f6ee8fcd2e
commit 2dbb178603
No known key found for this signature in database
GPG Key ID: 197E3CACA1C980B5
9 changed files with 20 additions and 142 deletions

11
Cargo.lock generated
View File

@ -82,7 +82,6 @@ dependencies = [
"atuin-client",
"atuin-common",
"atuin-server",
"atuin-syntect",
"base64 0.20.0",
"bitflags",
"cassowary",
@ -101,11 +100,13 @@ dependencies = [
"interim",
"itertools",
"log",
"once_cell",
"rpassword",
"runtime-format",
"semver",
"serde",
"serde_json",
"syntect",
"tiny-bip39",
"tokio",
"tracing-subscriber",
@ -189,14 +190,6 @@ dependencies = [
"whoami",
]
[[package]]
name = "atuin-syntect"
version = "14.0.0"
dependencies = [
"once_cell",
"syntect",
]
[[package]]
name = "autocfg"
version = "1.1.0"

View File

@ -32,7 +32,7 @@ buildflags = ["--release"]
atuin = { path = "/usr/bin/atuin" }
[workspace]
members = ["./atuin-client", "./atuin-server", "./atuin-common", "./atuin-syntect"]
members = ["./atuin-client", "./atuin-server", "./atuin-common"]
[features]
# TODO(conradludgate)
@ -47,7 +47,6 @@ server = ["atuin-server", "tracing-subscriber"]
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-common = { path = "atuin-common", version = "14.0.0" }
atuin-syntect = { path = "atuin-syntect", version = "14.0.0" }
log = "0.4"
env_logger = "0.10.0"
@ -76,6 +75,9 @@ futures-util = "0.3"
fuzzy-matcher = "0.3.7"
colored = "2.0.0"
syntect = { version = "5.0.0", default-features = false, features = ["dump-load", "parsing", "regex-fancy"] }
once_cell = "1"
# ratatui
bitflags = "1.3"
cassowary = "0.3"

View File

@ -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"

View File

@ -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
}
}

View File

@ -16,6 +16,7 @@ mod duration;
mod engines;
mod history_list;
mod interactive;
mod search_syntect;
pub use duration::{format_duration, format_duration_into};
#[allow(clippy::struct_excessive_bools)]

View File

@ -1,5 +1,6 @@
use std::{collections::HashMap, time::Duration};
use super::search_syntect::{ParsedSyntax, Theme};
use crate::ratatui::{
buffer::Buffer,
layout::Rect,
@ -7,7 +8,6 @@ use crate::ratatui::{
widgets::{Block, StatefulWidget, Widget},
};
use atuin_client::history::History;
use atuin_syntect::{ParsedSyntax, Theme};
use super::format_duration;
@ -172,9 +172,7 @@ impl DrawState<'_> {
let selected = self.y as usize + self.state.offset == self.state.selected;
let with_select = move |style: Style| {
if selected {
style
.bg(map_color(theme.selection))
.add_modifier(Modifier::BOLD)
style.bg(theme.selection).add_modifier(Modifier::BOLD)
} else {
style
}
@ -185,7 +183,7 @@ impl DrawState<'_> {
if t.is_empty() {
self.x += 1;
} else {
self.draw(t, with_select(map_style(style)));
self.draw(t, with_select(style));
}
});
} else {
@ -209,34 +207,3 @@ impl DrawState<'_> {
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(),
}
}

View File

@ -4,7 +4,6 @@ use std::{
time::Duration,
};
use atuin_syntect::{ParsedSyntax, Theme, ShellSyntax, get_syntax, get_theme};
use crossterm::{
event::{self, Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
execute, terminal,
@ -12,10 +11,6 @@ use crossterm::{
use eyre::Result;
use futures_util::FutureExt;
use semver::Version;
// use syntect::{
// dumps::from_uncompressed_data,
// parsing::{ScopeStackOp, SyntaxReference, SyntaxSet},
// };
use unicode_width::UnicodeWidthStr;
use atuin_client::{
@ -28,23 +23,21 @@ use super::{
cursor::Cursor,
engines::{SearchEngine, SearchState},
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::{
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_QUERY: usize = usize::MAX - 1;
struct State {
history_count: i64,
update_needed: Option<Version>,
@ -621,4 +614,3 @@ pub async fn history(
#[allow(clippy::let_and_return)]
res
}

View File

@ -7,8 +7,7 @@ use syntect::{
},
};
mod style;
pub use style::*;
use crate::ratatui::style::{Color, Style};
impl Theme {
// this is a manual/simpler implementation of