Codebase list rust-stfu8 / e23467e
spotify-tui: added patch bump-tui Henry-Nicolas Tourneur 3 years ago
4 changed file(s) with 364 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
00 rust-spotify-tui (0.11.0-4) UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; urgency=medium
11
2 [ Sylvestre Ledru ]
23 * Team upload.
34 * Package spotify-tui 0.11.0 from crates.io using debcargo 2.4.3
5
6 [ Henry-Nicolas Tourneur ]
7 * Added patch bump-tui.patch, fixing an FTBFS following update of the tui
8 crate to version 0.9 (was 0.8)
49
510 -- Sylvestre Ledru <sylvestre@debian.org> Sun, 15 Nov 2020 16:42:55 +0100
611
0 Index: spotify-tui/Cargo.toml
1 ===================================================================
2 --- spotify-tui.orig/Cargo.toml
3 +++ spotify-tui/Cargo.toml
0 --- a/Cargo.toml
1 +++ b/Cargo.toml
42 @@ -37,7 +37,7 @@ version = "2.33.0"
53 version = "0.5.0"
64
0 Author: Florian Dehau <work@fdehau.com>
1 Origin: commit:650e35ea213f17ce455a976dacfbdadd07059940
2 Description: Bump tui from 0.8.0 to 0.9.1
3 ---
4 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
5 --- a/Cargo.toml
6 +++ b/Cargo.toml
7 @@ -56,7 +56,7 @@ version = "0.8"
8 version = "1.5.4"
9
10 [dependencies.tui]
11 -version = "0.8.0"
12 +version = "0.9.0"
13
14 [dependencies.unicode-width]
15 version = "0.1.7"
16 --- a/src/ui/mod.rs
17 +++ b/src/ui/mod.rs
18 @@ -9,7 +9,7 @@ use rspotify::spotify::senum::RepeatStat
19 use tui::backend::Backend;
20 use tui::layout::{Constraint, Direction, Layout, Rect};
21 use tui::style::{Color, Modifier, Style};
22 -use tui::widgets::{Block, Borders, Gauge, Paragraph, Row, SelectableList, Table, Text, Widget};
23 +use tui::widgets::{Block, Borders, Gauge, List, ListState, Paragraph, Row, Table, Text};
24 use tui::Frame;
25 use util::{
26 create_artist_string, display_track_progress, get_color, get_percentage_width,
27 @@ -82,7 +82,7 @@ where
28 .iter()
29 .map(|item| Row::StyledData(item.iter(), gray));
30
31 - Table::new(header.iter(), rows)
32 + let help_menu = Table::new(header.iter(), rows)
33 .block(
34 Block::default()
35 .borders(Borders::ALL)
36 @@ -96,8 +96,8 @@ where
37 Constraint::Length(50),
38 Constraint::Length(40),
39 Constraint::Length(20),
40 - ])
41 - .render(f, chunks[0]);
42 + ]);
43 + f.render_widget(help_menu, chunks[0]);
44 }
45
46 pub fn draw_input_and_help_box<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
47 @@ -117,16 +117,15 @@ where
48 );
49
50 let input_string: String = app.input.iter().collect();
51 - Paragraph::new([Text::raw(&input_string)].iter())
52 - .style(Style::default().fg(Color::Yellow))
53 - .block(
54 - Block::default()
55 - .borders(Borders::ALL)
56 - .title("Search")
57 - .title_style(get_color(highlight_state))
58 - .border_style(get_color(highlight_state)),
59 - )
60 - .render(f, chunks[0]);
61 + let lines = [Text::raw(&input_string)];
62 + let input = Paragraph::new(lines.iter()).block(
63 + Block::default()
64 + .borders(Borders::ALL)
65 + .title("Search")
66 + .title_style(get_color(highlight_state))
67 + .border_style(get_color(highlight_state)),
68 + );
69 + f.render_widget(input, chunks[0]);
70
71 let block = Block::default()
72 .title("Help")
73 @@ -134,10 +133,11 @@ where
74 .border_style(Style::default().fg(Color::Gray))
75 .title_style(Style::default().fg(Color::Gray));
76
77 - Paragraph::new([Text::raw("Type ?")].iter())
78 + let lines = [Text::raw("Type ?")];
79 + let help = Paragraph::new(lines.iter())
80 .block(block)
81 - .style(Style::default().fg(Color::Gray))
82 - .render(f, chunks[1]);
83 + .style(Style::default().fg(Color::Gray));
84 + f.render_widget(help, chunks[1]);
85 }
86
87 pub fn draw_main_layout<B>(f: &mut Frame<B>, app: &App)
88 @@ -652,12 +652,12 @@ where
89 current_route.hovered_block == ActiveBlock::PlayBar,
90 );
91
92 - Block::default()
93 + let title_block = Block::default()
94 .borders(Borders::ALL)
95 .title(&title)
96 .title_style(get_color(highlight_state))
97 - .border_style(get_color(highlight_state))
98 - .render(f, layout_chunk);
99 + .border_style(get_color(highlight_state));
100 + f.render_widget(title_block, layout_chunk);
101
102 let track_name = if app
103 .liked_song_ids_set
104 @@ -668,25 +668,25 @@ where
105 track_item.name.clone()
106 };
107
108 - Paragraph::new(
109 - [Text::styled(
110 - create_artist_string(&track_item.artists),
111 - Style::default().fg(Color::White),
112 - )]
113 - .iter(),
114 - )
115 - .style(Style::default().fg(Color::White))
116 - .block(
117 + let lines = [Text::styled(
118 + create_artist_string(&track_item.artists),
119 + Style::default().fg(Color::White),
120 + )];
121 + let artist = Paragraph::new(lines.iter())
122 + .style(Style::default().fg(Color::White))
123 + .block(
124 Block::default().title(&track_name).title_style(
125 - Style::default()
126 - .fg(Color::LightCyan)
127 - .modifier(Modifier::BOLD),
128 + Style::default()
129 + .fg(Color::LightCyan)
130 + .modifier(Modifier::BOLD),
131 ),
132 - )
133 - .render(f, chunks[0]);
134 + );
135 + f.render_widget(artist, chunks[0]);
136 let perc = get_track_progress_percentage(app.song_progress_ms, track_item.duration_ms);
137
138 - Gauge::default()
139 + let song_progress_label =
140 + display_track_progress(app.song_progress_ms, track_item.duration_ms);
141 + let song_progress = Gauge::default()
142 .block(Block::default().title(""))
143 .style(
144 Style::default()
145 @@ -695,11 +695,8 @@ where
146 .modifier(Modifier::ITALIC | Modifier::BOLD),
147 )
148 .percent(perc)
149 - .label(&display_track_progress(
150 - app.song_progress_ms,
151 - track_item.duration_ms,
152 - ))
153 - .render(f, chunks[1]);
154 + .label(&song_progress_label);
155 + f.render_widget(song_progress, chunks[1]);
156 }
157 }
158 }
159 @@ -744,7 +741,7 @@ Hint: a playback device must be either a
160 ))
161 }
162
163 - Paragraph::new(playing_text.iter())
164 + let playing_paragraph = Paragraph::new(playing_text.iter())
165 .wrap(true)
166 .style(Style::default().fg(Color::White))
167 .block(
168 @@ -753,8 +750,8 @@ Hint: a playback device must be either a
169 .title("Error")
170 .title_style(Style::default().fg(Color::Red))
171 .border_style(Style::default().fg(Color::Red)),
172 - )
173 - .render(f, chunks[0]);
174 + );
175 + f.render_widget(playing_paragraph, chunks[0]);
176 }
177
178 fn draw_home<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
179 @@ -773,12 +770,12 @@ where
180 current_route.hovered_block == ActiveBlock::Home,
181 );
182
183 - Block::default()
184 + let welcome = Block::default()
185 .title("Welcome!")
186 .borders(Borders::ALL)
187 .title_style(get_color(highlight_state))
188 - .border_style(get_color(highlight_state))
189 - .render(f, layout_chunk);
190 + .border_style(get_color(highlight_state));
191 + f.render_widget(welcome, layout_chunk);
192
193 let changelog = include_str!("../../CHANGELOG.md").to_string();
194
195 @@ -798,18 +795,18 @@ where
196 ];
197
198 // Contains the banner
199 - Paragraph::new(top_text.iter())
200 + let top_text = Paragraph::new(top_text.iter())
201 .style(Style::default().fg(Color::White))
202 - .block(Block::default())
203 - .render(f, chunks[0]);
204 + .block(Block::default());
205 + f.render_widget(top_text, chunks[0]);
206
207 // CHANGELOG
208 - Paragraph::new(bottom_text.iter())
209 + let bottom_text = Paragraph::new(bottom_text.iter())
210 .style(Style::default().fg(Color::White))
211 .block(Block::default())
212 .wrap(true)
213 - .scroll(app.home_scroll)
214 - .render(f, chunks[1]);
215 + .scroll(app.home_scroll);
216 + f.render_widget(bottom_text, chunks[1]);
217 }
218
219 fn draw_not_implemented_yet<B>(
220 @@ -834,11 +831,11 @@ fn draw_not_implemented_yet<B>(
221
222 let text = vec![Text::raw("Not implemented yet!")];
223
224 - Paragraph::new(text.iter())
225 + let not_implemented = Paragraph::new(text.iter())
226 .style(Style::default().fg(Color::White))
227 .block(display_block)
228 - .wrap(true)
229 - .render(f, layout_chunk);
230 + .wrap(true);
231 + f.render_widget(not_implemented, layout_chunk);
232 }
233
234 fn draw_artist_albums<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
235 @@ -880,14 +877,14 @@ where
236 .margin(5)
237 .split(f.size());
238
239 - let device_instructions = vec![
240 - "To play tracks, please select a device.",
241 - "Use `j/k` or up/down arrow keys to move up and down and <Enter> to select",
242 - "Your choice here will be cached so you can jump straight back in when you next open `spotify-tui`.",
243 - "You can change the playback device at any time by pressing `d`.",
244 + let device_instructions = [
245 + Text::raw("To play tracks, please select a device."),
246 + Text::raw("Use `j/k` or up/down arrow keys to move up and down and <Enter> to select"),
247 + Text::raw("Your choice here will be cached so you can jump straight back in when you next open `spotify-tui`."),
248 + Text::raw("You can change the playback device at any time by pressing `d`."),
249 ];
250
251 - Paragraph::new([Text::raw(device_instructions.join("\n"))].iter())
252 + let instructions = Paragraph::new(device_instructions.iter())
253 .style(Style::default().fg(Color::White))
254 .wrap(true)
255 .block(
256 @@ -895,27 +892,25 @@ where
257 .borders(Borders::NONE)
258 .title("Welcome to spotify-tui!")
259 .title_style(Style::default().fg(Color::Cyan).modifier(Modifier::BOLD)),
260 - )
261 - .render(f, chunks[0]);
262 + );
263 + f.render_widget(instructions, chunks[0]);
264
265 - let no_device_message = vec!["No devices found: Make sure a device is active".to_string()];
266 + let no_device_message = vec![Text::raw("No devices found: Make sure a device is active")];
267
268 - let items = match &app.devices {
269 + let items: Box<dyn Iterator<Item = Text>> = match &app.devices {
270 Some(items) => {
271 if items.devices.is_empty() {
272 - no_device_message
273 + Box::new(no_device_message.into_iter())
274 } else {
275 - items
276 - .devices
277 - .iter()
278 - .map(|device| device.name.to_owned())
279 - .collect()
280 + Box::new(items.devices.iter().map(|device| Text::raw(&device.name)))
281 }
282 }
283 - None => no_device_message,
284 + None => Box::new(no_device_message.into_iter()),
285 };
286
287 - SelectableList::default()
288 + let mut state = ListState::default();
289 + state.select(app.selected_device_index);
290 + let list = List::new(items)
291 .block(
292 Block::default()
293 .title("Devices")
294 @@ -923,15 +918,13 @@ where
295 .title_style(Style::default().fg(Color::LightCyan))
296 .border_style(Style::default().fg(Color::Gray)),
297 )
298 - .items(&items)
299 .style(Style::default().fg(Color::White))
300 - .select(app.selected_device_index)
301 .highlight_style(
302 Style::default()
303 .fg(Color::LightCyan)
304 .modifier(Modifier::BOLD),
305 - )
306 - .render(f, chunks[1]);
307 + );
308 + f.render_stateful_widget(list, chunks[1], &mut state);
309 }
310
311 pub fn draw_album_list<B>(f: &mut Frame<B>, app: &App, layout_chunk: Rect)
312 @@ -1072,7 +1065,10 @@ fn draw_selectable_list<B, S>(
313 B: Backend,
314 S: std::convert::AsRef<str>,
315 {
316 - SelectableList::default()
317 + let mut state = ListState::default();
318 + state.select(selected_index);
319 +
320 + let list = List::new(items.iter().map(|i| Text::raw(i.as_ref())))
321 .block(
322 Block::default()
323 .title(title)
324 @@ -1080,11 +1076,9 @@ fn draw_selectable_list<B, S>(
325 .title_style(get_color(highlight_state))
326 .border_style(get_color(highlight_state)),
327 )
328 - .items(items)
329 .style(Style::default().fg(Color::White))
330 - .select(selected_index)
331 - .highlight_style(get_color(highlight_state).modifier(Modifier::BOLD))
332 - .render(f, layout_chunk);
333 + .highlight_style(get_color(highlight_state).modifier(Modifier::BOLD));
334 + f.render_stateful_widget(list, layout_chunk, &mut state);
335 }
336
337 fn draw_table<B>(
338 @@ -1163,7 +1157,7 @@ fn draw_table<B>(
339 .map(|h| Constraint::Length(h.width))
340 .collect::<Vec<tui::layout::Constraint>>();
341
342 - Table::new(header.items.iter().map(|h| h.text), rows)
343 + let table = Table::new(header.items.iter().map(|h| h.text), rows)
344 .block(
345 Block::default()
346 .borders(Borders::ALL)
347 @@ -1173,6 +1167,6 @@ fn draw_table<B>(
348 .border_style(get_color(highlight_state)),
349 )
350 .style(Style::default().fg(Color::White))
351 - .widths(&widths)
352 - .render(f, layout_chunk);
353 + .widths(&widths);
354 + f.render_widget(table, layout_chunk);
355 }
00 bump-dirs.diff
1 bump-tui.patch