aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlukeflo2025-07-05 20:21:52 +0200
committerlukeflo2025-07-05 20:21:52 +0200
commit80c04702012cb1a43711d559e8ffbe9e250b1a57 (patch)
tree7068c6915d4ee6c84f38f65798d0aeb276941d5b /src
parent52079ee745831b06a6c4060f38ee49e42d689dcd (diff)
downloadbibiman-80c04702012cb1a43711d559e8ffbe9e250b1a57.tar.gz
bibiman-80c04702012cb1a43711d559e8ffbe9e250b1a57.zip
first steps for create new note
Diffstat (limited to 'src')
-rw-r--r--src/app.rs62
-rw-r--r--src/bibiman.rs4
-rw-r--r--src/tui/commands.rs2
-rw-r--r--src/tui/popup.rs2
4 files changed, 67 insertions, 3 deletions
diff --git a/src/app.rs b/src/app.rs
index d475328..14cc864 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -365,7 +365,7 @@ impl App {
{
if entry.doi_url.is_some() {
items.push((
- format!("{} ", cfg.general.link_symbol.clone().trim()),
+ "Link: ".into(),
entry.doi_url.unwrap().clone(),
PopupItem::Link,
))
@@ -373,7 +373,7 @@ impl App {
if entry.filepath.is_some() {
entry.filepath.unwrap().iter().for_each(|p| {
items.push((
- format!("{} ", cfg.general.file_symbol.clone().trim()),
+ "File: ".into(),
// p.clone().into_string().unwrap(),
if entry.file_field && cfg.general.file_prefix.is_some() {
cfg.general
@@ -394,7 +394,7 @@ impl App {
if entry.notes.is_some() {
entry.notes.unwrap().iter().for_each(|n| {
items.push((
- format!("{} ", cfg.general.note_symbol.clone().trim()),
+ "Note: ".into(),
n.clone().into_string().unwrap(),
PopupItem::Notefile,
));
@@ -419,6 +419,62 @@ impl App {
self.bibiman.add_entry();
}
}
+ CmdAction::CreateNote => {
+ if let CurrentArea::EntryArea = self.bibiman.current_area {
+ if cfg.general.note_path.is_some()
+ && cfg.general.note_extensions.is_some()
+ && self.bibiman.entry_table.entry_table_items[self
+ .bibiman
+ .entry_table
+ .entry_table_state
+ .selected()
+ .unwrap()]
+ .notes
+ .is_none()
+ {
+ let mut items = vec![];
+ for ex in cfg.general.note_extensions.as_ref().unwrap() {
+ items.push((
+ self.bibiman.entry_table.entry_table_items[self
+ .bibiman
+ .entry_table
+ .entry_table_state
+ .selected()
+ .unwrap()]
+ .citekey()
+ .to_string(),
+ ex.clone(),
+ PopupItem::Notefile,
+ ));
+ }
+ self.bibiman
+ .open_popup(PopupKind::CreateNote, None, None, Some(items));
+ } else if cfg.general.note_path.is_some()
+ && self.bibiman.entry_table.entry_table_items[self
+ .bibiman
+ .entry_table
+ .entry_table_state
+ .selected()
+ .unwrap()]
+ .notes
+ .is_some()
+ {
+ self.bibiman.open_popup(
+ PopupKind::MessageError,
+ Some("Selected entry already has a connected note"),
+ None,
+ None,
+ )?;
+ } else {
+ self.bibiman.open_popup(
+ PopupKind::MessageError,
+ Some("No note path found. Set it in config file."),
+ None,
+ None,
+ )?;
+ }
+ }
+ }
CmdAction::ShowHelp => {
self.bibiman.open_popup(PopupKind::Help, None, None, None)?;
}
diff --git a/src/bibiman.rs b/src/bibiman.rs
index 6aec1fb..c92b869 100644
--- a/src/bibiman.rs
+++ b/src/bibiman.rs
@@ -740,6 +740,10 @@ impl Bibiman {
Ok(())
}
+ pub fn create_note(&mut self, cfg: &BibiConfig) -> Result<()> {
+ Ok(())
+ }
+
pub fn open_connected_res(&mut self, cfg: &BibiConfig, tui: &mut Tui) -> Result<()> {
// Index of selected entry
let entry_idx = self.entry_table.entry_table_state.selected().unwrap();
diff --git a/src/tui/commands.rs b/src/tui/commands.rs
index 08ee677..47d2802 100644
--- a/src/tui/commands.rs
+++ b/src/tui/commands.rs
@@ -73,6 +73,8 @@ pub enum CmdAction {
ShowHelp,
// Add new entry
AddEntry,
+ // Create note
+ CreateNote,
// Do nothing.
Nothing,
}
diff --git a/src/tui/popup.rs b/src/tui/popup.rs
index 4aaa2c1..46e4792 100644
--- a/src/tui/popup.rs
+++ b/src/tui/popup.rs
@@ -38,6 +38,8 @@ pub enum PopupKind {
AddEntry,
/// select an item of the current entry to yank to clipboard
YankItem,
+ /// Create a new note, select extension
+ CreateNote,
}
#[derive(Debug)]