diff options
| author | lukeflo | 2024-12-16 13:46:24 +0100 |
|---|---|---|
| committer | lukeflo | 2024-12-23 21:03:19 +0100 |
| commit | bf93bbee1b59c9804a01a7476e12264bbbcf5f40 (patch) | |
| tree | e8b1454a9c85e6932b443a34a4a18a02b71bfccc /src/tui/ui.rs | |
| parent | a6fca1fcf164142d84d09242b9d95a1da0b2d2d9 (diff) | |
| download | bibiman-bf93bbee1b59c9804a01a7476e12264bbbcf5f40.tar.gz bibiman-bf93bbee1b59c9804a01a7476e12264bbbcf5f40.zip | |
rewrite add-entry via DOI workflow
+ split some functions to fit with different popups
+ select if append to file (and to which) or create new file
+ error handling if resolving doi ist not possible
+ error handling for wront doi patterns
Diffstat (limited to 'src/tui/ui.rs')
| -rw-r--r-- | src/tui/ui.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/tui/ui.rs b/src/tui/ui.rs index e3fddfd..6a3b8de 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -212,25 +212,14 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { let doi_lines = paragraph.line_count(area.width / 2); // Calculate popup size - let popup_width = area.width / 2; + let popup_width = area.width / 4 * 3; let popup_height = doi_lines as u16; // Adjust as needed let popup_area = popup_area(area, popup_width, popup_height); // Render the popup frame.render_widget(Clear, popup_area); - render_cursor(app, frame, popup_area, 6, 2); + render_cursor(app, frame, popup_area, 6, doi_lines as u16 - 1); frame.render_widget(paragraph, popup_area); - - // // Set the cursor position - // if app.input_mode { - // // Calculate cursor x and y - // let input_prefix_len = "Title: ".len() as u16 + 1; // +1 for padding - // let cursor_x = popup_area.x - // + input_prefix_len - // + app.bibiman.popup_area.add_entry_cursor_position as u16; - // let cursor_y = popup_area.y + 1; // Line after 'Title: ' - // frame.set_cursor_position(Position::new(cursor_x, cursor_y)); - // } } Some(PopupKind::MessageConfirm) => { let area = frame.area(); @@ -294,7 +283,7 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { frame.render_widget(Clear, popup_area); frame.render_widget(&content, popup_area) } - Some(PopupKind::Selection) => { + Some(PopupKind::SelectRes) | Some(PopupKind::SelectFile) => { let list_items: Vec<ListItem> = app .bibiman .popup_area @@ -303,8 +292,16 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { .map(|item| ListItem::from(item.to_owned())) .collect(); + let title = if let Some(PopupKind::SelectRes) = app.bibiman.popup_area.popup_kind { + " Open " + } else if let Some(PopupKind::SelectFile) = app.bibiman.popup_area.popup_kind { + " Select file to append entry " + } else { + " Select " + }; + let block = Block::bordered() - .title_top(" Open ".bold()) + .title_top(title.bold()) .title_bottom(" (j,k|↓,↑) ━ (ENTER) ━ (ESC) ".bold()) .title_alignment(Alignment::Center) .style( |
