mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Run cargo format
This commit is contained in:
parent
293f7f59b6
commit
412c63965b
3 changed files with 82 additions and 84 deletions
|
@ -14,7 +14,7 @@ use unicode_width::UnicodeWidthStr;
|
||||||
use chrono::{DateTime, Duration, Local, NaiveDateTime, TimeZone};
|
use chrono::{DateTime, Duration, Local, NaiveDateTime, TimeZone};
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::{Backend},
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
terminal::Frame,
|
terminal::Frame,
|
||||||
|
@ -23,7 +23,7 @@ use tui::{
|
||||||
Terminal,
|
Terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::util::{Key};
|
use crate::util::Key;
|
||||||
|
|
||||||
pub fn cmp(t1: &Task, t2: &Task) -> Ordering {
|
pub fn cmp(t1: &Task, t2: &Task) -> Ordering {
|
||||||
let urgency1 = match &t1.uda()["urgency"] {
|
let urgency1 = match &t1.uda()["urgency"] {
|
||||||
|
@ -277,7 +277,7 @@ impl App {
|
||||||
}
|
}
|
||||||
pub fn next(&mut self) {
|
pub fn next(&mut self) {
|
||||||
if self.tasks.len() == 0 {
|
if self.tasks.len() == 0 {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let i = match self.state.selected() {
|
let i = match self.state.selected() {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
|
@ -293,7 +293,7 @@ impl App {
|
||||||
}
|
}
|
||||||
pub fn previous(&mut self) {
|
pub fn previous(&mut self) {
|
||||||
if self.tasks.len() == 0 {
|
if self.tasks.len() == 0 {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let i = match self.state.selected() {
|
let i = match self.state.selected() {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
|
@ -406,7 +406,6 @@ impl App {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -7,21 +7,20 @@ mod util;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
use crate::util::{EventConfig, Event, Events, setup_terminal, destruct_terminal};
|
use crate::util::{destruct_terminal, setup_terminal, Event, EventConfig, Events};
|
||||||
use std::time::{Duration, Instant};
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::{stdout, Write};
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::io::{stdout, Write};
|
||||||
|
use std::process::Command;
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
use tui::backend::Backend;
|
use tui::backend::Backend;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
use std::env;
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use app::App;
|
use app::App;
|
||||||
use app::InputMode;
|
use app::InputMode;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
// Terminal initialization
|
// Terminal initialization
|
||||||
let mut terminal = setup_terminal();
|
let mut terminal = setup_terminal();
|
||||||
terminal.clear()?;
|
terminal.clear()?;
|
||||||
|
@ -45,7 +44,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
if app.should_quit {
|
if app.should_quit {
|
||||||
destruct_terminal(terminal);
|
destruct_terminal(terminal);
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
12
src/util.rs
12
src/util.rs
|
@ -7,11 +7,10 @@ use crossterm::{
|
||||||
#[cfg(feature = "crossterm")]
|
#[cfg(feature = "crossterm")]
|
||||||
use tui::{backend::CrosstermBackend, Terminal};
|
use tui::{backend::CrosstermBackend, Terminal};
|
||||||
|
|
||||||
|
|
||||||
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
||||||
use termion::{
|
use termion::{
|
||||||
event,
|
event,
|
||||||
input::{TermRead,MouseTerminal},
|
input::{MouseTerminal, TermRead},
|
||||||
raw::{IntoRawMode, RawTerminal},
|
raw::{IntoRawMode, RawTerminal},
|
||||||
screen::AlternateScreen,
|
screen::AlternateScreen,
|
||||||
};
|
};
|
||||||
|
@ -78,9 +77,9 @@ pub fn destruct_terminal(mut terminal: Terminal<CrosstermBackend<io::Stdout>>) {
|
||||||
terminal.show_cursor().unwrap();
|
terminal.show_cursor().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
||||||
pub fn setup_terminal() -> Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>> {
|
pub fn setup_terminal(
|
||||||
|
) -> Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>> {
|
||||||
let stdout = io::stdout().into_raw_mode().unwrap();
|
let stdout = io::stdout().into_raw_mode().unwrap();
|
||||||
let stdout = MouseTerminal::from(stdout);
|
let stdout = MouseTerminal::from(stdout);
|
||||||
let stdout = AlternateScreen::from(stdout);
|
let stdout = AlternateScreen::from(stdout);
|
||||||
|
@ -89,10 +88,11 @@ pub fn setup_terminal() -> Terminal<TermionBackend<AlternateScreen<MouseTerminal
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
||||||
pub fn destruct_terminal(terminal: Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>> ) {
|
pub fn destruct_terminal(
|
||||||
|
terminal: Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>>,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct Events {
|
pub struct Events {
|
||||||
rx: mpsc::Receiver<Event<Key>>,
|
rx: mpsc::Receiver<Event<Key>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue