Commit a4505a6abe

a4505a6abeebd3b6391e48db0863ddf595220506

parent: 262311623d

Unsigned

Siriusmart <71584876+Siriusmart@users.noreply.github.com> · 2022-05-08 15:27 UTC

Can switch tabs etc and stuff

Layout: unified · split

Cargo.lock +11
@@ -263,6 +263,15 @@ dependencies = [
263263 "libc",
264264]
265265
266[[package]]
267name = "home"
268version = "0.5.3"
269source = "registry+https://github.com/rust-lang/crates.io-index"
270checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
271dependencies = [
272 "winapi",
273]
274
266275[[package]]
267276name = "hrtime"
268277version = "0.2.0"
@@ -1169,7 +1178,9 @@ version = "0.1.0"
11691178dependencies = [
11701179 "crossterm",
11711180 "futures",
1181 "home",
11721182 "hrtime",
11731183 "invidious",
1184 "reqwest",
11741185 "tui",
11751186]
Cargo.toml +2
@@ -11,6 +11,8 @@ crossterm = "0.23"
1111invidious = "0.1.0"
1212futures = "0.3"
1313hrtime = "0.2"
14home = "0.5"
15reqwest = "0.11"
1416
1517[profile.dev.package."*"]
1618opt-level = 3
README.md +14 −1
@@ -1 +1,14 @@
1Very bad coding, but if it works, it works.
\ No newline at end of file
1## Basic Movements
2Arrow keys: Move in the direction of the arrow key.
3Enter: Select an item (Everything is an item)
4Esc: Unselect an item
5q: Quit the program (Only works when nothing is selected)
6
7## Basic Display
8Green (Or your terminal's default foreground color): All the items
9Red: The item that you have your "cursor" on (Aka hovering)
10Blue/Purple: The item that you have selected
11Yellow: Selected but not selected? (I don't know how to say that)
12
13## Bugs
14NONE! It's just a feature. If you found one, please report the feature on GitHub
\ No newline at end of file
src/app/app.rs +6 −2
@@ -64,7 +64,11 @@ impl App {
6464 self = item.key_input(key, self);
6565 self.state[y].items[x].item = Item::Global(item);
6666 }
67 _ => {}
67 Item::MainMenu(item) => {
68 let mut item = item.clone();
69 self = item.key_input(key, self);
70 self.state[y].items[x].item = Item::MainMenu(item);
71 }
6872 }
6973
7074 return self;
@@ -175,7 +179,7 @@ impl App {
175179 }
176180}
177181
178#[derive(Debug)]
182#[derive(Debug, PartialEq)]
179183pub enum Page {
180184 MainMenu { tab: MainMenuSelector },
181185}
src/app/pages/global.rs +17 −1
@@ -1,5 +1,5 @@
11use crossterm::event::KeyCode;
2use invidious::structs::{hidden::TrendingVideo, video::Video};
2use invidious::structs::{hidden::{TrendingVideo, PopularItem}, video::Video};
33
44use crate::{
55 app::app::App,
@@ -84,3 +84,19 @@ impl From<TrendingVideo> for MiniVideo {
8484 }
8585 }
8686}
87
88impl From<PopularItem> for MiniVideo {
89 fn from(original: PopularItem) -> Self {
90 MiniVideo {
91 title: original.title,
92 video_id: original.videoId,
93 video_thumbnail: original.videoThumbnails[0].url.clone(),
94 length: hrtime::from_sec(original.lengthSeconds as u64),
95 view_count: original.viewCount,
96 author: original.author,
97 author_url: original.authorUrl,
98 published: original.publishedText,
99 description: String::new(),
100 }
101 }
102}
\ No newline at end of file
src/app/pages/main_menu.rs +44 −20
@@ -1,20 +1,21 @@
11use std::{collections::LinkedList, error::Error};
22
3use futures::{executor::block_on, future::join_all};
4
35use crate::{
46 app::{
57 app::{App, Item, Page, Row, RowItem},
6 pages::global::{GlobalItem, ListItem, MiniVideo},
8 pages::global::{GlobalItem, ListItem},
79 },
810 traits::{KeyInput, LoadItem, SelectItem},
911 widgets::text_list::TextList,
1012};
1113use crossterm::event::KeyCode;
12use invidious::{blocking::Client, structs::video::Video};
1314use tui::layout::Constraint;
1415#[derive(Debug, Clone)]
1516pub enum MainMenuItem {
1617 SeletorTab(MainMenuSelector),
17 VideoList(Option<(LinkedList<ListItem>, TextList, usize)>), // Videos, List, page
18 VideoList(Option<(LinkedList<ListItem>, TextList, Option<usize>)>), // Videos, List, page
1819}
1920
2021// app.client.trending(None)
@@ -23,7 +24,12 @@ impl SelectItem for MainMenuItem {
2324 fn select(&mut self, mut app: App) -> (App, bool) {
2425 let selected = match self {
2526 MainMenuItem::SeletorTab(selector) => {
27 if app.page == (Page::MainMenu { tab: *selector }) {
28 return (app, false);
29 }
2630 app.page = Page::MainMenu { tab: *selector };
31 app.load = true;
32 app.message = Some(String::from("Loading videos..."));
2733 false
2834 }
2935
@@ -41,6 +47,13 @@ impl SelectItem for MainMenuItem {
4147impl KeyInput for MainMenuItem {
4248 fn key_input(&mut self, key: KeyCode, app: App) -> App {
4349 match self {
50 MainMenuItem::VideoList(Some((_, list, _))) => match key {
51 KeyCode::Up => list.up(),
52 KeyCode::Down => list.down(),
53 KeyCode::PageUp => list.selected = 0,
54 KeyCode::PageDown => list.selected = list.items.len() - 1,
55 _ => {}
56 },
4457 _ => {}
4558 }
4659
@@ -56,7 +69,7 @@ impl LoadItem for MainMenuItem {
5669 MainMenuItem::VideoList(enum_items) => match app.page {
5770 Page::MainMenu { tab } => match tab {
5871 MainMenuSelector::Trending => {
59 let mut list: LinkedList<ListItem> = app
72 let list: LinkedList<ListItem> = app
6073 .client
6174 .trending(None)?
6275 .videos
@@ -64,26 +77,41 @@ impl LoadItem for MainMenuItem {
6477 .map(|t| ListItem::Video(t.into()))
6578 .collect();
6679
67 list.push_back(ListItem::PageTurner(true));
68
6980 let mut text_list = TextList::default();
7081
71 if let Some((video_list, text_list, page)) = enum_items {
72 if *page > 0 {
73 list.push_front(ListItem::PageTurner(false));
74 }
75
82 if let Some((video_list, text_list, _)) = enum_items {
7683 *text_list = TextList::default();
7784 text_list.items(textlist_from_video_list(&list));
7885
7986 *video_list = list;
8087 } else {
8188 text_list.items(textlist_from_video_list(&list));
82 *enum_items = Some((list, text_list, 0));
89 *enum_items = Some((list, text_list, None));
8390 };
91 }
92
93 MainMenuSelector::Popular => {
94 let list: LinkedList<ListItem> = app
95 .client
96 .popular(None)?
97 .items
98 .into_iter()
99 .map(|t| ListItem::Video(t.into()))
100 .collect();
84101
85 //let text_list = TextList::default().items();
102 let mut text_list = TextList::default();
103
104 if let Some((video_list, text_list, _)) = enum_items {
105 *text_list = TextList::default();
106 text_list.items(textlist_from_video_list(&list));
107
108 *video_list = list;
109 } else {
110 text_list.items(textlist_from_video_list(&list));
111 *enum_items = Some((list, text_list, None));
112 };
86113 }
114
87115 _ => {}
88116 },
89117 },
@@ -104,18 +132,14 @@ fn textlist_from_video_list(original: &LinkedList<ListItem>) -> Vec<String> {
104132 .chars()
105133 .map(|c| if c.is_ascii() { c } else { '?' })
106134 .collect(),
107 ListItem::PageTurner(b) => {
108 if *b {
109 "Next Page".to_string()
110 } else {
111 "Previous Page".to_string()
112 }
135 _ => {
136 unreachable!()
113137 }
114138 })
115139 .collect()
116140}
117141
118#[derive(Debug, Clone, Copy)]
142#[derive(Debug, Clone, Copy, PartialEq)]
119143pub enum MainMenuSelector {
120144 Trending,
121145 Popular,
src/functions/download_all_thumbnails.rs added +52
@@ -0,0 +1,52 @@
1use std::{collections::LinkedList, error::Error, io::Cursor};
2
3use futures::executor::block_on;
4
5use crate::app::pages::global::ListItem;
6
7pub enum ItemType {
8 Video,
9 Playlist,
10}
11
12pub fn download_all_thumbnails(list: &LinkedList<ListItem>) -> Result<(), Box<dyn Error>>{
13 let mut urls: Vec<(&str, &str, ItemType)> = Vec::new();
14 for i in list.iter() {
15 match i {
16 ListItem::Video(video) => {
17 urls.push((&video.video_thumbnail, &video.video_id, ItemType::Video));
18 }
19 _ => {}
20 }
21 }
22
23 block_on(download_items(urls))?;
24
25 Ok(())
26}
27
28pub async fn download_items(urls: Vec<(&str, &str, ItemType)>) -> Result<(), Box<dyn Error>>{
29 let mut dir = home::home_dir().expect("Cannot get your home directory");
30 dir.push(".siriusmart");
31 dir.push("youtube-tui");
32 dir.push("cache");
33
34 for (url, video_id, item_type) in urls {
35 dir.push(match item_type {
36 ItemType::Video => "videos",
37 ItemType::Playlist => "playlists",
38 });
39
40 fetch_url(url, &format!("{:?}/{}.png", dir, video_id)).await?;
41 }
42
43 Ok(())
44}
45
46async fn fetch_url(url: &str, file_name: &str) -> Result<(), Box<dyn Error>> {
47 let response = reqwest::get(url).await?;
48 let mut file = std::fs::File::create(file_name)?;
49 let mut content = Cursor::new(response.bytes().await?);
50 std::io::copy(&mut content, &mut file)?;
51 Ok(())
52}
\ No newline at end of file
src/functions/mod.rs added +2
@@ -0,0 +1,2 @@
1mod download_all_thumbnails;
2pub use download_all_thumbnails::*;
\ No newline at end of file
src/lib.rs +1
@@ -1,4 +1,5 @@
11pub mod app;
22pub mod traits;
33pub mod widgets;
4pub mod functions;
45mod render;
\ No newline at end of file
src/main.rs +49 −2
@@ -3,7 +3,7 @@ use crossterm::{
33 execute,
44 terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
55};
6use std::{error::Error, io};
6use std::{error::Error, fs, io, path::Path};
77use tui::{
88 backend::{Backend, CrosstermBackend},
99 Terminal,
@@ -14,6 +14,8 @@ use youtube_tui::{
1414};
1515
1616fn main() -> Result<(), Box<dyn Error>> {
17 init()?;
18
1719 let app = App::new();
1820
1921 enable_raw_mode()?;
@@ -31,7 +33,9 @@ fn main() -> Result<(), Box<dyn Error>> {
3133 )?;
3234 disable_raw_mode()?;
3335
34 res
36 res?;
37
38 Ok(())
3539}
3640
3741fn run_app<B: Backend>(mut terminal: &mut Terminal<B>, mut app: App) -> Result<(), Box<dyn Error>> {
@@ -111,3 +115,46 @@ fn ui<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Result<(), Box<d
111115
112116 Ok(())
113117}
118
119fn init() -> Result<(), Box<dyn Error>> {
120 let mut dir = home::home_dir().expect("Cannot get your home directory");
121
122 dir.push(".siriusmart");
123 if !dir.exists() {
124 fs::create_dir(&dir)?;
125 }
126
127 dir.push("youtube-tui");
128 if !dir.exists() {
129 fs::create_dir(&dir)?;
130 }
131
132 dir.push("cache");
133
134 if dir.exists() {
135 fs::remove_dir_all(&dir)?;
136 }
137 fs::create_dir(&dir)?;
138
139 dir.push("thumbnails");
140
141 if !dir.exists() {
142 fs::create_dir(&dir)?;
143 }
144
145 dir.push("videos");
146
147 if !dir.exists() {
148 fs::create_dir(&dir)?;
149 }
150
151 dir.pop();
152
153 dir.push("playlists");
154
155 if !dir.exists() {
156 fs::create_dir(&dir)?;
157 }
158
159 Ok(())
160}
src/render/pages/global.rs +17 −10
@@ -1,4 +1,7 @@
1use crate::{app::{pages::global::GlobalItem, app::App}, traits::RenderItem};
1use crate::{
2 app::{app::App, pages::global::GlobalItem},
3 traits::RenderItem,
4};
25use tui::{
36 backend::Backend,
47 layout::{Alignment, Rect},
@@ -19,17 +22,16 @@ impl GlobalItem {
1922 ) {
2023 match self {
2124 GlobalItem::SearchBar(search) => {
22 let style = Style::default().fg(if selected {
23 Color::LightBlue
24 } else if hover {
25 Color::LightRed
26 } else {
27 Color::Reset
28 });
2925 let block = Block::default()
3026 .border_type(BorderType::Rounded)
3127 .borders(Borders::ALL)
32 .style(style)
28 .border_style(Style::default().fg(if selected {
29 Color::LightBlue
30 } else if hover {
31 Color::LightRed
32 } else {
33 Color::Reset
34 }))
3335 .title("Search YouTube")
3436 .title_alignment(Alignment::Center);
3537 let paragraph = Paragraph::new(search.clone()).block(block);
@@ -39,7 +41,12 @@ impl GlobalItem {
3941 // let color = Color::LightYellow;
4042 let block = Block::default()
4143 .border_type(BorderType::Rounded)
42 .borders(Borders::ALL);
44 .borders(Borders::ALL)
45 .border_style(Style::default().fg(if message.is_some() {
46 Color::LightRed
47 } else {
48 Color::Reset
49 }));
4350 let paragraph =
4451 Paragraph::new(message.clone().unwrap_or(String::from("All good :)")))
4552 .block(block);
src/render/pages/main_menu.rs +30 −23
@@ -1,24 +1,26 @@
11use crate::{
2 app::{pages::main_menu::{MainMenuItem, MainMenuSelector}, app::App},
2 app::{pages::main_menu::{MainMenuItem, MainMenuSelector}, app::Page},
33 traits::RenderItem,
4 widgets::horizontal_split::HorizontalSplit,
45};
56use tui::{
67 backend::Backend,
7 layout::{Alignment, Constraint, Layout, Rect, Direction},
8 layout::{Alignment, Constraint, Direction, Layout, Rect},
89 style::{Color, Style},
910 widgets::{Block, BorderType, Borders, Paragraph},
1011 Frame,
1112};
1213
13impl RenderItem for MainMenuItem {
14 fn render_item<B: Backend>(
14impl MainMenuItem {
15 pub fn render_item<B: Backend>(
1516 &mut self,
1617 frame: &mut Frame<B>,
1718 rect: Rect,
1819 selected: bool,
1920 hover: bool,
21 page: &Page
2022 ) {
21 let style = Style::default().fg(if selected {
23 let mut style = Style::default().fg(if selected {
2224 Color::LightBlue
2325 } else if hover {
2426 Color::LightRed
@@ -28,6 +30,9 @@ impl RenderItem for MainMenuItem {
2830
2931 match self {
3032 MainMenuItem::SeletorTab(selector) => {
33 if !hover && page == &(Page::MainMenu { tab: *selector }){
34 style = style.fg(Color::LightYellow);
35 }
3136 let text = match selector {
3237 MainMenuSelector::Trending => "Trending",
3338 MainMenuSelector::Popular => "Popular",
@@ -45,28 +50,30 @@ impl RenderItem for MainMenuItem {
4550 frame.render_widget(paragraph, rect);
4651 }
4752 MainMenuItem::VideoList(data) => {
48 let chunks = Layout::default()
49 .constraints([Constraint::Percentage(40), Constraint::Percentage(60)].as_ref())
50 .direction(Direction::Horizontal)
51 .split(rect);
52
53 let block = Block::default()
54 .border_type(BorderType::Rounded)
55 .borders(Borders::ALL)
56 .border_style(style);
53 let split = HorizontalSplit::default()
54 .percentages(vec![40, 60])
55 .border_style(Style::default().fg(if selected {
56 Color::LightBlue
57 } else if hover {
58 Color::LightRed
59 } else {
60 Color::Reset
61 }));
5762
58 let inner = block.inner(chunks[0]);
63 let chunks = split.inner(rect);
5964
60 frame.render_widget(block, chunks[0]);
61
62 let block = Block::default()
63 .border_type(BorderType::Rounded)
64 .borders(Borders::ALL);
65 frame.render_widget(block, chunks[1]);
65 frame.render_widget(split, rect);
6666
6767 if let Some((videos, list, _)) = data {
68 list.area(inner);
69 frame.render_widget(list.clone(), inner);
68 list.area(chunks[0]);
69 let mut list = list.clone();
70
71 if selected {
72 list.selected_style(Style::default().fg(Color::LightRed));
73 } else {
74 list.selected_style(Style::default().fg(Color::LightYellow));
75 }
76 frame.render_widget(list, chunks[0]);
7077 }
7178 }
7279 }
src/render/render.rs +1 −1
@@ -88,7 +88,7 @@ impl App {
8888 i.render_item(frame, chunk, selected, hover, &self.message);
8989 }
9090 Item::MainMenu(i) => {
91 i.render_item(frame, chunk, selected, hover);
91 i.render_item(frame, chunk, selected, hover, &self.page);
9292 }
9393 }
9494 }
src/widgets/horizontal_split.rs added +168
@@ -0,0 +1,168 @@
1use tui::{
2 buffer::Buffer,
3 layout::Rect,
4 style::Style,
5 symbols::line::{
6 HORIZONTAL, HORIZONTAL_DOWN, HORIZONTAL_UP, ROUNDED_BOTTOM_LEFT, ROUNDED_BOTTOM_RIGHT,
7 ROUNDED_TOP_LEFT, ROUNDED_TOP_RIGHT, VERTICAL,
8 },
9 widgets::Widget,
10};
11
12#[derive(Debug, Clone)]
13pub struct HorizontalSplit {
14 pub percentages: Vec<usize>,
15 pub border_style: Style,
16}
17
18impl Widget for HorizontalSplit {
19 fn render(self, rect: Rect, buffer: &mut Buffer) {
20 let mut width_left = rect.width as usize;
21
22 let widths = self
23 .percentages
24 .iter()
25 .enumerate()
26 .map(|(i, p)| {
27 if i == self.percentages.len() - 1 {
28 return width_left;
29 }
30 let width = p * rect.width as usize / 100;
31 width_left -= width;
32 width
33 })
34 .collect::<Vec<_>>();
35
36 let mut top = String::new();
37 let mut mid = String::new();
38 let mut bottom = String::new();
39
40 buffer.set_style(Rect { height: 1, ..rect }, self.border_style);
41 buffer.set_style(
42 Rect {
43 height: 1,
44 y: rect.y + rect.height - 1,
45 ..rect
46 },
47 self.border_style,
48 );
49
50 buffer.set_style(
51 Rect {
52 x: rect.x + rect.width - 1,
53 y: rect.y + 1,
54 width: 1,
55 height: rect.height - 2,
56 },
57 self.border_style,
58 );
59
60 let mut x = rect.x;
61
62 for (index, width) in widths.iter().enumerate() {
63 buffer.set_style(
64 Rect {
65 x,
66 y: rect.y + 1,
67 width: 1,
68 height: rect.height - 2,
69 },
70 self.border_style,
71 );
72
73 x += *width as u16;
74
75 if index == 0 {
76 top.push_str(ROUNDED_TOP_LEFT);
77 bottom.push_str(ROUNDED_BOTTOM_LEFT);
78 } else {
79 top.push_str(HORIZONTAL_DOWN);
80 bottom.push_str(HORIZONTAL_UP);
81 }
82
83 mid.push_str(VERTICAL);
84
85 if index == widths.len() - 1 {
86 top.push_str(&HORIZONTAL.repeat(*width - 2));
87 mid.push_str(&" ".repeat(*width - 2));
88 bottom.push_str(&HORIZONTAL.repeat(*width - 2));
89
90 top.push_str(ROUNDED_TOP_RIGHT);
91 mid.push_str(VERTICAL);
92 bottom.push_str(ROUNDED_BOTTOM_RIGHT);
93 } else {
94 top.push_str(&HORIZONTAL.repeat(*width - 1));
95 mid.push_str(&" ".repeat(*width - 1));
96 bottom.push_str(&HORIZONTAL.repeat(*width - 1));
97 }
98 }
99
100 buffer.set_string(rect.x, rect.y, &top, Style::default());
101
102 for y in rect.y + 1..rect.y + rect.height - 1 {
103 buffer.set_string(rect.x, y, &mid, Style::default());
104 }
105
106 buffer.set_string(rect.x, rect.y + rect.height - 1, &bottom, Style::default());
107 }
108}
109
110impl Default for HorizontalSplit {
111 fn default() -> Self {
112 HorizontalSplit {
113 percentages: vec![50, 50],
114 border_style: Style::default(),
115 }
116 }
117}
118
119impl HorizontalSplit {
120 pub fn inner(&self, rect: Rect) -> Vec<Rect> {
121 let mut width_left = rect.width as usize;
122
123 let widths = self
124 .percentages
125 .iter()
126 .enumerate()
127 .map(|(i, p)| {
128 if i == self.percentages.len() - 1 {
129 return width_left;
130 }
131 let width = p * rect.width as usize / 100;
132 width_left -= width;
133 width
134 })
135 .collect::<Vec<_>>();
136
137 let mut x = rect.x as usize + 1;
138
139 widths
140 .iter()
141 .enumerate()
142 .map(|(i, width)| {
143 let cell_rect = Rect {
144 x: x as u16,
145 y: rect.y + 1,
146 width: *width as u16 - if i == widths.len() - 1 { 2 } else { 1 },
147 height: rect.height - 2,
148 };
149 x += width;
150 cell_rect
151 })
152 .collect::<Vec<_>>()
153 }
154
155 pub fn percentages(self, percentages: Vec<usize>) -> Self{
156 Self {
157 percentages,
158 ..self
159 }
160 }
161
162 pub fn border_style(self, border_style: Style) -> Self {
163 Self {
164 border_style,
165 ..self
166 }
167 }
168}
src/widgets/item_info.rs added +3
@@ -0,0 +1,3 @@
1pub struct ItemInfo {
2
3}
\ No newline at end of file
src/widgets/mod.rs +2 −1
@@ -1 +1,2 @@
1pub mod text_list;
\ No newline at end of file
1pub mod text_list;
2pub mod horizontal_split;
\ No newline at end of file
src/widgets/text_list.rs +18 −6
@@ -15,6 +15,8 @@ pub struct TextList {
1515 pub selected: usize,
1616 pub scroll: usize,
1717 pub area: Option<Rect>,
18 pub style: Style,
19 pub selected_style: Style,
1820}
1921
2022impl Widget for TextList {
@@ -27,6 +29,8 @@ impl Widget for TextList {
2729 let width_minus_5 = (area.width - 5) as usize;
2830 let mut y = area.y;
2931
32 buf.set_style(area, self.style);
33
3034 for (i, mut item) in self
3135 .items
3236 .into_iter()
@@ -55,15 +59,13 @@ impl Widget for TextList {
5559 ROUNDED_BOTTOM_RIGHT,
5660 );
5761
58 let color = Color::LightYellow;
59
6062 let mut rect = Rect {
6163 x: area.x,
6264 y: y,
6365 width: area.width,
6466 height: 1,
6567 };
66 buf.set_style(rect, Style::default().fg(color));
68 buf.set_style(rect, self.selected_style);
6769
6870 rect = Rect {
6971 x: area.x,
@@ -71,7 +73,7 @@ impl Widget for TextList {
7173 width: 1,
7274 height: 1,
7375 };
74 buf.set_style(rect, Style::default().fg(color));
76 buf.set_style(rect, self.selected_style);
7577
7678 rect = Rect {
7779 x: area.x + area.width - 1,
@@ -79,7 +81,7 @@ impl Widget for TextList {
7981 width: 1,
8082 height: 1,
8183 };
82 buf.set_style(rect, Style::default().fg(color));
84 buf.set_style(rect, self.selected_style);
8385
8486 rect = Rect {
8587 x: area.x,
@@ -87,7 +89,7 @@ impl Widget for TextList {
8789 width: area.width,
8890 height: 1,
8991 };
90 buf.set_style(rect, Style::default().fg(color));
92 buf.set_style(rect, self.selected_style);
9193
9294 for line in lines.lines() {
9395 for (x, c) in (0..area.width).zip(line.chars()) {
@@ -112,6 +114,8 @@ impl Default for TextList {
112114 selected: 0,
113115 scroll: 0,
114116 area: None,
117 style: Style::default(),
118 selected_style: Style::default().fg(Color::Yellow),
115119 }
116120 }
117121}
@@ -146,4 +150,12 @@ impl TextList {
146150 }
147151 }
148152 }
153
154 pub fn style(&mut self, style: Style) {
155 self.style = style;
156 }
157
158 pub fn selected_style(&mut self, style: Style) {
159 self.selected_style = style;
160 }
149161}