Skip to content

Commit c42d691

Browse files
author
cht
committed
update subscribe
1 parent ea4710b commit c42d691

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::app::*;
2-
use crate::subscribe::{self, render};
2+
use crate::subscribe::render;
33
use std::io;
44
use tui::{backend::Backend, Terminal};
55
pub enum IFEXIT {
@@ -10,8 +10,8 @@ pub enum IFEXIT {
1010
pub fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<()> {
1111
loop {
1212
// here ,need with different tab ,use different draw funcitons
13-
terminal.draw(|f| render::ui(f, &mut app))?;
14-
if let IFEXIT::Exit = subscribe::state::subscribe_state(&mut app)? {
13+
//terminal.draw(|f| render::ui(f, &mut app))?;
14+
if let IFEXIT::Exit = render::run_app_subscribe(terminal,&mut app)? {
1515
return Ok(());
1616
}
1717
}

src/subscribe/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub mod render;
2-
pub mod state;
2+
mod state;
33
use super::{app, spider, state::IFEXIT, utils};

src/subscribe/render.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::app::*;
22
use tui::{
3+
Terminal,
34
backend::Backend,
45
layout::{Constraint, Direction, Layout, Rect},
56
style::{Color, Modifier, Style},
@@ -8,7 +9,13 @@ use tui::{
89
Frame,
910
};
1011
use unicode_width::UnicodeWidthStr;
11-
pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
12+
use super::IFEXIT;
13+
use std::io;
14+
pub fn run_app_subscribe<B: Backend>(terminal: &mut Terminal<B>,app: &mut App) -> io::Result<IFEXIT> {
15+
terminal.draw(|f| ui(f,app))?;
16+
super::state::subscribe_state(app)
17+
}
18+
fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
1219
let chunks = Layout::default()
1320
.direction(Direction::Vertical)
1421
.margin(2)

src/subscribe/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn subscribe_state(app: &mut App) -> io::Result<IFEXIT> {
2828
InputMode::Editing => match key.code {
2929
KeyCode::Enter => {
3030
let input = vec![app.input.clone()];
31-
let get_list = spider::get_the_key(input.clone());
31+
let get_list = spider::get_the_key(input);
3232
if let Ok(list) = get_list {
3333
let mut storge: String = String::new();
3434
storge.push('[');

0 commit comments

Comments
 (0)