Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip ci] update libraries #16

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,038 changes: 644 additions & 394 deletions Cargo.lock

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ license = "MIT"
homepage = "https://github.com/kyoto7250/zhobo"
repository = "https://github.com/kyoto7250/zhobo"
readme = "README.md"
description = "A cross-platform TUI database management tool written in Rust"
description = "A cross-platform TUI database viewer written in Rust. Personaly maintained gobang project"
exclude = ["resources/"]

[dependencies]
tui = { version = "0.15.0", features = ["crossterm"], default-features = false }
crossterm = "0.20"
anyhow = "1.0.38"
unicode-width = "0.1"
sqlx = { version = "0.5.6", features = ["mysql", "postgres", "sqlite", "chrono", "runtime-tokio-rustls", "decimal", "json"], default-features = false }
chrono = "0.4"
tokio = { version = "1.11.0", features = ["full"] }
futures = "0.3.5"
serde_json = "1.0"
thiserror = "1.0"
serde = "1.0"
toml = "0.4"
strum = "0.21"
strum_macros = "0.21"
easy-cast = "0.4"
async-trait = "0.1.50"
itertools = "0.10.0"
rust_decimal = "1.15"
dirs-next = "2.0"
clap = "2.33.3"
structopt = "0.3.22"
syntect = { version = "4.5", default-features = false, features = ["metadata", "default-fancy"]}
unicode-segmentation = "1.7"
ratatui = { version = "0.26.3" }
crossterm = "0.27.0"
anyhow = "1.0.86"
unicode-width = "0.1.13"
sqlx = { version = "0.7.4", features = ["mysql", "postgres", "sqlite", "chrono", "rust_decimal", "runtime-tokio-rustls", "json"], default-features = false }
chrono = "0.4.38"
tokio = { version = "1.37.0", features = ["full"] }
futures = "0.3.30"
serde_json = "1.0.117"
thiserror = "1.0.61"
serde = "1.0.203"
toml = "0.8.14"
strum = "0.26.2"
strum_macros = "0.26.4"
easy-cast = "0.5.2"
async-trait = "0.1.80"
itertools = "0.13.0"
rust_decimal = "1.35"
dirs-next = "2.0.0"
clap = "4.5.7"
structopt = "0.3.26"
syntect = { version = "5.0", default-features = false, features = ["metadata", "default-fancy"]}
unicode-segmentation = "1.11.0"

[target.'cfg(all(target_family="unix",not(target_os="macos")))'.dependencies]
which = "4.1"
which = "6.0.1"

[dev-dependencies]
pretty_assertions = "1.0.0"
pretty_assertions = "1.4.0"
5 changes: 2 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use crate::components::{
use crate::config::Config;
use crate::database::{MySqlPool, Pool, PostgresPool, SqlitePool, RECORDS_LIMIT_PER_PAGE};
use crate::event::Key;
use tui::{
backend::Backend,
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
Frame,
};
Expand Down Expand Up @@ -56,7 +55,7 @@ impl App {
}
}

