From ae44577979db3660db1ca3f8f7c468e3d1fe2dbf Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 28 Aug 2023 23:24:08 -0400 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20Bump=20to=20ratatui=200.23.0=20?= =?UTF-8?q?=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 82 ++++++++++++++++++++++++++------------------- Cargo.toml | 10 +++--- src/app.rs | 14 ++++---- src/calendar.rs | 2 +- src/completion.rs | 4 +-- src/config.rs | 8 ++--- src/help.rs | 2 +- src/main.rs | 2 +- src/pane/context.rs | 2 +- src/pane/project.rs | 2 +- src/scrollbar.rs | 2 +- src/table.rs | 18 +++++----- src/ui.rs | 2 +- 13 files changed, 82 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 767d9f30..0d0e3bdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ "clap_builder", "clap_derive", @@ -205,9 +205,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" dependencies = [ "anstream", "anstyle", @@ -277,22 +277,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" -[[package]] -name = "crossterm" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - [[package]] name = "crossterm" version = "0.27.0" @@ -998,15 +982,17 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8285baa38bdc9f879d92c0e37cb562ef38aa3aeefca22b3200186bc39242d3d5" +checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" dependencies = [ "bitflags 2.4.0", "cassowary", - "crossterm 0.26.1", + "crossterm", "indoc", + "itertools", "paste", + "strum", "unicode-segmentation", "unicode-width", ] @@ -1042,9 +1028,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ "aho-corasick", "memchr", @@ -1054,9 +1040,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", @@ -1065,9 +1051,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "rustc-demangle" @@ -1088,6 +1074,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "rustyline" version = "12.0.0" @@ -1137,9 +1129,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.186" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f5db24220c009de9bd45e69fb2938f4b6d2df856aa9304ce377b3180f83b7c1" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -1156,9 +1148,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.186" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad697f7e0b65af4983a4ce8f56ed5b357e8d3c36651bf6a7e13639c17b8e670" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -1276,6 +1268,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.29", +] + [[package]] name = "syn" version = "1.0.109" @@ -1323,7 +1337,7 @@ dependencies = [ "chrono", "clap", "clap_complete", - "crossterm 0.27.0", + "crossterm", "dirs", "futures", "itertools", diff --git a/Cargo.toml b/Cargo.toml index 80d5da04..f2df8006 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ anyhow = "1.0.75" better-panic = "0.3.0" cassowary = "0.3.0" chrono = "0.4.26" -clap = { version = "4.4.0", features = ["derive"] } +clap = { version = "4.4.1", features = ["derive"] } crossterm = { version = "0.27.0", features = [ "event-stream", ] } @@ -29,16 +29,16 @@ log = "0.4.20" log4rs = "1.2.0" path-clean = "1.0.1" rand = "0.8.5" -regex = "1.9.3" +regex = "1.9.4" rustyline = { version = "12.0.0", features = ["with-file-history", "derive"] } -serde = { version = "1.0.186", features = ["derive"] } +serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.105" shellexpand = "3.1.0" shlex = "1.1.0" task-hookrs = "0.9.0" tokio = { version = "1.32.0", features = ["full"] } tokio-stream = "0.1.14" -tui = { package = "ratatui", version = "0.22.0" } +ratatui = "0.23.0" unicode-segmentation = "1.10.1" unicode-truncate = "0.2.0" unicode-width = "0.1.10" @@ -60,6 +60,6 @@ incremental = true lto = "off" [build-dependencies] -clap = { version = "4.4.0", features = ["derive"] } +clap = { version = "4.4.1", features = ["derive"] } clap_complete = "4.4.0" shlex = "1.1.0" diff --git a/src/app.rs b/src/app.rs index 9ea3b0e2..82433b46 100644 --- a/src/app.rs +++ b/src/app.rs @@ -22,11 +22,11 @@ use std::io::Write; use std::time::SystemTime; +use ratatui::symbols::bar::FULL; use task_hookrs::date::Date; use task_hookrs::import::import; use task_hookrs::status::TaskStatus; use task_hookrs::task::Task; -use tui::symbols::bar::FULL; use uuid::Uuid; use unicode_segmentation::Graphemes; @@ -42,8 +42,7 @@ use std::sync::mpsc; use std::sync::{Arc, Mutex}; -use std::time::Duration; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}, style::{Color, Modifier, Style}, @@ -51,6 +50,7 @@ use tui::{ text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap}, }; +use std::time::Duration; use rustyline::history::SearchDirection as HistoryDirection; use rustyline::line_buffer::LineBuffer; @@ -60,8 +60,8 @@ use rustyline::Word; use crate::history::HistoryContext; +use ratatui::{backend::CrosstermBackend, Terminal}; use std::io; -use tui::{backend::CrosstermBackend, Terminal}; use regex::Regex; @@ -88,7 +88,7 @@ use task_hookrs::project::Project; use versions::Versioning; use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; -use tui::widgets::Tabs; +use ratatui::widgets::Tabs; const MAX_LINE: usize = 4096; @@ -3732,12 +3732,12 @@ pub fn remove_tag(task: &mut Task, tag: &str) { #[cfg(test)] mod tests { use super::*; + use ratatui::backend::TestBackend; + use ratatui::buffer::Buffer; use std::ffi::OsStr; use std::fs::File; use std::path::Path; use std::{fmt::Write, io}; - use tui::backend::TestBackend; - use tui::buffer::Buffer; /// Returns a string representation of the given buffer for debugging purpose. fn buffer_view(buffer: &Buffer) -> String { diff --git a/src/calendar.rs b/src/calendar.rs index a7058573..896cf08f 100644 --- a/src/calendar.rs +++ b/src/calendar.rs @@ -7,7 +7,7 @@ const COL_WIDTH: usize = 21; use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; -use tui::{ +use ratatui::{ buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, diff --git a/src/completion.rs b/src/completion.rs index aaa0ba83..0fa37eab 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -1,12 +1,12 @@ use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; -use std::{error::Error, io}; -use tui::{ +use ratatui::{ layout::{Constraint, Corner, Direction, Layout}, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{Block, Borders, List, ListItem, ListState}, Terminal, }; +use std::{error::Error, io}; use rustyline::highlight::{Highlighter, MatchingBracketHighlighter}; use rustyline::hint::Hinter; diff --git a/src/config.rs b/src/config.rs index 5ffefbb2..86867c04 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,12 +1,12 @@ use anyhow::{Context, Result}; -use std::collections::HashMap; -use std::error::Error; -use std::str; -use tui::{ +use ratatui::{ style::{Color, Modifier, Style}, symbols::bar::FULL, symbols::line::DOUBLE_VERTICAL, }; +use std::collections::HashMap; +use std::error::Error; +use std::str; trait TaskWarriorBool { fn get_bool(&self) -> Option; diff --git a/src/help.rs b/src/help.rs index f5749420..01bc2130 100644 --- a/src/help.rs +++ b/src/help.rs @@ -1,6 +1,6 @@ use std::cmp; -use tui::{ +use ratatui::{ buffer::Buffer, layout::{Alignment, Rect}, style::{Modifier, Style}, diff --git a/src/main.rs b/src/main.rs index 34d07a66..6030b4e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}, }; use futures::stream::{FuturesUnordered, StreamExt}; -use tui::{backend::CrosstermBackend, Terminal}; +use ratatui::{backend::CrosstermBackend, Terminal}; use path_clean::PathClean; diff --git a/src/pane/context.rs b/src/pane/context.rs index f1dbdd85..5062d1d9 100644 --- a/src/pane/context.rs +++ b/src/pane/context.rs @@ -9,7 +9,7 @@ const ACTIVE: &str = "Complete"; use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; -use tui::{ +use ratatui::{ buffer::Buffer, layout::{Alignment, Rect}, style::{Color, Modifier, Style}, diff --git a/src/pane/project.rs b/src/pane/project.rs index 1211ba91..1b12e1c9 100644 --- a/src/pane/project.rs +++ b/src/pane/project.rs @@ -10,7 +10,7 @@ const COMPLETE_HEADER: &str = "Complete"; use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; -use tui::{ +use ratatui::{ buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, diff --git a/src/scrollbar.rs b/src/scrollbar.rs index efe1c34d..4149d91c 100644 --- a/src/scrollbar.rs +++ b/src/scrollbar.rs @@ -1,4 +1,4 @@ -use tui::{ +use ratatui::{ backend::Backend, buffer::Buffer, layout::{Margin, Rect}, diff --git a/src/table.rs b/src/table.rs index b1f9c5e5..9f61fb45 100644 --- a/src/table.rs +++ b/src/table.rs @@ -3,18 +3,18 @@ use cassowary::{ WeightedRelation::{EQ, GE, LE}, {Expression, Solver}, }; +use ratatui::{ + buffer::Buffer, + layout::{Constraint, Rect}, + style::Style, + widgets::{Block, StatefulWidget, Widget}, +}; use std::collections::HashSet; use std::{ collections::HashMap, fmt::Display, iter::{self, Iterator}, }; -use tui::{ - buffer::Buffer, - layout::{Constraint, Rect}, - style::Style, - widgets::{Block, StatefulWidget, Widget}, -}; use unicode_segmentation::Graphemes; use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; @@ -113,9 +113,9 @@ where /// # Examples /// /// ```rust -/// # use tui::widgets::{Block, Borders, Table, Row}; -/// # use tui::layout::Constraint; -/// # use tui::style::{Style, Color}; +/// # use ratatui::widgets::{Block, Borders, Table, Row}; +/// # use ratatui::layout::Constraint; +/// # use ratatui::style::{Style, Color}; /// let row_style = Style::default().fg(Color::White); /// Table::new( /// ["Col1", "Col2", "Col3"].into_iter(), diff --git a/src/ui.rs b/src/ui.rs index 8d38d723..ba18ab4a 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,4 +1,4 @@ -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, From bc0c3f10a63b7067c6e44aaf7a5e36d5fcc88794 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 28 Aug 2023 23:31:27 -0400 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20rustfmt=20with=20nightly=20options?= =?UTF-8?q?=20=E2=99=BB=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- .rustfmt.toml | 2 + src/app.rs | 140 +++++++++++++++------------------------ src/calendar.rs | 5 +- src/completion.rs | 21 +++--- src/config.rs | 8 +-- src/event.rs | 13 ++-- src/history.rs | 15 +++-- src/keyconfig.rs | 8 +-- src/main.rs | 34 +++++----- src/pane/context.rs | 34 +++++----- src/pane/mod.rs | 11 +-- src/pane/project.rs | 34 +++++----- src/table.rs | 17 +++-- src/task_report.rs | 7 +- src/utils.rs | 4 +- 16 files changed, 167 insertions(+), 188 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c07f8cf..3734b434 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: nightly override: true - run: rustup component add rustfmt - uses: actions-rs/cargo@v1 diff --git a/.rustfmt.toml b/.rustfmt.toml index d870fddb..db495491 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,2 +1,4 @@ max_width = 150 tab_spaces = 2 +group_imports = "StdExternalCrate" +imports_granularity = "Crate" diff --git a/src/app.rs b/src/app.rs index 82433b46..ba4c9791 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,94 +1,64 @@ -use crate::calendar::Calendar; -use crate::completion::{get_start_word_under_cursor, CompletionList}; -use crate::config; -use crate::config::Config; -use crate::event::Event; -use crate::help::Help; -use crate::keyconfig::KeyConfig; -use crate::scrollbar::Scrollbar; -use crate::table::{Row, Table, TableMode, TableState}; -use crate::task_report::TaskReportTable; -use crate::ui; -use crate::utils; - -use std::cmp::Ordering; -use std::collections::{HashMap, HashSet}; -use std::convert::TryInto; -use std::fs; -use std::path::Path; - -use std::io::Read; -use std::io::Write; - -use std::time::SystemTime; - -use ratatui::symbols::bar::FULL; -use task_hookrs::date::Date; -use task_hookrs::import::import; -use task_hookrs::status::TaskStatus; -use task_hookrs::task::Task; -use uuid::Uuid; - -use unicode_segmentation::Graphemes; -use unicode_segmentation::UnicodeSegmentation; -use unicode_width::UnicodeWidthStr; +use std::{ + borrow::Borrow, + cmp::Ordering, + collections::{HashMap, HashSet}, + convert::TryInto, + fs, io, + io::{Read, Write}, + path::Path, + sync::{mpsc, Arc, Mutex}, + time::{Duration, Instant, SystemTime}, +}; +use anyhow::{anyhow, Context as AnyhowContext, Result}; use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, NaiveDateTime, TimeZone, Timelike}; - -use anyhow::Context as AnyhowContext; -use anyhow::{anyhow, Result}; - -use std::sync::mpsc; - -use std::sync::{Arc, Mutex}; - +use crossterm::{ + event::{DisableMouseCapture, EnableMouseCapture}, + execute, + style::style, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; +use futures::SinkExt; +use lazy_static::lazy_static; +use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; use ratatui::{ - backend::Backend, + backend::{Backend, CrosstermBackend}, layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}, style::{Color, Modifier, Style}, + symbols::bar::FULL, terminal::Frame, text::{Line, Span, Text}, - widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap}, + widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Tabs, Wrap}, + Terminal, }; -use std::time::Duration; - -use rustyline::history::SearchDirection as HistoryDirection; -use rustyline::line_buffer::LineBuffer; -use rustyline::At; -use rustyline::Editor; -use rustyline::Word; - -use crate::history::HistoryContext; - -use ratatui::{backend::CrosstermBackend, Terminal}; -use std::io; - use regex::Regex; - -use lazy_static::lazy_static; - -use crate::action::Action; -use crate::event::KeyCode; -use crate::pane::context::{ContextDetails, ContextsState}; -use crate::pane::project::ProjectsState; -use crate::pane::Pane; - -use crossterm::style::style; -use crossterm::{ - event::{DisableMouseCapture, EnableMouseCapture}, - execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, -}; - -use futures::SinkExt; -use std::borrow::Borrow; -use std::time::Instant; -use task_hookrs::project::Project; - +use rustyline::{history::SearchDirection as HistoryDirection, line_buffer::LineBuffer, At, Editor, Word}; +use task_hookrs::{date::Date, import::import, project::Project, status::TaskStatus, task::Task}; +use unicode_segmentation::{Graphemes, UnicodeSegmentation}; +use unicode_width::UnicodeWidthStr; +use uuid::Uuid; use versions::Versioning; -use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; -use ratatui::widgets::Tabs; +use crate::{ + action::Action, + calendar::Calendar, + completion::{get_start_word_under_cursor, CompletionList}, + config, + config::Config, + event::{Event, KeyCode}, + help::Help, + history::HistoryContext, + keyconfig::KeyConfig, + pane::{ + context::{ContextDetails, ContextsState}, + project::ProjectsState, + Pane, + }, + scrollbar::Scrollbar, + table::{Row, Table, TableMode, TableState}, + task_report::TaskReportTable, + ui, utils, +}; const MAX_LINE: usize = 4096; @@ -3731,13 +3701,11 @@ pub fn remove_tag(task: &mut Task, tag: &str) { #[cfg(test)] mod tests { + use std::{ffi::OsStr, fmt::Write, fs::File, io, path::Path}; + + use ratatui::{backend::TestBackend, buffer::Buffer}; + use super::*; - use ratatui::backend::TestBackend; - use ratatui::buffer::Buffer; - use std::ffi::OsStr; - use std::fs::File; - use std::path::Path; - use std::{fmt::Write, io}; /// Returns a string representation of the given buffer for debugging purpose. fn buffer_view(buffer: &Buffer) -> String { diff --git a/src/calendar.rs b/src/calendar.rs index 896cf08f..04d50566 100644 --- a/src/calendar.rs +++ b/src/calendar.rs @@ -5,8 +5,9 @@ use std::fmt; const COL_WIDTH: usize = 21; -use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; +use std::cmp::min; +use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; use ratatui::{ buffer::Buffer, layout::Rect, @@ -15,8 +16,6 @@ use ratatui::{ widgets::{Block, Widget}, }; -use std::cmp::min; - #[derive(Debug, Clone)] pub struct Calendar<'a> { pub block: Option>, diff --git a/src/completion.rs b/src/completion.rs index 0fa37eab..858c3d84 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -1,3 +1,5 @@ +use std::{error::Error, io}; + use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; use ratatui::{ layout::{Constraint, Corner, Direction, Layout}, @@ -6,16 +8,15 @@ use ratatui::{ widgets::{Block, Borders, List, ListItem, ListState}, Terminal, }; -use std::{error::Error, io}; - -use rustyline::highlight::{Highlighter, MatchingBracketHighlighter}; -use rustyline::hint::Hinter; -use rustyline::line_buffer::LineBuffer; -use rustyline::Context; -use rustyline::{error::ReadlineError, history::FileHistory}; - -use unicode_segmentation::Graphemes; -use unicode_segmentation::UnicodeSegmentation; +use rustyline::{ + error::ReadlineError, + highlight::{Highlighter, MatchingBracketHighlighter}, + hint::Hinter, + history::FileHistory, + line_buffer::LineBuffer, + Context, +}; +use unicode_segmentation::{Graphemes, UnicodeSegmentation}; use unicode_width::UnicodeWidthStr; pub fn get_start_word_under_cursor(line: &str, cursor_pos: usize) -> usize { diff --git a/src/config.rs b/src/config.rs index 86867c04..fa7afa1c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,12 +1,10 @@ +use std::{collections::HashMap, error::Error, str}; + use anyhow::{Context, Result}; use ratatui::{ style::{Color, Modifier, Style}, - symbols::bar::FULL, - symbols::line::DOUBLE_VERTICAL, + symbols::{bar::FULL, line::DOUBLE_VERTICAL}, }; -use std::collections::HashMap; -use std::error::Error; -use std::str; trait TaskWarriorBool { fn get_bool(&self) -> Option; diff --git a/src/event.rs b/src/event.rs index 800965b8..87047f54 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,12 +1,13 @@ -use crossterm::event::KeyEvent; +use crossterm::event::{ + KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F}, + KeyEvent, KeyModifiers, +}; use futures::StreamExt; use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; use serde::{Deserialize, Serialize}; -use tokio::{sync::mpsc, sync::oneshot, task::JoinHandle}; - -use crossterm::event::{ - KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F}, - KeyModifiers, +use tokio::{ + sync::{mpsc, oneshot}, + task::JoinHandle, }; #[derive(Debug, Clone, Copy)] diff --git a/src/history.rs b/src/history.rs index 60ba76ba..1b9aa52d 100644 --- a/src/history.rs +++ b/src/history.rs @@ -1,10 +1,13 @@ +use std::{ + fs::File, + path::{Path, PathBuf}, +}; + use anyhow::{anyhow, Result}; -use rustyline::error::ReadlineError; -use rustyline::history::DefaultHistory; -use rustyline::history::History; -use rustyline::history::SearchDirection; -use std::fs::File; -use std::path::{Path, PathBuf}; +use rustyline::{ + error::ReadlineError, + history::{DefaultHistory, History, SearchDirection}, +}; pub struct HistoryContext { history: DefaultHistory, diff --git a/src/keyconfig.rs b/src/keyconfig.rs index f686e327..e6d1256c 100644 --- a/src/keyconfig.rs +++ b/src/keyconfig.rs @@ -1,9 +1,9 @@ -use crate::event::KeyCode; +use std::{collections::HashSet, error::Error, hash::Hash}; + use anyhow::{anyhow, Result}; use serde::{Deserialize, Serialize}; -use std::collections::HashSet; -use std::error::Error; -use std::hash::Hash; + +use crate::event::KeyCode; #[derive(Serialize, Deserialize, Debug)] pub struct KeyConfig { diff --git a/src/main.rs b/src/main.rs index 6030b4e4..f47d328d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,18 +20,17 @@ mod task_report; mod ui; mod utils; -use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; -use log4rs::append::file::FileAppender; -use log4rs::config::{Appender, Config, Logger, Root}; -use log4rs::encode::pattern::PatternEncoder; -use std::env; -use std::error::Error; -use std::io::{self, Write}; -use std::panic; -use std::path::{Path, PathBuf}; -use std::time::Duration; +use std::{ + env, + error::Error, + io::{self, Write}, + panic, + path::{Path, PathBuf}, + time::Duration, +}; use anyhow::Result; +use app::{Mode, TaskwarriorTui}; use crossterm::{ cursor, event::{DisableMouseCapture, EnableMouseCapture, EventStream}, @@ -39,15 +38,16 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}, }; use futures::stream::{FuturesUnordered, StreamExt}; -use ratatui::{backend::CrosstermBackend, Terminal}; - +use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; +use log4rs::{ + append::file::FileAppender, + config::{Appender, Config, Logger, Root}, + encode::pattern::PatternEncoder, +}; use path_clean::PathClean; +use ratatui::{backend::CrosstermBackend, Terminal}; -use app::{Mode, TaskwarriorTui}; - -use crate::action::Action; -use crate::event::Event; -use crate::keyconfig::KeyConfig; +use crate::{action::Action, event::Event, keyconfig::KeyConfig}; const LOG_PATTERN: &str = "{d(%Y-%m-%d %H:%M:%S)} | {l} | {f}:{L} | {m}{n}"; diff --git a/src/pane/context.rs b/src/pane/context.rs index 5062d1d9..07a5daf7 100644 --- a/src/pane/context.rs +++ b/src/pane/context.rs @@ -1,14 +1,22 @@ -use anyhow::Context as AnyhowContext; -use anyhow::{anyhow, Result}; use std::fmt; +use anyhow::{anyhow, Context as AnyhowContext, Result}; + const NAME: &str = "Name"; const TYPE: &str = "Remaining"; const DEFINITION: &str = "Avg age"; const ACTIVE: &str = "Complete"; -use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; +use std::{ + cmp, + cmp::min, + collections::{HashMap, HashSet}, + error::Error, + process::{Command, Output}, +}; +use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; +use itertools::Itertools; use ratatui::{ buffer::Buffer, layout::{Alignment, Rect}, @@ -17,20 +25,16 @@ use ratatui::{ text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, StatefulWidget, Widget}, }; - -use crate::action::Action; -use crate::app::{Mode, TaskwarriorTui}; -use crate::event::KeyCode; -use crate::pane::Pane; -use crate::table::TableState; -use itertools::Itertools; -use std::cmp; -use std::cmp::min; -use std::collections::{HashMap, HashSet}; -use std::error::Error; -use std::process::{Command, Output}; use uuid::Uuid; +use crate::{ + action::Action, + app::{Mode, TaskwarriorTui}, + event::KeyCode, + pane::Pane, + table::TableState, +}; + #[derive(Debug, Clone, Default)] pub struct ContextDetails { pub name: String, diff --git a/src/pane/mod.rs b/src/pane/mod.rs index 21c3811d..ee1f1b30 100644 --- a/src/pane/mod.rs +++ b/src/pane/mod.rs @@ -1,9 +1,12 @@ +use std::ops::Index; + use anyhow::Result; -use crate::action::Action; -use crate::app::{Mode, TaskwarriorTui}; -use crate::event::KeyCode; -use std::ops::Index; +use crate::{ + action::Action, + app::{Mode, TaskwarriorTui}, + event::KeyCode, +}; pub mod context; pub mod project; diff --git a/src/pane/project.rs b/src/pane/project.rs index 1b12e1c9..5e379067 100644 --- a/src/pane/project.rs +++ b/src/pane/project.rs @@ -1,15 +1,22 @@ -use anyhow::Context as AnyhowContext; -use anyhow::{anyhow, Result}; use std::fmt; +use anyhow::{anyhow, Context as AnyhowContext, Result}; + const COL_WIDTH: usize = 21; const PROJECT_HEADER: &str = "Name"; const REMAINING_TASK_HEADER: &str = "Remaining"; const AVG_AGE_HEADER: &str = "Avg age"; const COMPLETE_HEADER: &str = "Complete"; -use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; +use std::{ + cmp::min, + collections::{HashMap, HashSet}, + error::Error, + process::{Command, Output}, +}; +use chrono::{Datelike, Duration, Local, Month, NaiveDate, NaiveDateTime, TimeZone}; +use itertools::Itertools; use ratatui::{ buffer::Buffer, layout::Rect, @@ -17,21 +24,18 @@ use ratatui::{ symbols, widgets::{Block, Widget}, }; - -use crate::action::Action; -use crate::app::{Mode, TaskwarriorTui}; -use crate::event::KeyCode; -use crate::pane::Pane; -use crate::table::TableState; -use crate::utils::Changeset; -use itertools::Itertools; -use std::cmp::min; -use std::collections::{HashMap, HashSet}; -use std::error::Error; -use std::process::{Command, Output}; use task_hookrs::project::Project; use uuid::Uuid; +use crate::{ + action::Action, + app::{Mode, TaskwarriorTui}, + event::KeyCode, + pane::Pane, + table::TableState, + utils::Changeset, +}; + pub struct ProjectsState { pub(crate) list: Vec, pub table_state: TableState, diff --git a/src/table.rs b/src/table.rs index 9f61fb45..b38b600f 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1,7 +1,13 @@ +use std::{ + collections::{HashMap, HashSet}, + fmt::Display, + iter::{self, Iterator}, +}; + use cassowary::{ strength::{MEDIUM, REQUIRED, WEAK}, + Expression, Solver, WeightedRelation::{EQ, GE, LE}, - {Expression, Solver}, }; use ratatui::{ buffer::Buffer, @@ -9,14 +15,7 @@ use ratatui::{ style::Style, widgets::{Block, StatefulWidget, Widget}, }; -use std::collections::HashSet; -use std::{ - collections::HashMap, - fmt::Display, - iter::{self, Iterator}, -}; -use unicode_segmentation::Graphemes; -use unicode_segmentation::UnicodeSegmentation; +use unicode_segmentation::{Graphemes, UnicodeSegmentation}; use unicode_width::UnicodeWidthStr; #[derive(Debug, Clone)] diff --git a/src/task_report.rs b/src/task_report.rs index 2ddb3e87..33572956 100644 --- a/src/task_report.rs +++ b/src/task_report.rs @@ -1,10 +1,9 @@ +use std::{error::Error, process::Command}; + use anyhow::Result; use chrono::{DateTime, Datelike, Local, NaiveDate, NaiveDateTime, TimeZone}; use itertools::join; -use std::error::Error; -use std::process::Command; -use task_hookrs::task::Task; -use task_hookrs::uda::UDAValue; +use task_hookrs::{task::Task, uda::UDAValue}; use unicode_truncate::UnicodeTruncateStr; use unicode_width::UnicodeWidthStr; diff --git a/src/utils.rs b/src/utils.rs index 426a252a..57f228ab 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,4 @@ -use rustyline::line_buffer::ChangeListener; -use rustyline::line_buffer::DeleteListener; -use rustyline::line_buffer::Direction; +use rustyline::line_buffer::{ChangeListener, DeleteListener, Direction}; /// Undo manager #[derive(Default)] From 83c3eb7048b9132b9ad59670accc8f5fea021bd5 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 29 Aug 2023 00:02:41 -0400 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20Add=20.editorconfig=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..2f614487 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# configuration for https://editorconfig.org + +root = true + +[*.rs] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 From 0ea6ce7d43cb3399d335fb3908dd73c9800629df Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 29 Aug 2023 00:05:02 -0400 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20Update=20upx-action=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index fe87201c..9869cbb5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -72,7 +72,8 @@ jobs: - name: Compress binaries uses: svenstaro/upx-action@v2 with: - file: target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} + files: | + target/${{ matrix.target }}/release/taskwarrior-tui${{ matrix.binary_postfix }} args: ${{ matrix.upx_args }} strip: ${{ matrix.strip }} - name: Packaging binary