-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
254 additions
and
199 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "picterm" | ||
version = "0.0.7" | ||
version = "0.0.8" | ||
authors = ["Keisuke Toyota <[email protected]>"] | ||
edition = "2018" | ||
repository = "https://github.com/ksk001100/picterm" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::app::Actions; | ||
use tui::{ | ||
layout::Constraint, | ||
style::{Color, Style}, | ||
text::Span, | ||
widgets::{Block, BorderType, Borders, Cell, Row, Table}, | ||
}; | ||
|
||
pub fn draw(actions: &Actions) -> Table { | ||
let key_style = Style::default().fg(Color::LightCyan); | ||
let help_style = Style::default().fg(Color::Gray); | ||
|
||
let mut rows = vec![]; | ||
for action in actions.actions().iter() { | ||
let keys: Vec<String> = action.keys().iter().map(|k| k.to_string()).collect(); | ||
let key = keys.join(", "); | ||
let row = Row::new(vec![ | ||
Cell::from(Span::styled(key, key_style)), | ||
Cell::from(Span::styled(action.to_string(), help_style)), | ||
]); | ||
rows.push(row); | ||
} | ||
|
||
Table::new(rows) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Plain), | ||
) | ||
.widths(&[Constraint::Length(30), Constraint::Percentage(70)]) | ||
.column_spacing(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::app::state::AppState; | ||
use tui::{ | ||
layout::Alignment, | ||
style::{Color, Style}, | ||
widgets::{Block, BorderType, Borders, Paragraph}, | ||
}; | ||
|
||
pub fn draw<'a>(state: &'a AppState) -> Paragraph<'a> { | ||
let result = if let Some(current_image) = state.get_current_image() { | ||
current_image | ||
} else { | ||
vec![] | ||
}; | ||
|
||
Paragraph::new(result) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.style(Style::default().fg(Color::White)) | ||
.border_type(BorderType::Plain), | ||
) | ||
.alignment(Alignment::Center) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::app::state::AppState; | ||
use tui::{ | ||
style::{Color, Style}, | ||
widgets::{Block, BorderType, Borders, List, ListItem}, | ||
}; | ||
|
||
pub fn draw<'a>(state: &AppState) -> List<'a> { | ||
let list_items: Vec<ListItem> = state | ||
.get_paths() | ||
.iter() | ||
.map(|img| { | ||
ListItem::new( | ||
img.file_name() | ||
.unwrap() | ||
.to_os_string() | ||
.into_string() | ||
.unwrap(), | ||
) | ||
}) | ||
.collect(); | ||
|
||
List::new(list_items).highlight_symbol(">>").block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.style(Style::default().fg(Color::White)) | ||
.border_type(BorderType::Plain), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::app::state::AppState; | ||
use byte_unit::Byte; | ||
use tui::{ | ||
layout::Constraint, | ||
style::{Color, Style}, | ||
text::Span, | ||
widgets::{Block, BorderType, Borders, Cell, Row, Table}, | ||
}; | ||
|
||
pub fn draw<'a>(state: &AppState) -> Table<'a> { | ||
let key_style = Style::default().fg(Color::LightCyan); | ||
let value_style = Style::default().fg(Color::Gray); | ||
|
||
let rows = if let Some(image_info) = state.get_current_image_info() { | ||
let size = Byte::from(image_info.size) | ||
.get_appropriate_unit(false) | ||
.to_string(); | ||
|
||
vec![ | ||
Row::new(vec![ | ||
Cell::from(Span::styled("Name", key_style)), | ||
Cell::from(Span::styled(image_info.name, value_style)), | ||
]), | ||
Row::new(vec![ | ||
Cell::from(Span::styled("Dimensions", key_style)), | ||
Cell::from(Span::styled( | ||
format!("{}x{}", image_info.dimensions.0, image_info.dimensions.1), | ||
value_style, | ||
)), | ||
]), | ||
Row::new(vec![ | ||
Cell::from(Span::styled("Size", key_style)), | ||
Cell::from(Span::styled(size, value_style)), | ||
]), | ||
] | ||
} else { | ||
vec![] | ||
}; | ||
|
||
Table::new(rows) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Plain), | ||
) | ||
.widths(&[Constraint::Length(15), Constraint::Percentage(85)]) | ||
.column_spacing(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use tui::{ | ||
layout::Alignment, | ||
style::{Color, Modifier, Style}, | ||
text::Span, | ||
widgets::{Block, BorderType, Borders, Paragraph, Wrap}, | ||
}; | ||
|
||
pub fn draw<'a>() -> Paragraph<'a> { | ||
Paragraph::new(Span::styled( | ||
"Loading...", | ||
Style::default() | ||
.fg(Color::White) | ||
.add_modifier(Modifier::BOLD), | ||
)) | ||
.block( | ||
Block::default() | ||
.borders(Borders::ALL) | ||
.style(Style::default().fg(Color::White)) | ||
.border_type(BorderType::Plain), | ||
) | ||
.alignment(Alignment::Center) | ||
.wrap(Wrap { trim: true }) | ||
} |
Oops, something went wrong.