11use crate :: app:: * ;
22use crate :: spider;
33use 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 } ;
66use tui:: {
77 backend:: Backend ,
88 layout:: { Constraint , Direction , Layout , Rect } ,
@@ -14,6 +14,7 @@ use tui::{
1414use unicode_width:: UnicodeWidthStr ;
1515pub 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