From 7806d5d3718d7a48f65eade81dcfa323545487f8 Mon Sep 17 00:00:00 2001 From: KlzXS Date: Thu, 28 Mar 2024 18:20:21 +0100 Subject: [PATCH 1/3] Prevent multiple icons options being selected at the same time --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 46c269e79..7661daea3 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ O_GITSTATUS := 0 # add git status to detail view O_NAMEFIRST := 0 # print file name first, add uid and guid to detail view O_RESTOREPREVIEW := 0 # add preview pipe to close and restore preview pane +T_ICONS := 0 # test if multiple icons options are set and fail + # convert targets to flags for backwards compatibility ifneq ($(filter debug,$(MAKECMDGOALS)),) O_DEBUG := 1 @@ -97,16 +99,28 @@ endif ifeq ($(strip $(O_ICONS)),1) ICONS_INCLUDE = icons-generated-icons-in-term.h CPPFLAGS += -DICONS_IN_TERM -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\" +ifeq ($(strip $(T_ICONS)),1) +$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI)) +endif + T_ICONS := 1 endif ifeq ($(strip $(O_NERD)),1) ICONS_INCLUDE = icons-generated-nerd.h CPPFLAGS += -DNERD -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\" +ifeq ($(strip $(T_ICONS)),1) +$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI)) +endif + T_ICONS := 1 endif ifeq ($(strip $(O_EMOJI)),1) ICONS_INCLUDE = icons-generated-emoji.h CPPFLAGS += -DEMOJI -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\" +ifeq ($(strip $(T_ICONS)),1) +$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI)) +endif + T_ICONS := 1 endif ifeq ($(strip $(O_QSORT)),1) From 28d993a8e85651e6e8a61b410472febc6069ceb0 Mon Sep 17 00:00:00 2001 From: Martin Ziemer Date: Thu, 4 Apr 2024 15:33:14 +0200 Subject: [PATCH 2/3] Fix file creation on OpenBSD On OpenBSD at least one of O_RDONLY, O_WRONLY or O_RDWR is needed to open a file. In creating a new file none of those is set, which leads to an EINVAL error ("invalid argument"). Since the new file is only created and never read, I chose to use O_WRONLY. --- src/nnn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nnn.c b/src/nnn.c index 416e0ca83..0fb748330 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -4732,7 +4732,7 @@ static bool xmktree(char *path, bool dir) return FALSE; } } else { - int fd = open(path, O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */ + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */ if (fd == -1 && errno != EEXIST) { DPRINTF_S("open!"); From 133c0d329bdfb1f52372e034b4486ff65a30e2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bechet?= <48946818+flipflop133@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:15:41 +0200 Subject: [PATCH 3/3] preview-tui: add full svg support --- plugins/preview-tui | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/preview-tui b/plugins/preview-tui index f813ca541..860a93a04 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -44,6 +44,7 @@ # - optional: pistol file viewer (https://github.com/doronbehar/pistol). # 1. install pistol # 2. set/export $NNN_PISTOL as 1 +# - optional: librsvg for rsvg-convert # # Usage: # You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG, @@ -94,7 +95,7 @@ # 'no_focus [title="preview-tui"]' to your i3 config file. # # Shell: Bash (for environment manipulation through arrays) -# Authors: Todd Yamakawa, Léo Villeveygoux, @Recidiviste, Mario Ortiz Manero, Luuk van Baal, @WanderLanz +# Authors: Todd Yamakawa, Léo Villeveygoux, @Recidiviste, Mario Ortiz Manero, Luuk van Baal, @WanderLanz, @flipflop133 # Configurable environment variables: NNN_SPLIT=${NNN_SPLIT:-} # permanent split direction @@ -416,7 +417,9 @@ generate_preview() { else image_preview "$1" "$2" "$3" && return fi ;; - image) if exists convert; then + image) if exists rsvg-convert && [[ "${3##*.}" == "svg" ]]; then + rsvg-convert -a -w "$NNN_PREVIEWWIDTH" -h "$NNN_PREVIEWHEIGHT" -f png -o "$NNN_PREVIEWDIR/$3.png" "$3" + elif exists convert; then convert "$3" -flatten -resize "$NNN_PREVIEWWIDTH"x"$NNN_PREVIEWHEIGHT"\> "$NNN_PREVIEWDIR/$3.jpg" else image_preview "$1" "$2" "$3" && return @@ -431,6 +434,8 @@ generate_preview() { fi if [ -f "$NNN_PREVIEWDIR/$3.jpg" ]; then image_preview "$1" "$2" "$NNN_PREVIEWDIR/$3.jpg" + elif [[ "${3##*.}" == "svg" ]] && [ -f "$NNN_PREVIEWDIR/$3.png" ]; then + image_preview "$1" "$2" "$NNN_PREVIEWDIR/$3.png" else fifo_pager print_bin_info "$3" fi