diff options
Diffstat (limited to 'src/frontend')
| -rw-r--r-- | src/frontend/entries.rs | 18 | ||||
| -rw-r--r-- | src/frontend/ui.rs | 58 |
2 files changed, 55 insertions, 21 deletions
diff --git a/src/frontend/entries.rs b/src/frontend/entries.rs index c532bf0..8eadfa2 100644 --- a/src/frontend/entries.rs +++ b/src/frontend/entries.rs @@ -29,7 +29,14 @@ impl FromIterator<Vec<String>> for EntryTable { let entry_table_items = iter .into_iter() .sorted() - .map(|i| EntryTableItem::new(&i[0], &i[1], &i[2], &i[3], &i[4], &i[5])) + // 0: authors, 1: title, 2: date, 3: pubtype, 4: keywords, 5: citekey + // 6: abstract, 7: doi/url, 8: pdf filepath + // See backend/bib.rs BibiEntry impl + .map(|i| { + EntryTableItem::new( + &i[0], &i[1], &i[2], &i[3], &i[4], &i[5], &i[6], &i[7], &i[8], + ) + }) .collect(); let entry_table_state = TableState::default().with_selected(0); Self { @@ -55,6 +62,9 @@ pub struct EntryTableItem { pub pubtype: String, pub keywords: String, pub citekey: String, + pub abstract_text: String, + pub doi_url: String, + pub filepath: String, } impl EntryTableItem { @@ -65,6 +75,9 @@ impl EntryTableItem { pubtype: &str, keywords: &str, citekey: &str, + abstract_text: &str, + doi_url: &str, + filepath: &str, ) -> Self { Self { authors: authors.to_string(), @@ -73,6 +86,9 @@ impl EntryTableItem { pubtype: pubtype.to_string(), keywords: keywords.to_string(), citekey: citekey.to_string(), + abstract_text: abstract_text.to_string(), + doi_url: doi_url.to_string(), + filepath: filepath.to_string(), } } diff --git a/src/frontend/ui.rs b/src/frontend/ui.rs index 3246145..4920b81 100644 --- a/src/frontend/ui.rs +++ b/src/frontend/ui.rs @@ -232,48 +232,66 @@ impl App { pub fn render_selected_item(&mut self, area: Rect, buf: &mut Buffer) { // We get the info depending on the item's state. - // TODO: Implement logic showin informations for selected entry: let style_value = Style::new().bold().fg(TEXT_FG_COLOR); + let style_value_sec = Style::new() + .add_modifier(Modifier::ITALIC) + .fg(TEXT_FG_COLOR); let lines = { + let idx = self.entry_table.entry_table_state.selected().unwrap(); + let cur_entry = &self.entry_table.entry_table_items[idx]; // if self.entry_table.entry_table_items.len() > 0 { if self.entry_table.entry_table_state.selected().is_some() { let mut lines = vec![]; lines.push(Line::from(vec![ Span::styled("Authors: ", style_value), Span::styled( - String::from(BibiEntry::get_authors( - &self.get_selected_citekey(), - &self.main_biblio.bibliography, - )), + // String::from(BibiEntry::get_authors( + // &self.get_selected_citekey(), + // &self.main_biblio.bibliography, + // )), + // Style::new().green(), + cur_entry.authors.clone(), Style::new().green(), ), ])); lines.push(Line::from(vec![ Span::styled("Title: ", style_value), Span::styled( - String::from(BibiEntry::get_title( - &self.get_selected_citekey(), - &self.main_biblio.bibliography, - )), + // String::from(BibiEntry::get_title( + // &self.get_selected_citekey(), + // &self.main_biblio.bibliography, + // )), + // Style::new().magenta(), + cur_entry.title.clone(), Style::new().magenta(), ), ])); lines.push(Line::from(vec![ Span::styled("Year: ", style_value), - Span::styled( - String::from(BibiEntry::get_year( - &self.get_selected_citekey(), - &self.main_biblio.bibliography, - )), - Style::new().light_magenta(), - ), + Span::styled(cur_entry.year.clone(), Style::new().light_magenta()), ])); + if !cur_entry.doi_url.is_empty() { + lines.push(Line::raw("")); + lines.push(Line::from(vec![ + Span::styled("DOI/URL: ", style_value_sec), + Span::styled( + cur_entry.doi_url.clone(), + Style::default().fg(TEXT_FG_COLOR).underlined(), + ), + ])); + } + if !cur_entry.filepath.is_empty() { + lines.push(Line::from(vec![ + Span::styled("File: ", style_value_sec), + Span::styled( + cur_entry.filepath.clone(), + Style::default().fg(TEXT_FG_COLOR), + ), + ])); + } lines.push(Line::from("")); lines.push(Line::from(vec![Span::styled( - String::from(BibiEntry::get_abstract( - &self.get_selected_citekey(), - &self.main_biblio.bibliography, - )), + cur_entry.abstract_text.clone(), Style::default().fg(TEXT_FG_COLOR), )])); lines |