pub fn draw<B: Backend>(&mut self, f: &mut Frame<'_, B>) -> anyhow::Result<()> {
pub fn draw(&mut self, f: &mut Frame) -> anyhow::Result<()> {
if let Focus::ConnectionList = self.focus {
self.connections.draw(
f,
Expand Down
12 changes: 2 additions & 10 deletions src/components/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result;
use tui::{
backend::Backend,
use ratatui::{
layout::Rect,
style::{Color, Style},
widgets::{Block, Borders, Clear, List, ListItem, ListState},
Expand Down Expand Up @@ -95,14 +94,7 @@ impl CompletionComponent {
}

impl MovableComponent for CompletionComponent {
fn draw<B: Backend>(
&mut self,
f: &mut Frame<B>,
area: Rect,
_focused: bool,
x: u16,
y: u16,
) -> Result<()> {
fn draw(&mut self, f: &mut Frame, area: Rect, _focused: bool, x: u16, y: u16) -> Result<()> {
if !self.word.is_empty() {
let width = 30;
let candidates = self
Expand Down
9 changes: 4 additions & 5 deletions src/components/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use crate::components::command::CommandInfo;
use crate::config::{Connection, KeyConfig};
use crate::event::Key;
use anyhow::Result;
use tui::{
backend::Backend,
use ratatui::{
layout::Rect,
style::{Color, Style},
text::{Span, Spans},
text::{Line, Span},
widgets::{Block, Borders, Clear, List, ListItem, ListState},
Frame,
};
Expand Down Expand Up @@ -82,14 +81,14 @@ impl ConnectionsComponent {
}

impl StatefulDrawableComponent for ConnectionsComponent {
fn draw<B: Backend>(&mut self, f: &mut Frame<B>, _area: Rect, _focused: bool) -> Result<()> {
fn draw(&mut self, f: &mut Frame, _area: Rect, _focused: bool) -> Result<()> {
let width = 80;
let height = 20;
let conns = &self.connections;
let mut connections: Vec<ListItem> = Vec::new();
for c in conns {
connections.push(
ListItem::new(vec![Spans::from(Span::raw(c.database_url_with_name()?))])
ListItem::new(vec![Line::from(Span::raw(c.database_url_with_name()?))])
.style(Style::default()),
)
}
Expand Down
9 changes: 4 additions & 5 deletions src/components/database_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use crate::components::command::CommandInfo;
use crate::event::Key;
use crate::tree::Table;
use anyhow::Result;
use tui::{
backend::Backend,
use ratatui::{
layout::Rect,
style::{Color, Style},
text::Spans,
text::Line,
widgets::{Block, Borders, Paragraph},
Frame,
};
Expand Down Expand Up @@ -43,8 +42,8 @@ impl DatabaseFilterComponent {
}

impl DrawableComponent for DatabaseFilterComponent {
fn draw<B: Backend>(&self, f: &mut Frame<B>, area: Rect, focused: bool) -> Result<()> {
let query = Paragraph::new(Spans::from(format!(
fn draw(&self, f: &mut Frame, area: Rect, focused: bool) -> Result<()> {
let query = Paragraph::new(Line::from(format!(
"{:w$}",
if self.input.is_empty() && !focused {
"Filter tables".to_string()
Expand Down
33 changes: 16 additions & 17 deletions src/components/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ use crate::tree::{Database, DatabaseTree, DatabaseTreeItem};
use crate::ui::common_nav;
use crate::ui::scrolllist::draw_list_block;
use anyhow::Result;
use std::collections::BTreeSet;
use std::convert::From;
use tui::{
backend::Backend,
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style},
text::{Span, Spans},
text::{Line, Span},
widgets::{Block, Borders},
Frame,
};
use std::collections::BTreeSet;
use std::convert::From;

// ▸
const FOLDER_ICON_COLLAPSED: &str = "\u{25b8}";
Expand Down Expand Up @@ -81,7 +80,7 @@ impl DatabasesComponent {
selected: bool,
width: u16,
filter: Option<String>,
) -> Spans<'static> {
) -> Line<'static> {
let name = item.kind().name();
let indent = item.info().indent();

Expand All @@ -105,7 +104,7 @@ impl DatabasesComponent {
if item.kind().is_table() && name.contains(&filter) {
let (first, rest) = &name.split_at(name.find(filter.as_str()).unwrap_or(0));
let (middle, last) = &rest.split_at(filter.len().clamp(0, rest.len()));
return Spans::from(vec![
return Line::from(vec![
Span::styled(
format!("{}{}{}", indent_str, arrow, first),
if selected {
Expand Down Expand Up @@ -134,7 +133,7 @@ impl DatabasesComponent {
}
}

Spans::from(Span::styled(
Line::from(Span::styled(
format!("{}{}{:w$}", indent_str, arrow, name, w = width as usize),
if selected {
Style::default().bg(Color::Blue)
Expand All @@ -144,7 +143,7 @@ impl DatabasesComponent {
))
}

fn draw_tree<B: Backend>(&self, f: &mut Frame<B>, area: Rect, focused: bool) -> Result<()> {
fn draw_tree(&self, f: &mut Frame, area: Rect, focused: bool) -> Result<()> {
f.render_widget(
Block::default()
.title("Databases")
Expand Down Expand Up @@ -206,7 +205,7 @@ impl DatabasesComponent {
}

impl DrawableComponent for DatabasesComponent {
fn draw<B: Backend>(&self, f: &mut Frame<B>, area: Rect, focused: bool) -> Result<()> {
fn draw(&self, f: &mut Frame, area: Rect, focused: bool) -> Result<()> {
let chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(100)].as_ref())
Expand Down Expand Up @@ -274,7 +273,7 @@ fn tree_nav(tree: &mut DatabaseTree, key: Key, key_config: &KeyConfig) -> bool {

#[cfg(test)]
mod test {
use super::{Color, Database, DatabaseTreeItem, DatabasesComponent, Span, Spans, Style};
use super::{Color, Database, DatabaseTreeItem, DatabasesComponent, Line, Span, Style};
use crate::tree::Table;

#[test]
Expand All @@ -293,7 +292,7 @@ mod test {
WIDTH,
None,
),
Spans::from(vec![Span::raw(format!(
Line::from(vec![Span::raw(format!(
"\u{25b8}{:w$}",
"foo",
w = WIDTH as usize
Expand All @@ -313,7 +312,7 @@ mod test {
WIDTH,
None,
),
Spans::from(vec![Span::styled(
Line::from(vec![Span::styled(
format!("\u{25b8}{:w$}", "foo", w = WIDTH as usize),
Style::default().bg(Color::Blue)
)])
Expand Down Expand Up @@ -342,7 +341,7 @@ mod test {
WIDTH,
None,
),
Spans::from(vec![Span::raw(format!(
Line::from(vec![Span::raw(format!(
" {:w$}",
"bar",
w = WIDTH as usize
Expand All @@ -368,7 +367,7 @@ mod test {
WIDTH,
None,
),
Spans::from(Span::styled(
Line::from(Span::styled(
format!(" {:w$}", "bar", w = WIDTH as usize),
Style::default().bg(Color::Blue),
))
Expand Down Expand Up @@ -397,7 +396,7 @@ mod test {
WIDTH,
Some("rb".to_string()),
),
Spans::from(vec![
Line::from(vec![
Span::raw(format!(" {}", "ba")),
Span::styled("rb", Style::default().fg(Color::Blue)),
Span::raw(format!("{:w$}", "az", w = WIDTH as usize))
Expand All @@ -423,7 +422,7 @@ mod test {
WIDTH,
Some("rb".to_string()),
),
Spans::from(vec![
Line::from(vec![
Span::styled(format!(" {}", "ba"), Style::default().bg(Color::Blue)),
Span::styled("rb", Style::default().bg(Color::Blue).fg(Color::Blue)),
Span::styled(
Expand Down
5 changes: 2 additions & 3 deletions src/components/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result;
use tui::{
backend::Backend,
use ratatui::{
layout::{Alignment, Rect},
widgets::{Block, Borders, Clear, Paragraph, Wrap},
Frame,
Expand All @@ -28,7 +27,7 @@ impl DebugComponent {
}

impl DrawableComponent for DebugComponent {
fn draw<B: Backend>(&self, f: &mut Frame<B>, _area: Rect, _focused: bool) -> Result<()> {
fn draw(&self, f: &mut Frame, _area: Rect, _focused: bool) -> Result<()> {
if true {
let width = 65;
let height = 10;
Expand Down
5 changes: 2 additions & 3 deletions src/components/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result;
use tui::{
backend::Backend,
use ratatui::{
layout::{Alignment, Rect},
style::{Color, Style},
widgets::{Block, Borders, Clear, Paragraph, Wrap},
Expand Down Expand Up @@ -35,7 +34,7 @@ impl ErrorComponent {
}

impl DrawableComponent for ErrorComponent {
fn draw<B: Backend>(&self, f: &mut Frame<B>, _area: Rect, _focused: bool) -> Result<()> {
fn draw(&self, f: &mut Frame, _area: Rect, _focused: bool) -> Result<()> {
if self.visible {
let width = 65;
let height = 10;
Expand Down
Loading