chore: fmt

pull/170/head
Valentin271 7 months ago
parent 0a1c65372c
commit f18d014332
No known key found for this signature in database
GPG Key ID: 77B4667C08D99D91

@ -1,9 +1,9 @@
use std::{collections::BTreeSet, usize};
use crate::{ use crate::{
databasetreeitems::DatabaseTreeItems, error::Result, item::DatabaseTreeItemKind, databasetreeitems::DatabaseTreeItems, error::Result, item::DatabaseTreeItemKind,
tree_iter::TreeIterator, tree_iter::TreeIterator, Database, Table,
}; };
use crate::{Database, Table};
use std::{collections::BTreeSet, usize};
/// ///
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
@ -366,9 +366,10 @@ impl DatabaseTree {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::{Database, DatabaseTree, MoveSelection, Schema, Table};
use std::collections::BTreeSet; use std::collections::BTreeSet;
use crate::{Database, DatabaseTree, MoveSelection, Schema, Table};
impl Table { impl Table {
fn new(name: String) -> Self { fn new(name: String) -> Self {
Table { Table {

@ -1,11 +1,13 @@
use crate::{error::Result, treeitems_iter::TreeItemsIterator};
use crate::{item::DatabaseTreeItemKind, DatabaseTreeItem};
use crate::{Child, Database};
use std::{ use std::{
collections::{BTreeSet, HashMap}, collections::{BTreeSet, HashMap},
usize, usize,
}; };
use crate::{
error::Result, item::DatabaseTreeItemKind, treeitems_iter::TreeItemsIterator, Child, Database,
DatabaseTreeItem,
};
#[derive(Default)] #[derive(Default)]
pub struct DatabaseTreeItems { pub struct DatabaseTreeItems {
pub tree_items: Vec<DatabaseTreeItem>, pub tree_items: Vec<DatabaseTreeItem>,

@ -1,4 +1,5 @@
use std::num::TryFromIntError; use std::num::TryFromIntError;
use thiserror::Error; use thiserror::Error;
#[derive(Error, Debug)] #[derive(Error, Debug)]

@ -6,8 +6,7 @@ mod tree_iter;
mod treeitems_iter; mod treeitems_iter;
pub use crate::{ pub use crate::{
databasetree::DatabaseTree, databasetree::{DatabaseTree, MoveSelection},
databasetree::MoveSelection,
item::{DatabaseTreeItem, TreeItemInfo}, item::{DatabaseTreeItem, TreeItemInfo},
}; };

@ -1,21 +1,19 @@
use crate::clipboard::copy_to_clipboard; use tui::{
use crate::components::{ backend::Backend,
CommandInfo, Component as _, DrawableComponent as _, EventState, StatefulDrawableComponent, layout::{Constraint, Direction, Layout, Rect},
Frame,
}; };
use crate::database::{MySqlPool, Pool, PostgresPool, SqlitePool, RECORDS_LIMIT_PER_PAGE};
use crate::event::Key;
use crate::{ use crate::{
components::tab::Tab, clipboard::copy_to_clipboard,
components::{ components::{
command, ConnectionsComponent, DatabasesComponent, ErrorComponent, HelpComponent, command, tab::Tab, CommandInfo, Component as _, ConnectionsComponent, DatabasesComponent,
PropertiesComponent, RecordTableComponent, SqlEditorComponent, TabComponent, DrawableComponent as _, ErrorComponent, EventState, HelpComponent, PropertiesComponent,
RecordTableComponent, SqlEditorComponent, StatefulDrawableComponent, TabComponent,
}, },
config::Config, config::Config,
}; database::{MySqlPool, Pool, PostgresPool, SqlitePool, RECORDS_LIMIT_PER_PAGE},
use tui::{ event::Key,
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
Frame,
}; };
pub enum Focus { pub enum Focus {

@ -1,6 +1,7 @@
use crate::config::CliConfig;
use structopt::StructOpt; use structopt::StructOpt;
use crate::config::CliConfig;
/// A cross-platform TUI database management tool written in Rust /// A cross-platform TUI database management tool written in Rust
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(name = "gobang")] #[structopt(name = "gobang")]

@ -1,8 +1,11 @@
use anyhow::{anyhow, Result};
#[cfg(all(target_family = "unix", not(target_os = "macos")))] #[cfg(all(target_family = "unix", not(target_os = "macos")))]
use std::ffi::OsStr; use std::ffi::OsStr;
use std::io::Write; use std::{
use std::process::{Command, Stdio}; io::Write,
process::{Command, Stdio},
};
use anyhow::{anyhow, Result};
fn execute_copy_command(command: Command, text: &str) -> Result<()> { fn execute_copy_command(command: Command, text: &str) -> Result<()> {
let mut command = command; let mut command = command;
@ -42,6 +45,7 @@ fn gen_command(path: impl AsRef<OsStr>, xclip_syntax: bool) -> Command {
#[cfg(all(target_family = "unix", not(target_os = "macos")))] #[cfg(all(target_family = "unix", not(target_os = "macos")))]
pub fn copy_to_clipboard(string: &str) -> Result<()> { pub fn copy_to_clipboard(string: &str) -> Result<()> {
use std::path::PathBuf; use std::path::PathBuf;
use which::which; use which::which;
let (path, xclip_syntax) = which("xclip").ok().map_or_else( let (path, xclip_syntax) = which("xclip").ok().map_or_else(
|| { || {

@ -1,7 +1,3 @@
use super::{Component, EventState, MovableComponent};
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use tui::{ use tui::{
backend::Backend, backend::Backend,
@ -11,6 +7,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, EventState, MovableComponent};
use crate::{components::command::CommandInfo, config::KeyConfig, event::Key};
const RESERVED_WORDS_IN_WHERE_CLAUSE: &[&str] = &["IN", "AND", "OR", "NOT", "NULL", "IS"]; const RESERVED_WORDS_IN_WHERE_CLAUSE: &[&str] = &["IN", "AND", "OR", "NOT", "NULL", "IS"];
const ALL_RESERVED_WORDS: &[&str] = &[ const ALL_RESERVED_WORDS: &[&str] = &[
"IN", "AND", "OR", "NOT", "NULL", "IS", "SELECT", "UPDATE", "DELETE", "FROM", "LIMIT", "WHERE", "IN", "AND", "OR", "NOT", "NULL", "IS", "SELECT", "UPDATE", "DELETE", "FROM", "LIMIT", "WHERE",

@ -1,7 +1,3 @@
use super::{Component, EventState, StatefulDrawableComponent};
use crate::components::command::CommandInfo;
use crate::config::{Connection, KeyConfig};
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use tui::{ use tui::{
backend::Backend, backend::Backend,
@ -12,6 +8,13 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, EventState, StatefulDrawableComponent};
use crate::{
components::command::CommandInfo,
config::{Connection, KeyConfig},
event::Key,
};
pub struct ConnectionsComponent { pub struct ConnectionsComponent {
connections: Vec<Connection>, connections: Vec<Connection>,
state: ListState, state: ListState,

@ -1,6 +1,3 @@
use super::{compute_character_width, Component, DrawableComponent, EventState};
use crate::components::command::CommandInfo;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use database_tree::Table; use database_tree::Table;
use tui::{ use tui::{
@ -13,6 +10,9 @@ use tui::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use super::{compute_character_width, Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, event::Key};
pub struct DatabaseFilterComponent { pub struct DatabaseFilterComponent {
pub table: Option<Table>, pub table: Option<Table>,
input: Vec<char>, input: Vec<char>,

@ -1,17 +1,7 @@
use super::{ use std::{collections::BTreeSet, convert::From};
utils::scroll_vertical::VerticalScroll, Component, DatabaseFilterComponent, DrawableComponent,
EventState,
};
use crate::components::command::{self, CommandInfo};
use crate::config::{Connection, KeyConfig};
use crate::database::Pool;
use crate::event::Key;
use crate::ui::common_nav;
use crate::ui::scrolllist::draw_list_block;
use anyhow::Result; use anyhow::Result;
use database_tree::{Database, DatabaseTree, DatabaseTreeItem}; use database_tree::{Database, DatabaseTree, DatabaseTreeItem};
use std::collections::BTreeSet;
use std::convert::From;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
@ -21,6 +11,18 @@ use tui::{
Frame, Frame,
}; };
use super::{
utils::scroll_vertical::VerticalScroll, Component, DatabaseFilterComponent, DrawableComponent,
EventState,
};
use crate::{
components::command::{self, CommandInfo},
config::{Connection, KeyConfig},
database::Pool,
event::Key,
ui::{common_nav, scrolllist::draw_list_block},
};
// ▸ // ▸
const FOLDER_ICON_COLLAPSED: &str = "\u{25b8}"; const FOLDER_ICON_COLLAPSED: &str = "\u{25b8}";
// ▾ // ▾
@ -274,9 +276,10 @@ fn tree_nav(tree: &mut DatabaseTree, key: Key, key_config: &KeyConfig) -> bool {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{Color, Database, DatabaseTreeItem, DatabasesComponent, Span, Spans, Style};
use database_tree::Table; use database_tree::Table;
use super::{Color, Database, DatabaseTreeItem, DatabasesComponent, Span, Spans, Style};
#[test] #[test]
fn test_tree_database_tree_item_to_span() { fn test_tree_database_tree_item_to_span() {
const WIDTH: u16 = 10; const WIDTH: u16 = 10;

@ -1,7 +1,3 @@
use super::{Component, DrawableComponent, EventState};
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use tui::{ use tui::{
backend::Backend, backend::Backend,
@ -10,6 +6,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, config::KeyConfig, event::Key};
pub struct DebugComponent { pub struct DebugComponent {
msg: String, msg: String,
visible: bool, visible: bool,

@ -1,7 +1,3 @@
use super::{Component, DrawableComponent, EventState};
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use tui::{ use tui::{
backend::Backend, backend::Backend,
@ -11,6 +7,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, config::KeyConfig, event::Key};
pub struct ErrorComponent { pub struct ErrorComponent {
pub error: String, pub error: String,
visible: bool, visible: bool,

@ -1,11 +1,7 @@
use super::{Component, DrawableComponent, EventState}; use std::convert::From;
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use crate::version::Version;
use anyhow::Result; use anyhow::Result;
use itertools::Itertools; use itertools::Itertools;
use std::convert::From;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
@ -15,6 +11,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, config::KeyConfig, event::Key, version::Version};
pub struct HelpComponent { pub struct HelpComponent {
cmds: Vec<CommandInfo>, cmds: Vec<CommandInfo>,
visible: bool, visible: bool,

@ -18,11 +18,17 @@ pub mod utils;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
pub mod debug; pub mod debug;
use std::convert::TryInto;
use anyhow::Result;
use async_trait::async_trait;
pub use command::{CommandInfo, CommandText}; pub use command::{CommandInfo, CommandText};
pub use completion::CompletionComponent; pub use completion::CompletionComponent;
pub use connections::ConnectionsComponent; pub use connections::ConnectionsComponent;
pub use database_filter::DatabaseFilterComponent; pub use database_filter::DatabaseFilterComponent;
pub use databases::DatabasesComponent; pub use databases::DatabasesComponent;
#[cfg(debug_assertions)]
pub use debug::DebugComponent;
pub use error::ErrorComponent; pub use error::ErrorComponent;
pub use help::HelpComponent; pub use help::HelpComponent;
pub use properties::PropertiesComponent; pub use properties::PropertiesComponent;
@ -33,17 +39,11 @@ pub use table::TableComponent;
pub use table_filter::TableFilterComponent; pub use table_filter::TableFilterComponent;
pub use table_status::TableStatusComponent; pub use table_status::TableStatusComponent;
pub use table_value::TableValueComponent; pub use table_value::TableValueComponent;
#[cfg(debug_assertions)]
pub use debug::DebugComponent;
use crate::database::Pool;
use anyhow::Result;
use async_trait::async_trait;
use std::convert::TryInto;
use tui::{backend::Backend, layout::Rect, Frame}; use tui::{backend::Backend, layout::Rect, Frame};
use unicode_width::UnicodeWidthChar; use unicode_width::UnicodeWidthChar;
use crate::database::Pool;
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)]
pub enum EventState { pub enum EventState {
Consumed, Consumed,

@ -1,10 +1,3 @@
use super::{Component, EventState, StatefulDrawableComponent};
use crate::clipboard::copy_to_clipboard;
use crate::components::command::{self, CommandInfo};
use crate::components::TableComponent;
use crate::config::KeyConfig;
use crate::database::Pool;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use database_tree::{Database, Table}; use database_tree::{Database, Table};
@ -16,6 +9,18 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, EventState, StatefulDrawableComponent};
use crate::{
clipboard::copy_to_clipboard,
components::{
command::{self, CommandInfo},
TableComponent,
},
config::KeyConfig,
database::Pool,
event::Key,
};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum Focus { pub enum Focus {
Column, Column,

@ -1,8 +1,3 @@
use super::{Component, EventState, StatefulDrawableComponent};
use crate::components::command::CommandInfo;
use crate::components::{TableComponent, TableFilterComponent};
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use database_tree::{Database, Table as DTable}; use database_tree::{Database, Table as DTable};
use tui::{ use tui::{
@ -11,6 +6,13 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, EventState, StatefulDrawableComponent};
use crate::{
components::{command::CommandInfo, TableComponent, TableFilterComponent},
config::KeyConfig,
event::Key,
};
pub enum Focus { pub enum Focus {
Table, Table,
Filter, Filter,

@ -1,12 +1,3 @@
use super::{
compute_character_width, CompletionComponent, Component, EventState, MovableComponent,
StatefulDrawableComponent, TableComponent,
};
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::database::{ExecuteResult, Pool};
use crate::event::Key;
use crate::ui::stateful_paragraph::{ParagraphState, StatefulParagraph};
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use tui::{ use tui::{
@ -18,6 +9,18 @@ use tui::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use super::{
compute_character_width, CompletionComponent, Component, EventState, MovableComponent,
StatefulDrawableComponent, TableComponent,
};
use crate::{
components::command::CommandInfo,
config::KeyConfig,
database::{ExecuteResult, Pool},
event::Key,
ui::stateful_paragraph::{ParagraphState, StatefulParagraph},
};
struct QueryResult { struct QueryResult {
updated_rows: u64, updated_rows: u64,
} }

@ -1,7 +1,3 @@
use super::{Component, DrawableComponent, EventState};
use crate::components::command::{self, CommandInfo};
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use strum_macros::EnumIter; use strum_macros::EnumIter;
use tui::{ use tui::{
@ -13,6 +9,13 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{
components::command::{self, CommandInfo},
config::KeyConfig,
event::Key,
};
#[derive(Debug, Clone, Copy, EnumIter)] #[derive(Debug, Clone, Copy, EnumIter)]
pub enum Tab { pub enum Tab {
Records, Records,

@ -1,13 +1,7 @@
use super::{ use std::convert::From;
utils::scroll_vertical::VerticalScroll, Component, DrawableComponent, EventState,
StatefulDrawableComponent, TableStatusComponent, TableValueComponent,
};
use crate::components::command::{self, CommandInfo};
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use database_tree::{Database, Table as DTable}; use database_tree::{Database, Table as DTable};
use std::convert::From;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
@ -17,6 +11,16 @@ use tui::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use super::{
utils::scroll_vertical::VerticalScroll, Component, DrawableComponent, EventState,
StatefulDrawableComponent, TableStatusComponent, TableValueComponent,
};
use crate::{
components::command::{self, CommandInfo},
config::KeyConfig,
event::Key,
};
pub struct TableComponent { pub struct TableComponent {
pub headers: Vec<String>, pub headers: Vec<String>,
pub rows: Vec<Vec<String>>, pub rows: Vec<Vec<String>>,
@ -573,9 +577,10 @@ impl Component for TableComponent {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{KeyConfig, TableComponent};
use tui::layout::Constraint; use tui::layout::Constraint;
use super::{KeyConfig, TableComponent};
#[test] #[test]
fn test_headers() { fn test_headers() {
let mut component = TableComponent::new(KeyConfig::default()); let mut component = TableComponent::new(KeyConfig::default());

@ -1,10 +1,3 @@
use super::{
compute_character_width, CompletionComponent, Component, EventState, MovableComponent,
StatefulDrawableComponent,
};
use crate::components::command::CommandInfo;
use crate::config::KeyConfig;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use database_tree::Table; use database_tree::Table;
use tui::{ use tui::{
@ -17,6 +10,12 @@ use tui::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use super::{
compute_character_width, CompletionComponent, Component, EventState, MovableComponent,
StatefulDrawableComponent,
};
use crate::{components::command::CommandInfo, config::KeyConfig, event::Key};
pub struct TableFilterComponent { pub struct TableFilterComponent {
key_config: KeyConfig, key_config: KeyConfig,
pub table: Option<Table>, pub table: Option<Table>,

@ -1,6 +1,3 @@
use super::{Component, DrawableComponent, EventState};
use crate::components::command::CommandInfo;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use database_tree::Table; use database_tree::Table;
use tui::{ use tui::{
@ -12,6 +9,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, event::Key};
pub struct TableStatusComponent { pub struct TableStatusComponent {
column_count: Option<usize>, column_count: Option<usize>,
row_count: Option<usize>, row_count: Option<usize>,

@ -1,6 +1,3 @@
use super::{Component, DrawableComponent, EventState};
use crate::components::command::CommandInfo;
use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use tui::{ use tui::{
backend::Backend, backend::Backend,
@ -10,6 +7,9 @@ use tui::{
Frame, Frame,
}; };
use super::{Component, DrawableComponent, EventState};
use crate::{components::command::CommandInfo, event::Key};
pub struct TableValueComponent { pub struct TableValueComponent {
value: String, value: String,
} }

@ -1,7 +1,9 @@
use crate::ui::scrollbar::draw_scrollbar;
use std::cell::Cell; use std::cell::Cell;
use tui::{backend::Backend, layout::Rect, Frame}; use tui::{backend::Backend, layout::Rect, Frame};
use crate::ui::scrollbar::draw_scrollbar;
pub struct VerticalScroll { pub struct VerticalScroll {
top: Cell<usize>, top: Cell<usize>,
max_top: Cell<usize>, max_top: Cell<usize>,

@ -1,14 +1,16 @@
use crate::log::LogLevel; use std::{
use crate::Key; fmt,
use serde::Deserialize; fs::File,
use std::fmt; io::{BufReader, Read},
use std::fs::File; path::{Path, PathBuf},
use std::io::{BufReader, Read}; };
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use serde::Deserialize;
#[cfg(test)] #[cfg(test)]
use serde::Serialize; use serde::Serialize;
use structopt::StructOpt;
use crate::{log::LogLevel, Key};
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
pub struct CliConfig { pub struct CliConfig {
@ -325,10 +327,12 @@ fn expand_path(path: &Path) -> Option<PathBuf> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{expand_path, KeyConfig, Path, PathBuf};
use serde_json::Value;
use std::env; use std::env;
use serde_json::Value;
use super::{expand_path, KeyConfig, Path, PathBuf};
#[test] #[test]
fn test_overlappted_key() { fn test_overlappted_key() {
let value: Value = let value: Value =

@ -2,13 +2,12 @@ pub mod mysql;
pub mod postgres; pub mod postgres;
pub mod sqlite; pub mod sqlite;
use async_trait::async_trait;
use database_tree::{Child, Database, Table};
pub use mysql::MySqlPool; pub use mysql::MySqlPool;
pub use postgres::PostgresPool; pub use postgres::PostgresPool;
pub use sqlite::SqlitePool; pub use sqlite::SqlitePool;
use async_trait::async_trait;
use database_tree::{Child, Database, Table};
pub const RECORDS_LIMIT_PER_PAGE: u8 = 200; pub const RECORDS_LIMIT_PER_PAGE: u8 = 200;
#[async_trait] #[async_trait]

@ -1,13 +1,16 @@
use crate::get_or_null; use std::time::Duration;
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use async_trait::async_trait; use async_trait::async_trait;
use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use database_tree::{Child, Database, Table}; use database_tree::{Child, Database, Table};
use futures::TryStreamExt; use futures::TryStreamExt;
use sqlx::mysql::{MySqlColumn, MySqlPoolOptions, MySqlRow}; use sqlx::{
use sqlx::{Column as _, Row as _, TypeInfo as _}; mysql::{MySqlColumn, MySqlPoolOptions, MySqlRow},
use std::time::Duration; Column as _, Row as _, TypeInfo as _,
};
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use crate::get_or_null;
pub struct MySqlPool { pub struct MySqlPool {
pool: sqlx::mysql::MySqlPool, pool: sqlx::mysql::MySqlPool,

@ -1,14 +1,17 @@
use crate::get_or_null; use std::time::Duration;
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use async_trait::async_trait; use async_trait::async_trait;
use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use database_tree::{Child, Database, Schema, Table}; use database_tree::{Child, Database, Schema, Table};
use futures::TryStreamExt; use futures::TryStreamExt;
use itertools::Itertools; use itertools::Itertools;
use sqlx::postgres::{PgColumn, PgPool, PgPoolOptions, PgRow}; use sqlx::{
use sqlx::{Column as _, Row as _, TypeInfo as _}; postgres::{PgColumn, PgPool, PgPoolOptions, PgRow},
use std::time::Duration; Column as _, Row as _, TypeInfo as _,
};
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use crate::get_or_null;
pub struct PostgresPool { pub struct PostgresPool {
pool: PgPool, pool: PgPool,

@ -1,13 +1,16 @@
use crate::get_or_null; use std::time::Duration;
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use async_trait::async_trait; use async_trait::async_trait;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use database_tree::{Child, Database, Table}; use database_tree::{Child, Database, Table};
use futures::TryStreamExt; use futures::TryStreamExt;
use sqlx::sqlite::{SqliteColumn, SqlitePoolOptions, SqliteRow}; use sqlx::{
use sqlx::{Column as _, Row as _, TypeInfo as _}; sqlite::{SqliteColumn, SqlitePoolOptions, SqliteRow},
use std::time::Duration; Column as _, Row as _, TypeInfo as _,
};
use super::{ExecuteResult, Pool, TableRow, RECORDS_LIMIT_PER_PAGE};
use crate::get_or_null;
pub struct SqlitePool { pub struct SqlitePool {
pool: sqlx::sqlite::SqlitePool, pool: sqlx::sqlite::SqlitePool,

@ -1,7 +1,9 @@
use crate::event::Key;
use crossterm::event;
use std::{sync::mpsc, thread, time::Duration}; use std::{sync::mpsc, thread, time::Duration};
use crossterm::event;
use crate::event::Key;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct EventConfig { pub struct EventConfig {
pub exit_key: Key, pub exit_key: Key,

@ -1,7 +1,7 @@
use crossterm::event;
use serde::Deserialize;
use std::fmt; use std::fmt;
use crossterm::event;
use serde::Deserialize;
#[cfg(test)] #[cfg(test)]
use serde::Serialize; use serde::Serialize;

@ -11,16 +11,20 @@ mod version;
#[macro_use] #[macro_use]
mod log; mod log;
use crate::app::App; use std::io;
use crate::event::{Event, Key};
use anyhow::Result; use anyhow::Result;
use crossterm::{ use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand, ExecutableCommand,
}; };
use std::io;
use tui::{backend::CrosstermBackend, Terminal}; use tui::{backend::CrosstermBackend, Terminal};
use crate::{
app::App,
event::{Event, Key},
};
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
let value = crate::cli::parse(); let value = crate::cli::parse();

@ -1,7 +1,7 @@
use crate::config::KeyConfig;
use crate::event::Key;
use database_tree::MoveSelection; use database_tree::MoveSelection;
use crate::{config::KeyConfig, event::Key};
pub mod reflow; pub mod reflow;
pub mod scrollbar; pub mod scrollbar;
pub mod scrolllist; pub mod scrolllist;

@ -227,9 +227,10 @@ fn trim_offset(src: &str, mut offset: usize) -> &str {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use super::*;
enum Composer { enum Composer {
WordWrapper { trim: bool }, WordWrapper { trim: bool },
LineTruncator, LineTruncator,
@ -473,7 +474,8 @@ mod test {
// to test double-width chars. // to test double-width chars.
// You are more than welcome to add word boundary detection based of alterations of // You are more than welcome to add word boundary detection based of alterations of
// hiragana and katakana... // hiragana and katakana...
// This happens to also be a test case for mixed width because regular spaces are single width. // This happens to also be a test case for mixed width because regular spaces are single
// width.
let text = "コンピュ ータ上で文字を扱う場合、 典型的には文 字による 通信を行 う場合にその両端点では、"; let text = "コンピュ ータ上で文字を扱う場合、 典型的には文 字による 通信を行 う場合にその両端点では、";
let (word_wrapper, word_wrapper_width) = let (word_wrapper, word_wrapper_width) =
run_composer(Composer::WordWrapper { trim: true }, text, width); run_composer(Composer::WordWrapper { trim: true }, text, width);

@ -1,5 +1,6 @@
use easy_cast::CastFloat;
use std::convert::TryFrom; use std::convert::TryFrom;
use easy_cast::CastFloat;
use tui::{ use tui::{
backend::Backend, backend::Backend,
buffer::Buffer, buffer::Buffer,

@ -1,4 +1,5 @@
use std::iter::Iterator; use std::iter::Iterator;
use tui::{ use tui::{
backend::Backend, backend::Backend,
buffer::Buffer, buffer::Buffer,

@ -1,7 +1,8 @@
#![allow(dead_code)] #![allow(dead_code)]
use easy_cast::Cast;
use std::iter; use std::iter;
use easy_cast::Cast;
use tui::{ use tui::{
buffer::Buffer, buffer::Buffer,
layout::{Alignment, Rect}, layout::{Alignment, Rect},

@ -1,4 +1,5 @@
use std::ops::Range; use std::ops::Range;
use syntect::{ use syntect::{
highlighting::{ highlighting::{
FontStyle, HighlightState, Highlighter, RangedHighlightIterator, Style, ThemeSet, FontStyle, HighlightState, Highlighter, RangedHighlightIterator, Style, ThemeSet,

Loading…
Cancel
Save