Skip to content

Commit 2693d28

Browse files
author
cht
committed
cargo fmt
1 parent a0be5e1 commit 2693d28

3 files changed

Lines changed: 31 additions & 37 deletions

File tree

src/app.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use tui::widgets::ListState;
21
use crate::spider;
2+
use tui::widgets::ListState;
33
pub enum InputMode {
44
Normal,
55
Editing,
@@ -24,7 +24,7 @@ pub struct App {
2424
pub stateoflist: bool,
2525
pub show_popup: bool,
2626
pub informations: Vec<spider::Information>,
27-
pub subscription : Vec<String>,
27+
pub subscription: Vec<String>,
2828
}
2929
impl App {
3030
pub fn next(&mut self) {
@@ -109,4 +109,3 @@ impl Default for App {
109109
}
110110
}
111111
}
112-

src/main.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ use crossterm::{
1414
execute,
1515
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
1616
};
17-
use std::{io,error::Error};
18-
use tui::{
19-
backend::CrosstermBackend,
20-
Terminal,
21-
};
22-
mod spider;
23-
mod utils;
17+
use std::{error::Error, io};
18+
use tui::{backend::CrosstermBackend, Terminal};
2419
mod app;
20+
mod spider;
2521
mod state;
22+
mod utils;
2623
use app::*;
2724

2825
fn main() -> Result<(), Box<dyn Error>> {
@@ -63,4 +60,3 @@ fn main() -> Result<(), Box<dyn Error>> {
6360

6461
Ok(())
6562
}
66-

src/state.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::app::*;
22
use crate::spider;
33
use crate::utils;
4-
use crossterm::event::{self,KeyCode,Event};
5-
use std::{env, io, process::Command};
4+
use crossterm::event::{self, Event, KeyCode};
5+
use std::{env, io, process::Command};
66
use tui::{
77
backend::Backend,
88
layout::{Constraint, Direction, Layout, Rect},
@@ -14,6 +14,7 @@ use tui::{
1414
use unicode_width::UnicodeWidthStr;
1515
pub fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<()> {
1616
loop {
17+
// here ,need with different tab ,use different draw funcitons
1718
terminal.draw(|f| ui(f, &mut app))?;
1819

1920
if let Event::Key(key) = event::read()? {
@@ -157,7 +158,7 @@ pub fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Resu
157158
KeyCode::Down => {
158159
if app.index_settings == 0 {
159160
app.index_settings = 1;
160-
} else if !app.subscription.is_empty(){
161+
} else if !app.subscription.is_empty() {
161162
app.input_mode = InputMode::SubscriptView;
162163
app.index_subscription.select(Some(0));
163164
} else {
@@ -180,18 +181,16 @@ pub fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Resu
180181
_ => {}
181182
}
182183
}
183-
InputMode::SubscriptView => {
184-
match key.code {
185-
KeyCode::Up => app.previous_sub(),
186-
KeyCode::Down => app.next_sub(),
187-
KeyCode::Esc => {
188-
app.index_settings =0;
189-
app.unselect_sub();
190-
app.input_mode = InputMode::PopupEdit;
191-
}
192-
_ => {}
184+
InputMode::SubscriptView => match key.code {
185+
KeyCode::Up => app.previous_sub(),
186+
KeyCode::Down => app.next_sub(),
187+
KeyCode::Esc => {
188+
app.index_settings = 0;
189+
app.unselect_sub();
190+
app.input_mode = InputMode::PopupEdit;
193191
}
194-
}
192+
_ => {}
193+
},
195194
}
196195
}
197196
}
@@ -211,7 +210,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
211210
.split(f.size());
212211

213212
let (msg, style) = match app.input_mode {
214-
InputMode::Normal | InputMode::Popup | InputMode::PopupEdit | InputMode::SubscriptView=> (
213+
InputMode::Normal | InputMode::Popup | InputMode::PopupEdit | InputMode::SubscriptView => (
215214
vec![
216215
Span::raw("Press "),
217216
Span::styled("q", Style::default().add_modifier(Modifier::BOLD)),
@@ -356,23 +355,23 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
356355
})
357356
.block(Block::default().borders(Borders::ALL).title("add domins"));
358357
f.render_widget(inputpop2, chunk[2]);
359-
let subscription : Vec<ListItem> = app
358+
let subscription: Vec<ListItem> = app
360359
.subscription
361360
.iter()
362361
.enumerate()
363-
.map(|(i,m)|{
364-
let content = vec![Spans::from(Span::raw(format!("{}:{}",i,m)))];
362+
.map(|(i, m)| {
363+
let content = vec![Spans::from(Span::raw(format!("{}:{}", i, m)))];
365364
ListItem::new(content)
366365
})
367-
.collect();
366+
.collect();
368367
let subscription = List::new(subscription)
369-
.block(Block::default().borders(Borders::ALL).title("List"))
370-
.highlight_style(
371-
Style::default()
372-
.bg(Color::LightBlue)
373-
.add_modifier(Modifier::BOLD),
374-
)
375-
.highlight_symbol(">> ");
368+
.block(Block::default().borders(Borders::ALL).title("List"))
369+
.highlight_style(
370+
Style::default()
371+
.bg(Color::LightBlue)
372+
.add_modifier(Modifier::BOLD),
373+
)
374+
.highlight_symbol(">> ");
376375
f.render_stateful_widget(subscription, chunk[3], &mut app.index_subscription);
377376
if let InputMode::PopupEdit = app.input_mode {
378377
let index = app.index_settings;

0 commit comments

Comments
 (0)