From 4c0c2182f49821e1e584a8465123e6fb9acbbe4e Mon Sep 17 00:00:00 2001 From: nimaaskarian Date: Sun, 31 Mar 2024 23:07:32 +0330 Subject: [PATCH 1/2] Add highlight-string argument - Add highlight-string argument - Add tui_app::highlight_string method --- src/main.rs | 4 ++++ src/tui_app.rs | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index f5dcb9f..0e2c552 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,10 @@ pub struct Args { #[arg(short='S', long)] search_and_select: Vec, + /// String behind highlighted todo in TUI mode + #[arg(short='H', long, default_value_t=String::from(">>"))] + highlight_string: String, + /// Set selected todo priority #[arg(long)] set_selected_priority: Option, diff --git a/src/tui_app.rs b/src/tui_app.rs index b6889d6..a884ff4 100644 --- a/src/tui_app.rs +++ b/src/tui_app.rs @@ -35,14 +35,14 @@ pub enum TodoWidget<'a> { Paragraph(ratatui::widgets::Paragraph<'a>), } -pub fn create_todo_widget(display_list:&Vec, title:String) -> TodoWidget { +pub fn create_todo_widget<'a>(display_list:&Vec, title:String, highlight_symbol: &'a str) -> TodoWidget<'a> { if display_list.is_empty() { return TodoWidget::Paragraph(Paragraph::new("No todo.").block(default_block(title))) } TodoWidget::List(List::new((*display_list).clone()) .block(default_block(title)) .highlight_style(Style::new().add_modifier(Modifier::REVERSED)) - .highlight_symbol(">>") + .highlight_symbol(highlight_symbol) .repeat_highlight_symbol(true)) } @@ -434,6 +434,11 @@ impl<'a>TuiApp<'a>{ main_layout } + #[inline] + fn highlight_string(&self) -> &str { + self.todo_app.args.highlight_string.as_str() + } + #[inline] fn render_dependency_widget(&self, frame: &mut Frame, todo: Option<&Todo>, dependency_layout: Rect) { if let Some(todo) = todo { @@ -444,7 +449,7 @@ impl<'a>TuiApp<'a>{ frame.render_widget(note_widget, dependency_layout); } if let Some(todo_list) = todo.dependency.todo_list() { - match create_todo_widget(&self.todo_app.display_list(todo_list), String::from("Todo dependencies")) { + match create_todo_widget(&self.todo_app.display_list(todo_list), String::from("Todo dependencies"), self.highlight_string()) { TodoWidget::List(widget) => frame.render_widget(widget, dependency_layout), TodoWidget::Paragraph(widget) => frame.render_widget(widget, dependency_layout), } @@ -454,7 +459,7 @@ impl<'a>TuiApp<'a>{ #[inline] fn render_todos_widget(&self, frame: &mut Frame, list_state: &mut ListState, todo_layout: &Rc<[Rect]>) { - match create_todo_widget(&self.todo_app.display_current(), self.title()) { + match create_todo_widget(&self.todo_app.display_current(), self.title(), self.highlight_string()) { TodoWidget::Paragraph(widget) => frame.render_widget(widget, todo_layout[1]), TodoWidget::List(widget) => frame.render_stateful_widget(widget, todo_layout[1], list_state), } From bc59743063b7ee6d5960b776e6a3121bb5fa7226 Mon Sep 17 00:00:00 2001 From: nimaaskarian Date: Sun, 31 Mar 2024 23:14:04 +0330 Subject: [PATCH 2/2] Update release.sh - Uploades source archive instead of downloading tag from GitHub --- release.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/release.sh b/release.sh index e0caacf..ec40168 100755 --- a/release.sh +++ b/release.sh @@ -6,6 +6,7 @@ LAST_TAG=$(git tag | tail -n 1) PACKAGE_NAME=c3 USERNAME=nimaaskarian TAG="$1" +MD5="" push_tag() { git tag "$TAG" || { @@ -19,7 +20,10 @@ push_tag() { release_package() { cp target/release/c3 c3.x86.linux || echo_exit copy linux binary failed cp target/x86_64-pc-windows-gnu/release/c3.exe c3.x86_64.windows.exe || echo_exit copy windows binary failed - FILES="c3.x86.linux c3.x86_64.windows.exe" + SOURCE=source.tar.gz + git archive --output=$SOURCE --prefix=c3-$TAG/ $TAG -9 + MD5=$(md5sum $SOURCE | cut -f 1 -d ' ') + FILES="c3.x86.linux c3.x86_64.windows.exe $SOURCE" gh release create "$TAG" $FILES --title "$TAG" --notes "**Full Changelog**: https://github.com/$USERNAME/$PACKAGE_NAME/compare/$LAST_TAG...$TAG" --repo $USERNAME/$PACKAGE_NAME rm $FILES } @@ -27,10 +31,7 @@ release_package() { release_c3() { cd aur || echo_exit cd to aur directory failed. sed -i "s/pkgver=$LAST_TAG/pkgver=$TAG/" c3/PKGBUILD - wget "https://github.com/$USERNAME/$PACKAGE_NAME/archive/refs/tags/$TAG.zip" - MD5=$(md5sum $TAG.zip | cut -f 1 -d ' ') sed -i "s/md5sums=('.*')/md5sums=('$MD5')/" c3/PKGBUILD - rm $TAG.zip cd c3 || echo_exit cd to c3 failed makepkg --printsrcinfo > .SRCINFO