mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
file list
This commit is contained in:
1
docs/drawio/component_lifecycle.drawio
Normal file
1
docs/drawio/component_lifecycle.drawio
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<mxfile host="Electron" modified="2021-03-04T08:07:06.708Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.3.1 Chrome/83.0.4103.119 Electron/9.0.5 Safari/537.36" etag="hf5xr88nEHbSVkpX1Y-k" version="13.3.1" type="device"><diagram id="tfe7Y5e8DOWIlyiIXn_Y" name="Page-1">7Vxbc6M2FP41nmkf2gGEMDwmTtLOdNN2Jp1205cMBhmrwYgKsbb3168wwlxEbOIEZOLNS5CQZOkcfd+5SPYEzFabX6gbL++Jj8KJofmbCbiZGIYOocb/ZTXbvMZ2YF4RUOyLRmXFA/6KRKXoF6TYR0mtISMkZDiuV3okipDHanUupWRdb7YgYf1TYzdAUsWD54Zy7T/YZ0uxCmNa1v+KcLAsPlm3nPzNyi0ai5UkS9cn60oVuJ2AGSWE5U+rzQyFmfAKueT97l54u58YRRHr0iFBd49//Wv8hmafV08PC+p8ur/5CeSjfHHDVCz4ymP4C2ZbMWm2LSTBR+NC54Xr9RIz9BC7XvZmzfXO65ZsFfKSzh89ssKeeF7gMJyRkNDdGMDz0dye8/qEUfKMKm+ABRzgZz1IxMQ20C1eFhNElKHNiyvX9/LkGxGRFWKUL0ATHQoNiC1oiuK61KdeNFlWdGmLOldsoWA/cCll/iAE/QqhF3u7Klyf7zpRJJQtSUAiN7wta68pSSMfZcNqvFS2+URILIT9H2JsK2TnpozU1YI2mH3Ouv8MRemx8uZmI0beFbZFIeLrrXTKio/Vd2W3Xano167EbJGHVchlQlLqoQPCE8BjLg0QO9DObt8SFIUu3+D1eby7hqcSrB74hNnpmHKTOGe3Bd5km6AOsoa0G6BDu7+DoHsHkIGpeQxl9qAgA0pBVoFYCbjRgMzuCDLdUIkyW0JZw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0l5ih1/OJrT4x6pCxa/YHCeDrx5xB8/EwceyrF7zqzylRw3G+0cyHaQo5om2U6VH1pD2ad/3Tc3xsG2jcDXafnGzDt9dYMXy18MyQFV/u4KuP0G</diagram></mxfile>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// locals
|
// locals
|
||||||
use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, States, Widget};
|
use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, Render, States};
|
||||||
// ext
|
// ext
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
use tui::{
|
use tui::{
|
||||||
@@ -131,7 +131,7 @@ impl Component for FileList {
|
|||||||
///
|
///
|
||||||
/// Based on the current properties and states, return a Widget instance for the Component
|
/// Based on the current properties and states, return a Widget instance for the Component
|
||||||
/// Returns None if the component is hidden
|
/// Returns None if the component is hidden
|
||||||
fn render(&self) -> Option<Box<dyn Widget>> {
|
fn render(&self) -> Option<Render> {
|
||||||
match self.props.visible {
|
match self.props.visible {
|
||||||
false => None,
|
false => None,
|
||||||
true => {
|
true => {
|
||||||
@@ -152,25 +152,28 @@ impl Component for FileList {
|
|||||||
None => String::new(),
|
None => String::new(),
|
||||||
};
|
};
|
||||||
// Render
|
// Render
|
||||||
Some(Box::new(
|
Some(Render {
|
||||||
List::new(list_item)
|
widget: Box::new(
|
||||||
.block(
|
List::new(list_item)
|
||||||
Block::default()
|
.block(
|
||||||
.borders(Borders::ALL)
|
Block::default()
|
||||||
.border_style(match self.props.focus {
|
.borders(Borders::ALL)
|
||||||
true => Style::default().fg(self.props.foreground),
|
.border_style(match self.props.focus {
|
||||||
false => Style::default(),
|
true => Style::default().fg(self.props.foreground),
|
||||||
})
|
false => Style::default(),
|
||||||
.title(title),
|
})
|
||||||
)
|
.title(title),
|
||||||
.start_corner(Corner::TopLeft)
|
)
|
||||||
.highlight_style(
|
.start_corner(Corner::TopLeft)
|
||||||
Style::default()
|
.highlight_style(
|
||||||
.bg(bg)
|
Style::default()
|
||||||
.fg(fg)
|
.bg(bg)
|
||||||
.add_modifier(self.props.get_modifiers()),
|
.fg(fg)
|
||||||
),
|
.add_modifier(self.props.get_modifiers()),
|
||||||
))
|
),
|
||||||
|
),
|
||||||
|
value: self.get_value(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,6 +250,13 @@ impl Component for FileList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### get_value
|
||||||
|
///
|
||||||
|
/// Return component value
|
||||||
|
fn get_value(&self) -> Payload {
|
||||||
|
Payload::Unumber(self.states.get_list_index())
|
||||||
|
}
|
||||||
|
|
||||||
// -- events
|
// -- events
|
||||||
|
|
||||||
/// ### should_umount
|
/// ### should_umount
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// imports
|
// imports
|
||||||
use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, States, Widget};
|
use super::{Component, InputEvent, Msg, Payload, Props, PropsBuilder, Render, States};
|
||||||
|
|
||||||
// exports
|
// exports
|
||||||
pub mod file_list;
|
pub mod file_list;
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ pub enum Payload {
|
|||||||
///
|
///
|
||||||
/// Render is the object which contains data related to the component render
|
/// Render is the object which contains data related to the component render
|
||||||
pub struct Render {
|
pub struct Render {
|
||||||
widget: Box<dyn Widget>,
|
pub widget: Box<dyn Widget>,
|
||||||
value: Payload,
|
pub value: Payload,
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- States
|
// -- States
|
||||||
|
|||||||
Reference in New Issue
Block a user