From 3a40bbb367a79dc3660c12aa7f62e3efc378ea22 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 30 Jun 2025 16:33:01 +0200 Subject: update README: note feature --- README.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 5bc40b3..4f0e505 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,16 @@ file_prefix = "/some/path/prefix" # of the format "citekey.pdf". Other PDF basenames are not accepted. # Use absolute paths (~ for HOME works). Otherwise, loading might not work. pdf_path = "/path/to/pdf-folder" +## Path to folder (with subfolders) containing note files with the basename of +## the format "citekey.extension". Other basenames are not accepted. The possible +## extensions can be set through the "note_extensions" array. +note_path = "path/to/note-files" +note_extensions = [ "md", "txt" ] + +## Symbols/chars to show if not has specific attachement + file_symbol = " " + link_symbol = "󰌹 " + note_symbol = "󰧮" ``` `bibfiles` @@ -246,13 +256,14 @@ pdf_path = "/path/to/pdf-folder" created through the `pdf_path` variable. Thus, it is safe to mix both approaches if wanted! -`pdf_path` +`pdf_path` and `note_path` -: The `pdf_path` is used as path wich is recursivley searched for files which - basename consists of the an entrys `citekey` plus a `.pdf` ending - (case-insensitive). Every file which matches this pattern for an existing - `citekey` is associated with the particular entry for the current `bibiman` - session and can be opened from within. +: The `pdf_path`/`note_path` is used as path wich is recursivley searched for + files which basename consists of the an entrys `citekey` plus a `.pdf` ending + or one of the specified note endinfs (case-insensitive). Every file which + matches this pattern for an existing `citekey` is associated with the + particular entry for the current `bibiman` session and can be opened from + within. ### Color Configuration @@ -272,6 +283,12 @@ warn_color = "124" bar_bg_color = "234" popup_bg_color = "234" selected_row_bg_color = "237" +note_color = "123" +file_color = "209" +link_color = "27" +author_color = "38" +title_color = "37" +year_color = "135" ``` Colors can be set through three different methods: @@ -309,7 +326,7 @@ These are the current features, the list will be updated: - [x] **Add Entry via DOI**. - [x] **Implement config file** for setting some default values like main bibfile, PDF-opener, or editor -- [ ] **Open related notes file** for specific entry. +- [x] **Open related notes file** for specific entry. - [ ] **Support Hayagriva(`.yaml`)** format as input (_on hold for now_, because the Hayagriva Yaml style doesn't offer keywords; s. issue in [Hayagriva repo](https://github.com/typst/hayagriva/issues/240)). @@ -346,7 +363,7 @@ Use the following keybindings to manage the TUI: There are some shortcuts to select an item from the opening/yanking popup without navigating the list: -- `o-o`|`o-l`: directly opens the first file/link for the selected entry. +- `o-o`|`o-l`|`o-n`: directly opens the first file|link|note for the selected entry. - `y-y`: directly yanks the citekey of the selected entry to the clipboard. ## Search -- cgit v1.2.3 From 9bd2f6fef0d835ffb97e18993161e6639c98d2d1 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 30 Jun 2025 21:49:53 +0200 Subject: align resource symbols, update README --- README.md | 2 ++ src/app.rs | 13 +++++++++---- src/bibiman.rs | 2 +- src/tui/ui.rs | 19 +++++++++++++++++-- tests/test-config.toml | 6 +++--- 5 files changed, 32 insertions(+), 10 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 4f0e505..ed620e8 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Here's a small impression how it looks and works: [![bibiman.gif](https://i.postimg.cc/Y0mCNDMg/bibiman.gif)](https://postimg.cc/ct0W0mK4) +![screenshot with new note feature](https://codeberg.org/attachments/69d35f36-cff3-43e5-8bfd-361064ba8ab2) + ## Installation ### Crates.io diff --git a/src/app.rs b/src/app.rs index 18a97e6..f912614 100644 --- a/src/app.rs +++ b/src/app.rs @@ -16,15 +16,14 @@ ///// use crate::bibiman::CurrentArea; -use crate::config::BibiConfig; -use color_eyre::eyre::{Context, Ok, Result}; -use editor_command::EditorBuilder; -// use super::Event; use crate::cliargs::CLIArgs; +use crate::config::BibiConfig; use crate::tui::commands::InputCmdAction; use crate::tui::popup::PopupKind; use crate::tui::{self, Tui}; use crate::{bibiman::Bibiman, tui::commands::CmdAction}; +use color_eyre::eyre::{Context, Ok, Result}; +use crossterm::event::KeyCode; use std::ffi::OsStr; use std::path::PathBuf; use std::process::{Command, Stdio}; @@ -84,6 +83,12 @@ impl App { self.bibiman.popup_area.popup_kind { self.bibiman.fast_selection(cfg, &mut tui, key_event.code)?; + // if a fast match char was used, restart event-loop. + // otherwise, the fast match char will be executed as command + match key_event.code { + KeyCode::Char('o' | 'l' | 'n' | 'y') => continue, + _ => {} + } } let command = if self.input_mode { CmdAction::Input(InputCmdAction::parse(key_event, &self.input)) diff --git a/src/bibiman.rs b/src/bibiman.rs index 9cc9280..f95bbc0 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -35,7 +35,7 @@ use std::fs::{self, read_to_string}; use std::fs::{File, OpenOptions}; use std::io::Write; use std::path::PathBuf; -use std::process::{Command, Stdio}; +use std::process::Command; use std::result::Result::Ok; use tui_input::Input; diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 3c83935..be53f61 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -300,7 +300,7 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { }; let bottom_info = if let Some(PopupKind::OpenRes) = app.bibiman.popup_area.popup_kind { - " (j,k|↓,↑) ━ (o,l) ━ (ENTER) ━ (ESC) ".bold() + " (j,k|↓,↑) ━ (o,l,n) ━ (ENTER) ━ (ESC) ".bold() } else if let Some(PopupKind::YankItem) = app.bibiman.popup_area.popup_kind { " (j,k|↓,↑) ━ (y) ━ (ENTER) ━ (ESC) ".bold() } else { @@ -580,7 +580,7 @@ pub fn render_entrytable(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rec .bg(cfg.colors.bar_bg_color); let header = Row::new(vec![ - Cell::from(Line::from("")).bg(cfg.colors.bar_bg_color), + Cell::from(Line::from("Res.")).bg(cfg.colors.bar_bg_color), Cell::from( Line::from(vec![{ Span::raw("Author") }, { if let Some(EntryTableColumn::Authors) = @@ -703,23 +703,38 @@ pub fn render_entrytable(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rec let mut symbol_vec = vec![]; + // use default or custom symbols for resources + // if an entry has no, replace it with the correct number + // of whitespace to align the symbols correct if let Some(f) = &item.symbols[0] { symbol_vec.push(Span::styled( f, Style::new().fg(cfg.colors.file_color).bold(), )); + } else { + symbol_vec.push(Span::raw( + " ".repeat(cfg.general.file_symbol.chars().count()), + )); } if let Some(l) = &item.symbols[1] { symbol_vec.push(Span::styled( l, Style::new().fg(cfg.colors.link_color).bold(), )); + } else { + symbol_vec.push(Span::raw( + " ".repeat(cfg.general.link_symbol.chars().count()), + )); } if let Some(n) = &item.symbols[2] { symbol_vec.push(Span::styled( n, Style::new().fg(cfg.colors.note_color).bold(), )) + } else { + symbol_vec.push(Span::raw( + " ".repeat(cfg.general.note_symbol.chars().count()), + )); } let row = Row::new(vec![ diff --git a/tests/test-config.toml b/tests/test-config.toml index 51bd4e6..1d29043 100644 --- a/tests/test-config.toml +++ b/tests/test-config.toml @@ -28,9 +28,9 @@ note_path = "tests/note-files" note_extensions = [ "md", "txt" ] ## Symbols/chars to show if not has specific attachement - file_symbol = " " - link_symbol = "󰌹 " - note_symbol = "󰧮" +file_symbol = " " +link_symbol = "󰌹 " +note_symbol = "󰧮" # [colors] ## Default values for dark-themed terminal -- cgit v1.2.3 From 2d71852fa5ed269e9ca10f841575a7a11640a7a0 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Thu, 3 Jul 2025 11:18:17 +0200 Subject: format README --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index ed620e8..c8ea715 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,8 @@ set through the CLI, `bibiman` will offer to create a default config file at the standard location. This will very likely happen on the first run of `bibiman` after installation. If rejected, you probably will be asked again next time. +The created config contains all values which are set as default by `bibiman`. + ### General Configuration The following general values can be set through the config file: @@ -202,19 +204,25 @@ The following general values can be set through the config file: # Default files/dirs which are loaded on startup # Use absolute paths (~ for HOME works). Otherwise, loading might not work. bibfiles = [ "/path/to/bibfile", "path/to/dir/with/bibfiles" ] + # Default editor to use when editing files. Arguments are possible editor = "vim" # with args: "vim -y" + # Default app to open PDFs/Epubs pdf_opener = "xdg-open" + # Default app to open URLs/DOIs url_opener = "xdg-open" + # Prefix which is prepended to the filepath from the `file` field # Use absolute paths (~ for HOME works). Otherwise, loading might not work. file_prefix = "/some/path/prefix" + # Path to folder (with subfolders) containing PDF files with the basename # of the format "citekey.pdf". Other PDF basenames are not accepted. # Use absolute paths (~ for HOME works). Otherwise, loading might not work. pdf_path = "/path/to/pdf-folder" + ## Path to folder (with subfolders) containing note files with the basename of ## the format "citekey.extension". Other basenames are not accepted. The possible ## extensions can be set through the "note_extensions" array. @@ -222,9 +230,9 @@ note_path = "path/to/note-files" note_extensions = [ "md", "txt" ] ## Symbols/chars to show if not has specific attachement - file_symbol = " " - link_symbol = "󰌹 " - note_symbol = "󰧮" +file_symbol = " " +link_symbol = "󰌹 " +note_symbol = "󰧮" ``` `bibfiles` -- cgit v1.2.3 From 19672076cf58e12355074b791a55d1d0cddfc7e4 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sat, 5 Jul 2025 22:41:29 +0200 Subject: updated README --- README.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index c8ea715..947c1d6 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ - [Search](#search) - [Edit bib entry](#edit-bib-entry) - [Open connected files or links](#open-connected-files-or-links) + - [Note file creation](#note-file-creation) - [Issues and code improvement](#issues-and-code-improvement) - [Alternatives](#alternatives) - [Comparison](#comparison) @@ -45,7 +46,7 @@ Here's a small impression how it looks and works: [![bibiman.gif](https://i.postimg.cc/Y0mCNDMg/bibiman.gif)](https://postimg.cc/ct0W0mK4) -![screenshot with new note feature](https://codeberg.org/attachments/69d35f36-cff3-43e5-8bfd-361064ba8ab2) +![screenshot with new note feature](https://codeberg.org/attachments/69d35f36-cff3-43e5-8bfd-361064ba8ab2) ## Installation @@ -291,6 +292,7 @@ info_color = "99" confirm_color = "47" warn_color = "124" bar_bg_color = "234" +popup_fg_color = "43" popup_bg_color = "234" selected_row_bg_color = "237" note_color = "123" @@ -337,6 +339,7 @@ These are the current features, the list will be updated: - [x] **Implement config file** for setting some default values like main bibfile, PDF-opener, or editor - [x] **Open related notes file** for specific entry. +- [x] **Create note file** for bib entries. - [ ] **Support Hayagriva(`.yaml`)** format as input (_on hold for now_, because the Hayagriva Yaml style doesn't offer keywords; s. issue in [Hayagriva repo](https://github.com/typst/hayagriva/issues/240)). @@ -362,6 +365,7 @@ Use the following keybindings to manage the TUI: | `e` | Open editor at selected entry | | `a` | Add entry through DOI | | `o` | Open related PDF or URL/DOI | +| `n` | Create new note file for selected entry | | `TAB` | Switch between entries and keywords | | `/`, `Ctrl-f` | Enter search mode | | `Enter` | Filter by selected keyword / Confirm search or selection | @@ -373,7 +377,8 @@ Use the following keybindings to manage the TUI: There are some shortcuts to select an item from the opening/yanking popup without navigating the list: -- `o-o`|`o-l`|`o-n`: directly opens the first file|link|note for the selected entry. +- `o-o`|`o-l`|`o-n`: directly opens the first file|link|note for the selected + entry. - `y-y`: directly yanks the citekey of the selected entry to the clipboard. ## Search @@ -411,12 +416,12 @@ thus, there might be unexpected errors with it. ## Open connected files or links -`bibiman` also provides the possibility to open PDFs (as value of the `file` -BibLaTeX field), as well as DOIs and URLs. +`bibiman` also provides the possibility to open PDFs , note files, as well as +DOIs and URLs connected with the different entries of the bibfile. For selecting the right program, it uses `xdg-open` on Linux, `open` on MacOS, -and `start` on Windows. Thanks to the report from @bastislack in #2 MacOS seems -to work. +and `start` on Windows by default. Thanks to the report from @bastislack in #2 +MacOS seems to work. _However, Windows does not work. Have to figure this out. Reports from some Windows users are very welcome._ @@ -425,6 +430,19 @@ Furthermore, DOIs have to begin with either `https://doi...` as full URL or `10.(...)` as regular DOI style. URLs work if they begin with either `http...` or with `www...`. +## Note file creation + +It is possible to create notes for an entry missing such a file. The `note_path` +and `note_extensions` values need to be set in the config file or it will fail. + +The notes basename is *always* the citekey of the selected entry and the +directory is set to the value of the `note_path` variable. The extension can be +choosen from one of the file format extension set in the `note_extensions` +array. + +The bibfile itself will *not be edited*. Therefore, you can't break anything in +your bibfile with this operation! + ## Issues and code improvement This is my first Rust project and, thus, also a learning process. If you find -- cgit v1.2.3 From 785c832d6a797103cf872b5ea6562e8dc59f24be Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 6 Jul 2025 12:36:53 +0200 Subject: add forbidden chars to README --- README.md | 6 ++++++ src/app.rs | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 947c1d6..c00d288 100644 --- a/README.md +++ b/README.md @@ -440,6 +440,12 @@ directory is set to the value of the `note_path` variable. The extension can be choosen from one of the file format extension set in the `note_extensions` array. +**Be aware**: The operation of creating new notes is not permitted if the +citekey contains some special chars which could cause problems with Unixish +shell commands and file operations. Currently the following chars are not +allowed as part of the citekey: `/` | `|` | `#` | `*` | `\\` | `"` | `'` | `;` | +`!` + The bibfile itself will *not be edited*. Therefore, you can't break anything in your bibfile with this operation! diff --git a/src/app.rs b/src/app.rs index 708ec37..8b76f17 100644 --- a/src/app.rs +++ b/src/app.rs @@ -435,11 +435,16 @@ impl App { .unwrap()] .citekey .clone(); + // disallow chars which can cause other shell executions if citekey.contains("/") | citekey.contains("|") | citekey.contains("#") | citekey.contains("\\") | citekey.contains("*") + | citekey.contains("\"") + | citekey.contains(";") + | citekey.contains("!") + | citekey.contains("\'") { self.bibiman.open_popup( PopupKind::MessageError, -- cgit v1.2.3 From 41a632f93cc893a23d6ca6a4578838eed9d0c8d1 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 6 Jul 2025 12:42:44 +0200 Subject: correction in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index c00d288..f5b7648 100644 --- a/README.md +++ b/README.md @@ -442,8 +442,8 @@ array. **Be aware**: The operation of creating new notes is not permitted if the citekey contains some special chars which could cause problems with Unixish -shell commands and file operations. Currently the following chars are not -allowed as part of the citekey: `/` | `|` | `#` | `*` | `\\` | `"` | `'` | `;` | +shell commands and file operations. Currently, the following chars are not +allowed as part of the citekey: `/` | `|` | `#` | `*` | `\` | `"` | `'` | `;` | `!` The bibfile itself will *not be edited*. Therefore, you can't break anything in -- cgit v1.2.3